false) { return $default_value; } else { return $encode_value; } } if($argc != 2 ) { echo "Vous devez sp�cifier le fichier de configuration!.\n You must specify the configuration file!\n"; exit; } else { $conf = $argv[1]; if(!file_exists($conf)) { echo "Pb � l'ouverture du fichier de configuration.\n Error during the configuration file opening!.\n"; exit; } // chargement du fichier de config $xmlconfig = simplexml_load_file($conf); foreach($xmlconfig->CONFIG as $CONFIG) { $_SESSION['config']['databaseserver'] = utf8_decode((string) $CONFIG->databaseserver); $_SESSION['config']['databasename'] = utf8_decode((string) $CONFIG->databasename); $_SESSION['config']['databaseuser'] = utf8_decode((string) $CONFIG->databaseuser); $_SESSION['config']['databasepassword'] = utf8_decode((string) $CONFIG->databasepassword); $_SESSION['config']['lang'] = utf8_decode((string) $CONFIG->lang); $_SESSION['config']['mail'] = utf8_decode((string) $CONFIG->mailfrom); $_SESSION['config']['debug'] = utf8_decode((string) $CONFIG->debug); $_SESSION['config']['MaarchDirectory'] = utf8_decode((string) $CONFIG->MaarchDirectory); $_SESSION['config']['MaarchURL'] = utf8_decode((string) $CONFIG->MaarchURL); $_SESSION['config']['tag_when_send'] = utf8_decode((string) $CONFIG->tag_when_send); } $i=0; foreach($xmlconfig->RESOURCES as $RESOURCES) { $_SESSION['ressources'][$i] = array("tablename" => utf8_decode((string) $RESOURCES->tablename), "comment" => utf8_decode((string) $RESOURCES->comment), ); $i++; } $table = $_SESSION['ressources'][0]['tablename']; foreach($xmlconfig->TABLENAME as $TABLENAME) { $_SESSION['tablename']['doctypes'] = utf8_decode((string) $TABLENAME->doctypes); $_SESSION['tablename']['history'] = utf8_decode((string) $TABLENAME->history); $_SESSION['tablename']['listinstance'] = utf8_decode((string) $TABLENAME->listinstance); $_SESSION['tablename']['users'] = utf8_decode((string) $TABLENAME->users); $_SESSION['tablename']['user_abs'] = utf8_decode((string) $TABLENAME->user_abs); $_SESSION['tablename']['services'] = utf8_decode((string) $TABLENAME->services); } //include("fr.php"); $lang_file = explode(DIRECTORY_SEPARATOR, $argv[0]); array_pop($lang_file); $lang_file = implode(DIRECTORY_SEPARATOR, $lang_file).'/'.$_SESSION['config']['lang'].'.php'; if(file_exists($lang_file)) { include($lang_file); } else { echo "Language file missing : ".$lang_file."...\r\n"; exit; } //notification des courriers cr�es dans la journ�e. //Les utilisateurs sont ainsi au courant des documents index�s dans la journ�e. require_once($_SESSION['config']['MaarchDirectory']."class_functions.php"); require_once($_SESSION['config']['MaarchDirectory']."class_db.php"); require_once($_SESSION['config']['MaarchDirectory']."class_users.php"); $func = new functions(); $db = new dbquery(); $db->connect(); $db2 = new dbquery(); $user = new users(); $db2->connect(); $db->query("SELECT DISTINCT USER_ID, MAIL, LASTNAME, FIRSTNAME, NOTIFICATION FROM ".$_SESSION['tablename']['users']." where ENABLED = 'Y'"); $datedujour=date("Y-m-d") ; $datedujourfr=date("d-m-Y") ; $date = Array('annee'=>date('Y'), 'mois'=>date('m'), 'jour'=>date('d')); $N = -1; $time = mktime(00, 00, 00, $date['mois'], $date['jour']+$N, $date['annee']); $dansNjours = date('Y-m-d', $time); $dansNjours = str_replace("-", "", $dansNjours ); $time18= "22:00:00"; $date = $dansNjours.$time18; $date = str_replace(":", "", $date); $users = array(); $the_res = array(); while($res = $db->fetch_object()) { //on v�rifie que l'user n'est pas absent $db2->query("select u.MAIL, ua.NEW_USER from ".$_SESSION['tablename']['users']." u, ".$_SESSION['tablename']['user_abs']." ua where u.USER_ID = ua.NEW_USER and ua.USER_ABS = '".htmlentities($res->USER_ID)."'"); if($db2->nb_result() < 1) { array_push($users, array( 'ID' => htmlentities(htmlentities($res->USER_ID)), 'MAIL' => htmlentities(utf8_decode($res->MAIL)), 'NOM' => htmlentities(utf8_decode($res->LASTNAME)), 'PRENOM' => htmlentities(utf8_decode($res->FIRSTNAME)), 'NOTIF' => $res->NOTIFICATION,'IS_ABS' => false)); } else { $res2 = $db2->fetch_object(); if( $users[$i]['NOTIF'] & 64 ) array_push($users, array( 'ID' => htmlentities($res->USER_ID), 'MAIL' => htmlentities($res->MAIL), 'NOM' => htmlentities(utf8_decode($res->LASTNAME)), 'PRENOM' => htmlentities(utf8_decode($res->FIRSTNAME)), 'NOTIF' => $res->NOTIFICATION, 'IS_ABS' => true, 'MAIL_ACTIF' => htmlentities(utf8_decode($res2->MAIL)), 'ID_ACTIF' => htmlentities(utf8_decode($res2->NEW_USER)))); } } if($_SESSION['config']['debug'] == "true") { print_r($users); echo "\n"; } for($i=0; $i < count($users); $i++) { //on v�rifie que l'user accept la notification if( ($users[$i]['NOTIF'] & 1) || ($users[$i]['NOTIF'] & 2) ) { //$db->query("select l.SEQUENCE, r.CUSTOM_T3, r.AUTHOR, r.CUSTOM_T4, r.DESTINATION, r.TYPE_ID, r.DESCRIPTION, date_format(date(r.CUSTOM_D2), '%d-%m-%Y') as DATE_LIM, r.DEST_USER, r.RES_ID, date_format(date(r.CREATION_DATE), '%d-%m-%Y') as DATE_CREA from ".$table." r, ".$_SESSION['tablename']['listinstance']." l where r.RES_ID=l.RES_ID and l.USER_ID='".$users[$i]['ID']."' and IS_FOLDER = 'Y' and r.FLAG_NOTIF = 'N' and (r.status = 'NEW' or r.status = 'COU')"); $db->query("select l.SEQUENCE, l.USER_ID, r.CUSTOM_T3, r.AUTHOR, r.CUSTOM_T4, r.DESTINATION, r.TYPE_ID, r.DESCRIPTION, date_format(date(r.CUSTOM_D2), '%d-%m-%Y') as DATE_LIM, r.DEST_USER, r.RES_ID, date_format(date(r.CREATION_DATE), '%d-%m-%Y') as DATE_CREA from ".$table." r left join ".$_SESSION['tablename']['listinstance']." l ON r.RES_ID=l.RES_ID where ((l.USER_ID='".$users[$i]['ID']."') OR (r.DEST_USER = '".$users[$i]['ID']."')) and IS_FOLDER = 'Y' and r.FLAG_NOTIF = 'N' and r.IS_INGOING = 'Y' and (r.status = 'NEW' or r.status = 'COU') group by r.RES_ID" ); if($_SESSION['config']['debug'] == "true") { $db->show(); echo "\n".$users[$i]['ID']."=> nb resultat : ".$db->nb_result()."\n"; } if($db->nb_result() > 0) { if($users[$i]['IS_ABS']) { $mail_trait = "
"._HELLO.", "._LIST_OF_MAIL_TO_PROCESS." "._FOR." ".$users[$i]['NOM']." ".$users[$i]['PRENOM']." :
"._HELLO.", "._LIST_OF_MAIL_TO_PROCESS." :
"._HELLO.", "._MAIL_COPIES_LIST." :
"._ORIGINAL_PAPERS_ALREADY_SEND.". ("._WARNING." : "._YOU_MUST_BE_LOGGED.".)
"; if($users[$i]['IS_ABS']) { $mail = $users[$i]['MAIL_ACTIF']; } else { $mail = $users[$i]['MAIL']; } if($_SESSION['config']['debug'] == "true") { $msg = "\nUser : ".$users[$i]['NOM']." ".$users[$i]['PRENOM']."\nMail : ".$mail."\nMail traitement : \n".$mail_trait."\n"; echo $msg; } if (mail($users[$i]['MAIL'], _MAIL_TO_PROCESS_LIST, $mail_trait , "From: ".$_SESSION['config']['mail']."\nReply-To: ".$_SESSION['config']['mail']." \nContent-Type: text/html; charset=\"iso-8859-1\"\n")) { for ($z=0; $z< count($the_res); $z++) { if ($_SESSION['config']['tag_when_send'] == "true") { //$db->query("UPDATE res_x set FLAG_NOTIF = 'Y' where RES_ID= '".$the_res[$z]."'"); } } } else { echo _MAIL_NO_SENDED; } } if(!empty($res_copies) && ($users[$i]['NOTIF'] & 2) ) { $mail_copies .= $res_copies."("._WARNING." : "._YOU_MUST_BE_LOGGED.".)
"; if($_SESSION['config']['debug'] == "true") { $msg = "\nUser : ".$users[$i]['NOM']." ".$users[$i]['PRENOM']."\nMail : ".$users[$i]['MAIL']."\nMail copies : \n".$mail_copies."\n"; echo $msg; } if (mail($users[$i]['MAIL'], _COPIES_MAIL_LIST, $mail_copies , "From: ".$_SESSION['config']['mail']."\nReply-To: ".$_SESSION['config']['mail']." \nContent-Type: text/html; charset=\"iso-8859-1\"\n")) { for ($z=0; $z