[4020] | 1 | <?php |
---|
[4029] | 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 | } |
---|
[4132] | 28 | |
---|
[4041] | 29 | if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
[4029] | 30 | |
---|
[4861] | 31 | define ("check_mailto", 0); define ("check_header_carbon",1); define ("check_header_text",2); |
---|
| 32 | define ("no_mail_list", 3); define ("no_connect",4); define ("set_auto",5); |
---|
| 33 | define ("ip",6); define ("set_id",7); |
---|
| 34 | |
---|
| 35 | |
---|
[4132] | 36 | if (!isset($_COOKIE[session_name()])) |
---|
| 37 | { |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | } |
---|
[4020] | 42 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
[4052] | 43 | include_once(PHPWG_ROOT_PATH.'include/functions.inc.php'); |
---|
[4132] | 44 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[4053] | 45 | global $lang ; |
---|
| 46 | |
---|
[4040] | 47 | include_once (MAIL_SUPERV_PATH.'include/function_test_send.php'); |
---|
[4132] | 48 | load_language('plugin.lang', MAIL_SUPERV_PATH); |
---|
| 49 | global $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ; |
---|
[4220] | 50 | |
---|
[4132] | 51 | //========================================================== |
---|
[4020] | 52 | function sauve_options() |
---|
| 53 | { |
---|
| 54 | global $mails_options ; |
---|
[4206] | 55 | if ( isset($mails_options) ) |
---|
| 56 | { |
---|
[4715] | 57 | |
---|
| 58 | while ( count($mails_options) < 10 ) |
---|
[4206] | 59 | { |
---|
[4715] | 60 | |
---|
| 61 | $mails_options[]='?'; |
---|
| 62 | } |
---|
| 63 | |
---|
[4206] | 64 | $valeurs = implode( ',',$mails_options); |
---|
[5670] | 65 | |
---|
| 66 | |
---|
[4206] | 67 | $query = ' |
---|
| 68 | UPDATE '.CONFIG_TABLE.' |
---|
| 69 | SET value="'. $valeurs . '" |
---|
| 70 | WHERE param = "mail_superv" |
---|
| 71 | LIMIT 1'; |
---|
| 72 | pwg_query($query); |
---|
[4715] | 73 | |
---|
[4206] | 74 | } |
---|
[4020] | 75 | } |
---|
| 76 | //================================================================================= |
---|
| 77 | function sauve_données() |
---|
| 78 | { |
---|
[4180] | 79 | |
---|
[4132] | 80 | global $mails_données,$superv_champs,$superv_type,$erreur_message ; |
---|
| 81 | //===================================================================== |
---|
| 82 | $clefs = $superv_champs ; |
---|
| 83 | $valeurs = array(); |
---|
[4029] | 84 | |
---|
[4132] | 85 | foreach ( $clefs as $champ) |
---|
| 86 | { |
---|
| 87 | $champ = trim($champ); |
---|
| 88 | |
---|
| 89 | if ( isset($mails_données[ $champ ]) ) { |
---|
| 90 | $sep= (is_string($mails_données[ $champ ])) ? '"' : '' ; |
---|
| 91 | array_push($valeurs , "`".$champ."`" . ' = ' . $sep . $mails_données[ $champ ] . $sep) ; |
---|
| 92 | }else{ |
---|
| 93 | |
---|
| 94 | array_push($valeurs , "`".$champ."`" . ' = ' . "0" ) ; |
---|
| 95 | } |
---|
[5670] | 96 | |
---|
[4132] | 97 | } |
---|
| 98 | $valeurs = implode(", ",$valeurs) ; |
---|
| 99 | //===================================================================== |
---|
[4029] | 100 | $query = ' |
---|
[4020] | 101 | UPDATE '.MAIL_SUPERV_TABLE.' |
---|
[4132] | 102 | SET '. $valeurs .' |
---|
| 103 | WHERE `id` = 1 LIMIT 1 '; |
---|
| 104 | ; |
---|
| 105 | ob_start(); |
---|
| 106 | $ret= pwg_query($query) ; |
---|
| 107 | $m= ob_get_contents(); |
---|
| 108 | ob_end_clean() ; |
---|
| 109 | $erreur_message .= $m ; |
---|
[4029] | 110 | |
---|
[4020] | 111 | } |
---|
[4132] | 112 | |
---|
[4020] | 113 | //================================================================================= |
---|
| 114 | function affiche_message() |
---|
| 115 | { |
---|
[4861] | 116 | global $template,$infos_message,$erreur_message, $user ,$ip; |
---|
[4132] | 117 | |
---|
[4156] | 118 | global $mails_options,$conf,$lang ; |
---|
[4180] | 119 | |
---|
[4156] | 120 | $mails_options = explode("," , $conf['mail_superv']); |
---|
[4861] | 121 | if (!isset($ip)) { |
---|
| 122 | if (getenv("HTTP_CLIENT_IP")) |
---|
| 123 | { $ip=getenv("HTTP_CLIENT_IP"); } |
---|
| 124 | else{ $ip=getenv("REMOTE_ADDR"); } |
---|
| 125 | } |
---|
| 126 | // unset ($_SESSION['pwg_'.'action_spam']); |
---|
| 127 | $action_spam = pwg_get_session_var('action_spam') ; |
---|
| 128 | if ($action_spam == null) { $action_spam = kill_list(); } |
---|
| 129 | |
---|
| 130 | if (is_bool($action_spam)) $action_spam =($action_spam == true) ? "true" : "false" ; |
---|
| 131 | if ($action_spam == "true" ) |
---|
| 132 | { |
---|
| 133 | $erreur_message = $ip . " " . $action_spam ; |
---|
[4366] | 134 | pwg_set_session_var('action_spam', "true"); |
---|
[4879] | 135 | $erreur_message .= "<BR />".l10n('Sv_is_a_spam') ; |
---|
[4861] | 136 | if ($mails_options[no_connect] == 'on' ){ |
---|
| 137 | //[status] => guest |
---|
| 138 | //[status] => normal |
---|
| 139 | //[status] => webmaster |
---|
[4323] | 140 | if ($user['status'] != 'webmaster' ) |
---|
[4156] | 141 | if (!isset($_GET['admin'])) { |
---|
| 142 | die('Blacklist : <br />' .$erreur_message. '<br /> Hacking attempt!'); |
---|
| 143 | }elseif ($_GET['admin'] != 'piwigo') |
---|
| 144 | { |
---|
| 145 | die('blacklist Hacking attempt!'); |
---|
| 146 | } |
---|
[4861] | 147 | unset ($_SESSION['pwg_'.'action_spam']); |
---|
[4156] | 148 | } |
---|
[4366] | 149 | }else{ |
---|
| 150 | pwg_set_session_var('action_spam', "false"); |
---|
| 151 | } |
---|
[4861] | 152 | |
---|
| 153 | |
---|
| 154 | // } |
---|
[4156] | 155 | |
---|
| 156 | //============================================================== |
---|
[4020] | 157 | if (isset($erreur_message)) |
---|
| 158 | { |
---|
| 159 | |
---|
| 160 | if ($erreur_message <> "") |
---|
| 161 | { |
---|
[4888] | 162 | $erreur_message = str_replace("\n",'<br />',$erreur_message) ; |
---|
[4020] | 163 | $template->assign('errors',$erreur_message); |
---|
[4888] | 164 | $erreur_message = ""; |
---|
[4020] | 165 | } |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | |
---|
| 169 | if (isset($infos_message)) |
---|
| 170 | { |
---|
| 171 | |
---|
| 172 | if ($infos_message <> "") |
---|
| 173 | { |
---|
[4888] | 174 | $infos_message = str_replace("\n",'<br />',$infos_message) ; |
---|
[4020] | 175 | $template->assign('infos',$infos_message); |
---|
[4888] | 176 | $infos_message = ""; |
---|
[4020] | 177 | } |
---|
| 178 | } |
---|
[4156] | 179 | //============================================================= |
---|
[4180] | 180 | |
---|
| 181 | |
---|
| 182 | return; |
---|
[4156] | 183 | |
---|
[4020] | 184 | } |
---|
| 185 | |
---|
[4180] | 186 | function Get_geo() |
---|
| 187 | { |
---|
[4361] | 188 | global $ip,$pays,$region,$ville, $latitude ,$longitude,$mails_options; |
---|
| 189 | //=================================================================================== |
---|
| 190 | $info_geo = pwg_get_session_var('info_geo'); |
---|
[4861] | 191 | print_r($info_geo ); |
---|
[4361] | 192 | if (count($info_geo) > 0) |
---|
| 193 | { |
---|
| 194 | |
---|
| 195 | $pays = $info_geo[0]; |
---|
| 196 | $region = $info_geo[1]; |
---|
| 197 | $ville = $info_geo[2]; |
---|
| 198 | $latitude = $info_geo[3]; |
---|
| 199 | $longitude = $info_geo[4]; |
---|
| 200 | $ip = $info_geo[5]; |
---|
| 201 | return true; |
---|
| 202 | } |
---|
| 203 | //======================================================================= |
---|
| 204 | |
---|
| 205 | if (isset($_POST['pays'])) { |
---|
| 206 | $pays = isset($_POST['pays']) ? $_POST['pays'] : ""; |
---|
| 207 | $region = isset($_POST['region']) ? $_POST['region'] :""; |
---|
| 208 | $ville = (isset($_POST['ville'])) ? $_POST['ville']: ""; |
---|
| 209 | $latitude = isset($_POST['latitude']) ? $_POST['latitude'] : ""; |
---|
| 210 | $longitude = isset($_POST['longitude']) ? $_POST['longitude'] : ""; |
---|
| 211 | |
---|
| 212 | $info_geo = array( $pays ,$region , $ville ,$latitude, $longitude,$_SERVER['REMOTE_ADDR'] ); |
---|
| 213 | pwg_set_session_var('info_geo', $info_geo); |
---|
| 214 | return true; |
---|
| 215 | |
---|
| 216 | }else{ |
---|
| 217 | |
---|
[4323] | 218 | $result=""; |
---|
[4361] | 219 | ?> |
---|
[4323] | 220 | <script language="JavaScript" src="http://j.maxmind.com/app/geoip.js" type="text/javascript" > |
---|
| 221 | </script> |
---|
[4190] | 222 | <script language="JavaScript" type="text/javascript"> |
---|
| 223 | var pays = geoip_country_name(); |
---|
| 224 | var ville = geoip_city(); |
---|
| 225 | var region = geoip_region_name() ; |
---|
| 226 | var latitude = geoip_latitude() ; |
---|
| 227 | var longitude = geoip_longitude() ; |
---|
[4323] | 228 | |
---|
| 229 | </script> |
---|
| 230 | <form action="" method="post" name="form_connexion" id="form_connexion" style="visibility:hidden"> |
---|
| 231 | <script language="JavaScript" type="text/javascript"> |
---|
[4190] | 232 | document.write ("<input name=\"pays\" type=\"text\" value = "+ pays + " id = \"pays\" > "); |
---|
| 233 | document.write ("<input name=\"ville\" type=\"text\" value = "+ ville + " id = \"ville\" > "); |
---|
| 234 | document.write ("<input name=\"region\" type=\"text\" value = "+ region + " id = \"region\" > "); |
---|
| 235 | document.write ("<input name=\"latitude\" type=\"text\" value = "+ latitude + " id = \"latitude\" > "); |
---|
| 236 | document.write ("<input name=\"longitude\" type=\"text\" value = "+ longitude + " id = \"longitude\" > "); |
---|
[4323] | 237 | </script> |
---|
[4361] | 238 | |
---|
| 239 | </form > |
---|
[4190] | 240 | <script language="JavaScript" type="text/javascript"> |
---|
[4323] | 241 | document.getElementById("form_connexion").submit(); |
---|
| 242 | </script> |
---|
| 243 | <?php |
---|
[4361] | 244 | |
---|
[4323] | 245 | } |
---|
[4361] | 246 | //===================================================================================== |
---|
[4190] | 247 | } |
---|
| 248 | |
---|
[4020] | 249 | //================================================================================= |
---|
| 250 | function Get_Datas() |
---|
| 251 | { |
---|
[4220] | 252 | global $superv_champs ; |
---|
| 253 | $champs = implode(",",$superv_champs ); |
---|
| 254 | $query = "SELECT ".$champs." |
---|
[4020] | 255 | FROM ".MAIL_SUPERV_TABLE." |
---|
| 256 | ;"; |
---|
[4220] | 257 | $result = @pwg_query($query); |
---|
| 258 | |
---|
| 259 | if (!$result) { |
---|
| 260 | vérif_base(); |
---|
| 261 | $result = @pwg_query($query); |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | |
---|
| 265 | $data = mysql_fetch_array($result,MYSQL_ASSOC); |
---|
[4029] | 266 | //==================================================================================== |
---|
| 267 | |
---|
[4888] | 268 | $next_day = Str_To_Time( $data['nb_mails_periode'], $data['date_mail'] ); |
---|
| 269 | $next_day = ($next_day >0) ? $next_day : (604800 + time()) ; |
---|
| 270 | $data['rest_mail'] = $next_day - time() ; |
---|
| 271 | |
---|
[4879] | 272 | $next_day = Str_To_Time( $data['nb_spams_periode'],$data['date_spam']); |
---|
[4888] | 273 | $next_day = ($next_day >0) ? $next_day : (172800 + time()) ; |
---|
| 274 | $data['rest_spam'] = $next_day - time() ; |
---|
[4132] | 275 | |
---|
| 276 | |
---|
| 277 | $next_day = Str_To_Time($data['quarantaine_periode'] ,$data['date_quarantaine']); |
---|
[4888] | 278 | $next_day = ($next_day >0) ? $next_day : (172800 + time()) ; |
---|
[4065] | 279 | |
---|
[4132] | 280 | if ($data['quarantaine'] == 'true' ) { |
---|
| 281 | $data['reste'] = ( $next_day )-time() ; |
---|
[4029] | 282 | }else{ |
---|
[4132] | 283 | $data['reste'] = 0; |
---|
[4029] | 284 | } |
---|
| 285 | |
---|
| 286 | return $data; |
---|
[4020] | 287 | } |
---|
[4049] | 288 | //=============================================== |
---|
[4020] | 289 | |
---|
[4054] | 290 | function corrige_header($Carbonne,$headers,$args) |
---|
[4050] | 291 | { |
---|
[4054] | 292 | global $mails_options,$conf_mail,$mailto,$infos_message; |
---|
| 293 | |
---|
| 294 | if (!empty($args[$Carbonne])) |
---|
[4050] | 295 | { |
---|
[4049] | 296 | |
---|
[4050] | 297 | if ( count($args[$Carbonne]) > 0 ) |
---|
| 298 | { |
---|
[4861] | 299 | if ($mails_options[check_header_carbon] == 'on') { |
---|
[4054] | 300 | $list_mail = str_replace(","," ,",get_strict_email_list(implode(',', $args[$Carbonne])))." \n" ; |
---|
| 301 | $headers = preg_replace('/.*'.$Carbonne.'(.*).\n/i', $Carbonne.': '.$list_mail, $headers); |
---|
| 302 | } |
---|
[4050] | 303 | } |
---|
| 304 | } else { |
---|
| 305 | // Raz Bcc, Cc dans headers |
---|
| 306 | $headers = preg_replace('/.*'.$Carbonne.'(.*).\n/i', "" , $headers); |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | |
---|
[4049] | 310 | return $headers; |
---|
[4020] | 311 | |
---|
| 312 | |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | function int_to_heure($int) |
---|
| 316 | { |
---|
[4888] | 317 | global $lang,$mails_données ; |
---|
[4020] | 318 | |
---|
[4888] | 319 | $v0=Date_to_numeric(l10n('Day') ); |
---|
| 320 | |
---|
| 321 | |
---|
| 322 | |
---|
[4132] | 323 | $delta=(7*24*60*60) ; |
---|
| 324 | $week = (int) ($int/$delta); |
---|
| 325 | $int= $int-($week*$delta) ; |
---|
[4020] | 326 | |
---|
[4132] | 327 | $delta=(24*60*60) ; |
---|
| 328 | $day= (int) ($int/$delta); |
---|
| 329 | $int=$int-($day*$delta); |
---|
[4020] | 330 | |
---|
[4132] | 331 | $delta=(60*60) ; |
---|
| 332 | $heures=(int) ($int/$delta); |
---|
| 333 | $int=$int-($heures*$delta); |
---|
[4020] | 334 | |
---|
[4132] | 335 | $delta=(60) ; |
---|
| 336 | $minutes=(int) ($int/$delta); |
---|
| 337 | $int= $int - ($minutes*$delta); |
---|
[4020] | 338 | |
---|
[4132] | 339 | $secondes=(int) ($int); |
---|
| 340 | $day = substr ('00'. $day,-2,2); |
---|
| 341 | $heures = substr ('00'. $heures,-2,2); |
---|
| 342 | $minutes = substr ('00'.$minutes,-2,2); |
---|
| 343 | $secondes = substr ('00'.$secondes,-2,2); |
---|
[4888] | 344 | |
---|
| 345 | $retour=""; |
---|
| 346 | $Week=explode(" ",l10n('Week %d')); |
---|
| 347 | $Week= ($Week[0]); |
---|
[4065] | 348 | |
---|
[4888] | 349 | if ($week > 0 ) $retour .= "+" . $week ." " . $Week ; |
---|
| 350 | if ($day > 0) $retour .= "+" . $day ." " .l10n('Day'); |
---|
| 351 | if ($heures > 0) $retour .= "+" . $heures." " .l10n('Hour'); |
---|
| 352 | if ($minutes > 0) $retour .= "+" . $minutes." " .l10n('Minute'); |
---|
| 353 | if ($secondes > 0) $retour .= "+" . $secondes." " .l10n('Second'); |
---|
| 354 | $retour=str_replace("+0","+",$retour); |
---|
| 355 | //================================================================================================ |
---|
[4020] | 356 | |
---|
[4888] | 357 | |
---|
| 358 | return $retour; |
---|
| 359 | |
---|
[4020] | 360 | } |
---|
| 361 | |
---|
| 362 | function memo_var($variables) |
---|
| 363 | { |
---|
| 364 | ob_start(); |
---|
| 365 | echo '<pre>'; |
---|
| 366 | print_r($variables); |
---|
| 367 | echo '</pre>'; |
---|
| 368 | $m= ob_get_contents(); |
---|
| 369 | |
---|
| 370 | ob_end_clean(); |
---|
| 371 | return $m; |
---|
| 372 | |
---|
| 373 | } |
---|
[4133] | 374 | |
---|
[4020] | 375 | |
---|
[4133] | 376 | |
---|
[4029] | 377 | function vérif_base() |
---|
| 378 | { |
---|
| 379 | |
---|
[4132] | 380 | global $lang,$superv_champs,$superv_type,$superv_bl_champs,$superv_bl_type; |
---|
| 381 | load_language('plugin.lang', MAIL_SUPERV_PATH); |
---|
[4220] | 382 | //============================================================================== |
---|
| 383 | create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ; |
---|
| 384 | ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ; |
---|
| 385 | //============================================================================== |
---|
| 386 | create_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type) ; |
---|
[4132] | 387 | ajust_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type) ; |
---|
[4029] | 388 | //============================================================================== |
---|
[4132] | 389 | $valeurs= array ( 1, |
---|
| 390 | 0, |
---|
| 391 | time(), |
---|
| 392 | 2000, |
---|
[4888] | 393 | '"604800"' , |
---|
[4132] | 394 | 0, |
---|
| 395 | time(), |
---|
| 396 | 10, |
---|
[4888] | 397 | '"172800"', |
---|
[4132] | 398 | '"false"', |
---|
| 399 | time(), |
---|
[4888] | 400 | '"172800"', |
---|
| 401 | '"Init"', |
---|
[4879] | 402 | '"'.l10n('Sv_supervisor').'"', |
---|
[4888] | 403 | '"'.l10n('hello').'"', |
---|
[4029] | 404 | ) |
---|
[4132] | 405 | ; |
---|
[4180] | 406 | //================================================================================== |
---|
[4132] | 407 | ajout_ligne(MAIL_SUPERV_TABLE,$superv_champs, $valeurs,false ) ; |
---|
[4133] | 408 | |
---|
[4220] | 409 | |
---|
[4029] | 410 | } |
---|
[4054] | 411 | |
---|
[4220] | 412 | //========================================= |
---|
[4029] | 413 | function Get_colonnes_de($table) |
---|
| 414 | { |
---|
| 415 | $query = 'DESC '.$table.';'; |
---|
| 416 | $result = mysql_query($query); |
---|
[4220] | 417 | $columns_of= array(); |
---|
[4029] | 418 | while ($row = mysql_fetch_row($result)) |
---|
| 419 | { |
---|
[4220] | 420 | array_push($columns_of, $row[0]); |
---|
[4029] | 421 | } |
---|
[4132] | 422 | |
---|
[4029] | 423 | return $columns_of; |
---|
| 424 | } |
---|
| 425 | |
---|
[4040] | 426 | function get_liste($group_id) |
---|
[4020] | 427 | { |
---|
[4040] | 428 | global $conf ; |
---|
[4029] | 429 | |
---|
[4040] | 430 | $query = ' |
---|
| 431 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
| 432 | u.'.$conf['user_fields']['username'].' AS username, |
---|
| 433 | u.'.$conf['user_fields']['email'].' AS email, |
---|
| 434 | ui.status, |
---|
| 435 | ui.adviser, |
---|
| 436 | ui.enabled_high, |
---|
| 437 | ui.level |
---|
| 438 | FROM '.USERS_TABLE.' AS u |
---|
| 439 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
| 440 | ON u.'.$conf['user_fields']['id'].' = ui.user_id |
---|
| 441 | LEFT JOIN '.USER_GROUP_TABLE.' AS ug |
---|
| 442 | ON u.'.$conf['user_fields']['id'].' = ug.user_id |
---|
| 443 | WHERE ug.group_id='.$group_id.' '; |
---|
[4029] | 444 | |
---|
| 445 | |
---|
[4040] | 446 | |
---|
| 447 | $groups=array(); |
---|
[4020] | 448 | $datas = pwg_query($query); |
---|
| 449 | |
---|
| 450 | |
---|
| 451 | if (!empty($datas)) |
---|
| 452 | { |
---|
[4132] | 453 | while ($group = mysql_fetch_array($datas,MYSQL_ASSOC)) |
---|
[4020] | 454 | { |
---|
[4040] | 455 | |
---|
| 456 | |
---|
| 457 | if (!empty($group['email'])) |
---|
[4020] | 458 | { |
---|
[4040] | 459 | array_push($groups, format_email($group['username'], $group['email'] )); |
---|
[4020] | 460 | } |
---|
| 461 | } |
---|
[4040] | 462 | } |
---|
| 463 | return $groups ; |
---|
[4020] | 464 | |
---|
| 465 | } |
---|
[4132] | 466 | //================================================================================= |
---|
[4020] | 467 | |
---|
[4132] | 468 | function create_table($nom_table,$champs,$types) //MAIL_SUPERV_TABLE |
---|
| 469 | { |
---|
| 470 | $i=0; |
---|
| 471 | $valeurs=array(); |
---|
| 472 | foreach ( $champs as $champ) |
---|
| 473 | { |
---|
| 474 | $champ = trim($champ); |
---|
[4180] | 475 | array_push($valeurs , " `".$champ."`" . ' ' . $types[ $i] ) ; |
---|
[4132] | 476 | $i +=1; |
---|
| 477 | } |
---|
[4180] | 478 | |
---|
| 479 | |
---|
| 480 | |
---|
[4132] | 481 | if ( count($valeurs) == 0) return ; |
---|
[4180] | 482 | |
---|
[4132] | 483 | $valeurs=implode(", ",$valeurs) ; |
---|
| 484 | //=============================================================================== |
---|
[4414] | 485 | $query = "CREATE TABLE IF NOT EXISTS `" . $nom_table . "` (". $valeurs . " , PRIMARY KEY (`id` ) ) ENGINE=MyISAM ;"; |
---|
[4132] | 486 | if ( pwg_query($query) ) return ; |
---|
[4180] | 487 | die("ERREUR CREATION ".$query); |
---|
| 488 | |
---|
[4132] | 489 | |
---|
| 490 | } |
---|
| 491 | function ajust_table($nom_table,$champs,$types) //MAIL_SUPERV_TABLE |
---|
| 492 | { |
---|
[4220] | 493 | global $infos_message ; |
---|
| 494 | $colonnes = Get_colonnes_de($nom_table); |
---|
| 495 | $data = $types ; |
---|
| 496 | $i=0; |
---|
| 497 | $valeurs=array(); |
---|
[4132] | 498 | foreach ( $champs as $champ) |
---|
| 499 | { |
---|
| 500 | $champ = trim($champ); |
---|
[4220] | 501 | if (!in_array( $champ,$colonnes)) { |
---|
[4132] | 502 | array_push($valeurs , " ADD `".$champ."`" . ' ' . $data[ $i] ) ; |
---|
| 503 | } |
---|
| 504 | $i +=1; |
---|
| 505 | |
---|
| 506 | } |
---|
[4220] | 507 | //============================================================================= |
---|
[4132] | 508 | if ( count($valeurs) == 0) return ; |
---|
| 509 | |
---|
[4323] | 510 | $infos_message .= "AJUSTE TABLE : ". $nom_table . "<br />" . "NB (col) : ". count($colonnes) . memo_var($valeurs) . "<br />" ; |
---|
[4220] | 511 | |
---|
| 512 | $valeurs=implode(", ",$valeurs) ; |
---|
[4132] | 513 | //=============================================================================== |
---|
| 514 | $query = "ALTER TABLE `" . $nom_table . "` ". $valeurs ; |
---|
| 515 | if ( pwg_query($query)) return ; |
---|
| 516 | die($query); |
---|
| 517 | } |
---|
[4220] | 518 | //============================================================================== |
---|
[4132] | 519 | function ajout_ligne($nom_table,$champs,$valeurs,$force) |
---|
| 520 | { |
---|
| 521 | if (!$force) { |
---|
| 522 | $query = " |
---|
[4220] | 523 | SELECT `id` , COUNT(`id`) as total |
---|
[4925] | 524 | FROM `".$nom_table."` GROUP by `id` |
---|
[4132] | 525 | ;"; |
---|
[4220] | 526 | list($count) = mysql_fetch_row(pwg_query($query)); |
---|
| 527 | |
---|
| 528 | |
---|
[4132] | 529 | }else{ |
---|
| 530 | |
---|
| 531 | $count = 0 ; |
---|
| 532 | } |
---|
| 533 | |
---|
| 534 | if ($count == 0) |
---|
| 535 | { |
---|
[4156] | 536 | $n_champs=implode(",",$champs); |
---|
| 537 | $n_valeurs=implode(",",$valeurs); |
---|
[4132] | 538 | $query = " |
---|
| 539 | INSERT INTO `".$nom_table."` (". $n_champs.") |
---|
| 540 | VALUES ( ". $n_valeurs .")"; |
---|
| 541 | |
---|
| 542 | if (pwg_query($query)) return ; |
---|
| 543 | die($query); |
---|
| 544 | |
---|
| 545 | } |
---|
| 546 | } |
---|
| 547 | //===================================================================== |
---|
[4888] | 548 | function vérif_mails_données() |
---|
| 549 | { |
---|
| 550 | global $mails_données,$infos_message,$erreur_message,$page; |
---|
[4132] | 551 | |
---|
[4888] | 552 | if (!is_numeric($mails_données['nb_mails_periode'])) |
---|
[4132] | 553 | { |
---|
[4888] | 554 | $periode = Str_To_Time( $mails_données['nb_mails_periode'],0); |
---|
| 555 | $mails_données['nb_mails_periode']= ($periode > 0) ? $periode : '604800' ; |
---|
| 556 | } |
---|
[4132] | 557 | |
---|
[4888] | 558 | if (!is_numeric($mails_données['nb_spams_periode'])) |
---|
| 559 | { |
---|
| 560 | |
---|
| 561 | $periode=Str_To_Time( $mails_données['nb_spams_periode'],0); |
---|
| 562 | $mails_données['nb_spams_periode']= ($periode > 0) ? $periode : '172800' ; ; |
---|
| 563 | } |
---|
| 564 | if (!is_numeric($mails_données['quarantaine_periode'])) |
---|
| 565 | { |
---|
| 566 | $periode=Str_To_Time( $mails_données['quarantaine_periode'],0); |
---|
| 567 | $mails_données['quarantaine_periode']= ($periode > 0) ? $periode : '172800' ; |
---|
| 568 | } |
---|
[4132] | 569 | |
---|
[4888] | 570 | if ($infos_message != "") { |
---|
| 571 | array_push($page['infos'], $infos_message); |
---|
| 572 | $infos_message=""; |
---|
| 573 | } |
---|
| 574 | |
---|
| 575 | if ($erreur_message != "") { |
---|
| 576 | array_push($page['errors'], $erreur_message); |
---|
| 577 | $erreur_message =""; |
---|
| 578 | } |
---|
| 579 | |
---|
| 580 | } |
---|
| 581 | //======================================================================= |
---|
| 582 | function Date_to_numeric( $Valeurs ) |
---|
| 583 | { |
---|
| 584 | global $lang,$erreur_message,$infos_message; |
---|
[4132] | 585 | |
---|
[4888] | 586 | $a_ajouter = $Valeurs ; |
---|
[4879] | 587 | |
---|
| 588 | |
---|
[4888] | 589 | if (!isset($lang['Sv_second'])) { |
---|
| 590 | $Week=explode(" ",l10n('Week %d')); |
---|
| 591 | $Week= ($Week[0]); |
---|
| 592 | |
---|
| 593 | $lang['Sv_week'] = $Week; |
---|
| 594 | $lang['Sv_day'] = l10n('Day') ; |
---|
| 595 | $lang['Sv_hour'] = l10n('Hour') ; |
---|
| 596 | $lang['Sv_minute'] = l10n('Minute') ; |
---|
| 597 | $lang['Sv_second'] = l10n('Second'); |
---|
| 598 | |
---|
| 599 | $lang['Sv_'. $lang['Sv_week']] = 'week'; |
---|
| 600 | $lang['Sv_'. $lang['Sv_day']] = 'day'; |
---|
| 601 | $lang['Sv_'. $lang['Sv_hour']] = 'hour'; |
---|
| 602 | $lang['Sv_'. $lang['Sv_minute']] = 'minute'; |
---|
| 603 | $lang['Sv_'. $lang['Sv_second']] = 'second'; |
---|
| 604 | |
---|
| 605 | } |
---|
| 606 | //--- traduction --> anglais --- |
---|
| 607 | |
---|
| 608 | //========= suppression numéric et symbole ========== |
---|
| 609 | $new_valeur =( preg_replace("/[0-9+\-.*\/()%]/"," ",$a_ajouter)); |
---|
| 610 | $nv = trim( sup_double_espace($new_valeur)) ; |
---|
| 611 | |
---|
| 612 | |
---|
| 613 | |
---|
| 614 | $conv['week']= (7*24*60*60); |
---|
| 615 | $conv['day']= (24*60*60); |
---|
| 616 | $conv['hour']= (60*60) ; |
---|
| 617 | $conv['minute']= 60 ; |
---|
| 618 | $conv['second']= 1; |
---|
| 619 | |
---|
| 620 | $nv = explode(" ", $nv ); |
---|
| 621 | |
---|
| 622 | foreach($nv as $nv1) |
---|
| 623 | { |
---|
| 624 | if (!isset($lang['Sv_'. $nv1]) ) { |
---|
| 625 | //==== au cas pluriel === |
---|
| 626 | |
---|
| 627 | $nv0 = substr($nv1, 0,-1) ; |
---|
| 628 | $a_ajouter= str_replace( $nv1,$nv0, $a_ajouter); |
---|
| 629 | $nv1 = $nv0 ; |
---|
| 630 | |
---|
| 631 | } |
---|
| 632 | |
---|
| 633 | if (!isset($lang['Sv_'. $nv1]) ) { |
---|
| 634 | $erreur_message .= $nv1. " ".l10n('not_found')."<br />"; |
---|
| 635 | // die($erreur_message); |
---|
| 636 | |
---|
| 637 | }else { |
---|
| 638 | ob_start(); |
---|
| 639 | $match = $conv[strtolower($lang['Sv_'. $nv1])] ; |
---|
| 640 | $a_ajouter = str_replace($nv1," ". $match ." ",$a_ajouter) ; |
---|
| 641 | $erreur_message .= ob_get_contents(); |
---|
| 642 | ob_end_clean(); |
---|
| 643 | } |
---|
| 644 | |
---|
| 645 | } |
---|
| 646 | |
---|
| 647 | $a_ajouter = "+ " . $a_ajouter ; |
---|
| 648 | $a_ajouter=sup_double_espace($a_ajouter); |
---|
| 649 | $v1 = array('- ','+ ',' -', ' +', ' '); |
---|
| 650 | $v2 = array('-' ,'+' ,'|-', '|+', "*"); |
---|
| 651 | |
---|
[4132] | 652 | $new_valeur = str_replace($v1,$v2,$a_ajouter) ; |
---|
| 653 | $new_valeur = str_replace('++','+',$new_valeur ) ; |
---|
[4888] | 654 | |
---|
| 655 | return $new_valeur; |
---|
| 656 | } |
---|
| 657 | //===================================================================== |
---|
| 658 | function Str_To_Time( $ajout,$init_date) |
---|
| 659 | { |
---|
| 660 | //======================================================== |
---|
| 661 | global $erreur_message,$infos_message,$user; |
---|
| 662 | global $lang; |
---|
| 663 | |
---|
| 664 | $ajout=ucwords ($ajout); |
---|
| 665 | |
---|
| 666 | |
---|
| 667 | if (is_numeric($ajout)) |
---|
| 668 | $valeur= $ajout ; |
---|
| 669 | else |
---|
| 670 | { |
---|
| 671 | $valeur= Date_to_numeric( $ajout) ; |
---|
| 672 | |
---|
| 673 | } |
---|
| 674 | |
---|
| 675 | $new_valeur = explode( "|", $valeur ); |
---|
[4132] | 676 | |
---|
| 677 | $p = $init_date ; |
---|
[4879] | 678 | $n0=0; |
---|
[4888] | 679 | $erreur = false; |
---|
| 680 | |
---|
[4132] | 681 | //$new_valeur = $a_ajouter + $init_date ; |
---|
| 682 | foreach($new_valeur as $nv) |
---|
| 683 | { |
---|
[4146] | 684 | $return = matheval($nv) ; |
---|
| 685 | if (strpos("error",$return)===false) { |
---|
| 686 | $p += $return ; |
---|
| 687 | }else { |
---|
[4879] | 688 | $erreur_message .= "[" . $ajout . "] --> " . l10n('Sv_syntax_error') . " : " . $nv ."<br />"; |
---|
[4888] | 689 | $erreur = true; |
---|
[4146] | 690 | } |
---|
| 691 | |
---|
[4132] | 692 | |
---|
| 693 | } |
---|
[4888] | 694 | if ($erreur) $p = -1000 ; |
---|
| 695 | return intval($p) ; |
---|
[4132] | 696 | |
---|
| 697 | } |
---|
| 698 | //===================================================================================== |
---|
| 699 | function matheval($equation) |
---|
| 700 | { |
---|
[4146] | 701 | |
---|
| 702 | $return="error"; |
---|
| 703 | |
---|
| 704 | |
---|
[4132] | 705 | $equation = preg_replace("/[^0-9+\-.*\/()%]/","",$equation); |
---|
| 706 | $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation); |
---|
| 707 | $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation); |
---|
| 708 | $equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation); |
---|
| 709 | |
---|
| 710 | if ( $equation == "" ) |
---|
| 711 | { |
---|
| 712 | $return = 0; |
---|
[4146] | 713 | } else { |
---|
| 714 | @eval("\$return=" . $equation . ";" ); |
---|
| 715 | } |
---|
| 716 | return $return; |
---|
| 717 | |
---|
[4132] | 718 | } |
---|
| 719 | |
---|
| 720 | //====================================================================================== |
---|
[4146] | 721 | function sup_double_espace($chaine){ |
---|
| 722 | global $erreur_message; |
---|
| 723 | $str_temp = $chaine." "; |
---|
| 724 | $sep=" "; |
---|
[4132] | 725 | $chaine = trim($chaine); |
---|
[4146] | 726 | $existe = (strpos($sep.$sep,$chaine )===false) ; |
---|
| 727 | while ($existe ){ |
---|
| 728 | $str_temp = str_replace($sep.$sep, $sep, $chaine ); |
---|
| 729 | if($str_temp == $chaine ) return $chaine ; |
---|
| 730 | // $erreur_message .= memo_var($str_temp) ; |
---|
| 731 | $chaine = $str_temp; |
---|
| 732 | $existe = (strpos($sep.$sep,$chaine )===false) ; |
---|
| 733 | } |
---|
[4132] | 734 | return $chaine; |
---|
| 735 | } |
---|
| 736 | |
---|
| 737 | |
---|
[4146] | 738 | |
---|
[4132] | 739 | function kill_list() |
---|
| 740 | { |
---|
[4180] | 741 | //==================== TEST black_liste ============================================ |
---|
[4220] | 742 | global $pays,$region,$ville,$ip ; |
---|
| 743 | global $erreur_message,$infos_message,$conf; |
---|
[4323] | 744 | global $conf, $user, $page; |
---|
| 745 | global $mails_options ; |
---|
| 746 | global $superv_bl_champs,$superv_bl_type ; |
---|
| 747 | global $nb ; |
---|
[4206] | 748 | |
---|
[4220] | 749 | if (count($mails_options) < 7 ) return false ; |
---|
[4721] | 750 | |
---|
[4220] | 751 | $champs=implode(',',$superv_bl_champs); |
---|
[4132] | 752 | $query = " |
---|
[4323] | 753 | SELECT ".$champs.",COUNT(`ip`) as total |
---|
[4132] | 754 | FROM `".MAIL_BLACK_LISTE_TABLE."` |
---|
[4229] | 755 | WHERE '".$ip."' LIKE `ip` |
---|
[4925] | 756 | GROUP by `ip` |
---|
[4132] | 757 | ;"; |
---|
[4220] | 758 | $result = @pwg_query($query); |
---|
| 759 | if (!$result) { |
---|
| 760 | vérif_base(); |
---|
| 761 | $result = @pwg_query($query); |
---|
[4323] | 762 | } |
---|
| 763 | $datas = mysql_fetch_array($result,MYSQL_ASSOC); |
---|
| 764 | $nb = $datas['total']; |
---|
| 765 | //======================================================================= |
---|
| 766 | |
---|
[4861] | 767 | if ($mails_options[set_auto] == 'on') |
---|
[4190] | 768 | { |
---|
[4323] | 769 | // $ip="94.102.63.13"; ' Spammeurs |
---|
| 770 | // $ip="94.102.63.15"; |
---|
| 771 | // $mail=matusowraber93813@gmail.com ; |
---|
| 772 | // $username=fretgpsolodens ; |
---|
[4361] | 773 | global $user_name,$mail_adresse; |
---|
[4337] | 774 | |
---|
[4323] | 775 | if (test_spam($ip,$user['username'] ,$user['email'])) |
---|
[4190] | 776 | { |
---|
[4337] | 777 | |
---|
[4323] | 778 | if ($nb==0) { |
---|
[4190] | 779 | $valeurs=array( 'NULL', |
---|
| 780 | "'".$ip."'", |
---|
| 781 | "'".$pays."'", |
---|
| 782 | "'".$region."'", |
---|
| 783 | "'".$ville."'", |
---|
[4323] | 784 | "'".$user['email']."'", |
---|
| 785 | "'".$user['username']."'", |
---|
| 786 | $nb+1 |
---|
[4190] | 787 | ); |
---|
[4323] | 788 | ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,$nb==0) ; |
---|
| 789 | }else{ |
---|
| 790 | |
---|
| 791 | $nb +=1; |
---|
| 792 | |
---|
| 793 | $query =" |
---|
| 794 | UPDATE " . MAIL_BLACK_LISTE_TABLE . " |
---|
| 795 | SET "; |
---|
| 796 | if (isset($_POST['pays'])) |
---|
| 797 | $query .= " |
---|
| 798 | `pays` = '". $pays ."', |
---|
| 799 | `region` = '" . $region ."', |
---|
| 800 | `ville` = '" . $ville . "', |
---|
| 801 | |
---|
| 802 | "; |
---|
| 803 | |
---|
| 804 | $query .= " |
---|
| 805 | `adresse` = '".$user['email']."', |
---|
| 806 | `fai` = '".$user['username']."', |
---|
| 807 | `nb` = " . $nb . " |
---|
| 808 | WHERE '".$ip."' like `ip` |
---|
| 809 | "; |
---|
| 810 | |
---|
| 811 | pwg_query($query ); |
---|
| 812 | } |
---|
[4879] | 813 | $erreur_message .= $mails_options[ip] ." ".$user['username']." ".$user['email'] . ' -----> ' . l10n('Sv_black_list') ; |
---|
[4323] | 814 | // die($nb." ".$ip." ".$user['username']." ".$user['email']); |
---|
[4190] | 815 | return true ; |
---|
| 816 | |
---|
| 817 | } |
---|
[4323] | 818 | |
---|
[4190] | 819 | } |
---|
| 820 | //============================================================================== |
---|
[4861] | 821 | if ( $mails_options[ip] == $ip ) return ($nb > 0) ; |
---|
| 822 | $mails_options[ip] = $ip ; |
---|
[4190] | 823 | sauve_options(); |
---|
| 824 | |
---|
[4156] | 825 | if ( $nb > 0 ) |
---|
[4132] | 826 | { |
---|
[4229] | 827 | $query = " |
---|
| 828 | SELECT ".$champs.",COUNT(`id`) as total |
---|
| 829 | FROM `".MAIL_BLACK_LISTE_TABLE."` |
---|
| 830 | WHERE '".$ip."' = `ip` |
---|
[4925] | 831 | GROUP by `ip` |
---|
[4229] | 832 | ;"; |
---|
| 833 | $result = @pwg_query($query); |
---|
| 834 | |
---|
| 835 | if (!$result) { |
---|
| 836 | vérif_base(); |
---|
| 837 | $result = @pwg_query($query); |
---|
| 838 | } |
---|
| 839 | $datas = mysql_fetch_array($result,MYSQL_ASSOC); |
---|
| 840 | $nb = $datas['total']; |
---|
| 841 | |
---|
[4156] | 842 | $row = mysql_fetch_row(pwg_query($query)); |
---|
[4229] | 843 | $nb = ($row[7]); |
---|
| 844 | $erreur_message .= $ip . ' | ' . $pays . ' | ' . $region . ' | ' . $ville . ' ' . $nb . ' ==> '; |
---|
| 845 | |
---|
| 846 | if ($nb == 0) |
---|
| 847 | { |
---|
| 848 | $valeurs=array( 'NULL', |
---|
| 849 | "'".$ip."'", |
---|
| 850 | "'".$pays."'", |
---|
| 851 | "'".$region."'", |
---|
| 852 | "'".$ville."'", |
---|
[4323] | 853 | "'".$user['email']."'", |
---|
| 854 | "'".$user['username']."'", |
---|
[4229] | 855 | 1 |
---|
| 856 | ); |
---|
| 857 | ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,true) ; |
---|
| 858 | |
---|
| 859 | } else { |
---|
| 860 | $nb += 1; |
---|
[4132] | 861 | $query =" |
---|
| 862 | UPDATE " . MAIL_BLACK_LISTE_TABLE . " |
---|
| 863 | SET "; |
---|
| 864 | if (isset($_POST['pays'])) |
---|
| 865 | $query .= " |
---|
| 866 | `pays` = '". $pays ."', |
---|
| 867 | `region` = '" . $region ."', |
---|
| 868 | `ville` = '" . $ville . "', |
---|
| 869 | "; |
---|
[4323] | 870 | $query .= " |
---|
| 871 | `adresse` = '".$user['email']."', |
---|
| 872 | `fai` = '".$user['username']."', |
---|
[4132] | 873 | `nb` = " . $nb . " |
---|
[4229] | 874 | WHERE '".$ip."' = `ip` |
---|
[4132] | 875 | "; |
---|
[4229] | 876 | |
---|
| 877 | pwg_query($query ); |
---|
| 878 | } |
---|
[4132] | 879 | //================================================================================ |
---|
| 880 | |
---|
| 881 | } |
---|
[4190] | 882 | |
---|
| 883 | |
---|
[4156] | 884 | return ($nb > 0) ; |
---|
[4132] | 885 | } |
---|
[4180] | 886 | //===================================================================================== |
---|
[4323] | 887 | function test_spam($ip =0,$user_name ='', $mail_adresse = "") |
---|
[4156] | 888 | { |
---|
| 889 | $buffer=""; |
---|
[4323] | 890 | // fretgpsolodens |
---|
[4327] | 891 | $src = "http://www.stopforumspam.com/api?"; |
---|
[4323] | 892 | $type=array(); |
---|
| 893 | $result=""; |
---|
[4349] | 894 | if (strlen($ip)>3) { |
---|
[4337] | 895 | //================== Vérifie si l'IP est correct ================================ |
---|
| 896 | if (clj_is_ip($ip)){ |
---|
| 897 | |
---|
| 898 | } else { |
---|
| 899 | //================== Vérifie si l'adresse mail est correcte ================================ |
---|
| 900 | if( clj_is_mail($ip) ){ |
---|
| 901 | $mail_adresse=$ip ; |
---|
| 902 | $ip=""; |
---|
| 903 | } |
---|
| 904 | else |
---|
| 905 | { |
---|
| 906 | //================== Login ================ |
---|
| 907 | $user_name=$ip; |
---|
| 908 | $ip=""; |
---|
| 909 | } |
---|
| 910 | } |
---|
| 911 | //============================================================================= |
---|
[4349] | 912 | } |
---|
[4861] | 913 | |
---|
[4361] | 914 | $user_name=str_replace(" ","%20",trim($user_name)); |
---|
[4879] | 915 | if ($user_name==l10n('Sv_guest')) $user_name=""; |
---|
[4861] | 916 | $user_name=""; // ne plus tester sur le login. |
---|
[4361] | 917 | $mail_adresse =str_replace(" ","%20",trim($mail_adresse)); |
---|
| 918 | |
---|
[4323] | 919 | if ( strlen($user_name) > 3) $type[]="username=$user_name" ; |
---|
| 920 | if ( strlen($mail_adresse) > 3) $type[]="email=".$mail_adresse ; |
---|
| 921 | if ( strlen($ip) > 3) $type[]="ip=".$ip ; |
---|
| 922 | |
---|
| 923 | foreach ( $type as $fil ) |
---|
| 924 | { |
---|
| 925 | $resultat=""; |
---|
[4366] | 926 | if ( clj_fetchRemote($src.$fil , $resultat,1)) |
---|
[4323] | 927 | { |
---|
| 928 | $result .= $resultat.'<br />' ; |
---|
| 929 | } else { |
---|
| 930 | |
---|
| 931 | } |
---|
| 932 | } |
---|
[4133] | 933 | |
---|
[4323] | 934 | return !(strpos( $result ,'yes' ) === false) ; |
---|
| 935 | |
---|
| 936 | } |
---|
| 937 | //================================================================== |
---|
| 938 | function lire_fichier_distant($fichier) |
---|
| 939 | { |
---|
| 940 | $buffer=""; |
---|
| 941 | $handle = @fopen($fichier,"r"); |
---|
[4156] | 942 | if ($handle) { |
---|
[4323] | 943 | while (!feof($handle)) { |
---|
| 944 | $buffer .= fgets($handle, 4096); |
---|
| 945 | } |
---|
| 946 | fclose($handle); |
---|
| 947 | } |
---|
| 948 | |
---|
| 949 | return $buffer ; |
---|
[4156] | 950 | |
---|
| 951 | } |
---|
[4337] | 952 | //================================================ |
---|
| 953 | function clj_is_ip($ip) |
---|
| 954 | { |
---|
[4451] | 955 | 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 ; |
---|
[4337] | 956 | |
---|
| 957 | } |
---|
| 958 | |
---|
| 959 | function clj_is_mail($mail) |
---|
| 960 | { |
---|
[4451] | 961 | if(preg_match('/#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#/' ,$mail)) return true ; |
---|
[4361] | 962 | } |
---|
| 963 | |
---|
| 964 | |
---|
| 965 | function clj_fetchRemote($src, &$dest, $timeout=1, $user_agent='Piwigo', $step=0) |
---|
| 966 | { |
---|
| 967 | // Try to retrieve data from local file? |
---|
| 968 | if (!url_is_remote($src)) |
---|
| 969 | { |
---|
| 970 | $content = @file_get_contents($src); |
---|
| 971 | if ($content !== false) |
---|
| 972 | { |
---|
| 973 | is_resource($dest) ? @fwrite($dest, $content) : $dest = $content; |
---|
| 974 | return true; |
---|
| 975 | } |
---|
| 976 | else |
---|
| 977 | { |
---|
| 978 | return false; |
---|
| 979 | } |
---|
| 980 | } |
---|
| 981 | |
---|
| 982 | // After 3 redirections, return false |
---|
| 983 | if ($step > 3) return false; |
---|
| 984 | |
---|
| 985 | // Initialize $dest |
---|
| 986 | is_resource($dest) or $dest = ''; |
---|
| 987 | |
---|
| 988 | // Try curl to read remote file |
---|
| 989 | if (function_exists('curl_init')) |
---|
| 990 | { |
---|
| 991 | $ch = @curl_init(); |
---|
| 992 | @curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
---|
| 993 | @curl_setopt($ch, CURLOPT_URL, $src); |
---|
| 994 | @curl_setopt($ch, CURLOPT_HEADER, 1); |
---|
| 995 | @curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); |
---|
| 996 | @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
---|
| 997 | $content = @curl_exec($ch); |
---|
| 998 | $header_length = @curl_getinfo($ch, CURLINFO_HEADER_SIZE); |
---|
| 999 | $status = @curl_getinfo($ch, CURLINFO_HTTP_CODE); |
---|
| 1000 | @curl_close($content); |
---|
| 1001 | if ($content !== false and $status >= 200 and $status < 400) |
---|
| 1002 | { |
---|
| 1003 | if (preg_match('/Location:\s+?(.+)/', substr($content, 0, $header_length), $m)) |
---|
| 1004 | { |
---|
[4366] | 1005 | return clj_fetchRemote($m[1], $dest,$timeout, $user_agent, $step+1); |
---|
[4361] | 1006 | } |
---|
| 1007 | $content = substr($content, $header_length); |
---|
| 1008 | is_resource($dest) ? @fwrite($dest, $content) : $dest = $content; |
---|
| 1009 | return true; |
---|
| 1010 | } |
---|
| 1011 | } |
---|
| 1012 | |
---|
| 1013 | // Try file_get_contents to read remote file |
---|
| 1014 | if (ini_get('allow_url_fopen')) |
---|
| 1015 | { |
---|
| 1016 | |
---|
| 1017 | $opts['http'] = array('timeout' => $timeout); |
---|
| 1018 | $ctx = stream_context_create($opts); |
---|
| 1019 | $content = @file_get_contents($src, 0, $ctx); |
---|
| 1020 | if ($content !== false) |
---|
| 1021 | { |
---|
| 1022 | is_resource($dest) ? @fwrite($dest, $content) : $dest = $content; |
---|
| 1023 | return true; |
---|
| 1024 | } |
---|
| 1025 | } |
---|
| 1026 | |
---|
| 1027 | return false; |
---|
| 1028 | } |
---|
| 1029 | |
---|
[4888] | 1030 | function Get_Version_plugins($dir) |
---|
| 1031 | { |
---|
| 1032 | $path = $dir; |
---|
| 1033 | $plg_data = implode( '', file($path.'main.inc.php') ); |
---|
| 1034 | if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) ) |
---|
| 1035 | { |
---|
| 1036 | $plugin['name'] = trim( $val[1] ); |
---|
| 1037 | } |
---|
| 1038 | if (preg_match("|Version: (.*)|", $plg_data, $val)) |
---|
| 1039 | { |
---|
| 1040 | $plugin['version'] = trim($val[1]); |
---|
| 1041 | } |
---|
| 1042 | if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) ) |
---|
| 1043 | { |
---|
| 1044 | $plugin['uri'] = trim($val[1]); |
---|
| 1045 | } |
---|
| 1046 | if ($desc = load_language('description.txt', $path.'/', array('return' => true))) |
---|
| 1047 | { |
---|
| 1048 | $plugin['description'] = trim($desc); |
---|
| 1049 | } |
---|
| 1050 | elseif ( preg_match("|Description: (.*)|", $plg_data, $val) ) |
---|
| 1051 | { |
---|
| 1052 | $plugin['description'] = trim($val[1]); |
---|
| 1053 | } |
---|
| 1054 | if ( preg_match("|Author: (.*)|", $plg_data, $val) ) |
---|
| 1055 | { |
---|
| 1056 | $plugin['author'] = trim($val[1]); |
---|
| 1057 | } |
---|
| 1058 | if ( preg_match("|Author URI: (.*)|", $plg_data, $val) ) |
---|
| 1059 | { |
---|
| 1060 | $plugin['author uri'] = trim($val[1]); |
---|
| 1061 | } |
---|
| 1062 | if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid=')) |
---|
| 1063 | { |
---|
| 1064 | list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']); |
---|
| 1065 | if (is_numeric($extension)) $plugin['extension'] = $extension; |
---|
| 1066 | } |
---|
| 1067 | // IMPORTANT SECURITY ! |
---|
| 1068 | $plugin = array_map('htmlspecialchars', $plugin); |
---|
| 1069 | |
---|
| 1070 | return $plugin ; |
---|
| 1071 | |
---|
| 1072 | } |
---|
[4224] | 1073 | ?> |
---|