Changeset 10419 for extensions/Mail_supervisor/include
- Timestamp:
- Apr 16, 2011, 3:53:31 PM (13 years ago)
- Location:
- extensions/Mail_supervisor/include
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Mail_supervisor/include/constants.php
r9702 r10419 5 5 if (!defined('MAIL_BLACK_LISTE_TABLE')) define('MAIL_BLACK_LISTE_TABLE', $prefixeTable.'mail_black_list'); 6 6 if (!defined('Sv_MAIL_TABLE')) define('Sv_MAIL_TABLE', $prefixeTable.'Sv_mail'); 7 global $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ;7 global $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ; 8 8 $superv_champs = array( 9 9 "id", 10 10 "nb_mails", 11 11 "date_mail", 12 "nb_mails_maxi", 13 "nb_mails_periode", 12 "nb_mails_maxi", 13 "nb_mails_periode", 14 14 "nb_spams", 15 "date_spam", 16 "nb_spams_maxi", 17 "nb_spams_periode", 15 "date_spam", 16 "nb_spams_maxi", 17 "nb_spams_periode", 18 18 "quarantaine", 19 19 "date_quarantaine", 20 "quarantaine_periode", 21 "message", 22 "message_test", 23 "header_text", 24 ); 25 26 27 28 29 30 "INT NOT NULL DEFAULT '2000'", 31 "TEXT" , 32 33 "INT NOT NULL DEFAULT '0'", 34 "INT NOT NULL DEFAULT '10'", 35 "TEXT" , 36 37 38 "TEXT" , 39 "TEXT" , 40 "TEXT" , 41 42 43 ); 44 45 46 47 48 49 50 "region", 51 "ville", 52 53 "fai", 54 55 56 57 58 59 60 61 62 63 64 65 66 ); 20 "quarantaine_periode", 21 "message", 22 "message_test", 23 "header_text", 24 ); 25 26 $superv_type = array( 27 " SMALLINT( 5 ) NOT NULL DEFAULT '0'" , 28 "INT NOT NULL DEFAULT '0'" , 29 "INT NOT NULL DEFAULT '0'" , 30 "INT NOT NULL DEFAULT '2000'", 31 "TEXT" , 32 "INT NOT NULL DEFAULT '0'", 33 "INT NOT NULL DEFAULT '0'", 34 "INT NOT NULL DEFAULT '10'", 35 "TEXT" , 36 "TEXT" , 37 "INT NOT NULL DEFAULT '0'", 38 "TEXT" , 39 "TEXT" , 40 "TEXT" , 41 "TEXT" , 42 43 ); 44 45 46 $superv_bl_champs = array( 47 "id", 48 "ip", 49 "pays", 50 "region", 51 "ville", 52 "adresse", 53 "fai", 54 "nb" 55 ); 56 57 $superv_bl_type = array( 58 " smallint(5) UNSIGNED NOT NULL auto_increment ", 59 "TEXT" , 60 "TEXT" , 61 "TEXT" , 62 "TEXT" , 63 "TEXT" , 64 "TEXT" , 65 " smallint(5) UNSIGNED " 66 ); 67 67 68 68 ?> -
extensions/Mail_supervisor/include/fonctions.php
r10385 r10419 26 26 27 27 28 global $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ;28 global $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ; 29 29 // if (!isset($_COOKIE[session_name()])){} 30 30 … … 32 32 global $template ; 33 33 //=============================================== 34 function corrige_header($Carbonne,$headers,$args,$cl_list_mail,$mailto="") 34 function corrige_header($Carbonne,$headers,$args,$cl_list_mail,$mailto="") { 35 35 global $mails_options,$conf_mail,$infos_message; 36 36 if (!empty($args[$Carbonne]) && count($args[$Carbonne]) > 0 ){ 37 $cl_list_mail = str_replace(","," , ",get_strict_email_list(implode(',', $args[$Carbonne])))." \n" ; 37 $cl_list_mail = str_replace(","," , ",get_strict_email_list(implode(',', $args[$Carbonne])))." \n" ; 38 38 $cl_liste_dest = implode(', ', $args[$Carbonne])." \n"; 39 if ($mails_options['check_header_carbon'] == 'on') { 40 $headers = preg_replace('/.*'.$Carbonne.':(.*).\n/i', $Carbonne.': '. $cl_list_mail, $headers); 41 } 42 $ret->list_mail = $cl_list_mail ; 39 if ($mails_options['check_header_carbon'] == 'on') { 40 $headers = preg_replace('/.*'.$Carbonne.':(.*).\n/i', $Carbonne.': '. $cl_list_mail, $headers); 41 } 42 $ret->list_mail = $cl_list_mail ; 43 43 } else { 44 44 // Raz Bcc, Cc dans headers 45 45 $headers = preg_replace('/.*'.$Carbonne.'(.*).\n/i', "" , $headers); 46 $ret->list_mail = "" ; 47 } 48 $ret->headers = $headers ; 49 return $ret; 50 } 51 46 $ret->list_mail = "" ; 47 } 48 $ret->headers = $headers ; 49 return $ret; 50 } 51 52 52 function int_to_heure($int){ 53 53 global $lang,$mails_donnees ; … … 56 56 57 57 58 59 $week = (int) ($int/$delta); 60 $int= $int-($week*$delta) ; 61 62 63 $day= (int) ($int/$delta); 64 65 66 67 68 69 70 71 72 73 74 75 $day = substr ('00'. $day,-2,2); 76 $heures = substr ('00'. $heures,-2,2); 77 78 79 58 $delta=(7*24*60*60) ; 59 $week = (int) ($int/$delta); 60 $int= $int-($week*$delta) ; 61 62 $delta=(24*60*60) ; 63 $day= (int) ($int/$delta); 64 $int=$int-($day*$delta); 65 66 $delta=(60*60) ; 67 $heures=(int) ($int/$delta); 68 $int=$int-($heures*$delta); 69 70 $delta=(60) ; 71 $minutes=(int) ($int/$delta); 72 $int= $int - ($minutes*$delta); 73 74 $secondes=(int) ($int); 75 $day = substr ('00'. $day,-2,2); 76 $heures = substr ('00'. $heures,-2,2); 77 $minutes = substr ('00'.$minutes,-2,2); 78 $secondes = substr ('00'.$secondes,-2,2); 79 80 80 $retour=""; 81 81 $Week=explode(" ",l10n('Week %d')); … … 88 88 if ($secondes > 0) $retour .= "+" . $secondes." " .l10n('Second'); 89 89 $retour=str_replace("+0","+",$retour); 90 //================================================================================================ 90 //================================================================================================ 91 91 return $retour; 92 } 93 94 92 } 93 94 95 95 function verif_base(){ 96 96 global $lang,$superv_champs,$superv_type,$superv_bl_champs,$superv_bl_type; 97 97 load_language('plugin.lang', MAIL_SUPERV_PATH); 98 //============================================================================== 98 //============================================================================== 99 99 create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ; 100 ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ; 101 //============================================================================== 100 ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ; 101 //============================================================================== 102 102 create_table(mail_superv_TABLE,$superv_champs,$superv_type) ; 103 103 ajust_table(mail_superv_TABLE,$superv_champs,$superv_type) ; 104 //============================================================================== 105 $valeurs= array ( 106 107 108 109 110 111 112 113 114 115 116 117 104 //============================================================================== 105 $valeurs= array ( 1, 106 0, 107 time(), 108 2000, 109 '"604800"' , 110 0, 111 time(), 112 10, 113 '"172800"', 114 '"false"', 115 time(), 116 '"172800"', 117 '"Init"', 118 118 '"'.l10n('Sv_supervisor').'"', 119 120 121 119 '"'.l10n('hello').'"', 120 ); 121 ajout_ligne(mail_superv_TABLE,$superv_champs, $valeurs,false ) ; 122 122 } 123 123 //================================================================================= … … 134 134 array_push($columns_of, $row[0]); 135 135 } 136 136 137 137 return $columns_of; 138 138 } … … 152 152 LEFT JOIN '.USER_GROUP_TABLE.' AS ug 153 153 ON u.'.$conf['user_fields']['id'].' = ug.user_id 154 WHERE ug.group_id='.$group_id.' '; 154 WHERE ug.group_id='.$group_id.' '; 155 155 $groups=array(); 156 $datas = pwg_query($query); 157 156 $datas = pwg_query($query); 157 158 158 if (!empty($datas)) { 159 while ($group = mysql_fetch_array($datas,MYSQL_ASSOC)){ 160 if (!empty($group['email'])){ 159 while ($group = mysql_fetch_array($datas,MYSQL_ASSOC)){ 160 if (!empty($group['email'])){ 161 161 array_push($groups, format_email($group['username'], $group['email'] )); 162 162 } 163 163 } 164 } 164 } 165 165 return $groups ; 166 166 167 167 } 168 168 //================================================================================= … … 170 170 function create_table($nom_table,$champs,$types) //mail_superv_TABLE 171 171 { 172 173 172 $i=0; 173 $valeurs=array(); 174 174 foreach ( $champs as $champ) { 175 175 $champ = trim($champ); … … 179 179 180 180 181 182 181 182 if ( count($valeurs) == 0) return ; 183 183 184 184 $valeurs=implode(", ",$valeurs) ; 185 186 $query = "CREATE TABLE IF NOT EXISTS `" . $nom_table . "` (". $valeurs . " , PRIMARY KEY (`id` ) ) ENGINE=MyISAM ;"; 187 if ( pwg_query($query) ) return ; 188 die("ERREUR CREATION ".$query); 189 190 185 //=============================================================================== 186 $query = "CREATE TABLE IF NOT EXISTS `" . $nom_table . "` (". $valeurs . " , PRIMARY KEY (`id` ) ) ENGINE=MyISAM ;"; 187 if ( pwg_query($query) ) return ; 188 die("ERREUR CREATION ".$query); 189 190 191 191 } 192 192 function ajust_table($nom_table,$champs,$types) //mail_superv_TABLE … … 194 194 global $infos_message ; 195 195 $colonnes = Get_colonnes_de($nom_table); 196 $data =$types ;197 198 196 $data = $types ; 197 $i=0; 198 $valeurs=array(); 199 199 foreach ( $champs as $champ) 200 200 { 201 201 $champ = trim($champ); 202 202 if (!in_array( $champ,$colonnes)) { 203 203 array_push($valeurs , " ADD `".$champ."`" . ' ' . $data[ $i] ) ; 204 205 206 207 } 208 //============================================================================= 209 210 204 } 205 $i +=1; 206 207 } 208 //============================================================================= 209 if ( count($valeurs) == 0) return ; 210 211 211 $infos_message .= "AJUSTE TABLE : ". $nom_table . "<br />" . "NB (col) : ". count($colonnes) . mail_supervisor::Memo_Var($valeurs) . "<br />" ; 212 212 213 213 $valeurs=implode(", ",$valeurs) ; 214 215 216 if ( pwg_query($query)) return ; 217 218 } 219 //============================================================================== 214 //=============================================================================== 215 $query = "ALTER TABLE `" . $nom_table . "` ". $valeurs ; 216 if ( pwg_query($query)) return ; 217 die($query); 218 } 219 //============================================================================== 220 220 function ajout_ligne($nom_table,$champs,$valeurs,$force) 221 221 { 222 222 if (!$force) { 223 223 $query = " 224 SELECT `id` , COUNT(`id`) as total225 226 ;";227 228 229 224 SELECT `id` , COUNT(`id`) as total 225 FROM `".$nom_table."` GROUP by `id` 226 ;"; 227 list($count) = mysql_fetch_row(pwg_query($query)); 228 229 230 230 }else{ 231 231 232 233 } 234 232 $count = 0 ; 233 } 234 235 235 if ($count == 0) 236 236 { 237 237 $n_champs=implode(",",$champs); 238 238 $n_valeurs=implode(",",$valeurs); 239 240 INSERT INTO `".$nom_table."` (". $n_champs.")241 VALUES ( ". 242 243 244 245 239 $query = " 240 INSERT INTO `".$nom_table."` (". $n_champs.") 241 VALUES ( ". $n_valeurs .")"; 242 243 if (pwg_query($query)) return ; 244 die($query); 245 246 246 } 247 247 } … … 260 260 if (!is_numeric($mails_donnees['quarantaine_periode'])){ 261 261 $periode=Str_To_Time( $mails_donnees['quarantaine_periode'],0); 262 $mails_donnees['quarantaine_periode']= ($periode > 0) ? $periode : '172800' ; 262 $mails_donnees['quarantaine_periode']= ($periode > 0) ? $periode : '172800' ; 263 263 } 264 264 if ($infos_message != "") { 265 265 array_push($page['infos'], $infos_message); 266 266 $infos_message=""; 267 } 267 } 268 268 if ($erreur_message != "") { 269 269 array_push($page['errors'], $erreur_message); 270 270 $erreur_message =""; 271 } 272 271 } 272 273 273 } 274 274 //======================================================================= … … 295 295 $lang['Sv_'. $lang['Sv_second']] = 'second'; 296 296 297 } 298 //--- traduction --> anglais --- 297 } 298 //--- traduction --> anglais --- 299 299 300 300 //========= suppression numeric et symbole ========== 301 $new_valeur =( preg_replace("/[0-9+\-.*\/()%]/"," ",$a_ajouter)); 301 $new_valeur =( preg_replace("/[0-9+\-.*\/()%]/"," ",$a_ajouter)); 302 302 $nv = trim( sup_double_espace($new_valeur)) ; 303 304 305 306 307 308 309 310 303 304 305 306 $conv['week']= (7*24*60*60); 307 $conv['day']= (24*60*60); 308 $conv['hour']= (60*60) ; 309 $conv['minute']= 60 ; 310 $conv['second']= 1; 311 311 312 312 $nv = explode(" ", $nv ); 313 313 314 314 foreach($nv as $nv1){ 315 315 if (!isset($lang['Sv_'. $nv1]) ) { 316 //==== au cas pluriel === 317 $nv0 = substr($nv1, 0,-1) ; 316 //==== au cas pluriel === 317 $nv0 = substr($nv1, 0,-1) ; 318 318 $a_ajouter= str_replace( $nv1,$nv0, $a_ajouter); 319 $nv1 = $nv0 ; 320 } 319 $nv1 = $nv0 ; 320 } 321 321 if (!isset($lang['Sv_'. $nv1]) ) { 322 $erreur_message .= $nv1. " ".l10n('not_found')."<br />"; 323 // die($erreur_message); 322 $erreur_message .= $nv1. " ".l10n('not_found')."<br />"; 323 // die($erreur_message); 324 324 }else { 325 ob_start(); 325 ob_start(); 326 326 $match = $conv[strtolower($lang['Sv_'. $nv1])] ; 327 327 $a_ajouter = str_replace($nv1," ". $match ." ",$a_ajouter) ; 328 328 $erreur_message .= ob_get_contents(); 329 329 ob_end_clean(); 330 } 330 } 331 331 } 332 332 … … 338 338 $new_valeur = str_replace($v1,$v2,$a_ajouter) ; 339 339 $new_valeur = str_replace('++','+',$new_valeur ) ; 340 340 341 341 return $new_valeur; 342 342 } … … 347 347 global $erreur_message,$infos_message,$user; 348 348 global $lang; 349 349 350 350 $ajout=ucwords ($ajout); 351 352 351 352 353 353 if (is_numeric($ajout)) 354 354 $valeur= $ajout ; … … 356 356 { 357 357 $valeur= Date_to_numeric( $ajout) ; 358 358 359 359 } 360 360 361 361 $new_valeur = explode( "|", $valeur ); 362 362 … … 365 365 $erreur = false; 366 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 367 //$new_valeur = $a_ajouter + $init_date ; 368 foreach($new_valeur as $nv) 369 { 370 $return = matheval($nv) ; 371 if (strpos("error",$return)===false) { 372 $p += $return ; 373 }else { 374 $erreur_message .= "[" . $ajout . "] --> " . l10n('Sv_syntax_error') . " : " . $nv ."<br />"; 375 $erreur = true; 376 } 377 378 379 } 380 if ($erreur) $p = -1000 ; 381 381 return intval($p) ; 382 382 383 383 } 384 384 //===================================================================================== 385 function matheval($equation) 386 { 385 function matheval($equation) 386 { 387 387 388 388 $return="error"; 389 389 390 391 $equation = preg_replace("/[^0-9+\-.*\/()%]/","",$equation); 392 $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation); 393 $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation); 394 $equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation); 395 396 if ( $equation == "" ) 397 { 398 $return = 0; 399 } else { 400 @eval("\$return=" . $equation . ";" ); 401 } 402 return $return; 403 404 } 390 391 $equation = preg_replace("/[^0-9+\-.*\/()%]/","",$equation); 392 $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation); 393 $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation); 394 $equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation); 395 396 if ( $equation == "" ) 397 { 398 $return = 0; 399 } else { 400 @eval("\$return=" . $equation . ";" ); 401 } 402 return $return; 403 404 } 405 405 406 406 //====================================================================================== 407 407 function sup_double_espace($chaine){ 408 408 global $erreur_message; 409 410 411 409 $str_temp = $chaine." "; 410 $sep=" "; 411 $chaine = trim($chaine); 412 412 if ($chaine=="") return ; 413 414 415 $str_temp = str_replace($sep.$sep, $sep, $chaine );416 417 // 418 419 420 421 422 } 423 //==================== TEST black_liste ============================================ 413 $existe = (strpos($sep.$sep,$chaine )===false) ; 414 while ($existe ){ 415 $str_temp = str_replace($sep.$sep, $sep, $chaine ); 416 if($str_temp == $chaine ) return $chaine ; 417 // $erreur_message .= mail_supervisor::Memo_Var($str_temp) ; 418 $chaine = $str_temp; 419 $existe = (strpos($sep.$sep,$chaine )===false) ; 420 } 421 return $chaine; 422 } 423 //==================== TEST black_liste ============================================ 424 424 function kill_list() { 425 425 global $pays,$region,$ville,$ip ; 426 global $erreur_message,$infos_message,$conf; 426 global $erreur_message,$infos_message,$conf; 427 427 global $conf, $user, $page; 428 428 global $mails_options ; 429 global $superv_bl_champs,$superv_bl_type ; 430 global $nb ; 429 global $superv_bl_champs,$superv_bl_type ; 430 global $nb ; 431 431 if (!isset($ip)) { 432 432 if (getenv("HTTP_CLIENT_IP")) { … … 437 437 } 438 438 $champs=implode(',',$superv_bl_champs); 439 $query = "SELECT ".$champs.",COUNT(`ip`) as total 440 FROM `".MAIL_BLACK_LISTE_TABLE."` 441 WHERE '".$ip."' LIKE `ip` 442 GROUP by `ip` 443 ;"; 444 445 446 447 448 449 450 $nb = $datas['total']|0;451 //======================================================================= 452 if ($mails_options['set_auto'] == 'on') { 439 $query = "SELECT ".$champs.",COUNT(`ip`) as total 440 FROM `".MAIL_BLACK_LISTE_TABLE."` 441 WHERE '".$ip."' LIKE `ip` 442 GROUP by `ip` 443 ;"; 444 $result = @pwg_query($query); 445 if (!$result) { 446 verif_base(); 447 $result = @pwg_query($query); 448 } 449 $datas = mysql_fetch_array($result,MYSQL_ASSOC); 450 $nb = $datas['total']|0; 451 //======================================================================= 452 if ($mails_options['set_auto'] == 'on') { 453 453 global $user_name,$mail_adresse; 454 454 455 455 if (isset($nb) && $nb>0) { 456 //if (test_spam($ip,$user['username'] ,$user['email'])) // ne plus tester automatiquement . 456 //if (test_spam($ip,$user['username'] ,$user['email'])) // ne plus tester automatiquement . 457 457 if ($nb==0) { 458 459 460 461 "'".$region."'", 462 463 464 "'".$user['username']."'", 465 466 467 ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,$nb==0) ;468 }else{ 469 mail_supervisor::Get_geo(); 470 $nb +=1; 471 472 if (isset($_POST['pays'])) 473 474 475 `ville` = '" . $ville . "', 476 "; 477 $query .= "`adresse` = '".$user['email']."', 478 `fai` = '".$user['username']."', 479 480 WHERE '".$ip."' like `ip` "; 481 pwg_query($query ); 482 483 484 // die($nb." ".$ip." ".$user['username']." ".$user['email']); 485 486 return true ; 487 } 458 $valeurs=array( 'NULL', 459 "'".$ip."'", 460 "'".$pays."'", 461 "'".$region."'", 462 "'".$ville."'", 463 "'".$user['email']."'", 464 "'".$user['username']."'", 465 $nb+1 466 ); 467 ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,$nb==0) ; 468 }else{ 469 mail_supervisor::Get_geo(); 470 $nb +=1; 471 $query ="UPDATE " . MAIL_BLACK_LISTE_TABLE . " SET "; 472 if (isset($_POST['pays'])) 473 $query .= "`pays` = '". $pays ."', 474 `region` = '" . $region ."', 475 `ville` = '" . $ville . "', 476 "; 477 $query .= "`adresse` = '".$user['email']."', 478 `fai` = '".$user['username']."', 479 `nb` = " . $nb . " 480 WHERE '".$ip."' like `ip` "; 481 pwg_query($query ); 482 } 483 $erreur_message .= $pays . $ip ." <br />User Name :".$user['username']."<br />User Mail :".$user['email'] . ' -----> ' . l10n('Sv_black_liste') ; 484 // die($nb." ".$ip." ".$user['username']." ".$user['email']); 485 486 return true ; 487 } 488 488 } 489 489 //============================================================================== 490 490 491 if ( $mails_options['ip'] == $ip ) return ($nb > 0) ; 491 if ( $mails_options['ip'] == $ip ) return ($nb > 0) ; 492 492 $ip0= $mails_options['ip'] ; 493 $mails_options['ip'] = $ip ; 494 mail_supervisor::sauve_options(); 495 496 497 498 SELECT ".$champs.",COUNT(`id`) as total499 FROM `".MAIL_BLACK_LISTE_TABLE."`500 WHERE '".$ip."' = `ip` 501 GROUP by `ip` 502 ;";503 504 505 506 507 508 509 510 $nb = $datas['total']; 511 512 513 514 $erreur_message .= $ip0 . ' | ' .$ip . ' | ' . $pays . ' | ' . $region . ' | ' . $ville . ' ' . $nb . ' ==> '; 515 516 517 518 519 520 521 "'".$region."'", 522 523 "'".$user['email']."'", 524 "'".$user['username']."'", 525 526 527 ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,true) ; 528 529 530 531 532 UPDATE " . MAIL_BLACK_LISTE_TABLE . " 533 534 if (isset($_POST['pays'])) 535 $query .= " 536 537 538 539 540 $query .= " 541 542 `fai` = '".$user['username']."', 543 544 WHERE '".$ip."' = `ip` 545 546 547 pwg_query($query ); 548 549 493 $mails_options['ip'] = $ip ; 494 mail_supervisor::sauve_options(); 495 if ( $nb > 0 ) 496 { 497 $query = " 498 SELECT ".$champs.",COUNT(`id`) as total 499 FROM `".MAIL_BLACK_LISTE_TABLE."` 500 WHERE '".$ip."' = `ip` 501 GROUP by `ip` 502 ;"; 503 $result = @pwg_query($query); 504 505 if (!$result) { 506 verif_base(); 507 $result = @pwg_query($query); 508 } 509 $datas = mysql_fetch_array($result,MYSQL_ASSOC); 510 $nb = $datas['total']; 511 512 $row = mysql_fetch_row(pwg_query($query)); 513 $nb = ($row[7]); 514 $erreur_message .= $ip0 . ' | ' .$ip . ' | ' . $pays . ' | ' . $region . ' | ' . $ville . ' ' . $nb . ' ==> '; 515 516 if ($nb == 0) 517 { 518 $valeurs=array( 'NULL', 519 "'".$ip."'", 520 "'".$pays."'", 521 "'".$region."'", 522 "'".$ville."'", 523 "'".$user['email']."'", 524 "'".$user['username']."'", 525 1 526 ); 527 ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,true) ; 528 529 } else { 530 $nb += 1; 531 $query =" 532 UPDATE " . MAIL_BLACK_LISTE_TABLE . " 533 SET "; 534 if (isset($_POST['pays'])) 535 $query .= " 536 `pays` = '". $pays ."', 537 `region` = '" . $region ."', 538 `ville` = '" . $ville . "', 539 "; 540 $query .= " 541 `adresse` = '".$user['email']."', 542 `fai` = '".$user['username']."', 543 `nb` = " . $nb . " 544 WHERE '".$ip."' = `ip` 545 "; 546 547 pwg_query($query ); 548 } 549 } 550 550 return ($nb > 0) ; 551 551 } … … 558 558 $result=""; 559 559 $ip= sup_double_espace($ip); 560 if (strlen($ip)>3) { 560 if (strlen($ip)>3) { 561 561 //================== Verifie si l'IP est correct ================================ 562 if (clj_is_ip($ip)){ 563 564 } else { 565 //================== Verifie si l'adresse mail est correcte ================================ 566 if( clj_is_mail($ip) ){ 567 568 569 570 571 572 //================== Login ================ 573 574 575 576 } 562 if (clj_is_ip($ip)){ 563 564 } else { 565 //================== Verifie si l'adresse mail est correcte ================================ 566 if( clj_is_mail($ip) ){ 567 $mail_adresse=$ip ; 568 $ip=""; 569 } 570 else 571 { 572 //================== Login ================ 573 $user_name=$ip; 574 $ip=""; 575 } 576 } 577 577 //============================================================================= 578 578 } … … 582 582 $user_name=""; // ne plus tester sur le login. 583 583 $mail_adresse =str_replace(" ","%20",trim($mail_adresse)); 584 if ( strlen($user_name) > 3) 584 if ( strlen($user_name) > 3) $type[]="username=$user_name" ; 585 585 if ( strlen($mail_adresse) > 3) $type[]="email=".$mail_adresse ; 586 if ( strlen($ip) > 3) $type[]="ip=".$ip ; 587 foreach ( $type as $fil ) { 586 if ( strlen($ip) > 3) $type[]="ip=".$ip ; 587 foreach ( $type as $fil ) { 588 588 $resultat=""; 589 589 if ( clj_fetchRemote($src.$fil , $resultat,1)) 590 $result .= $resultat.'<br />' ; 590 $result .= $resultat.'<br />' ; 591 591 } 592 592 593 593 return !(strpos( $result ,'yes' ) === false) ; 594 594 595 595 } 596 596 //================================================================== 597 597 function lire_fichier_distant($fichier){ 598 598 $buffer=""; 599 $handle = @fopen($fichier,"r"); 599 $handle = @fopen($fichier,"r"); 600 600 if ($handle) { 601 while (!feof($handle)) { 601 while (!feof($handle)) { 602 602 $buffer .= fgets($handle, 4096); 603 } 604 605 606 603 } 604 fclose($handle); 605 } 606 607 607 return $buffer ; 608 608 … … 611 611 function clj_is_ip($ip){ 612 612 if (preg_match("/^(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]|[1-9])\.){1}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9])\.){2}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9]){1}))$/",$ip)) return true ; 613 613 614 614 } 615 615 616 616 function clj_is_mail($mail) 617 { 618 619 if(preg_match('/^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$/' ,$mail)) return true ; 620 if(preg_match('/#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#/' ,$mail)) return true ; 621 } 622 623 617 { 618 619 if(preg_match('/^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$/' ,$mail)) return true ; 620 if(preg_match('/#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#/' ,$mail)) return true ; 621 } 622 623 624 624 function clj_fetchRemote($src, &$dest, $timeout=1, $user_agent='Piwigo', $step=0) 625 625 { … … 628 628 629 629 if ($src=="") return ; 630 630 631 631 if (!url_is_remote($src)) 632 632 { 633 633 634 634 $content = @file_get_contents($src); 635 635 if ($content !== false) … … 643 643 } 644 644 } 645 645 646 646 // After 3 redirections, return false 647 647 if ($step > 3) return false; -
extensions/Mail_supervisor/include/function_test_send.php
r9702 r10419 23 23 24 24 if ( !defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 25 function test_envoie($message,$group_name,$group_id){ 25 function test_envoie($message,$group_name,$group_id){ 26 26 global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_donnees,$args,$lang ; 27 $mailto=""; 27 $mailto=""; 28 28 load_language('plugin.lang', MAIL_SUPERV_PATH); 29 29 30 30 //================================================================================== 31 31 if (!isset($infos_message)) 32 33 34 32 { 33 $infos_message = ""; 34 } 35 35 if (!isset($erreur_message)) 36 37 38 36 { 37 $erreur_message = ''; 38 } 39 39 if (!isset($mails_donnees)) 40 41 42 } 40 { 41 $mails_donnees = mail_supervisor::Get_Datas(); 42 } 43 43 if (!isset($conf_mail)) 44 44 { 45 45 $conf_mail = get_mail_configuration(); 46 46 } 47 48 { 47 if (isset($args)) 48 { 49 49 $infos_message=mail_supervisor::Memo_Var($args); 50 50 }else{ 51 52 51 $args = array(); 52 } 53 53 //===================================================================================================== 54 54 55 55 56 56 57 57 $groups=get_liste($group_id); … … 62 62 $args['Bcc']=$groups; 63 63 } else { 64 $mailto = $conf_mail['formated_email_webmaster']; 65 } 66 64 $mailto = $conf_mail['formated_email_webmaster']; 65 } 66 67 67 $args['from'] =(function_exists('get_user_language_desc')) ? get_user_language_desc($conf_mail['formated_email_webmaster']):$conf_mail['formated_email_webmaster']; 68 68 $message_html =$message; 69 69 if (function_exists('get_user_language_desc') and isset($message) and $message <> '') 70 70 $message = get_user_language_desc($message)."\n\n"; 71 72 73 71 72 //================================================================== 73 $message_texte=sprintf( 74 74 l10n('Sv_message_texte %s %s %s %s'), 75 75 format_date( date("Y-m-d H:i:s")), 76 77 78 79 ); 80 81 76 $group_name, 77 $message, 78 $args['from'] 79 ); 80 //================================================================== 81 $message_html .= "</br>" . $message . "</br>" . $message_texte; 82 82 //========================================================================== 83 83 84 85 86 87 88 $ret= pwg_mail($mailto , $args); 89 90 { 91 92 93 94 95 96 97 98 99 100 84 $args['subject']="Plugin Piwigo TEST"; 85 $args['content']=$message_html; 86 $infos_message .="To :" . $mailto; 87 88 $ret= pwg_mail($mailto , $args); 89 if ( $group_name <> '' or $mailto <> '' ) 90 { 91 if ($group_name<>'') { 92 $infos_message .= '<br />'. sprintf( l10n('An information email was sent to group "%s"'), $group_name ).'<br />'; 93 } 94 if ($mailto <> '') { 95 $infos_message .= '<br />'. sprintf( l10n('Sv_mail_sent_to'), $mailto ).'<br />'; 96 } 97 98 }else{ 99 $infos_message .='<br />'.l10n('Sv_no_receiver_available') ; 100 } 101 101 } 102 102 //=============================================================================================================== … … 105 105 106 106 $mails_donnees = mail_supervisor::Get_Datas(); 107 107 if (!isset($conf_mail)) 108 108 { 109 109 $conf_mail = get_mail_configuration(); … … 112 112 load_language('plugin.lang', MAIL_SUPERV_PATH); 113 113 114 $nom ='piwigo_logo_sombre_214x100.png';115 116 117 118 $fd = fopen( $fichier, "r" ); 119 $contenu = fread( $fd, filesize( $fichier ) );120 fclose( $fd );121 $piecejointe = chunk_split(base64_encode($contenu));122 123 124 114 $nom ='piwigo_logo_sombre_214x100.png'; 115 $fichier=PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png' ; 116 $typemime='image/jpeg'; 117 118 $fd = fopen( $fichier, "r" ); 119 $contenu = fread( $fd, filesize( $fichier ) ); 120 fclose( $fd ); 121 $piecejointe = chunk_split(base64_encode($contenu)); 122 123 124 $from=$args['from']; 125 125 $to=""; 126 126 … … 128 128 l10n('Sv_message_texte %s %s %s'), 129 129 format_date( date("Y-m-d H:i:s")), 130 131 132 ); 133 134 135 $message_html = 136 ob_start(); 137 130 $to, 131 $from 132 ); 133 134 135 $message_html = '<img src="'.PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png" />'; 136 ob_start(); 137 138 138 echo str_replace("\n","<br />",$message_texte); 139 139 140 140 $message_html .= ob_get_contents()."\n"; 141 141 //ob_flush(); 142 142 ob_end_clean(); 143 143 144 $limite=$conf_mail['boundary_key']; 145 $headers = date("Y-m-d H:i:s") ."\n"; 144 $limite=$conf_mail['boundary_key']; 145 $headers = date("Y-m-d H:i:s") ."\n"; 146 146 147 147 //======================================================================================= … … 149 149 $headers.= "Reply-To: ".$args['from']."\n"; 150 150 $nb_destinataires=0; 151 $destinataire = $conf_mail['email_webmaster']; 151 $destinataire = $conf_mail['email_webmaster']; 152 152 if (!empty($args['Cc'])){ 153 153 $nb_destinataires += count($args['Cc']); 154 154 $to= explode(',', $args['Cc']); 155 $headers .= get_strict_email_list($to) ;156 157 if (!empty($args['Bcc'])){ 158 $nb_destinataires += count($args['Bcc']); 155 $headers .= get_strict_email_list($to) ; 156 } 157 if (!empty($args['Bcc'])){ 158 $nb_destinataires += count($args['Bcc']); 159 159 $to = implode(',', $args['Bcc']); 160 $headers .= 'Bcc :'.get_strict_email_list($to)."\n" ;160 $headers .= 'Bcc :'.get_strict_email_list($to)."\n" ; 161 161 } 162 162 … … 166 166 $headers.= 'MIME-Version: 1.0'."\n"; 167 167 $headers.= 'X-Mailer: Piwigo Mailer'."\n"; 168 //Le message en texte simple pour les navigateurs qui n'acceptent pas le HTML 169 $texte = "This is a multi-part message in MIME format.\n"; 170 $texte .= "-----=".$limite."\n"; 171 $texte .= "Ceci est un message est au format MIME.\n"; 172 $texte .= 'Content-Type: text/plain; charset="UTF-8"'."\n"; 173 $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 174 $texte .= $message_texte ; 175 $texte .= "\n\n"; 176 $texte .= "-----=".$limite."\n"; 177 $texte .= 'Content-Type: text/html; charset="UTF-8"'."\n"; 178 $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 179 $texte .= $message_html; 180 $texte .= "\n\n"; 181 $attachement = "-----=".$limite."\n"; 182 $attachement .= "Content-Type: ".$typemime."; name=\"".$nom."\"\n"; 183 $attachement .= "Content-Transfer-Encoding: base64\n"; 184 $attachement .= "Content-Disposition: attachment; filename=\"".$nom."\"\n\n"; 185 $attachement .= $piecejointe; 186 $attachement .= "\n\n\n-----=".$limite."\n"; 168 //Le message en texte simple pour les navigateurs qui n'acceptent pas le HTML 169 $texte = "This is a multi-part message in MIME format.\n"; 170 $texte .= "-----=".$limite."\n"; 171 $texte .= "Ceci est un message est au format MIME.\n"; 172 $texte .= 'Content-Type: text/plain; charset="UTF-8"'."\n"; 173 $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 174 $texte .= $message_texte ; 175 $texte .= "\n\n"; 176 $texte .= "-----=".$limite."\n"; 177 $texte .= 'Content-Type: text/html; charset="UTF-8"'."\n"; 178 $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 179 $texte .= $message_html; 180 $texte .= "\n\n"; 181 $attachement = "-----=".$limite."\n"; 182 $attachement .= "Content-Type: ".$typemime."; name=\"".$nom."\"\n"; 183 $attachement .= "Content-Transfer-Encoding: base64\n"; 184 $attachement .= "Content-Disposition: attachment; filename=\"".$nom."\"\n\n"; 185 $attachement .= $piecejointe; 186 $attachement .= "\n\n\n-----=".$limite."\n"; 187 187 $ret=false; 188 188 ob_start(); 189 $ret= mail( $destinataire, $args['subject'], $texte.$attachement, $headers); 189 $ret= mail( $destinataire, $args['subject'], $texte.$attachement, $headers); 190 190 $message = ob_get_contents() ; 191 191 //ob_flush(); … … 195 195 $infos_message = "-------------------"; 196 196 } 197 return $ret; 197 return $ret; 198 198 } 199 199 ?> -
extensions/Mail_supervisor/include/save_info.php
r9702 r10419 4 4 switch (strtolower($info_ip)) 5 5 { 6 case 'ajout' : 6 case 'ajout' : 7 7 $ip_black=str_replace("*","%",$ip_black); 8 8 if (!($ip_black == '')) { 9 9 $query = " 10 SELECT `ip`11 FROM `".MAIL_BLACK_LISTE_TABLE."`12 WHERE '".$ip_black."' LIKE ip 13 ;";14 //============================================================================== 10 SELECT `ip` 11 FROM `".MAIL_BLACK_LISTE_TABLE."` 12 WHERE '".$ip_black."' LIKE ip 13 ;"; 14 //============================================================================== 15 15 list($count) = mysql_fetch_row(pwg_query($query)); 16 //============================================================================== 16 //============================================================================== 17 17 $valeurs=array( 'NULL', 18 19 20 "'".$region."'", 21 22 23 24 25 26 ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,($count==0)) ;18 "'".$ip_black."'", 19 "'".$pays."'", 20 "'".$region."'", 21 "'".$ville."'", 22 '"adresse"', 23 '"fai" ', 24 $count + 1 25 ); 26 ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,($count==0)) ; 27 27 } 28 28 29 29 break; 30 30 //================================================================================================ 31 31 case 'raz': 32 32 $ip_black=str_replace('*',"%",$ip_black); 33 34 35 33 $query = "DELETE FROM `".MAIL_BLACK_LISTE_TABLE."` WHERE `ip` like '%".$ip_black."%' "; 34 pwg_query($query); 35 36 36 unset ($_SESSION['pwg_'.'action_spam']); 37 37 break; 38 39 default: 38 39 default: 40 40 break; 41 42 } 41 42 } 43 43 //================ Liste Black liste ================= 44 44 $query = " 45 SELECT *, COUNT(`ip`) as total , `ip` as blacklist, `ip` as U_DELETE45 SELECT *, COUNT(`ip`) as total , `ip` as blacklist, `ip` as U_DELETE 46 46 FROM ".MAIL_BLACK_LISTE_TABLE." 47 GROUP by ip 47 GROUP by ip 48 48 ;"; 49 49 $liste_bl = array(); 50 50 $result = pwg_query($query); 51 while ($row = mysql_fetch_array($result,MYSQL_ASSOC)){52 53 }54 //================ Liste IP ============== 55 $req = mysql_query('SELECT count(distinct(`IP`)) FROM '.HISTORY_TABLE.' '); 51 while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { 52 array_push($liste_bl,$row); 53 } 54 //================ Liste IP ============== 55 $req = mysql_query('SELECT count(distinct(`IP`)) FROM '.HISTORY_TABLE.' '); 56 56 $nbip = array_pop(mysql_fetch_row($req)) ; 57 57 58 $query = 'SELECT DISTINCTH.`id`,58 $query = 'SELECT DISTINCT H.`id`, 59 59 H.`date`, 60 60 H.`time`, 61 61 H.`user_id`, 62 H.`IP`, 63 COUNT(H.`IP`) as total 64 FROM '.HISTORY_TABLE.' AS H 65 WHERE "'.$ip.'"not LIKE H.`IP` 66 67 $query .= 'AND H.`IP` not IN ( SELECT `ip`62 H.`IP`, 63 COUNT(H.`IP`) as total 64 FROM '.HISTORY_TABLE.' AS H 65 WHERE "'.$ip.'"not LIKE H.`IP` ';// 66 if (count($liste_bl)>0){ 67 $query .= ' AND H.`IP` not IN ( SELECT `ip` 68 68 FROM '.MAIL_BLACK_LISTE_TABLE.' ) '; 69 } 70 71 $query .= ' 72 GROUP by H.`IP` 73 ORDER by `id` DESC 74 LIMIT '.(int)($params['per_page']*$params['start']).','.(int)$params['per_page'].' 75 ' ; 69 } 76 70 77 $result = pwg_query($query); 78 $liste_ip=array(); 79 while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { 71 $query .= ' 72 GROUP by H.`IP` 73 ORDER by `id` DESC 74 LIMIT '.(int)($params['per_page']*$params['start']).','.(int)$params['per_page'].' 75 ' ; 80 76 81 array_push($liste_ip, $row); 82 } 77 $result = pwg_query($query); 78 $liste_ip=array(); 79 while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { 80 81 array_push($liste_ip, $row); 82 } 83 83 84 84 ?>
Note: See TracChangeset
for help on using the changeset viewer.