95 lines
No EOL
2.6 KiB
PHP
95 lines
No EOL
2.6 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: jedi
|
|
* Date: 12/27/18
|
|
* Time: 2:49 AM
|
|
*/
|
|
|
|
include "backend.php";
|
|
|
|
function auth(){
|
|
if(!isset($_SERVER['PHP_AUTH_USER']))
|
|
return false;
|
|
if(!isset($_SERVER['PHP_AUTH_PW']))
|
|
return false;
|
|
if($_SERVER['PHP_AUTH_USER']!="c3cloc")
|
|
return false;
|
|
if($_SERVER['PHP_AUTH_PW']!="findetalles")
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
function get_founditems($onlyUnmatched = false){
|
|
global $mysqli;
|
|
if ($onlyUnmatched) {
|
|
$res = $mysqli->query("SELECT items.* FROM items LEFT JOIN matches ON items.id = matches.l_id WHERE matches.l_id IS NOT NULL ORDER BY items.id ASC");
|
|
} else {
|
|
$res = $mysqli->query("SELECT * FROM items ORDER BY id ASC");
|
|
}
|
|
$ret = array();
|
|
while ($row = $res->fetch_assoc()) {
|
|
$ret[] = $row;
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
function get_lostitems($onlyUnmatched = false){
|
|
global $mysqli;
|
|
if ($onlyUnmatched) {
|
|
$res = $mysqli->query("SELECT lost.* FROM lost LEFT JOIN matches ON lost.id = matches.f_id WHERE matches.f_id IS NOT NULL ORDER BY lost.id ASC");
|
|
} else {
|
|
$res = $mysqli->query("SELECT * FROM lost ORDER BY id ASC");
|
|
}
|
|
$ret = array();
|
|
while ($row = $res->fetch_assoc()) {
|
|
$ret[] = $row;
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
function get_matches(){
|
|
global $mysqli;
|
|
$res = $mysqli->query("SELECT matches.id AS id, matches.f_id as f_id, matches.l_id as l_id, lost.was as l_desc, items.was as f_desc "
|
|
."FROM lost, items, matches WHERE lost.id = matches.l_id and items.id = matches.f_id ORDER BY matches.id ASC;");
|
|
$ret = array();
|
|
while ($row = $res->fetch_assoc()) {
|
|
$ret[] = $row;
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
function get_stats(){
|
|
global $mysqli;
|
|
$ret = array();
|
|
$ret["lost"]=0;
|
|
$ret["found"]=0;
|
|
$res = $mysqli->query("SELECT COUNT(*) AS c FROM lost ORDER BY id ASC");
|
|
if ($row = $res->fetch_assoc()) {
|
|
$ret["lost"] = $row["c"];
|
|
}
|
|
$res = $mysqli->query("SELECT COUNT(*) AS c FROM items ORDER BY id ASC");
|
|
if ($row = $res->fetch_assoc()) {
|
|
$ret["found"] = $row["c"];
|
|
}
|
|
$res = $mysqli->query("SELECT COUNT(*) AS c FROM matches ORDER BY id ASC");
|
|
if ($row = $res->fetch_assoc()) {
|
|
$ret["match"] = $row["c"];
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
if(file_exists("currentgithash"))
|
|
$hash = file_get_contents("currentgithash");
|
|
|
|
$page = isset($_GET["page"])?$_GET["page"]:"dashboard";
|
|
|
|
if (!auth()) {
|
|
header('WWW-Authenticate: Basic realm="C3CLOC"');
|
|
header('HTTP/1.0 401 Unauthorized');
|
|
include "templates/404.php";
|
|
exit;
|
|
} else {
|
|
include "templates/page.php";
|
|
}
|
|
?>
|