.htpassdb + tentative map

This commit is contained in:
Baptiste Rebillard 2022-01-21 02:50:15 +01:00
parent 3903101311
commit a16f693a1a
3 changed files with 52 additions and 3 deletions

View file

@ -4,6 +4,45 @@
}
</style>
<script type="text/javascript" src="assets/map/map.js"></script>
<?php
function get_map_info($selector)
{
$sql = 'SELECT title, description FROM map_insa WHERE selector = ?';
$cursor = $this->conn->prepare($sql);
$cursor->execute([$selector]);
return $cursor->fetchAll(PDO::FETCH_ASSOC);
}
function get_map_selectors()
{
$sql = 'SELECT selector FROM map_insa';
$cursor = $this->conn->prepare($sql);
$cursor->execute();
return $cursor->fetchAll(PDO::FETCH_ASSOC);
}
function save_map_info($selector, $info_json)
{
$sql = 'DELETE FROM map_insa WHERE selector = ?';
$cursor = $this->conn->prepare($sql);
$cursor->execute([$selector]);
$sql = 'INSERT INTO map_insa (title, description, selector) VALUES (?, ?, ?)';
$cursor = $this->conn->prepare($sql);
$cursor->execute([$info_json['title'], $info_json['description'], $selector]);
}
function is_in_map($selector) {
$sql = 'SELECT selector FROM map_insa WHERE selector = ?';
$query = $this->conn->prepare($sql);
$query->execute([$selector]);
return $query->fetchAll(PDO::FETCH_ASSOC);
}
?>
<div id="maps_button">
<button onclick="enable3DMap()" class="main-button">Map 3D</button>
<button onclick="enable2DMap()" class="main-button">Map 2D</button>
@ -39,6 +78,4 @@ function enable2DMap() {
map3d.classList.add("hidden");
map.classList.remove("hidden");
}
</script>
<script type='text/javascript' src='map.js'></script>
</script>

0
script/.htpassdb Normal file
View file

View file

@ -0,0 +1,12 @@
<?php
function read_password()
{
$real_path = __DIR__.DIRECTORY_SEPARATOR.".htpassdb";
$file = fopen($real_path, "r") or die("Unable to open DB password file!");;
$password = fgets($file);
fclose($file);
return trim($password);
}
$db = new PDO('mysql:host=127.0.0.1;dbname=accueil_insa','root', read_password());
?>