Commit d1edb807 authored by Gabriel Moreau's avatar Gabriel Moreau
Browse files

Better check DB version. Now it's robust

parent 96e37162
......@@ -7,23 +7,27 @@ require_once('module/auth-functions.php');
require_once('module/html-functions.php');
require_once('module/base-functions.php');
session_start();
if (empty($_SESSION['logged_user'])) {
$logged_level = 0;
} else {
$logged_id = $_SESSION['logged_id'];
$logged_user = strtolower($_SESSION['logged_user']);
$logged_level = $_SESSION['logged_level'];
}
// Authenticate
auth_or_login('index.php');
level_or_alert(4, 'Console Administrateur');
// session_start();
// if (empty($_SESSION['logged_user'])) {
// $logged_level = 0;
// } else {
// $logged_id = $_SESSION['logged_id'];
// $logged_user = strtolower($_SESSION['logged_user']);
// $logged_level = $_SESSION['logged_level'];
// }
en_tete('Console Administrateur');
if ($logged_level < 4) {
echo 'Permission denied !';
exit();
}
// if ($logged_level < 4) {
// echo 'Permission denied !';
// exit();
// }
$pdo = connect_db();
$pdo = connect_db_minimal();
?>
<div class="adm-panel-body">
......@@ -35,15 +39,17 @@ $pdo = connect_db();
<table class="version-item">
<tr>
<td>Version</td>
<td><a>v<?=$current_version["version"]?></a></td>
<td><?=$current_version['version']?></td>
</tr>
<tr>
<td>Updated on</td>
<td><a><?=$current_version["updated_on"]?></a></td>
<td><?php if (isset($current_version['updated_on'])) { echo $current_version['updated_on']; } ?></td>
</tr>
</table>
</div><?php
} ?>
Database version needed: <?= GESTEX_DB_VERSION ?>
</div>
<content>
<h3>Logs</h3>
......
......@@ -26,7 +26,7 @@ function auth($reqlevel, $logged_user='', $password='') {
return false;
}
$pdo = connect_db();
$pdo = connect_db_minimal();
$user = get_user_all_by_login($pdo, $logged_user);
// is the password correct
......
......@@ -33,7 +33,8 @@ function connect_db() {
$datasheet_version = get_version_by_name($pdo, 'database');
if ($datasheet_version < GESTEX_DB_VERSION) {
error_log('Database version error: update the database schema');
echo "Code en version ".GESTEX_DB_VERSION.", mettre à jour le schéma de la base de données qui est actuellement en version $datasheet_version.";
echo 'Erreur: code de gestion de la base de donnée en version '.GESTEX_DB_VERSION.',';
echo " mettre à jour le schéma de la base de données qui est actuellement en version $datasheet_version.";
return false;
}
}
......@@ -1378,7 +1379,7 @@ function get_version_by_name($pdo, $name) {
$stmt->execute(array($name));
$version_fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($version_fetch) > 0)
return $version_fetch[0];
return $version_fetch[0]['version'];
return false;
}
......
......@@ -38,7 +38,7 @@ define('ICON_INTERVENTION', '<span><svg width="1.2em" height="1.2em" fill="curr
// ---------------------------------------------------------------------
function en_tete($titre, $find=false) {
$pdo = connect_db();
$pdo = connect_db_minimal();
if (empty($_SESSION['logged_user']))
$logged_level = 0;
if (!empty($_SESSION)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment