forked from vergnet/site-accueil-insa
Edited project for debug local use
This commit is contained in:
parent
248b9b4a94
commit
c56f82ffd6
8 changed files with 79 additions and 77 deletions
11
.htaccess
Normal file
11
.htaccess
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Turn mod_rewrite on
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
|
||||
# To externally redirect /dir/foo.php to /dir/foo
|
||||
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
|
||||
RewriteRule ^ %1 [R,L,NC]
|
||||
|
||||
## To internally redirect /dir/foo to /dir/foo.php
|
||||
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
|
||||
RewriteRule ^ %{REQUEST_URI}.php [L]
|
|
@ -1,45 +1,51 @@
|
|||
<?php
|
||||
|
||||
class Dao {
|
||||
class Dao
|
||||
{
|
||||
|
||||
private $conn;
|
||||
|
||||
private $debug = false;
|
||||
private $debug = true;
|
||||
|
||||
public function __construct($path_to_password)
|
||||
{
|
||||
if ($this->debug) {
|
||||
$username = 'phpmyadmin';
|
||||
$password = $this->read_password($path_to_password);
|
||||
$dsn = 'mysql:dbname=phpmyadmin;host=127.0.0.1';
|
||||
} else {
|
||||
$username = 'accueil_insa';
|
||||
$password = $this->read_password($path_to_password);
|
||||
$dsn = 'mysql:dbname=accueil_insa;host=127.0.0.1';
|
||||
}
|
||||
try {
|
||||
$this->conn = new PDO($dsn, $username, $password, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
|
||||
}
|
||||
catch (PDOException $e){
|
||||
$this->debug = true;
|
||||
} catch (PDOException $e) {
|
||||
echo $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function read_password($path_to_password){
|
||||
$file = fopen($path_to_password."includes/.htpassdb", "r") or die("Unable to open file!");;
|
||||
private function read_password($path_to_password)
|
||||
{
|
||||
if ($this->debug)
|
||||
$real_path = $path_to_password . "includes/.htpassdb_debug";
|
||||
else
|
||||
$real_path = $path_to_password . "includes/.htpassdb";
|
||||
$file = fopen($real_path, "r") or die("Unable to open file!");;
|
||||
$password = fgets($file);
|
||||
fclose($file);
|
||||
return $password;
|
||||
}
|
||||
|
||||
public function get_score_team($team){
|
||||
if (!$this->debug)
|
||||
public function get_score_team($team)
|
||||
{
|
||||
$sql = 'SELECT text, points FROM scores WHERE team = ?';
|
||||
$cursor = $this->conn->prepare($sql);
|
||||
$cursor->execute([$team]);
|
||||
return $cursor->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function save_scores($scores_json, $team){
|
||||
if (!$this->debug)
|
||||
public function save_scores($scores_json, $team)
|
||||
{
|
||||
$sql = 'DELETE FROM scores WHERE team = ?';
|
||||
$cursor = $this->conn->prepare($sql);
|
||||
|
@ -52,7 +58,6 @@ class Dao {
|
|||
$cursor->execute([$value->text, $value->points, $team]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
AuthName "Generals Only"
|
||||
AuthType Basic
|
||||
AuthUserFile /home_clubs/accueil_insa/public_html/includes/.htpassurss
|
||||
require valid-user
|
||||
#AuthName "Generals Only"
|
||||
#AuthType Basic
|
||||
#AuthUserFile /home_clubs/accueil_insa/public_html/includes/.htpassurss
|
||||
#require valid-user
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
AuthName "Generals Only"
|
||||
AuthType Basic
|
||||
AuthUserFile /home_clubs/accueil_insa/public_html/includes/.htpassusa
|
||||
require valid-user
|
||||
#AuthName "Generals Only"
|
||||
#AuthType Basic
|
||||
#AuthUserFile /home_clubs/accueil_insa/public_html/includes/.htpassusa
|
||||
#require valid-user
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
require_once 'classes/dao.php';
|
||||
function get_total_points($team)
|
||||
{
|
||||
// $dao = new Dao('');
|
||||
$dao = new Dao('');
|
||||
$points = 0;
|
||||
// foreach ($dao->get_score_team($team) as $row) {
|
||||
// $points += $row['points'];
|
||||
// }
|
||||
foreach ($dao->get_score_team($team) as $row) {
|
||||
$points += $row['points'];
|
||||
}
|
||||
return $points;
|
||||
}
|
||||
|
||||
|
|
13
sponsors.php
13
sponsors.php
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
ob_start(); // Start reading html
|
||||
?>
|
||||
<h1>Sponsors</h1>
|
||||
<p>
|
||||
Apparemment on a des sponsors.
|
||||
</p>
|
||||
|
||||
<?php
|
||||
$pageContent = ob_get_clean(); // Store html content in variable
|
||||
$pageTitle = "Info";
|
||||
include("template.php"); // Display template with variable content
|
||||
?>
|
30
stats.php
30
stats.php
|
@ -6,21 +6,21 @@ ob_start(); // Start reading html
|
|||
|
||||
function get_stats($team)
|
||||
{
|
||||
// $dao = new Dao('');
|
||||
// foreach ($dao->get_score_team($team) as $row) {
|
||||
// $text = $row['text'];
|
||||
// $points = $row['points'];
|
||||
// if ($points > 0)
|
||||
// $id = "positive";
|
||||
// else
|
||||
// $id = "negative";
|
||||
// ?>
|
||||
<!-- <tr id="--><?//= $id ?><!--">-->
|
||||
<!-- <td>--><?//= htmlspecialchars($text) ?><!--</td>-->
|
||||
<!-- <td>--><?//= $points ?><!--</td>-->
|
||||
<!-- </tr>-->
|
||||
<!-- --><?php
|
||||
// }
|
||||
$dao = new Dao('');
|
||||
foreach ($dao->get_score_team($team) as $row) {
|
||||
$text = $row['text'];
|
||||
$points = $row['points'];
|
||||
if ($points > 0)
|
||||
$id = "positive";
|
||||
else
|
||||
$id = "negative";
|
||||
?>
|
||||
<tr id="<?= $id ?>">
|
||||
<td><?= htmlspecialchars($text) ?></td>
|
||||
<td><?= $points ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -2,17 +2,16 @@
|
|||
require_once 'classes/dao.php';
|
||||
function get_total_points($team)
|
||||
{
|
||||
// $dao = new Dao('');
|
||||
$dao = new Dao('');
|
||||
$points = 0;
|
||||
// foreach ($dao->get_score_team($team) as $row) {
|
||||
// $points += $row['points'];
|
||||
// }
|
||||
foreach ($dao->get_score_team($team) as $row) {
|
||||
$points += $row['points'];
|
||||
}
|
||||
return $points;
|
||||
}
|
||||
|
||||
$scoreUSA = get_total_points('usa');
|
||||
$scoreURSS = get_total_points('urss');
|
||||
$pageMeta = "";
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
|
Loading…
Reference in a new issue