Changeset 1157
- Timestamp:
- Apr 13, 2006, 12:56:55 AM (19 years ago)
- Location:
- branches/branch-1_6
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1_6/admin/include/functions_notification_by_mail.inc.php
r1116 r1157 28 28 29 29 /* nbm_global_var */ 30 $env_nbm = array(); 30 $env_nbm = array 31 ( 32 'start_time' => get_moment(), 33 'sendmail_timeout' => (intval(ini_get('max_execution_time')) * $conf['nbm_max_treatment_timeout_percent']), 34 'is_sendmail_timeout' => false 35 ); 36 31 37 32 38 /* … … 56 62 } 57 63 } 64 } 65 66 /* 67 * Check sendmail timeout state 68 * 69 * @return true, if it's timeout 70 */ 71 function check_sendmail_timeout() 72 { 73 global $env_nbm; 74 75 $env_nbm['is_sendmail_timeout'] = ((get_moment() - $env_nbm['start_time']) > $env_nbm['sendmail_timeout']); 76 77 return $env_nbm['is_sendmail_timeout']; 58 78 } 59 79 … … 319 339 * check_key list where action will be done 320 340 * 321 * @return updated data count341 * @return check_key lisr treated 322 342 */ 323 343 function do_subscribe_unsubcribe_notification_by_mail($is_admin_request, $is_subscribe = false, $check_key_list = array()) … … 325 345 global $conf, $page, $env_nbm, $conf; 326 346 347 $check_key_treated = array(); 327 348 $updated_data_count = 0; 328 349 $error_on_updated_data_count = 0; … … 345 366 $data_users = get_user_notifications('subscribe', $check_key_list, !$is_subscribe); 346 367 368 // Prepare message after change language 369 $msg_break_timeout = l10n('nbm_nbm_break_timeout_send_mail'); 370 347 371 // Begin nbm users environment 348 372 begin_users_env_nbm(true); … … 350 374 foreach ($data_users as $nbm_user) 351 375 { 352 if ( ($env_nbm['error_on_mail_count'] + $env_nbm['sent_mail_count']) >= $conf['nbm_max_mails_send'])376 if (check_sendmail_timeout()) 353 377 { 354 378 // Stop fill list on 'send', if the quota is override 355 array_push($page['errors'], sprintf(l10n('nbm_nbm_break_send_mail'), $conf['nbm_max_mails_send']));379 array_push($page['errors'], $msg_break_timeout); 356 380 break; 357 381 } 382 383 // Fill return list 384 array_push($check_key_treated, $nbm_user['check_key']); 358 385 359 386 $do_update = true; … … 437 464 } 438 465 439 return $ updated_data_count;466 return $check_key_treated; 440 467 } 441 468 … … 445 472 * check_key list where action will be done 446 473 * 447 * @return updated data count474 * @return check_key lisr treated 448 475 */ 449 476 function unsubcribe_notification_by_mail($is_admin_request, $check_key_list = array()) … … 457 484 * check_key list where action will be done 458 485 * 459 * @return updated data count486 * @return check_key lisr treated 460 487 */ 461 488 function subcribe_notification_by_mail($is_admin_request, $check_key_list = array()) -
branches/branch-1_6/admin/notification_by_mail.php
r1116 r1157 48 48 49 49 // +-----------------------------------------------------------------------+ 50 // | Initialization | 51 // +-----------------------------------------------------------------------+ 52 $base_url = get_root_url().'admin.php'; 53 54 // +-----------------------------------------------------------------------+ 50 55 // | functions | 51 56 // +-----------------------------------------------------------------------+ 57 58 /* 59 * Do background treatmetn in order to finish to send mails 60 * 61 * @param $post_keyname: key of check_key post array 62 * @param check_key_treated:array of check_key treated 63 * @return none 64 */ 65 function do_background_treatment($post_keyname, $check_key_treated = array()) 66 { 67 global $env_nbm, $base_url; 68 69 if ($env_nbm['is_sendmail_timeout']) 70 { 71 if (isset($_POST[$post_keyname])) 72 { 73 $post_count = count($_POST[$post_keyname]); 74 $treated_count = count($check_key_treated); 75 if ($treated_count != 0) 76 { 77 $time_refresh = ceil((get_moment() - $env_nbm['start_time']) * $post_count / $treated_count); 78 } 79 else 80 { 81 $time_refresh = 10; 82 } 83 $_POST[$post_keyname] = array_diff($_POST[$post_keyname], $check_key_treated); 84 re_post_http($base_url.get_query_string_diff(array()), sprintf(l10n('nbm_background_treatment_redirect'), $time_refresh) , $time_refresh); 85 } 86 } 87 88 } 52 89 53 90 /* … … 79 116 function insert_new_data_user_mail_notification() 80 117 { 81 global $conf, $page ;118 global $conf, $page, $env_nbm; 82 119 83 120 // Set null mail_address empty … … 138 175 mass_inserts(USER_MAIL_NOTIFICATION_TABLE, array('user_id', 'check_key', 'enabled'), $inserts); 139 176 // Update field enabled with specific function 140 do_subscribe_unsubcribe_notification_by_mail177 $check_key_treated = do_subscribe_unsubcribe_notification_by_mail 141 178 ( 142 179 true, … … 144 181 $check_key_list 145 182 ); 183 184 // On timeout simulate like tabsheet send 185 if ($env_nbm['is_sendmail_timeout']) 186 { 187 if ($conf['nbm_default_value_user_enabled']) 188 { 189 $_POST['trueify'] = 'trueify'; 190 $_POST['cat_false'] = $check_key_list; 191 do_background_treatment('cat_false', $check_key_treated); 192 } 193 else 194 { 195 $_POST['falsify'] = 'falsify'; 196 $_POST['cat_true'] = $check_key_list; 197 do_background_treatment('cat_true', $check_key_treated); 198 } 199 } 146 200 } 147 201 } … … 149 203 /* 150 204 * Send mail for notification to all users 151 * Return list of "treated/selected" users 205 * Return list of "selected" users for 'list_to_send' 206 * Return list of "treated" check_key for 'send' 152 207 */ 153 208 function do_action_send_mail_notification($action = 'list_to_send', $check_key_list = array(), $customize_mail_content = '') … … 177 232 $datas = array(); 178 233 234 // Prepare message after change language 235 if ($is_action_send) 236 { 237 $msg_break_timeout = l10n('nbm_nbm_break_timeout_send_mail'); 238 } 239 else 240 { 241 $msg_break_timeout = l10n('nbm_break_timeout_list_user'); 242 } 243 179 244 // Begin nbm users environment 180 245 begin_users_env_nbm($is_action_send); … … 182 247 foreach ($data_users as $nbm_user) 183 248 { 184 if ((!$is_action_send) and (count($return_list) >= $conf['nbm_max_list_users_to_send']))249 if ((!$is_action_send) and check_sendmail_timeout()) 185 250 { 186 251 // Stop fill list on 'list_to_send', if the quota is override 187 array_push($page['infos'], sprintf(l10n('nbm_break_list_user'), $conf['nbm_max_list_users_to_send']));252 array_push($page['infos'], $msg_break_timeout); 188 253 break; 189 254 } 190 if (($is_action_send) and (count($return_list) >= $conf['nbm_max_mails_send']))255 if (($is_action_send) and check_sendmail_timeout()) 191 256 { 192 257 // Stop fill list on 'send', if the quota is override 193 array_push($page['errors'], sprintf(l10n('nbm_nbm_break_send_mail'), $conf['nbm_max_mails_send']));258 array_push($page['errors'], $msg_break_timeout); 194 259 break; 195 260 } … … 200 265 if ($is_action_send) 201 266 { 267 // Fill return list of "treated" check_key for 'send' 268 array_push($return_list, $nbm_user['check_key']); 202 269 $message = ''; 203 270 … … 214 281 if ($exist_data) 215 282 { 216 array_push($return_list, $nbm_user);217 218 283 $subject = '['.$conf['gallery_title'].']: '.l10n('nbm_object_news'); 219 284 $message .= sprintf(l10n('nbm_content_hello'), $nbm_user['username']).",\n\n"; … … 263 328 if (news_exists($nbm_user['last_send'], $dbnow)) 264 329 { 330 // Fill return list of "selected" users for 'list_to_send' 265 331 array_push($return_list, $nbm_user); 266 332 } … … 296 362 { 297 363 // Quick List, don't check news 364 // Fill return list of "selected" users for 'list_to_send' 298 365 $return_list = $data_users; 299 366 } 300 367 } 368 369 // Return list of "selected" users for 'list_to_send' 370 // Return list of "treated" check_key for 'send' 301 371 return $return_list; 302 372 } … … 384 454 if (isset($_POST['falsify']) and isset($_POST['cat_true'])) 385 455 { 386 unsubcribe_notification_by_mail(true, $_POST['cat_true']); 456 $check_key_treated = unsubcribe_notification_by_mail(true, $_POST['cat_true']); 457 do_background_treatment('cat_true', $check_key_treated); 387 458 } 388 459 else 389 460 if (isset($_POST['trueify']) and isset($_POST['cat_false'])) 390 461 { 391 subcribe_notification_by_mail(true, $_POST['cat_false']); 462 $check_key_treated = subcribe_notification_by_mail(true, $_POST['cat_false']); 463 do_background_treatment('cat_false', $check_key_treated); 392 464 } 393 465 break; … … 398 470 if (isset($_POST['send_submit']) and isset($_POST['send_selection']) and isset($_POST['send_customize_mail_content'])) 399 471 { 400 do_action_send_mail_notification('send', $_POST['send_selection'], $_POST['send_customize_mail_content']); 472 $check_key_treated = do_action_send_mail_notification('send', $_POST['send_selection'], $_POST['send_customize_mail_content']); 473 do_background_treatment('send_selection', $check_key_treated); 401 474 } 402 475 } … … 415 488 ); 416 489 417 $base_url = get_root_url().'admin.php';418 419 490 $template->assign_vars 420 491 ( … … 422 493 ( 423 494 'U_TABSHEET_TITLE' => l10n('nbm_'.$page['mode'].'_mode'), 424 'U_HELP' => add_url_params(get_root_url().' /popuphelp.php', array('page' => 'notification_by_mail')),495 'U_HELP' => add_url_params(get_root_url().'popuphelp.php', array('page' => 'notification_by_mail')), 425 496 'F_ACTION'=> $base_url.get_query_string_diff(array()) 426 497 ) -
branches/branch-1_6/include/config_default.inc.php
r1132 r1157 471 471 $conf['nbm_default_value_user_enabled'] = false; 472 472 473 // Max user to show on list users to send notification474 // Parameter not used if $conf['nbm_list_all_enabled_users_to_send'] is true475 $conf['nbm_max_list_users_to_send'] = 100;476 477 473 // Search List user to send with quick (List all without check news) 478 474 // More quickly but less fun to use … … 480 476 481 477 // Max mails sended on one pass 482 $conf['nbm_max_mails_send'] = 35; 478 $conf['nbm_max_treatment_timeout_percent'] = 0.8; 479 483 480 ?> -
branches/branch-1_6/include/functions.inc.php
r1131 r1157 519 519 * 520 520 * @param string $url 521 * @param string $title_msg 522 * @param integer $refreh_time 521 523 * @return void 522 524 */ 523 function redirect( $url )525 function redirect( $url , $msg = '', $refreh_time = 0) 524 526 { 525 527 global $user, $template, $lang_info, $conf, $lang, $t2, $page, $debug; 526 528 527 // $re fresh, $url_link and $title are required for creating an automated529 // $redirect_msg, $refresh, $url_link and $title are required for creating an automated 528 530 // refresh page in header.tpl 529 $refresh = 0; 531 if (!isset($msg) or ($msg == '')) 532 { 533 $redirect_msg = l10n('redirect_msg'); 534 } 535 else 536 { 537 $redirect_msg = $msg; 538 } 539 $refresh = $refreh_time; 530 540 $url_link = $url; 531 541 $title = 'redirection'; … … 860 870 return $available_upgrade_ids; 861 871 } 872 873 /** 874 * Adaptation of _HTTPRequestToString (http://fr.php.net/urlencode) 875 * 876 * 877 * @return array request to string 878 */ 879 function http_request_to_string($arr_request, $var_name, $separator='&') { 880 $ret = ""; 881 if (is_array($arr_request)) { 882 foreach ($arr_request as $key => $value) { 883 if (is_array($value)) { 884 if ($var_name) { 885 $ret .= http_request_to_string($value, "{$var_name}[{$key}]", $separator); 886 } else { 887 $ret .= http_request_to_string($value, "{$key}", $separator); 888 } 889 } else { 890 if ($var_name) { 891 $ret .= "{$var_name}[{$key}]=".urlencode($value)."&"; 892 } else { 893 $ret .= "{$key}=".urlencode($value)."&"; 894 } 895 } 896 } 897 } 898 if (!$var_name) { 899 $ret = substr($ret,0,-1); 900 } 901 return $ret; 902 } 903 904 /** 905 * Post request HTTP on backgroung and redirec to selected url 906 * 907 * Note : once this function called, the execution doesn't go further 908 * (presence of an exit() instruction. 909 * 910 * @param string $url_redirect 911 * @param string $redirect_message 912 * @param integer $redirect_refreh_time 913 * @return void 914 */ 915 function re_post_http($url_redirect, $redirect_message, $redirect_refreh_time) 916 { 917 global $conf; 918 919 $data_post = http_request_to_string($_POST, ''); 920 921 $message_post = "POST ".$_SERVER['PHP_SELF'].html_entity_decode(get_query_string_diff(array()))." HTTP/1.1\r\n"; 922 923 foreach (array_flip(array_diff(array_flip(apache_request_headers()), array('Content-Type', 'Content-Length'))) as $header_name => $header_value) 924 { 925 $message_post .= $header_name.": ".$header_value."\r\n"; 926 } 927 928 929 // $message_post .= "Host: ".$_SERVER['HTTP_HOST']."\r\n"; 930 // $message_post .= "Cookie: ".$conf['session_name']."=".$_COOKIE[$conf['session_name']]."\r\n"; 931 $message_post .= "Content-Type: application/x-www-form-urlencoded\r\n"; 932 $message_post .= "Content-Length: ".strlen($data_post)."\r\n"; 933 $message_post .= "\r\n"; 934 $message_post .= $data_post."\r\n"; 935 936 $fd = fsockopen($_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT']); 937 fputs($fd, $message_post); 938 fclose($fd); 939 940 redirect($url_redirect, $redirect_message, $redirect_refreh_time); 941 //exit(); done by redirect 942 } 943 862 944 ?> -
branches/branch-1_6/include/page_header.php
r1120 r1157 58 58 59 59 // refresh 60 if ( isset( $refresh ) and intval($refresh) >= 0 and isset( $url_link ) )60 if ( isset( $refresh ) and intval($refresh) >= 0 and isset( $url_link ) and isset( $redirect_msg ) ) 61 61 { 62 62 $template->assign_vars( 63 63 array( 64 'U_REDIRECT_MSG' => $redirect_msg, 64 65 'REFRESH_TIME' => $refresh, 65 66 'U_REFRESH' => $url_link -
branches/branch-1_6/language/en_UK.iso-8859-1/admin.lang.php
r1129 r1157 254 254 $lang['metadata_iptc'] = 'IPTC'; 255 255 $lang['name'] = 'name'; 256 $lang['nbm_break_list_user'] = 'List of users to send mail is limited to %d. Others users are not listed.'; 256 $lang['nbm_background_treatment_redirect'] = 'Execution time is out, treatment continue on background. Re-display on %d secondes...'; 257 $lang['nbm_break_timeout_list_user'] = 'Prepared time for list of users to send mail is limited. Others users are not listed.'; 257 258 $lang['nbm_col_check_user_send_mail'] = 'To send ?'; 258 259 $lang['nbm_col_last_send'] = 'Last send'; … … 278 279 $lang['nbm_msg_n_mails_sent'] = '%d mails were sent.'; 279 280 $lang['nbm_msg_no_mail_to_send'] = '%d mails were not sent.'; 280 $lang['nbm_nbm_break_ send_mail'] = 'Sent mail is limited to %d send by pass. Others mails are skipped.';281 $lang['nbm_nbm_break_timeout_send_mail'] = 'Time to send mail is limited. Others mails are skipped or sent on background.'; 281 282 $lang['nbm_no_mail_to_send'] = 'No mail to send.'; 282 283 $lang['nbm_no_user_available_to_send_L1'] = 'No user are available in order to send mail.'; -
branches/branch-1_6/language/en_UK.iso-8859-1/common.lang.php
r1125 r1157 344 344 $lang['w_month'] = 'Month'; 345 345 $lang['yes'] = 'Yes'; 346 $lang['redirect_msg'] = 'Redirection...'; 346 347 ?> -
branches/branch-1_6/language/fr_FR.iso-8859-1/admin.lang.php
r1152 r1157 257 257 $lang['metadata_iptc'] = 'IPTC'; 258 258 $lang['name'] = 'nom'; 259 $lang['nbm_break_list_user'] = 'La liste des utilisateurs pour l\'envoi est limitéé à %d. Les autres utilisateurs ne sont pas listés.'; 259 $lang['nbm_background_treatment_redirect'] = 'Le temps d\'éxécution étant dépassé, le traitement continue en arrière plan. Ré-affichage dans %d secondes...'; 260 $lang['nbm_break_timeout_list_user'] = 'Le temps de préparation de la liste des utilisateurs pour l\'envoi est limité. Les autres utilisateurs ne sont pas listés.'; 260 261 $lang['nbm_col_check_user_send_mail'] = 'A envoyer ?'; 261 262 $lang['nbm_col_last_send'] = 'Dernier envoi'; … … 281 282 $lang['nbm_msg_n_mails_sent'] = '%s mails ont été envoyés.'; 282 283 $lang['nbm_msg_no_mail_to_send'] = '%s mails n\'ont pas été envoyés.'; 283 $lang['nbm_nbm_break_ send_mail'] = 'Les mails envoyés sont limités à %d envois d\'une seule passe. Les autres envois de mail ont été ignorés.';284 $lang['nbm_nbm_break_timeout_send_mail'] = 'Le temps d\'envoi des mails est limité. Les autres envois de mail ont été ignorés ou vont être envoyés en arrière plan.'; 284 285 $lang['nbm_no_mail_to_send'] = 'Pas de mail à envoyer.'; 285 286 $lang['nbm_no_user_available_to_send_L1'] = 'Il n\'y a pas d\'utilisateur à notifier par mail.'; -
branches/branch-1_6/language/fr_FR.iso-8859-1/common.lang.php
r1125 r1157 344 344 $lang['w_month'] = 'Mois'; 345 345 $lang['yes'] = 'Oui'; 346 $lang['redirect_msg'] = 'Redirection...'; 346 347 ?> -
branches/branch-1_6/template/yoga/redirect.tpl
r1052 r1157 1 <p> Redirection...</p>1 <p>{U_REDIRECT_MSG}</p> 2 2 <p><a href="{U_REFRESH}">{lang:click_to_redirect}</a></p>
Note: See TracChangeset
for help on using the changeset viewer.