Ejemplo n.º 1
0
function check_login()
{
    // If session does not exist on server side, or IP address has changed, or session has expired, show login screen.
    if (!isset($_SESSION['uid']) || !$_SESSION['uid'] || time() >= $_SESSION['expires_on']) {
        logout();
    }
    $_SESSION['expires_on'] = time() + INACTIVITY_TIMEOUT;
    // User accessed a page : Update his/her session expiration date.
    $numero_ID = $_SESSION['numero_abo'];
    if ($_SESSION['username'] != 'beprev') {
        $today = new DateTime('now');
        $horodate = date_format($today, 'Y-m-d H:i:s');
        $req = 'SELECT MAX("ID") from user_log;';
        $result = sypel_query($req);
        $table = sypel_fetch_row($result);
        $Id = $table[0];
        if (strlen($Id) == 0) {
            $Id = 0;
        }
        $Id = $Id + 1;
        $page = $_SESSION["ipFrontOffice"] . $_SERVER['PHP_SELF'];
        $req = "INSERT INTO user_log (\"ID\", id_user,page,horodate) VALUES ('{$Id}','{$numero_ID}','{$page}','{$horodate}');";
        $result = sypel_query($req);
    }
}
# REQUETES
//$dbconn = pg_connect(CONFIG_DB) or die('Connexion impossible : ' . pg_last_error());
# GRAPHE Semaine Type
$req = 'SELECT table1."NODE_Y"+table2."NODE_Y" as weekpower FROM 
(
SELECT "NODE_X" as jour, "INSTANT", "NODE_Y" FROM mot_springbok_model_point WHERE "ID" = 
(select "ID" from mot_springbok_model_ref where "ID_plic" = ' . $idplic . ' order by date_calib desc limit 1)
AND "NUM_VAR" = 1
) as table1,
(
SELECT "INSTANT", "NODE_Y" FROM mot_springbok_model_point WHERE "ID" = 
(select "ID" from mot_springbok_model_ref where "ID_plic" = ' . $idplic . ' order by date_calib desc limit 1)
AND "NUM_VAR" = 4 
) as table2
WHERE table1."INSTANT" = table2."INSTANT" ORDER BY table1."jour", table1."INSTANT"';
$result = sypel_query($req);
// or die('Échec de la requête : ' . pg_last_error());
$data_semaine_type = array();
$i = 0;
while ($ligne = pg_fetch_row($result)) {
    #print_r($i." : ".$ligne[0]."\n");
    $data_semaine_type[$i] = round($ligne[0]);
    //print_r($ligne);
    $i = $i + 1;
}
?>