'Mail supervisor',
'URL' => get_admin_plugin_menu_link(MAIL_SUPERV_PATH . 'admin/mail_superv_admin.php')
)
);
return $menu;
}
//============================================================
/*
* init
*/
static public function init() {
global $template,$version,$icon_path,$page;
$action_spam = pwg_get_session_var('action_spam') ;
$theme="default";
$themeconf=$template->get_template_vars('themeconf');
$theme=$themeconf['id'];
if (file_exists ( 'admin/themes/clear/icon/help.png')) $icon_path = 'admin/themes/clear/icon/help.png';
else $icon_path = "admin/template/goto/theme/clear/icon/help.png";
if (PHPWG_VERSION < 2.2 ) {
$file =MAIL_SUPERV_PATH_ABS.'admin/header_2_1.tpl' ;
} else {
$file = MAIL_SUPERV_PATH_ABS.'admin/header_2_2.tpl' ;
}
if(isset($_GET['action_spam']) and $_GET['action_spam']=="no"){
pwg_set_session_var('action_spam', "false");
unset ($_SESSION['pwg_'.'action_spam']);
}
$action_spam=pwg_get_session_var('action_spam');
$template->set_filenames(array('mail_superv_init'=> $file ));
$MAIL_SUPERV_PATH=str_replace(PHPWG_ROOT_PATH,"",MAIL_SUPERV_PATH) ;
$profile=array('theme' => $theme,
'PHPWG_VERSION' => PHPWG_VERSION ,
'MAIL_SUPERV_PATH' => $MAIL_SUPERV_PATH ,
'MAIL_SUPERV_PATH_ABS' => MAIL_SUPERV_PATH_ABS
);
$template->assign( $profile );
$template->append('footer_elements', '');
$template->parse( 'mail_superv_init', false);
return ;//
}// function init
//============================================================
/*
* affiche_message
*/
//============================================================
static public function affiche_message(){
global $template,$infos_message,$erreur_message, $user ,$ip;
global $mails_options,$conf,$lang,$page ;
global $action_spam ;
if (!isset($ip)) {
if (getenv("HTTP_CLIENT_IP")) {
$ip=getenv("HTTP_CLIENT_IP");
}else{
$ip=getenv("REMOTE_ADDR");
}
}
// unset ($_SESSION['pwg_'.'action_spam']);
$action_spam = pwg_get_session_var('action_spam') ;
if ($action_spam == null or $action_spam == 'false') {
$action_spam = kill_list();
}
if (is_bool($action_spam)) $action_spam =($action_spam == true) ? "true" : "false" ;
if ($action_spam == "true" ) {
$erreur_message .= $ip . " " . $action_spam ;
pwg_set_session_var('action_spam', "true");
$erreur_message .= "
".l10n('Sv_is_a_spam') ;
if ($mails_options['no_connect'] == 'on1' ){
//[status] => guest
//[status] => normal
//[status] => webmaster
if ($user['status'] != 'webmaster' )
if (!isset($_GET['admin'])) {
die('Blacklist :
' .$erreur_message. '
Hacking attempt!');
}elseif ($_GET['admin'] != 'piwigo'){
die('blacklist Hacking attempt!');
}
unset ($_SESSION['pwg_'.'action_spam']);
}
}else{
pwg_set_session_var('action_spam', "false");
}
if (isset($infos_message))
if ($infos_message != "") {
$infos_message = str_replace("\n",'
',$infos_message) ;
if (!isset($page['infos'])) $page['infos']=Array($infos_message);
else if(is_array($page['infos'])) array_push($page['infos'], $infos_message);
else $page['infos']=Array($infos_message);
$infos_message="";
}
if (isset($erreur_message))
if ($erreur_message != "") {
$erreur_message = str_replace("\n",'
',$erreur_message) ;
if (!isset($page['errors'])) $page['errors']=Array($erreur_message);
else if(is_array($page['errors'])) array_push($page['errors'], $erreur_message);
else $page['errors']=Array($erreur_message);
$erreur_message ="";
}
return $action_spam;
} //fin Affiche_message
//============================================================
/*
* Get_geo
*/
static public function Get_geo() {
global $info_geo,$ip,$pays,$region,$ville, $latitude ,$longitude,$mails_options;
//===================================================================================
$info_geo = pwg_get_session_var('info_geo');
if (count($info_geo) > 0){
$pays = $info_geo[0];
$region = $info_geo[1];
$ville = $info_geo[2];
$latitude = $info_geo[3];
$longitude = $info_geo[4];
$ip = $info_geo[5];
return true;
}
//=======================================================================
if (isset($_POST['pays'])) {
$pays = isset($_POST['pays']) ? $_POST['pays'] : "";
$region = isset($_POST['region']) ? $_POST['region'] :"";
$ville = (isset($_POST['ville'])) ? $_POST['ville']: "";
$latitude = isset($_POST['latitude']) ? $_POST['latitude'] : "";
$longitude = isset($_POST['longitude']) ? $_POST['longitude'] : "";
$info_geo = array( $pays ,$region , $ville ,$latitude, $longitude,$_SERVER['REMOTE_ADDR'] );
pwg_set_session_var('info_geo', $info_geo);
return true;
}else{
$result="";
echo '';
return true;
}
} // fin get_geo
//=====================================================================================
/*
* Memo_Var
*/
static public function Memo_Var($variables) {
ob_start();
echo '
'; if(count($variables)>1){ foreach($variables as $key => $line){ echo $key . " => " . $line ; echo "
"; } }else{ echo "".$variables."
"; } $m= ob_get_contents(); ob_end_clean(); return $m; } //====================================================================================== static public function Get_Version_plugins($dir){ $path = $dir; $plg_data = implode( '', file($path.'main.inc.php') ); if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) ) { $plugin['name'] = trim( $val[1] ); } if (preg_match("|Version: (.*)|", $plg_data, $val)) { $plugin['version'] = trim($val[1]); } if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) ) { $plugin['uri'] = trim($val[1]); } if ($desc = load_language('description.txt', $path.'/', array('return' => true))) { $plugin['description'] = trim($desc); } elseif ( preg_match("|Description: (.*)|", $plg_data, $val) ) { $plugin['description'] = trim($val[1]); } if ( preg_match("|Author: (.*)|", $plg_data, $val) ) { $plugin['author'] = trim($val[1]); } if ( preg_match("|Author URI: (.*)|", $plg_data, $val) ) { $plugin['author uri'] = trim($val[1]); } if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid=')) { list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']); if (is_numeric($extension)) $plugin['extension'] = $extension; } // IMPORTANT SECURITY ! $plugin = array_map('htmlspecialchars', $plugin); return $plugin ; } //========================================================== function Get_Options(&$parametres,$str_index){ global $conf ; $mails_options= $conf[$str_index]; if(isset($mails_options)) if ( preg_match("|s:(.*)|", $mails_options, $val) ) $parametres = unserialize($conf['mail_superv']); else{ $parametres=explode(",",$mails_options); } //====== par defaut ======================= $new_val=false; if (empty($def_para)) $def_para = (object) ''; $def_para->check_mailto="on"; $def_para->check_header_carbon="on"; $def_para->check_send_webmaster="off"; $def_para->no_ipaddress="off"; // interdiction adresse ip $def_para->no_mail_list="on"; $def_para->no_connect="on"; // empeche l'ip de se connecter au site. $def_para->set_auto="on"; // Test a l'ouverture et enregistrement $def_para->ip="127.0.0.1"; // derniere adresse IP $def_para->set_id="on"; // enregistrment nouvel $def_para->debug_mail="off"; // debogage foreach ($def_para as $key => $value) { if(isset($parametres[$key])){ $value=$parametres[$key]; } else { $new_val=true; } $new_val= isset($_POST[$key]) && $new_val ; unset( $parametres[$key]) ; $parametres[$key]= (isset($_POST[$key]))? "on" : $value ; } if($new_val){ sauve_options(); } return $parametres ; } //========================================================== function Set_Options($parametres,$str_index){ global $infos_message,$conf; foreach ($parametres as $key => $value) { $parametres[$key]=(isset($_POST[$key]))? "on" : $value ; } $parametres['no_connect']= 'off' ; return $parametres ; } //========================================================== function sauve_options(){ global $options,$infos_message,$conf,$mails_options ; $infos_message .=l10n("save_config")."
"; if (empty($mail_supervisor)) { $mail_supervisor = new mail_supervisor(); } $mails_parametres= $mail_supervisor->Set_Options($mails_options,"mail_superv"); if ( isset($mails_parametres) ) { $query = ' UPDATE '.CONFIG_TABLE.' SET value="'.addslashes(serialize($mails_parametres)).'" WHERE param = "mail_superv" LIMIT 1'; pwg_query($query); } } /**************************************** * sauve_donnees() ****************************************/ function sauve_donnees(){ global $mails_donnees,$superv_champs,$superv_type,$erreur_message ; //===================================================================== $clefs = $superv_champs ; $valeurs = array(); foreach ( $clefs as $champ){ $champ = trim($champ); if($champ !="id") if ( isset($mails_donnees[ $champ ]) ) { $sep= (is_string($mails_donnees[ $champ ])) ? '"' : '' ; array_push($valeurs , "`".$champ."`" . ' = ' . $sep . $mails_donnees[ $champ ] . $sep) ; }else{ array_push($valeurs , "`".$champ."`" . ' = ' . "0" ) ; } } $valeurs = implode(", ",$valeurs) ; //===================================================================== $query = ' UPDATE '.mail_superv_TABLE.' SET '. $valeurs .' WHERE `id` = 1 LIMIT 1 '; ; ob_start(); $ret= pwg_query($query) ; $m= ob_get_contents(); if($m!="") $m="Mail_super.inc.php sauve_donnees() l:323
".$m; ob_end_clean() ; $erreur_message .= $m ; } //================================================================================= function Get_Datas(){ global $superv_champs ; verif_base(); $champs = implode(",",$superv_champs ); $query = "SELECT ".$champs." FROM ".mail_superv_TABLE." ;"; $result = @pwg_query($query); if (!$result) { verif_base(); $result = @pwg_query($query); } $data = mysql_fetch_array($result,MYSQL_ASSOC); //==================================================================================== $next_day = Str_To_Time( $data['nb_mails_periode'], $data['date_mail'] ); $next_day = ($next_day >0) ? $next_day : (604800 + time()) ; $data['rest_mail'] = $next_day - time() ; $next_day = Str_To_Time( $data['nb_spams_periode'],$data['date_spam']); $next_day = ($next_day >0) ? $next_day : (172800 + time()) ; $data['rest_spam'] = $next_day - time() ; $next_day = Str_To_Time($data['quarantaine_periode'] ,$data['date_quarantaine']); $next_day = ($next_day >0) ? $next_day : (172800 + time()) ; //==================================================================================== if ($data['quarantaine'] == 'true' ) { $data['reste'] = ( $next_day )-time() ; }else{ $data['reste'] = 0; } return $data; } } ?>