diff options
author | rub <rub@piwigo.org> | 2006-04-12 22:56:55 +0000 |
---|---|---|
committer | rub <rub@piwigo.org> | 2006-04-12 22:56:55 +0000 |
commit | 53e48e76751d5e1cc821ce3a59b8ade4cf5da08d (patch) | |
tree | 051db5297bf8d628213ee44eefcb4f36f73077c4 /include | |
parent | bcc40eb10dd50d26a7d66c4ff59cdb474415aeb6 (diff) |
Issue ID 330:
o Change NBM configuration in order to avoid lose treatment action when occurred timeout
o Add news redirect/repost functions
Reports of svn:1156
git-svn-id: http://piwigo.org/svn/branches/branch-1_6@1157 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/config_default.inc.php | 7 | ||||
-rw-r--r-- | include/functions.inc.php | 88 | ||||
-rw-r--r-- | include/page_header.php | 3 |
3 files changed, 89 insertions, 9 deletions
diff --git a/include/config_default.inc.php b/include/config_default.inc.php index ee55461bf..e441de35a 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -470,14 +470,11 @@ $conf['tags_levels'] = 5; // Default Value for nbm user $conf['nbm_default_value_user_enabled'] = false; -// Max user to show on list users to send notification -// Parameter not used if $conf['nbm_list_all_enabled_users_to_send'] is true -$conf['nbm_max_list_users_to_send'] = 100; - // Search List user to send with quick (List all without check news) // More quickly but less fun to use $conf['nbm_list_all_enabled_users_to_send'] = false; // Max mails sended on one pass -$conf['nbm_max_mails_send'] = 35; +$conf['nbm_max_treatment_timeout_percent'] = 0.8; + ?> diff --git a/include/functions.inc.php b/include/functions.inc.php index 5a1245c4b..2b53b5c26 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -518,15 +518,25 @@ function pwg_debug( $string ) * (presence of an exit() instruction. * * @param string $url + * @param string $title_msg + * @param integer $refreh_time * @return void */ -function redirect( $url ) +function redirect( $url , $msg = '', $refreh_time = 0) { global $user, $template, $lang_info, $conf, $lang, $t2, $page, $debug; - // $refresh, $url_link and $title are required for creating an automated + // $redirect_msg, $refresh, $url_link and $title are required for creating an automated // refresh page in header.tpl - $refresh = 0; + if (!isset($msg) or ($msg == '')) + { + $redirect_msg = l10n('redirect_msg'); + } + else + { + $redirect_msg = $msg; + } + $refresh = $refreh_time; $url_link = $url; $title = 'redirection'; @@ -859,4 +869,76 @@ function get_available_upgrade_ids() return $available_upgrade_ids; } + +/** + * Adaptation of _HTTPRequestToString (http://fr.php.net/urlencode) + * + * + * @return array request to string + */ +function http_request_to_string($arr_request, $var_name, $separator='&') { + $ret = ""; + if (is_array($arr_request)) { + foreach ($arr_request as $key => $value) { + if (is_array($value)) { + if ($var_name) { + $ret .= http_request_to_string($value, "{$var_name}[{$key}]", $separator); + } else { + $ret .= http_request_to_string($value, "{$key}", $separator); + } + } else { + if ($var_name) { + $ret .= "{$var_name}[{$key}]=".urlencode($value)."&"; + } else { + $ret .= "{$key}=".urlencode($value)."&"; + } + } + } + } + if (!$var_name) { + $ret = substr($ret,0,-1); + } + return $ret; +} + +/** + * Post request HTTP on backgroung and redirec to selected url + * + * Note : once this function called, the execution doesn't go further + * (presence of an exit() instruction. + * + * @param string $url_redirect + * @param string $redirect_message + * @param integer $redirect_refreh_time + * @return void + */ +function re_post_http($url_redirect, $redirect_message, $redirect_refreh_time) +{ + global $conf; + + $data_post = http_request_to_string($_POST, ''); + + $message_post = "POST ".$_SERVER['PHP_SELF'].html_entity_decode(get_query_string_diff(array()))." HTTP/1.1\r\n"; + + foreach (array_flip(array_diff(array_flip(apache_request_headers()), array('Content-Type', 'Content-Length'))) as $header_name => $header_value) + { + $message_post .= $header_name.": ".$header_value."\r\n"; + } + + +// $message_post .= "Host: ".$_SERVER['HTTP_HOST']."\r\n"; +// $message_post .= "Cookie: ".$conf['session_name']."=".$_COOKIE[$conf['session_name']]."\r\n"; + $message_post .= "Content-Type: application/x-www-form-urlencoded\r\n"; + $message_post .= "Content-Length: ".strlen($data_post)."\r\n"; + $message_post .= "\r\n"; + $message_post .= $data_post."\r\n"; + + $fd = fsockopen($_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT']); + fputs($fd, $message_post); + fclose($fd); + + redirect($url_redirect, $redirect_message, $redirect_refreh_time); + //exit(); done by redirect +} + ?> diff --git a/include/page_header.php b/include/page_header.php index f9b130c3c..f1f10cf56 100644 --- a/include/page_header.php +++ b/include/page_header.php @@ -57,10 +57,11 @@ $template->assign_vars( )); // refresh -if ( isset( $refresh ) and intval($refresh) >= 0 and isset( $url_link ) ) +if ( isset( $refresh ) and intval($refresh) >= 0 and isset( $url_link ) and isset( $redirect_msg ) ) { $template->assign_vars( array( + 'U_REDIRECT_MSG' => $redirect_msg, 'REFRESH_TIME' => $refresh, 'U_REFRESH' => $url_link )); |