public function execSqlRequest() { $result = gquery($this->getSqlRequest()); // or die('Échec de la requête : ' . pg_last_error()); $data = array(); $i = 0; while ($ligne = pg_fetch_array($result, NULL, PGSQL_ASSOC)) { $data[$i] = $ligne; $i = $i + 1; } if ($this->result_transpose == 1) { $data = $this->flipDiagonally($data); } return $data; }
public function execSqlRequest() { $result = gquery($this->getSqlRequest()); // or die('Échec de la requête : ' . pg_last_error()); $data = array(); $i = 0; while ($ligne = mysql_fetch_array($result, MYSQL_ASSOC)) { $data[$i] = $ligne; foreach ($data[$i] as &$a) { $a = $this->ascii_to_entities($a); } $i = $i + 1; } return $data; }
/** * Check authentification via token * * @return boolean */ protected function verify_auth_token() { if (array_key_exists('token', $this->app->request()->params())) { $token = $this->app->request()->params('token'); $nb_seconds_last = 3600 * 3; # VERIFICATION token dans la table web_user_token (et retour id_user) $req = 'SELECT id_user FROM web_user_token WHERE token = \'' . $token . '\' AND EXTRACT(EPOCH FROM (now() - date_creation)) <= ' . $nb_seconds_last . ' ORDER BY date_creation DESC LIMIT 1;'; $result = gquery($req); $id_user = -1; # INIT while ($ligne = pg_fetch_row($result)) { $id_user = $ligne[0]; } # ACTION SUITE A VERIFICATION DU TOKEN (KO or OK) if ($id_user == -1) { return false; } else { return true; } } return false; }
$date_choisie = $_GET["date"]; $date_fin = date("Y-m-d", mktime(0, 0, 0, substr($date_choisie, 3, 2), substr($date_choisie, 0, 2), substr($date_choisie, 6, 4))); } else { $date_choisie = date("d/m/Y", strtotime("now")); $date_fin = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y"))); } /* LANCEMENT DES REQUETES */ $req_panier_region = getReq_panier_region(); //echo "REQ_PANIER :".$req_panier_region."<br><br>"; $result_panier_region = gquery($req_panier_region); $req_nebu = getReq_nebu($date_fin); //echo "REQ_NEBU :".$req_nebu."<br><br>"; $result_panier_region_nebu = gquery($req_nebu); $req_minmax = getReq_minmax($date_fin); //echo "REQ_MINMAX :".$req_minmax."<br><br>"; $result_minmax = gquery($req_minmax); ?> <?php $stationParDefaut = "met_p6.php?&station=156&date=" . $date_choisie; ?> <table width=320 border=0> <tr> <td> <svg width="320px" height="320px" style="background:#FFFFFF" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink= "http://www.w3.org/1999/xlink"> <image xlink:href="pics/widget_meteo/widget_map_france.png" x="0" y="0" height="320px" width="320px"/> <?php $infoRegion = array(); for ($n = 0; $n <= 17; $n++) {
// ENDPOINT /AUTH $app->get('/auth', function () use($app) { echo 'ee'; if (array_key_exists('login', $app->request()->params()) && array_key_exists('password', $app->request()->params())) { $login = $app->request()->params('login'); $password = $app->request()->params('password'); # TRAITMENT AVEC PARAMETRES (presence utilisateur) $req = 'SELECT "ID" FROM web_user_list WHERE ("NNI"=\'' . $login . '\' or login=\'' . $login . '\') AND password=\'' . $password . '\' LIMIT 1;'; $id_user = -1; $result = gquery($req); while ($ligne = pg_fetch_row($result)) { $id_user = $ligne[0]; } # ACTION SUITE A VERIFICATION DE L AUTHENTIFICATION if ($id_user == -1) { # ERREUR LOGIN et/ou MOT DE PASSE $app->render(400, array('error' => true, 'msg' => 'Login et/ou mot de passe chiffré incorrect')); } else { # CREATION ET STOCKAGE DU TOKEN $today = new DateTime('now'); $horodate = date_format($today, 'Y-m-d H:i:s'); $token = '__' . bin2hex(openssl_random_pseudo_bytes(25, $cstrong)) . '__'; $req = 'INSERT INTO web_user_token (id_user, token, date_creation) VALUES (' . $id_user . ',\'' . $token . '\',\'' . $horodate . '\');'; # echo $req; $result = gquery($req); $app->render(200, array('error' => true, 'msg' => 'Création du token d\'authentification', 'token' => $token)); } } else { $app->render(400, array('error' => true, 'msg' => 'Veuillez fournir un login et le mot de passe chiffré')); } });
function check_auth($login, $password) { $validation = 0; // Verification en BdD $req = 'SELECT count("ID") FROM user_list WHERE login=\'' . $login . '\' AND password=\'' . md5($password) . '\';'; $result = gquery($req); $table = pg_fetch_row($result); $validation = $table[0]; $req = 'SELECT "ID" FROM user_list WHERE login=\'' . $login . '\' AND password=\'' . md5($password) . '\';'; $result = gquery($req); $table = pg_fetch_row($result); $_SESSION['numero_abo'] = $table[0]; $_SESSION['typeBDD'] = "p"; // VERIF if ($validation == 1) { $_SESSION['uid'] = sha1(uniqid('', true) . '_' . mt_rand()); // generate unique random number (different than phpsessionid) // which can be used to hmac forms and form token (to prevent XSRF) $_SESSION['username'] = $login; $_SESSION['expires_on'] = time() + INACTIVITY_TIMEOUT; // Set session expiration. return True; } else { return False; } }
function generate_csv($req, $entete) { // $dbconn = pg_connect(CONFIG_DB) or die('Connexion impossible : ' . pg_last_error()); $result = gquery($req); // pg_query($req) or die('Échec de la requête : ' . pg_last_error()); $data = array(); $i = 0; while ($ligne = pg_fetch_array($result, NULL, PGSQL_NUM)) { $data[$i] = $ligne; foreach ($data[$i] as &$a) { $a = ascii_to_entities($a); } $i = $i + 1; } //$data = flipDiagonally($data); //pg_close($dbconn); header('Content-Encoding: UTF-8'); header("Content-type: text/csv; charset=UTF-8"); header("Content-Disposition: attachment; filename=file.csv"); header("Pragma: no-cache"); header("Expires: 0"); $content = json_encode($data, JSON_NUMERIC_CHECK); $content = str_replace('],[', "\n", $content); $content = str_replace(',', ';', $content); $content = str_replace('[', '', $content); $content = str_replace(']', '', $content); echo html_entity_decode(ascii_to_entities($entete)) . "\n" . html_entity_decode($content); }
public function execSqlRequest() { $result = gquery($this->getSqlRequest()); // or die('Échec de la requête : ' . pg_last_error()); return $true; }