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 | if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
30 | |
---|
31 | |
---|
32 | if (!isset($_COOKIE[session_name()])) |
---|
33 | { |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | } |
---|
38 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
39 | include_once(PHPWG_ROOT_PATH.'include/functions.inc.php'); |
---|
40 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
41 | global $lang ; |
---|
42 | |
---|
43 | |
---|
44 | include_once (MAIL_SUPERV_PATH.'include/function_test_send.php'); |
---|
45 | |
---|
46 | |
---|
47 | load_language('plugin.lang', MAIL_SUPERV_PATH); |
---|
48 | |
---|
49 | |
---|
50 | global $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ; |
---|
51 | |
---|
52 | //========================================================== |
---|
53 | function sauve_options() |
---|
54 | { |
---|
55 | global $mails_options ; |
---|
56 | if ( isset($mails_options) ) |
---|
57 | { |
---|
58 | if ( count($mails_options) > 6 ) |
---|
59 | { |
---|
60 | $valeurs = implode( ',',$mails_options); |
---|
61 | $query = ' |
---|
62 | UPDATE '.CONFIG_TABLE.' |
---|
63 | SET value="'. $valeurs . '" |
---|
64 | WHERE param = "mail_superv" |
---|
65 | LIMIT 1'; |
---|
66 | pwg_query($query); |
---|
67 | } |
---|
68 | } |
---|
69 | } |
---|
70 | //================================================================================= |
---|
71 | function sauve_données() |
---|
72 | { |
---|
73 | |
---|
74 | global $mails_données,$superv_champs,$superv_type,$erreur_message ; |
---|
75 | //===================================================================== |
---|
76 | $clefs = $superv_champs ; |
---|
77 | $valeurs = array(); |
---|
78 | |
---|
79 | foreach ( $clefs as $champ) |
---|
80 | { |
---|
81 | $champ = trim($champ); |
---|
82 | |
---|
83 | if ( isset($mails_données[ $champ ]) ) { |
---|
84 | $sep= (is_string($mails_données[ $champ ])) ? '"' : '' ; |
---|
85 | array_push($valeurs , "`".$champ."`" . ' = ' . $sep . $mails_données[ $champ ] . $sep) ; |
---|
86 | }else{ |
---|
87 | |
---|
88 | array_push($valeurs , "`".$champ."`" . ' = ' . "0" ) ; |
---|
89 | } |
---|
90 | } |
---|
91 | $valeurs = implode(", ",$valeurs) ; |
---|
92 | //===================================================================== |
---|
93 | $query = ' |
---|
94 | UPDATE '.MAIL_SUPERV_TABLE.' |
---|
95 | SET '. $valeurs .' |
---|
96 | WHERE `id` = 1 LIMIT 1 '; |
---|
97 | ; |
---|
98 | ob_start(); |
---|
99 | $ret= pwg_query($query) ; |
---|
100 | $m= ob_get_contents(); |
---|
101 | ob_end_clean() ; |
---|
102 | $erreur_message .= $m ; |
---|
103 | |
---|
104 | } |
---|
105 | |
---|
106 | //================================================================================= |
---|
107 | function affiche_message() |
---|
108 | { |
---|
109 | global $template,$infos_message,$erreur_message, $user ;; |
---|
110 | |
---|
111 | global $mails_options,$conf,$lang ; |
---|
112 | |
---|
113 | $mails_options = explode("," , $conf['mail_superv']); |
---|
114 | |
---|
115 | if ( count($_POST)==5 || count($_POST)==0 ) { |
---|
116 | if (kill_list()) |
---|
117 | { |
---|
118 | $erreur_message .= "<BR />".l10n('is_a_spam') ; |
---|
119 | if ($mails_options[4] == 'on' ){ |
---|
120 | |
---|
121 | //[status] => guest |
---|
122 | //[status] => normal |
---|
123 | //[status] => webmaster |
---|
124 | |
---|
125 | if ($user['status'] != 'webmaster' ) |
---|
126 | if (!isset($_GET['admin'])) { |
---|
127 | die('Blacklist : <br />' .$erreur_message. '<br /> Hacking attempt!'); |
---|
128 | }elseif ($_GET['admin'] != 'piwigo') |
---|
129 | { |
---|
130 | die('blacklist Hacking attempt!'); |
---|
131 | } |
---|
132 | } |
---|
133 | } |
---|
134 | } |
---|
135 | |
---|
136 | //============================================================== |
---|
137 | if (isset($erreur_message)) |
---|
138 | { |
---|
139 | |
---|
140 | if ($erreur_message <> "") |
---|
141 | { |
---|
142 | $erreur_message=str_replace("\n",'<br />',$erreur_message) ; |
---|
143 | $template->assign('errors',$erreur_message); |
---|
144 | $erreur_message=""; |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | |
---|
149 | if (isset($infos_message)) |
---|
150 | { |
---|
151 | |
---|
152 | if ($infos_message <> "") |
---|
153 | { |
---|
154 | $infos_message=str_replace("\n",'<br />',$infos_message) ; |
---|
155 | $template->assign('infos',$infos_message); |
---|
156 | $infos_message=""; |
---|
157 | } |
---|
158 | } |
---|
159 | //============================================================= |
---|
160 | |
---|
161 | |
---|
162 | return; |
---|
163 | |
---|
164 | } |
---|
165 | |
---|
166 | function Get_geo() |
---|
167 | { |
---|
168 | global $pays,$region,$ville ; |
---|
169 | if (!isset($_POST['submit'])) { |
---|
170 | if (!isset($_POST['ville'])) |
---|
171 | { |
---|
172 | $result=""; |
---|
173 | $src = "http://j.maxmind.com/app/geoip.js" ; |
---|
174 | if ( !fetchRemote($src , $result)) |
---|
175 | { |
---|
176 | |
---|
177 | ?> |
---|
178 | <script language="JavaScript" type="text/javascript"> |
---|
179 | var pays = "??"; |
---|
180 | var ville = "??"; |
---|
181 | var region = "??"; |
---|
182 | var latitude = "??"; |
---|
183 | var longitude = "??"; |
---|
184 | </script> |
---|
185 | <?php |
---|
186 | }else{ |
---|
187 | ?> |
---|
188 | <script language="JavaScript" src="http://j.maxmind.com/app/geoip.js" type="text/javascript" > |
---|
189 | </script> |
---|
190 | <script language="JavaScript" type="text/javascript"> |
---|
191 | var pays = geoip_country_name(); |
---|
192 | var ville = geoip_city(); |
---|
193 | var region = geoip_region_name() ; |
---|
194 | var latitude = geoip_latitude() ; |
---|
195 | var longitude = geoip_longitude() ; |
---|
196 | |
---|
197 | </script> |
---|
198 | <?php |
---|
199 | } |
---|
200 | ?> |
---|
201 | <form action="" method="post" name="form_connexion" id="form_connexion" style="visibility:hidden"> |
---|
202 | <script language="JavaScript" type="text/javascript"> |
---|
203 | document.write ("<input name=\"pays\" type=\"text\" value = "+ pays + " id = \"pays\" > "); |
---|
204 | document.write ("<input name=\"ville\" type=\"text\" value = "+ ville + " id = \"ville\" > "); |
---|
205 | document.write ("<input name=\"region\" type=\"text\" value = "+ region + " id = \"region\" > "); |
---|
206 | document.write ("<input name=\"latitude\" type=\"text\" value = "+ latitude + " id = \"latitude\" > "); |
---|
207 | document.write ("<input name=\"longitude\" type=\"text\" value = "+ longitude + " id = \"longitude\" > "); |
---|
208 | </script> |
---|
209 | </form > |
---|
210 | <script language="JavaScript" type="text/javascript"> |
---|
211 | document.getElementById("form_connexion").submit(); |
---|
212 | </script> |
---|
213 | ?> |
---|
214 | <?php |
---|
215 | } |
---|
216 | } |
---|
217 | $pays = isset($_POST['pays']) ? $_POST['pays'] : $pays ; |
---|
218 | $ville = (isset($_POST['ville'])) ? $_POST['ville']: $ville ; |
---|
219 | $region = isset($_POST['region']) ? $_POST['region'] : $region; |
---|
220 | |
---|
221 | } |
---|
222 | |
---|
223 | //================================================================================= |
---|
224 | function Get_Datas() |
---|
225 | { |
---|
226 | global $superv_champs ; |
---|
227 | $champs = implode(",",$superv_champs ); |
---|
228 | $query = "SELECT ".$champs." |
---|
229 | FROM ".MAIL_SUPERV_TABLE." |
---|
230 | ;"; |
---|
231 | $result = @pwg_query($query); |
---|
232 | |
---|
233 | if (!$result) { |
---|
234 | vérif_base(); |
---|
235 | $result = @pwg_query($query); |
---|
236 | } |
---|
237 | |
---|
238 | |
---|
239 | $data = mysql_fetch_array($result,MYSQL_ASSOC); |
---|
240 | //==================================================================================== |
---|
241 | $next_day = Str_To_Time( $data['nb_mails_periode'], $data['date_mail'] );; |
---|
242 | $data['rest_mail']= $next_day - time() ; |
---|
243 | |
---|
244 | $next_day = + Str_To_Time( $data['nb_spams_periode'],$data['date_spam']); |
---|
245 | $data['rest_spam']= $next_day - time() ; |
---|
246 | |
---|
247 | |
---|
248 | $next_day = Str_To_Time($data['quarantaine_periode'] ,$data['date_quarantaine']); |
---|
249 | |
---|
250 | if ($data['quarantaine'] == 'true' ) { |
---|
251 | $data['reste'] = ( $next_day )-time() ; |
---|
252 | }else{ |
---|
253 | $data['reste'] = 0; |
---|
254 | } |
---|
255 | |
---|
256 | return $data; |
---|
257 | } |
---|
258 | //=============================================== |
---|
259 | |
---|
260 | function corrige_header($Carbonne,$headers,$args) |
---|
261 | { |
---|
262 | global $mails_options,$conf_mail,$mailto,$infos_message; |
---|
263 | |
---|
264 | if (!empty($args[$Carbonne])) |
---|
265 | { |
---|
266 | |
---|
267 | if ( count($args[$Carbonne]) > 0 ) |
---|
268 | { |
---|
269 | if ($mails_options[1] == 'on') { |
---|
270 | $list_mail = str_replace(","," ,",get_strict_email_list(implode(',', $args[$Carbonne])))." \n" ; |
---|
271 | $headers = preg_replace('/.*'.$Carbonne.'(.*).\n/i', $Carbonne.': '.$list_mail, $headers); |
---|
272 | } |
---|
273 | } |
---|
274 | } else { |
---|
275 | // Raz Bcc, Cc dans headers |
---|
276 | $headers = preg_replace('/.*'.$Carbonne.'(.*).\n/i', "" , $headers); |
---|
277 | } |
---|
278 | |
---|
279 | |
---|
280 | return $headers; |
---|
281 | |
---|
282 | |
---|
283 | } |
---|
284 | |
---|
285 | function int_to_heure($int) |
---|
286 | { |
---|
287 | |
---|
288 | $delta=(7*24*60*60) ; |
---|
289 | $week = (int) ($int/$delta); |
---|
290 | $int= $int-($week*$delta) ; |
---|
291 | |
---|
292 | $delta=(24*60*60) ; |
---|
293 | $day= (int) ($int/$delta); |
---|
294 | $int=$int-($day*$delta); |
---|
295 | |
---|
296 | $delta=(60*60) ; |
---|
297 | $heures=(int) ($int/$delta); |
---|
298 | $int=$int-($heures*$delta); |
---|
299 | |
---|
300 | $delta=(60) ; |
---|
301 | $minutes=(int) ($int/$delta); |
---|
302 | $int= $int - ($minutes*$delta); |
---|
303 | |
---|
304 | $secondes=(int) ($int); |
---|
305 | $day = substr ('00'. $day,-2,2); |
---|
306 | $heures = substr ('00'. $heures,-2,2); |
---|
307 | $minutes = substr ('00'.$minutes,-2,2); |
---|
308 | $secondes = substr ('00'.$secondes,-2,2); |
---|
309 | |
---|
310 | |
---|
311 | if ($week > 0 ) |
---|
312 | { |
---|
313 | return $week. " " .l10n('Week'). " " . $day . " " .l10n('Day'). "s ". $heures . " ". l10n('Hour'). "s " . $minutes. " " .l10n('minute'). "s ". $secondes." " .l10n('seconde')."s"; |
---|
314 | } |
---|
315 | return $day . " " .l10n('Day'). "s ". $heures . " ". l10n('Hour'). "s " . $minutes. " " .l10n('Minute'). "s ". $secondes." " .l10n('Seconde')."s"; |
---|
316 | |
---|
317 | } |
---|
318 | |
---|
319 | function memo_var($variables) |
---|
320 | { |
---|
321 | ob_start(); |
---|
322 | echo '<pre>'; |
---|
323 | print_r($variables); |
---|
324 | echo '</pre>'; |
---|
325 | $m= ob_get_contents(); |
---|
326 | |
---|
327 | ob_end_clean(); |
---|
328 | return $m; |
---|
329 | |
---|
330 | } |
---|
331 | |
---|
332 | |
---|
333 | |
---|
334 | function vérif_base() |
---|
335 | { |
---|
336 | |
---|
337 | global $lang,$superv_champs,$superv_type,$superv_bl_champs,$superv_bl_type; |
---|
338 | load_language('plugin.lang', MAIL_SUPERV_PATH); |
---|
339 | //============================================================================== |
---|
340 | create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ; |
---|
341 | ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ; |
---|
342 | //============================================================================== |
---|
343 | create_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type) ; |
---|
344 | ajust_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type) ; |
---|
345 | //============================================================================== |
---|
346 | $valeurs= array ( 1, |
---|
347 | 0, |
---|
348 | time(), |
---|
349 | 2000, |
---|
350 | '"1 '.l10n('Week').'"' , |
---|
351 | 0, |
---|
352 | time(), |
---|
353 | 10, |
---|
354 | '"2 '.l10n('Day').'"', |
---|
355 | '"false"', |
---|
356 | time(), |
---|
357 | '"2 '.l10n('Day').'"', |
---|
358 | |
---|
359 | '"Init"', |
---|
360 | '"'.l10n('supervisor').'"', |
---|
361 | '"'.l10n('hello').'"', |
---|
362 | ) |
---|
363 | ; |
---|
364 | //================================================================================== |
---|
365 | ajout_ligne(MAIL_SUPERV_TABLE,$superv_champs, $valeurs,false ) ; |
---|
366 | |
---|
367 | |
---|
368 | } |
---|
369 | |
---|
370 | //========================================= |
---|
371 | function Get_colonnes_de($table) |
---|
372 | { |
---|
373 | $query = 'DESC '.$table.';'; |
---|
374 | $result = mysql_query($query); |
---|
375 | $columns_of= array(); |
---|
376 | while ($row = mysql_fetch_row($result)) |
---|
377 | { |
---|
378 | array_push($columns_of, $row[0]); |
---|
379 | } |
---|
380 | |
---|
381 | return $columns_of; |
---|
382 | } |
---|
383 | |
---|
384 | function get_liste($group_id) |
---|
385 | { |
---|
386 | global $conf ; |
---|
387 | |
---|
388 | $query = ' |
---|
389 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
390 | u.'.$conf['user_fields']['username'].' AS username, |
---|
391 | u.'.$conf['user_fields']['email'].' AS email, |
---|
392 | ui.status, |
---|
393 | ui.adviser, |
---|
394 | ui.enabled_high, |
---|
395 | ui.level |
---|
396 | FROM '.USERS_TABLE.' AS u |
---|
397 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
398 | ON u.'.$conf['user_fields']['id'].' = ui.user_id |
---|
399 | LEFT JOIN '.USER_GROUP_TABLE.' AS ug |
---|
400 | ON u.'.$conf['user_fields']['id'].' = ug.user_id |
---|
401 | WHERE ug.group_id='.$group_id.' '; |
---|
402 | |
---|
403 | |
---|
404 | |
---|
405 | $groups=array(); |
---|
406 | $datas = pwg_query($query); |
---|
407 | |
---|
408 | |
---|
409 | if (!empty($datas)) |
---|
410 | { |
---|
411 | while ($group = mysql_fetch_array($datas,MYSQL_ASSOC)) |
---|
412 | { |
---|
413 | |
---|
414 | |
---|
415 | if (!empty($group['email'])) |
---|
416 | { |
---|
417 | array_push($groups, format_email($group['username'], $group['email'] )); |
---|
418 | } |
---|
419 | } |
---|
420 | } |
---|
421 | return $groups ; |
---|
422 | |
---|
423 | } |
---|
424 | //================================================================================= |
---|
425 | |
---|
426 | function create_table($nom_table,$champs,$types) //MAIL_SUPERV_TABLE |
---|
427 | { |
---|
428 | $i=0; |
---|
429 | $valeurs=array(); |
---|
430 | foreach ( $champs as $champ) |
---|
431 | { |
---|
432 | $champ = trim($champ); |
---|
433 | array_push($valeurs , " `".$champ."`" . ' ' . $types[ $i] ) ; |
---|
434 | $i +=1; |
---|
435 | } |
---|
436 | |
---|
437 | |
---|
438 | |
---|
439 | if ( count($valeurs) == 0) return ; |
---|
440 | |
---|
441 | $valeurs=implode(", ",$valeurs) ; |
---|
442 | //=============================================================================== |
---|
443 | $query = "CREATE TABLE IF NOT EXISTS `" . $nom_table . "` (". $valeurs . " , PRIMARY KEY (`id` ) ) ;"; |
---|
444 | if ( pwg_query($query) ) return ; |
---|
445 | die("ERREUR CREATION ".$query); |
---|
446 | |
---|
447 | |
---|
448 | } |
---|
449 | function ajust_table($nom_table,$champs,$types) //MAIL_SUPERV_TABLE |
---|
450 | { |
---|
451 | global $infos_message ; |
---|
452 | $colonnes = Get_colonnes_de($nom_table); |
---|
453 | $data = $types ; |
---|
454 | $i=0; |
---|
455 | $valeurs=array(); |
---|
456 | foreach ( $champs as $champ) |
---|
457 | { |
---|
458 | $champ = trim($champ); |
---|
459 | if (!in_array( $champ,$colonnes)) { |
---|
460 | array_push($valeurs , " ADD `".$champ."`" . ' ' . $data[ $i] ) ; |
---|
461 | } |
---|
462 | $i +=1; |
---|
463 | |
---|
464 | } |
---|
465 | //============================================================================= |
---|
466 | if ( count($valeurs) == 0) return ; |
---|
467 | |
---|
468 | $infos_message .= "AJUSTE TABLE : ". $nom_table . "<br />" . "NB (col) : ". count($colonnes) . memo_var($valeurs) . "<br />" ; |
---|
469 | |
---|
470 | $valeurs=implode(", ",$valeurs) ; |
---|
471 | //=============================================================================== |
---|
472 | $query = "ALTER TABLE `" . $nom_table . "` ". $valeurs ; |
---|
473 | if ( pwg_query($query)) return ; |
---|
474 | die($query); |
---|
475 | } |
---|
476 | //============================================================================== |
---|
477 | function ajout_ligne($nom_table,$champs,$valeurs,$force) |
---|
478 | { |
---|
479 | if (!$force) { |
---|
480 | $query = " |
---|
481 | SELECT `id` , COUNT(`id`) as total |
---|
482 | FROM `".$nom_table."` |
---|
483 | ;"; |
---|
484 | list($count) = mysql_fetch_row(pwg_query($query)); |
---|
485 | |
---|
486 | |
---|
487 | }else{ |
---|
488 | |
---|
489 | $count = 0 ; |
---|
490 | } |
---|
491 | |
---|
492 | if ($count == 0) |
---|
493 | { |
---|
494 | $n_champs=implode(",",$champs); |
---|
495 | $n_valeurs=implode(",",$valeurs); |
---|
496 | $query = " |
---|
497 | INSERT INTO `".$nom_table."` (". $n_champs.") |
---|
498 | VALUES ( ". $n_valeurs .")"; |
---|
499 | |
---|
500 | if (pwg_query($query)) return ; |
---|
501 | die($query); |
---|
502 | |
---|
503 | } |
---|
504 | } |
---|
505 | //===================================================================== |
---|
506 | |
---|
507 | function Str_To_Time( $ajout,$init_date) |
---|
508 | { |
---|
509 | //======================================================== |
---|
510 | global $erreur_message; |
---|
511 | $a_ajouter=$ajout ; |
---|
512 | |
---|
513 | $period_search=array("W","D","H","M","S"); |
---|
514 | array_push($period_search,l10n('Week').'s',l10n('Day').'s',l10n('Hour').'s',l10n('Minute').'s',l10n('Seconde').'s'); |
---|
515 | array_push($period_search,l10n('Week'),l10n('Day'),l10n('Hour'),l10n('Minute'),l10n('Seconde')); |
---|
516 | |
---|
517 | |
---|
518 | |
---|
519 | $period_match = array(' week ',' day ',' hour ',' minute ',' seconde '); |
---|
520 | array_push($period_match,' week ',' day ',' hour ',' minute ',' seconde '); |
---|
521 | array_push($period_match,' week ',' day ',' hour ',' minute ',' seconde '); |
---|
522 | |
---|
523 | |
---|
524 | |
---|
525 | $a_ajouter = "+ " . str_replace($period_search, $period_match, $a_ajouter) ; |
---|
526 | $a_ajouter=sup_double_espace($a_ajouter); |
---|
527 | |
---|
528 | $v1 = array('- ','+ ','week','day','hour','minute','seconde',' -',' +',' '); |
---|
529 | $v2 = array('-','+', (7*24*60*60) , (24*60*60), (60*60), 60,1,'|-','|+',"*" ); |
---|
530 | $new_valeur = str_replace($v1,$v2,$a_ajouter) ; |
---|
531 | $new_valeur = str_replace('++','+',$new_valeur ) ; |
---|
532 | |
---|
533 | $new_valeur = explode( "|",$new_valeur ); |
---|
534 | $p = $init_date ; |
---|
535 | |
---|
536 | //$new_valeur = $a_ajouter + $init_date ; |
---|
537 | foreach($new_valeur as $nv) |
---|
538 | { |
---|
539 | $return = matheval($nv) ; |
---|
540 | if (strpos("error",$return)===false) { |
---|
541 | $p += $return ; |
---|
542 | }else { |
---|
543 | $erreur_message .= $return . " nv : " . $nv ; |
---|
544 | } |
---|
545 | |
---|
546 | |
---|
547 | } |
---|
548 | return $p ; |
---|
549 | |
---|
550 | } |
---|
551 | //===================================================================================== |
---|
552 | function matheval($equation) |
---|
553 | { |
---|
554 | |
---|
555 | $return="error"; |
---|
556 | |
---|
557 | |
---|
558 | $equation = preg_replace("/[^0-9+\-.*\/()%]/","",$equation); |
---|
559 | $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation); |
---|
560 | $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation); |
---|
561 | $equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation); |
---|
562 | |
---|
563 | if ( $equation == "" ) |
---|
564 | { |
---|
565 | $return = 0; |
---|
566 | } else { |
---|
567 | @eval("\$return=" . $equation . ";" ); |
---|
568 | } |
---|
569 | return $return; |
---|
570 | |
---|
571 | } |
---|
572 | |
---|
573 | //====================================================================================== |
---|
574 | function sup_double_espace($chaine){ |
---|
575 | global $erreur_message; |
---|
576 | $str_temp = $chaine." "; |
---|
577 | $sep=" "; |
---|
578 | $chaine = trim($chaine); |
---|
579 | $existe = (strpos($sep.$sep,$chaine )===false) ; |
---|
580 | while ($existe ){ |
---|
581 | $str_temp = str_replace($sep.$sep, $sep, $chaine ); |
---|
582 | if($str_temp == $chaine ) return $chaine ; |
---|
583 | // $erreur_message .= memo_var($str_temp) ; |
---|
584 | $chaine = $str_temp; |
---|
585 | $existe = (strpos($sep.$sep,$chaine )===false) ; |
---|
586 | } |
---|
587 | return $chaine; |
---|
588 | } |
---|
589 | |
---|
590 | |
---|
591 | |
---|
592 | function kill_list() |
---|
593 | { |
---|
594 | //==================== TEST black_liste ============================================ |
---|
595 | global $pays,$region,$ville,$ip ; |
---|
596 | global $erreur_message,$infos_message,$conf; |
---|
597 | global $conf, $user, $page; |
---|
598 | global $mails_options ; |
---|
599 | global $superv_bl_champs,$superv_bl_type ; |
---|
600 | global $nb ; |
---|
601 | |
---|
602 | if (count($mails_options) < 7 ) return false ; |
---|
603 | |
---|
604 | $ip = $_SERVER['REMOTE_ADDR'] ; |
---|
605 | if ( !isset($_POST['pays'])) { |
---|
606 | if ( !isset($_POST['ip_black_test'])) { |
---|
607 | Get_Geo(); |
---|
608 | } |
---|
609 | return ; |
---|
610 | } else { |
---|
611 | $pays = (isset($_POST['pays'])) ? $_POST['pays'] : "" ; |
---|
612 | $ville = (isset($_POST['ville'])) ? $_POST['ville'] : "" ; |
---|
613 | $region = ( isset($_POST['region'])) ? $_POST['region'] : "" ; |
---|
614 | } |
---|
615 | $champs=implode(',',$superv_bl_champs); |
---|
616 | $query = " |
---|
617 | SELECT ".$champs.",COUNT(`ip`) as total |
---|
618 | FROM `".MAIL_BLACK_LISTE_TABLE."` |
---|
619 | WHERE '".$ip."' LIKE `ip` |
---|
620 | ;"; |
---|
621 | $result = @pwg_query($query); |
---|
622 | if (!$result) { |
---|
623 | vérif_base(); |
---|
624 | $result = @pwg_query($query); |
---|
625 | } |
---|
626 | $datas = mysql_fetch_array($result,MYSQL_ASSOC); |
---|
627 | $nb = $datas['total']; |
---|
628 | //======================================================================= |
---|
629 | |
---|
630 | if ($mails_options[5] == 'on') |
---|
631 | { |
---|
632 | // $ip="94.102.63.13"; ' Spammeurs |
---|
633 | // $ip="94.102.63.15"; |
---|
634 | // $mail=matusowraber93813@gmail.com ; |
---|
635 | // $username=fretgpsolodens ; |
---|
636 | global $user_name,$mail_adresse,$ip ; |
---|
637 | |
---|
638 | if (test_spam($ip,$user['username'] ,$user['email'])) |
---|
639 | { |
---|
640 | |
---|
641 | if ($nb==0) { |
---|
642 | $valeurs=array( 'NULL', |
---|
643 | "'".$ip."'", |
---|
644 | "'".$pays."'", |
---|
645 | "'".$region."'", |
---|
646 | "'".$ville."'", |
---|
647 | "'".$user['email']."'", |
---|
648 | "'".$user['username']."'", |
---|
649 | $nb+1 |
---|
650 | ); |
---|
651 | ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,$nb==0) ; |
---|
652 | }else{ |
---|
653 | |
---|
654 | $nb +=1; |
---|
655 | |
---|
656 | $query =" |
---|
657 | UPDATE " . MAIL_BLACK_LISTE_TABLE . " |
---|
658 | SET "; |
---|
659 | if (isset($_POST['pays'])) |
---|
660 | $query .= " |
---|
661 | `pays` = '". $pays ."', |
---|
662 | `region` = '" . $region ."', |
---|
663 | `ville` = '" . $ville . "', |
---|
664 | |
---|
665 | "; |
---|
666 | |
---|
667 | $query .= " |
---|
668 | `adresse` = '".$user['email']."', |
---|
669 | `fai` = '".$user['username']."', |
---|
670 | `nb` = " . $nb . " |
---|
671 | WHERE '".$ip."' like `ip` |
---|
672 | "; |
---|
673 | |
---|
674 | pwg_query($query ); |
---|
675 | } |
---|
676 | $erreur_message .= $mails_options[6] ." ".$user['username']." ".$user['email'] . ' -----> ' . l10n('black_list') ; |
---|
677 | // die($nb." ".$ip." ".$user['username']." ".$user['email']); |
---|
678 | return true ; |
---|
679 | |
---|
680 | } |
---|
681 | |
---|
682 | } |
---|
683 | //============================================================================== |
---|
684 | |
---|
685 | if ( $mails_options[6] == $ip ) return ($nb > 0) ; |
---|
686 | |
---|
687 | $mails_options[6] = $ip ; |
---|
688 | sauve_options(); |
---|
689 | |
---|
690 | if ( $nb > 0 ) |
---|
691 | { |
---|
692 | $query = " |
---|
693 | SELECT ".$champs.",COUNT(`id`) as total |
---|
694 | FROM `".MAIL_BLACK_LISTE_TABLE."` |
---|
695 | WHERE '".$ip."' = `ip` |
---|
696 | ;"; |
---|
697 | $result = @pwg_query($query); |
---|
698 | |
---|
699 | if (!$result) { |
---|
700 | vérif_base(); |
---|
701 | $result = @pwg_query($query); |
---|
702 | } |
---|
703 | $datas = mysql_fetch_array($result,MYSQL_ASSOC); |
---|
704 | $nb = $datas['total']; |
---|
705 | |
---|
706 | $row = mysql_fetch_row(pwg_query($query)); |
---|
707 | $nb = ($row[7]); |
---|
708 | $erreur_message .= $ip . ' | ' . $pays . ' | ' . $region . ' | ' . $ville . ' ' . $nb . ' ==> '; |
---|
709 | |
---|
710 | if ($nb == 0) |
---|
711 | { |
---|
712 | $valeurs=array( 'NULL', |
---|
713 | "'".$ip."'", |
---|
714 | "'".$pays."'", |
---|
715 | "'".$region."'", |
---|
716 | "'".$ville."'", |
---|
717 | "'".$user['email']."'", |
---|
718 | "'".$user['username']."'", |
---|
719 | 1 |
---|
720 | ); |
---|
721 | ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,true) ; |
---|
722 | |
---|
723 | } else { |
---|
724 | $nb += 1; |
---|
725 | $query =" |
---|
726 | UPDATE " . MAIL_BLACK_LISTE_TABLE . " |
---|
727 | SET "; |
---|
728 | if (isset($_POST['pays'])) |
---|
729 | $query .= " |
---|
730 | `pays` = '". $pays ."', |
---|
731 | `region` = '" . $region ."', |
---|
732 | `ville` = '" . $ville . "', |
---|
733 | "; |
---|
734 | $query .= " |
---|
735 | `adresse` = '".$user['email']."', |
---|
736 | `fai` = '".$user['username']."', |
---|
737 | `nb` = " . $nb . " |
---|
738 | WHERE '".$ip."' = `ip` |
---|
739 | "; |
---|
740 | |
---|
741 | pwg_query($query ); |
---|
742 | } |
---|
743 | //================================================================================ |
---|
744 | |
---|
745 | } |
---|
746 | |
---|
747 | |
---|
748 | return ($nb > 0) ; |
---|
749 | } |
---|
750 | //===================================================================================== |
---|
751 | function test_spam($ip =0,$user_name ='', $mail_adresse = "") |
---|
752 | { |
---|
753 | $buffer=""; |
---|
754 | // fretgpsolodens |
---|
755 | $src = "http://www.stopforumspam.com/api?"; |
---|
756 | $type=array(); |
---|
757 | $result=""; |
---|
758 | if (strlen($ip)>3) { |
---|
759 | //================== Vérifie si l'IP est correct ================================ |
---|
760 | if (clj_is_ip($ip)){ |
---|
761 | |
---|
762 | } else { |
---|
763 | //================== Vérifie si l'adresse mail est correcte ================================ |
---|
764 | if( clj_is_mail($ip) ){ |
---|
765 | $mail_adresse=$ip ; |
---|
766 | $ip=""; |
---|
767 | } |
---|
768 | else |
---|
769 | { |
---|
770 | //================== Login ================ |
---|
771 | $user_name=$ip; |
---|
772 | $ip=""; |
---|
773 | } |
---|
774 | } |
---|
775 | //============================================================================= |
---|
776 | } |
---|
777 | $user_name=str_replace(" ","%20",$user_name); |
---|
778 | $mail_adresse =str_replace(" ","%20",$mail_adresse); |
---|
779 | if ( strlen($user_name) > 3) $type[]="username=$user_name" ; |
---|
780 | if ( strlen($mail_adresse) > 3) $type[]="email=".$mail_adresse ; |
---|
781 | if ( strlen($ip) > 3) $type[]="ip=".$ip ; |
---|
782 | |
---|
783 | foreach ( $type as $fil ) |
---|
784 | { |
---|
785 | $resultat=""; |
---|
786 | if ( fetchRemote($src.$fil , $resultat)) |
---|
787 | { |
---|
788 | $result .= $resultat.'<br />' ; |
---|
789 | } else { |
---|
790 | |
---|
791 | } |
---|
792 | } |
---|
793 | |
---|
794 | return !(strpos( $result ,'yes' ) === false) ; |
---|
795 | |
---|
796 | } |
---|
797 | //================================================================== |
---|
798 | function lire_fichier_distant($fichier) |
---|
799 | { |
---|
800 | $buffer=""; |
---|
801 | $handle = @fopen($fichier,"r"); |
---|
802 | if ($handle) { |
---|
803 | while (!feof($handle)) { |
---|
804 | $buffer .= fgets($handle, 4096); |
---|
805 | } |
---|
806 | fclose($handle); |
---|
807 | } |
---|
808 | |
---|
809 | return $buffer ; |
---|
810 | |
---|
811 | } |
---|
812 | //================================================ |
---|
813 | function clj_is_ip($ip) |
---|
814 | { |
---|
815 | if (ereg("^(((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 ; |
---|
816 | |
---|
817 | } |
---|
818 | |
---|
819 | function clj_is_mail($mail) |
---|
820 | { |
---|
821 | if(preg_match('#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#' ,$mail)) return true ; |
---|
822 | } |
---|
823 | ?> |
---|