mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-01-05 23:42:21 +00:00
Compteur de vues (n'inclut pas les vues des administrateurs)
This commit is contained in:
parent
3e2690d819
commit
0b7e5c5e10
@ -40,6 +40,7 @@ class Config
|
||||
private $start_phase4_date;
|
||||
private $end_phase4_date;
|
||||
private $index_page;
|
||||
private $views;
|
||||
|
||||
public function initDB()
|
||||
{
|
||||
@ -58,7 +59,8 @@ class Config
|
||||
('end_phase3_date_$YEAR', CURRENT_TIMESTAMP + INTERVAL 7 DAY),
|
||||
('start_phase4_date_$YEAR', CURRENT_TIMESTAMP + INTERVAL 8 DAY),
|
||||
('end_phase4_date_$YEAR', CURRENT_TIMESTAMP + INTERVAL 9 DAY),
|
||||
('index_page_$YEAR', ?);")->execute([$index_template_page]);
|
||||
('index_page_$YEAR', ?),
|
||||
('views_$YEAR', 0);")->execute([$index_template_page]);
|
||||
}
|
||||
|
||||
public function loadConfigValues()
|
||||
@ -202,6 +204,22 @@ class Config
|
||||
|
||||
$this->index_page = $index_page;
|
||||
}
|
||||
|
||||
public function getViews()
|
||||
{
|
||||
return $this->views;
|
||||
}
|
||||
|
||||
public function incrViews()
|
||||
{
|
||||
global $DB, $YEAR;
|
||||
|
||||
if (isset($_SESSION["user_id"]) && $_SESSION["role"] == Role::ADMIN)
|
||||
return;
|
||||
|
||||
$DB->exec("UPDATE `config` SET `value` = " . ($this->views + 1) . " WHERE `key` = 'views_$YEAR';");
|
||||
$this->views++;
|
||||
}
|
||||
}
|
||||
|
||||
session_start();
|
||||
|
@ -1,3 +1,5 @@
|
||||
<?php $CONFIG->incrViews() ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
|
Loading…
Reference in New Issue
Block a user