* Date de derniere modification : ___________
* @version ___________
* @author ___________
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
* @copyright CNRS (c) 2010
LPC Clermont-Ferrand UMR6533
* 24 Av des Landais
Aubière
* @package phpMyLab
*/
/*********************************************************************************
****************************** PLAN *****************************************
*********************************************************************************/
// | -A- Gestion de la deconnexion
// | -B- Fonctione
// | -C- Initialisation generale (configuration et php)
// | -D- Initialisation Session et variables
// | -E- Gestion des variables Recherche
// | -F- Gestion des variables du module
// | -G- Choix du module
// | -H- HTML
/*********************************************************************************
*********************** -A- Gestion de la deconnexion ***************************
**********************************************************************************/
if (isset($_REQUEST[ 'disconnect' ]) && file_exists("CAS/config_cas.php"))
{
//On détruit la session
session_regenerate_id();
session_unset();
session_destroy ( );
$_SESSION[ 'connection' ][ 'utilisateur' ] = '';
$_SESSION[ 'connection' ][ 'nom' ] = '';
$_SESSION[ 'connection' ][ 'prenom' ] = '';
$_SESSION[ 'connection' ][ 'mot_de_passe' ] = '';
$_SESSION[ 'connection' ][ 'mot_de_passe_new1' ] = '';
$_SESSION[ 'connection' ][ 'mot_de_passe_new2' ] = '';
$_SESSION[ 'connection' ][ 'ss' ] = '';
$_SESSION[ 'connection' ][ 'mel' ] = '';
$_SESSION[ 'connection' ][ 'groupe' ] = '';
$_SESSION[ 'connection' ][ 'status' ] = 0;
// Load the CAS lib
require_once 'CAS/CAS.php';
require_once 'CAS/config_cas.php';
// Uncomment to enable debugging
phpCAS::setDebug();
// Initialize phpCAS
phpCAS::client(CAS_VERSION_2_0,$cas_host,$cas_port,$cas_context,false);
// For quick testing you can disable SSL validation of the CAS server.
// THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION.
// VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL!
phpCAS::setNoCasServerValidation();
//session_start();
if(phpCAS::isAuthenticated())
{
include_once('CAS/config_cas.php');
phpCAS::logoutWithRedirectService($url_reception);
}
else
{
$self=$_SERVER[ 'PHP_SELF' ];
$chemin_module=substr($self,0,-strlen(strrchr($self,"/")));
$chemin_module.='/reception.php';
header('location:'.$chemin_module);
}
}
/*********************************************************************************
*********************** -B- Fonctions *******************************************
**********************************************************************************/
/**
* Envoyer un mail.
*
* Formate le message à envoyer de manière à etre compatible avec la majorité des clients de messagerie et envoie le message au moyen de la fonction mail().
* @param string Adresse mail du destinataire
* @param string Message
* @param string Objet du mail.
* @param string Adresse mail de l'envoyeur
* @param string Nom de l'envoyeur
* @param bool Avec ou sans fichier attaché
* @return Retourne le résultat de la fonction mail()
*/
function send_mail($to, $body, $subject, $fromaddress, $fromname, $attachments=false)
{
$eol="\r\n";
$mime_boundary=md5(time());
# Common Headers
$headers = "From: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol; // these two to set reply address
$headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters
# Boundry for marking the split & Multitype Headers
// $headers .= 'MIME-Version: 1.0'.$eol.$eol;
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"".$eol.$eol;
# Open the first part of the mail
$msg = "--".$mime_boundary.$eol;
$htmlalt_mime_boundary = $mime_boundary."_htmlalt"; //we must define a different MIME boundary for this section
# Setup for text OR html -
$msg .= "Content-Type: multipart/alternative; boundary=\"".$htmlalt_mime_boundary."\"".$eol.$eol;
# Text Version
$msg .= "--".$htmlalt_mime_boundary.$eol;
$msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$msg .= strip_tags(str_replace("
", "\n", substr($body, (strpos($body, "
")+6)))).$eol.$eol;
# HTML Version
$msg .= "--".$htmlalt_mime_boundary.$eol;
$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$msg .= $body.$eol.$eol;
//close the html/plain text alternate portion
$msg .= "--".$htmlalt_mime_boundary."--".$eol.$eol;
if ($attachments !== false)
{
for($i=0; $i < count($attachments); $i++)
{
if (is_file($attachments[$i]["file"]))
{
# File for Attachment
$file_name = substr($attachments[$i]["file"], (strrpos($attachments[$i]["file"], "/")+1));
$handle=fopen($attachments[$i]["file"], 'rb');
$f_contents=fread($handle, filesize($attachments[$i]["file"]));
$f_contents=chunk_split(base64_encode($f_contents)); //Encode The Data For Transition using base64_encode();
$f_type=filetype($attachments[$i]["file"]);
fclose($handle);
# Attachment
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: ".$attachments[$i]["content_type"]."; name=\"".$file_name."\"".$eol; // sometimes i have to send MS Word, use 'msword' instead of 'pdf'
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Description: ".$file_name.$eol;
$msg .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
$msg .= $f_contents.$eol.$eol;
}
}
}
# Finished
$msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two eol's for better security. see Injection.
# SEND THE EMAIL
ini_set('sendmail_from',$fromaddress); // the INI lines are to force the From Address to be used !
// $mail_sent = mail($to, $subject, $msg, $headers);
$mail_sent = mail($to, utf8_decode($subject), $msg, $headers);
ini_restore('sendmail_from');
return $mail_sent;
}
/**********************************************************************************
*************** -C- Initialisation generale (configuration et php) ****************
**********************************************************************************/
/**
**/
include 'config.php';
// Fix magic_quotes_gpc garbage
if (get_magic_quotes_gpc())
{
function stripslashes_deep($value)
{ return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value));}
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
// To allow multiple independent portail sessions,
// propagate session ID in the URL instead of a cookie.
ini_set('session.use_cookies', '0');
// We'll add the session ID to URLs ourselves - disable trans_sid
ini_set('url_rewriter.tags', '');
// Rather dumb character set detection:
// Try switching to UTF-8 automagically on stuff like "NLS_LANG=american_america.UTF8"
$charset = 'ISO-8859-1';
if (getenv('NLS_LANG'))
if (strtoupper(substr(getenv('NLS_LANG'), -5)) == '.UTF8')
$charset = 'UTF-8';
//les dates en francais:
setlocale(LC_TIME, "fr_FR");
/*********************************************************************************
************************** -D- Initialisation Session et variables **************
**********************************************************************************/
// Initialize session ID
$sid = '';
if (isset($_REQUEST[ 'sid' ])) $sid = substr(trim(preg_replace('/[^a-f0-9]/', '', $_REQUEST[ 'sid' ])), 0, 13);
if ($sid == '') $sid = uniqid('');
// Start PHP session
session_id($sid);
session_name('phpmylab');//conge?
session_start();
if ($_SESSION[ 'connection' ][ 'utilisateur' ] == '')
{
$self=$_SERVER[ 'PHP_SELF' ];
$chemin_module=substr($self,0,-strlen(strrchr($self,"/")));
$chemin_module.='/reception.php';
header('location:'.$chemin_module);
}
if (isset($_REQUEST[ 'disconnect' ]))
{
session_regenerate_id();
session_unset();
session_destroy ( );
$_SESSION[ 'connection' ][ 'utilisateur' ] = '';
$_SESSION[ 'connection' ][ 'nom' ] = '';
$_SESSION[ 'connection' ][ 'prenom' ] = '';
$_SESSION[ 'connection' ][ 'mot_de_passe' ] = '';
$_SESSION[ 'connection' ][ 'mot_de_passe_new1' ] = '';
$_SESSION[ 'connection' ][ 'mot_de_passe_new2' ] = '';
$_SESSION[ 'connection' ][ 'ss' ] = '';
$_SESSION[ 'connection' ][ 'mel' ] = '';
$_SESSION[ 'connection' ][ 'groupe' ] = '';
$_SESSION[ 'connection' ][ 'status' ] = 0;
$_SESSION[ 'connection' ][ 'admin' ] = 0;
$self=$_SERVER[ 'PHP_SELF' ];
$chemin_module=substr($self,0,-strlen(strrchr($self,"/")));
$chemin_module.='/reception.php';
header('location:'.$chemin_module);
}
/*********************************************************************************
******************** -E- Gestion des variables Recherche ************************
**********************************************************************************/
//A remplir si vous disposez d'une fonctionnalité de recherche
/*********************************************************************************
******************** -F- Gestion des variables de module ***********************
**********************************************************************************/
//Gestion des variables de session relatives à l'utilisation du module
/*********************************************************************************
*********************** G - Choix du module *************************************
**********************************************************************************/
if (! isset($_SESSION[ 'choix_module' ])) $_SESSION[ 'choix_module' ] = $modules[0];
if (isset($_GET["dec"])) $_SESSION[ 'choix_module' ]="CONGES";
if (isset($_REQUEST[ 'choix_module' ]))
{
$_SESSION[ 'choix_module' ] = $_REQUEST[ 'choix_module' ];
for ($i=0;$i