Changeset 4029 for extensions/Mail_supervisor/include/fonctions.php
- Timestamp:
- Oct 13, 2009, 1:40:08 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Mail_supervisor/include/fonctions.php
r4020 r4029 1 1 <?php 2 // +-----------------------------------------------------------------------+ 3 // | Piwigo - a PHP based picture gallery | 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | 8 // +-----------------------------------------------------------------------+ 9 // | This program is free software; you can redistribute it and/or modify | 10 // | it under the terms of the GNU General Public License as published by | 11 // | the Free Software Foundation | 12 // | | 13 // | This program is distributed in the hope that it will be useful, but | 14 // | WITHOUT ANY WARRANTY; without even the implied warranty of | 15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 // | General Public License for more details. | 17 // | | 18 // | You should have received a copy of the GNU General Public License | 19 // | along with this program; if not, write to the Free Software | 20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | 21 // | USA. | 22 // +-----------------------------------------------------------------------+ 23 24 if (!defined('PHPWG_ROOT_PATH')) 25 { 26 die('Hacking attempt!'); 27 } 28 29 2 30 load_language('plugin.lang', MAIL_SUPERV_PATH); 3 31 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 32 global $period_search,$period_match ; 33 $period_search=array("D","H","M","S","W"); 34 array_push($period_search,l10n('Week'),l10n('Day'),l10n('Hour'),l10n('Minute'),l10n('Seconde')); 35 36 $period_match=array(" day"," hour"," minute"," second"," week"); 37 array_push($period_match,'week','day','hour','minute','seconde'); 4 38 5 39 function sauve_options() … … 18 52 { 19 53 global $mails_données ; 20 $query = ' 54 55 $query = ' 21 56 UPDATE '.MAIL_SUPERV_TABLE.' 22 57 SET `nb_mails` = '.$mails_données['nb_mails'].', 23 58 `date_mail` = '.$mails_données['date_mail'].', 24 59 `nb_mails_maxi` = '.$mails_données['nb_mails_maxi'].', 25 `nb_mails_periode` = "'.$mails_données['nb_mails_periode'].'",26 60 `nb_mails_periode` = "'.$mails_données['nb_mails_periode'].'", 61 27 62 `nb_spams` = '.$mails_données['nb_spams'].', 28 63 `date_spam` = '.$mails_données['date_spam'].', 29 64 `nb_spams_maxi` = '.$mails_données['nb_spams_maxi'].', 30 `nb_spams_periode` = "'.$mails_données['nb_spams_periode'].'",65 `nb_spams_periode` = "'.$mails_données['nb_spams_periode'].'", 31 66 32 67 `quarantaine` = "'.$mails_données['quarantaine'].'", 33 68 `date_quarantaine` = '.$mails_données['date_quarantaine'].', 34 69 70 `quarantaine_periode` = "'.$mails_données['quarantaine_periode'].'", 71 35 72 `message` = "'.$mails_données['message'].'", 36 73 `header_text` = "'.$mails_données['header_text'].'" 37 74 WHERE `id` =1 LIMIT 1 '; 75 76 38 77 pwg_query($query); 78 79 39 80 } 40 81 //================================================================================= … … 48 89 if ($erreur_message <> "") 49 90 { 50 $erreur_message=str_replace("\n",'<br />',$erreur_message) ; 51 $erreur_message=sprintf(l10n('free_message "%s"'), $erreur_message ) ; 91 $erreur_message=str_replace("\n",'<br />',$erreur_message) ; 52 92 $template->assign('errors',$erreur_message); 53 93 $erreur_message=""; … … 61 101 if ($infos_message <> "") 62 102 { 63 $infos_message=str_replace("\n",'<br />',$infos_message) ;103 $infos_message=str_replace("\n",'<br />',$infos_message) ; 64 104 $template->assign('infos',$infos_message); 65 105 $infos_message=""; … … 76 116 function Get_Datas() 77 117 { 78 79 $query = " 118 ob_start(); 119 120 $data=Lire_datas(); 121 122 123 $m= ob_get_contents(); 124 ob_end_clean(); 125 126 if (strlen($m)>0) { 127 vérif_base() ; 128 $data=Lire_datas(); 129 } 130 return $data; 131 } 132 133 function Lire_datas() 134 { 135 global $period_search,$period_match ; 136 $query = " 80 137 SELECT * 81 138 FROM ".MAIL_SUPERV_TABLE." 82 139 ;"; 83 140 $data = mysql_fetch_array(pwg_query($query)); 84 $data['reste']= ($data['date_quarantaine']-time()) ; 85 $data['reste_mail']= ($data['date_mail']-time()) ; 86 $data['reste_spam']= ($data['date_spam']-time()) ; 87 88 return $data; 141 //==================================================================================== 142 143 144 $mails_periode="+".str_replace($period_search, $period_match, $data['nb_mails_periode']); 145 $next_day = strtotime( $mails_periode,$data['date_mail']); 146 $data['rest_mail']= ( $next_day )-time() ; 147 148 149 $spams_periode="+".str_replace($period_search, $period_match, $data['nb_spams_periode']); 150 $next_day = strtotime( $spams_periode,$data['date_spam']); 151 $data['rest_spam']= ( $next_day )-time() ; 152 153 154 $quarantaine_periode="+".str_replace($period_search, $period_match, $data['quarantaine_periode']); 155 $next_day = strtotime( $quarantaine_periode,$data['date_quarantaine']); 156 if ($data['quarantaine']) { 157 $data['reste'] = ( $next_day )-time() ; 158 }else{ 159 $data['reste'] = 0; 160 } 161 162 return $data; 89 163 } 90 164 … … 147 221 $minutes=substr ('00'.$minutes,-2,2); 148 222 $secondes=substr ('00'.$secondes,-2,2); 223 149 224 if ($week > 0 ) 150 225 { 226 151 227 return $week. " " .l10n('Week'). " " . $day . " " .l10n('Day'). "s ". $heures . " ". l10n('Hour'). "s " . $minutes. " " .l10n('minute'). "s ". $secondes." " .l10n('seconde')."s"; 152 228 } 153 return $day . " " .l10n('Day'). "s ". $heures . " ". l10n('Hour'). "s " . $minutes. " " .l10n(' minute'). "s ". $secondes." " .l10n('seconde')."s";229 return $day . " " .l10n('Day'). "s ". $heures . " ". l10n('Hour'). "s " . $minutes. " " .l10n('Minute'). "s ". $secondes." " .l10n('Seconde')."s"; 154 230 155 231 } … … 168 244 } 169 245 246 function vérif_base() 247 { 248 249 $q = " 250 CREATE TABLE IF NOT EXISTS ".MAIL_SUPERV_TABLE." ( 251 `id` SMALLINT( 5 ) NOT NULL DEFAULT '0', 252 253 `nb_mails` INT NOT NULL DEFAULT '0', 254 `date_mail` INT NOT NULL DEFAULT '0', 255 `nb_mails_maxi` INT NOT NULL DEFAULT '2000', 256 `nb_mails_periode` TEXT , 257 258 `nb_spams` INT NOT NULL DEFAULT '0', 259 `date_spam` INT NOT NULL DEFAULT '0', 260 261 `nb_spams_maxi` INT NOT NULL DEFAULT '10', 262 `nb_spams_periode` TEXT , 263 264 `quarantaine` TEXT NOT NULL , 265 `date_quarantaine` INT NOT NULL DEFAULT '0', 266 `quarantaine_periode` TEXT , 267 268 269 `message` TEXT NOT NULL , 270 `header_text` TEXT NOT NULL , 271 PRIMARY KEY (`id` ) 272 ) 273 ;"; 274 pwg_query($q); 275 276 $nb = Get_colonnes_de(MAIL_SUPERV_TABLE); 277 $table=$nb[MAIL_SUPERV_TABLE]; 278 //================================================================================ 279 if (!in_array( "nb_mails",$table)) { 280 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_mails` INT NOT NULL default '0' "; 281 pwg_query($query); } 282 if (!in_array( "date_mail",$table)) { 283 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `date_mail` INT NOT NULL default '0' "; 284 pwg_query($query); } 285 if (!in_array( "nb_mails_maxi",$table)) { 286 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_mails_maxi` INT NOT NULL default '2000' "; 287 pwg_query($query); } 288 if (!in_array( "nb_mails_periode",$table)) { 289 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_mails_periode` TEXT "; 290 pwg_query($query); } 291 292 293 if (!in_array( "nb_spams",$table)) { 294 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_spams` INT NOT NULL default '0' "; 295 pwg_query($query); } 296 if (!in_array( "date_spam",$table)) { 297 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `date_spam` INT NOT NULL default '0' "; 298 pwg_query($query); } 299 300 if (!in_array( "nb_spams_maxi",$table)) { 301 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_spams_maxi` INT NOT NULL default '10' "; 302 pwg_query($query); 303 if (!in_array( "nb_spams_periode",$table)) { 304 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_spams_periode` TEXT "; 305 pwg_query($query); } } 306 307 if (!in_array( "quarantaine",$table)) { 308 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `quarantaine` TEXT NOT NULL , "; 309 pwg_query($query); } 310 311 if (!in_array( "date_quarantaine",$table)) { 312 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `date_quarantaine` INT NOT NULL default '0' "; 313 pwg_query($query); 314 } 315 if (!in_array( "quarantaine_periode",$table)) { 316 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `quarantaine_periode` TEXT "; 317 pwg_query($query); } 318 319 if (!in_array( "message",$table)) { 320 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `message` TEXT "; 321 pwg_query($query); } 322 323 if (!in_array( "header_text",$table)) { 324 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `header_text` TEXT "; 325 pwg_query($query); } 326 327 328 $query = " 329 SELECT COUNT(*) 330 FROM ".MAIL_SUPERV_TABLE." 331 ;"; 332 //============================================================================== 333 list($count) = mysql_fetch_row(pwg_query($query)); 334 if ($count == 0) 335 { 336 $next_day = time() ; 337 $date_quarantaine=time(); 338 $q = ' 339 INSERT INTO '.MAIL_SUPERV_TABLE.' (id, 340 nb_mails,date_mail,nb_mails_maxi,nb_mails_periode, 341 nb_spams,date_spam,nb_spams_maxi,nb_spams_periode, 342 quarantaine, date_quarantaine,quarantaine_periode, 343 message,header_text) 344 VALUES (1, 345 0, 346 '.time().', 347 2000, 348 "1 week", 349 350 0, 351 '.time().', 352 10, 353 "2 day", 354 355 false, 356 '.time().', 357 "2 day", 358 359 "Init.", 360 "'.l10n('hello').'" 361 ) 362 ;'; 363 364 365 pwg_query($q); 366 367 } 368 } 369 function Get_colonnes_de($table) 370 { 371 $columns_of = array(); 372 $query = 'DESC '.$table.';'; 373 $result = mysql_query($query); 374 $columns_of[$table] = array(); 375 while ($row = mysql_fetch_row($result)) 376 { 377 array_push($columns_of[$table], $row[0]); 378 } 379 return $columns_of; 380 } 381 170 382 function test_envoie() 171 383 { 172 384 global $infos_message,$erreur_message ,$conf,$user ; 385 386 387 $infos_message=memo_var($user); 388 173 389 $admins = array(); 174 390 $query = ' … … 210 426 ob_start(); 211 427 $erreur_message =""; 212 $infos_message = memo_var($admins); 428 $infos_message .= memo_var($admins); 429 430 431 213 432 //=========================================================== 214 433 $args = array(); 215 216 434 $args['Bcc']=$admins; 217 218 $message_texte="Bonjour."; 219 $message_html="Test"; 220 435 $message_texte="Bonjour."; 436 $message_html="Test"; 221 437 /* 222 438 $limite = "_parties_".generate_key(32);; … … 235 451 $attachement .= "\n\n\n-----=".$limite."\n"; 236 452 */ 237 238 //========================================================================== 453 //========================================================================== 239 454 240 455 $args['subject']="Plugin Piwigo TEST"; 241 456 $args['content']="TEST "; 242 243 $infos_message ="TEST ENVOIE [admin].".memo_var($admins); 457 458 $infos_message .="ARGUMENTS.".memo_var($args); 459 $infos_message .="TEST ENVOIE [admin].".memo_var($admins); 460 244 461 $ret= pwg_mail( "", $args); 245 462 $m= ob_get_contents();
Note: See TracChangeset
for help on using the changeset viewer.