Source for file functions_auth.php
Documentation is available at functions_auth.php
* @author linea21 <info@linea21.com>
* @license http://opensource.org/licenses/gpl-3.0.html
* AuthenthificationProcess()
* Authentification d'un utilisateur
* @param $type ='PUBLIC' || 'ADMIN'
* @return boolean (true) ou message d'erreur
$crypt_pass = crypt($pass, SALT_CRYPT);
if ($data != 0 && count($data) == 1) {
for ($i = 0; $i < count($data_w); $i++ ) {
$workshop_list .= "/" . $data_w[$i]['jwu_workshop_id'];
$table['id'] = $data[0]['user_id'];
$table['login'] = $login;
// préparation du tableau de droits
$right['dashboard'] = $data[0]['rights_dashboard'];
$right['workshop'] = $data[0]['rights_workshop'];
$right['project'] = $data[0]['rights_project'];
$right['publication'] = $data[0]['rights_publication'];
$right['news'] = $data[0]['rights_news'];
$right['yellowpages'] = $data[0]['rights_yellowpages'];
$right['theme'] = $data[0]['rights_theme'];
$right['scale'] = $data[0]['rights_scale'];
$right['level'] = $data[0]['rights_level'];
$right['category_user'] = $data[0]['rights_category_user'];
// est simple utilisateur
return $GLOBALS['lang']['divers']['errorauth'];
// est utilisateur avec droits
$_SESSION['sess_is_known'] = true;
$_SESSION['sess_login'] = $login;
$_SESSION['sess_right'] = $right;
$error_msg = $GLOBALS['lang']['divers']['errorauth'];
for ($i = 0; $i < count($data); $i++ ) {
if ($id_workshop == $data[$i]['jwu_workshop_id']) $result = true;
* @param integer $workshop_id
* @param object $sql_object
for ($i = 0; $i < count($data); $i++ ) {
* @param string $item (id, whois, login, right)
return $_SESSION['sess_login'];
return $_SESSION['sess_right']['theme'];
return $_SESSION['sess_right']['dashboard'];
return $_SESSION['sess_right']['workshop'];
return $_SESSION['sess_right']['project'];
case 'right_publication':
return $_SESSION['sess_right']['publication'];
return $_SESSION['sess_right']['news'];
case 'right_yellowpages':
return $_SESSION['sess_right']['yellowpages'];
return $_SESSION['sess_right']['scale'];
return $_SESSION['sess_right']['level'];
case 'right_category_user':
return $_SESSION['sess_right']['category_user'];
* set les infos contenu en tableau PHP en cookie
while (list ($key, $value) = @each($table)) {
setcookie('linea21[' . $key . ']', $value, (time() + 3600 * 720), '/');
* Détruit les infos contenu en cookie
while (list ($key, $val) = @each($_COOKIE['linea21'])) {
* Mise à jour du mot de passe dans le cookie (cas de changement)
setcookie('linea21[whois]', $newpass, (time() + 3600 * 720), '/');
* Ajout d'un Groupe de travail aux droits d'un utiliateur
$string_id .= "/" . $workshop_id;
setcookie('linea21[workshop]', $string_id, (time() + 3600 * 720), '/');
* vérification de l'inscription de l'utilisateur au groupe de travail
if (isset ($_COOKIE['linea21']['workshop'])) {
$table_id = @explode('/', $string_id);
for ($i = 0; $i < count($table_id); $i++ ) {
if ($workshop_id == $table_id[$i])return true;
* Set_Cookie_last_connexion()
function LogAccess($type, $login = - 1, $pass = - 1)
if ($type == 'PUBLIC') $file = LOG_PUBLIC_ACCESS;
if ($type == 'ADMIN') $file = LOG_ADMIN_ACCESS;
$fp = @fopen($file, 'a');
@fwrite($fp, $_SERVER['HTTP_USER_AGENT'] . $sep); //agent
@fwrite($fp, $_SERVER['HTTP_REFERER'] . $sep); // referer
@fwrite($fp, $_SERVER['REQUEST_METHOD'] . $sep); // methode requetes HTTP
@fwrite($fp, $_SERVER['REQUEST_URI'] . $sep); // script courant
@fwrite($fp, $_SERVER['QUERY_STRING'] . $sep); // requete url
@fwrite($fp, $_SERVER['HTTP_COOKIE'] . $sep); // cookie
@fwrite($fp, date('[d-m-y H:i:s]' . $sep)); // date
if ($login != - 1) @fwrite($fp, $login . $sep); // login
if ($pass != - 1) @fwrite($fp, $pass . $sep); // mot de passe
// Returns the real IP address of the user
// No IP found (will be overwritten by for
// if any IP is found behind a firewall)
// If HTTP_CLIENT_IP is set, then give it priority
if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
$ip = $_SERVER["HTTP_CLIENT_IP"];
// User is behind a proxy and check that we discard RFC1918 IP addresses
// if they are behind a proxy then only figure out which IP belongs to the
// user. Might not need any more hackin if there is a squid reverse proxy
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
// Put the IP's into an array which we shall work with shortly.
$ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
for ($i = 0; $i < count($ips); $i++ ) {
// Skip RFC 1918 IP's 10.0.0.0/8, 172.16.0.0/12 and
// 192.168.0.0/16 -- jim kill me later with my regexp pattern
if (!eregi ("^(10|172\.16|192\.168)\.", $ips[$i])) {
// Return with the found IP or the remote address
return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
|