New router and associated pages
This commit is contained in:
parent
68dcb996c9
commit
bed471d75a
129
htdocs/index.php
129
htdocs/index.php
@ -2,112 +2,107 @@
|
||||
//Inclusion de l'API Onyx
|
||||
require_once(trim(file_get_contents('./.onyx')));
|
||||
|
||||
define("SALT_USER", "connected");
|
||||
define("SALT_ADMIN", "admin");
|
||||
|
||||
//On active le débogage si l'on est sur le domaine de debug
|
||||
if ($_SERVER["SERVER_NAME"] == "localhost" || $_SERVER["SERVER_NAME"] == "fic" || $_SERVER["SERVER_NAME"] == "atlantis.chen.li")
|
||||
define("DEBUG", true);
|
||||
|
||||
//Chargement de tout le nécessaire pour le site
|
||||
require_once("common.php");
|
||||
//require_once("common.php");
|
||||
|
||||
$p = strtolower(gpc("p"));
|
||||
$n = preg_match_all("#[^/]+#", strtolower(gpc("p")), $out);
|
||||
$p = $out[0];
|
||||
|
||||
if (empty($page) && $SESS->level > 0)
|
||||
// Admin part
|
||||
if ($p[0] == SALT_ADMIN)
|
||||
{
|
||||
if ($SESS->level > 1)
|
||||
if ($n <= 1)
|
||||
$page = require("admin/home.php");
|
||||
else
|
||||
{
|
||||
switch($p)
|
||||
switch($p[1])
|
||||
{
|
||||
case "exercices/import/":
|
||||
case "exercices/import":
|
||||
include("admin/import_exercices.php");
|
||||
$page = require("admin/import_exercices.php");
|
||||
break;
|
||||
|
||||
case "users":
|
||||
case "users/":
|
||||
include("admin/list_users.php");
|
||||
$page = require("admin/list_users.php");
|
||||
break;
|
||||
|
||||
case "users/import":
|
||||
case "users/import/":
|
||||
include("admin/import_users.php");
|
||||
$page = require("admin/import_users.php");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch($p)
|
||||
{
|
||||
case "":
|
||||
$_GET["p"] = "";
|
||||
case "accueil":
|
||||
include("users/accueil.php");
|
||||
break;
|
||||
|
||||
case "disconnect":
|
||||
include("public/login.php");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($page)) // Public pages
|
||||
// Known users
|
||||
else if ($p[0] == SALT_USER)
|
||||
{
|
||||
switch($p)
|
||||
$connected = true;
|
||||
|
||||
if ($n <= 1)
|
||||
$page = require("team/home.php");
|
||||
else
|
||||
{
|
||||
case "":
|
||||
$_GET["p"] = "";
|
||||
case "home":
|
||||
include("public/home.php");
|
||||
$TEAM = $p[1];
|
||||
|
||||
if ($n <= 2)
|
||||
$page = require("team/team.php");
|
||||
else
|
||||
{
|
||||
switch($p[2])
|
||||
{
|
||||
case "change/":
|
||||
case "change":
|
||||
$page = require("team/change.php");
|
||||
break;
|
||||
|
||||
case "login":
|
||||
include("public/login.php");
|
||||
case "summary":
|
||||
case "summary/":
|
||||
$page = require("team/summary.php");
|
||||
break;
|
||||
}
|
||||
|
||||
case "score":
|
||||
include("public/score.php");
|
||||
break;
|
||||
// SALT/$team/$theme
|
||||
if (empty($page))
|
||||
{
|
||||
$THEME = $p[2];
|
||||
|
||||
case "403":
|
||||
$template->assign("err", 403);
|
||||
$page = "404";
|
||||
break;
|
||||
case "404":
|
||||
$template->assign("err", 404);
|
||||
$page = "404";
|
||||
break;
|
||||
case "5mail":
|
||||
include("mail.php");
|
||||
exit;
|
||||
case "500":
|
||||
$template->assign("err", 500);
|
||||
$page = "404";
|
||||
break;
|
||||
if ($n == 4)
|
||||
{
|
||||
$EXERCICE = $p[3];
|
||||
$page = require("team/exercice.php");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Public part
|
||||
else
|
||||
{
|
||||
if ($n == 0)
|
||||
$page = require("public/home.php");
|
||||
else if ($n == 1)
|
||||
{
|
||||
$TEAM = $p[0];
|
||||
|
||||
$page = require("public/team.php");
|
||||
}
|
||||
}
|
||||
|
||||
// No page here...?
|
||||
if (empty($page))
|
||||
{
|
||||
$template->assign("err", 404);
|
||||
$template->display("404.tpl");
|
||||
}
|
||||
else
|
||||
{
|
||||
$ALERTS = array();
|
||||
$nbAlert = @count($SESS->values["alerts"]);
|
||||
if ($nbAlert > 0)
|
||||
{
|
||||
for ($i = 0; $i < $nbAlert; $i++)
|
||||
{
|
||||
if ($SESS->values["alerts"][$i]->page == $page)
|
||||
{
|
||||
$ALERTS[] = $SESS->values["alerts"][$i];
|
||||
unset($SESS->values["alerts"][$i]);
|
||||
$i--; $nbAlert--;
|
||||
$SESS->values["alerts"] = array_values($SESS->values["alerts"]);
|
||||
}
|
||||
}
|
||||
$SESS->put();
|
||||
}
|
||||
$template->assign("ALERTS", $ALERTS);
|
||||
|
||||
$template->display($page.".tpl");
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
listen [::]:80 ipv6only=on;
|
||||
server_name fic fic.p0m.fr fic.nemunai.re;
|
||||
|
||||
access_log /var/log/nginx/fic.access_log;
|
||||
|
@ -38,16 +38,6 @@
|
||||
<option name="no_connection"><![CDATA[Connexion à la base de donnée impossible]]></option>
|
||||
</module>
|
||||
|
||||
<module name="session">
|
||||
<option name="active">1</option>
|
||||
<option name="time">3600</option>
|
||||
<option name="maxip">20</option>
|
||||
<option name="cookie">jdlsession</option>
|
||||
<option name="db">
|
||||
<option name="table">sessions</option>
|
||||
</option>
|
||||
</module>
|
||||
|
||||
<module name="lang" />
|
||||
|
||||
<module name="bbcode" />
|
||||
@ -55,7 +45,5 @@
|
||||
<module name="templates">
|
||||
<option name="tpl">bootstrap</option>
|
||||
</module>
|
||||
|
||||
<module name="captcha" />
|
||||
</config>
|
||||
</configs>
|
||||
|
@ -7,26 +7,13 @@ if (empty($sess->values["connected"]) && !defined("xCSRF"))
|
||||
require_once("functions.php"); //Inclusion des principales fonctions
|
||||
|
||||
require_once("common/Exercice.class.php");
|
||||
require_once("common/Team.class.php");
|
||||
require_once("common/Theme.class.php");
|
||||
require_once("common/User.class.php");
|
||||
|
||||
//On charge la session
|
||||
$SESS = new Session();
|
||||
|
||||
$template = new Template();
|
||||
|
||||
$template->assign("ERRmessage", false);
|
||||
$template->assign("auth_lvl", $SESS->level);
|
||||
$template->assign("SESS", $SESS->values);
|
||||
$template->assign("END", $VAR['end_challenge'] - time());
|
||||
|
||||
if (!empty($LANG))
|
||||
$template->assign("LANG", $LANG);
|
||||
|
||||
//Evite les attaques CSRF
|
||||
if ($SESS->level > 2 && !empty($_SERVER["HTTP_REFERER"]) && !(preg_match('#^http://'.$_SERVER['HTTP_HOST'].'#', $_SERVER["HTTP_REFERER"]) && defined("xCSRF")))
|
||||
{
|
||||
elog("Possibilité d'attaque CSRF\n".var_export($_REQUEST, TRUE), 2);
|
||||
unset($_POST, $_GET);
|
||||
$_GET = $_POST = array();
|
||||
}
|
||||
|
@ -2,16 +2,7 @@
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
$t = Team::get_teams();
|
||||
foreach ($t as $tt){
|
||||
var_dump ($tt->get_username());
|
||||
}
|
||||
$template->assign("teams", Team::get_teams());
|
||||
$template->assign("top", Team::get_top());
|
||||
|
||||
if ($SESS->level < 1)
|
||||
{
|
||||
$page = "public/home";
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = "users/home";
|
||||
}
|
||||
return "public/home";
|
||||
|
16
onyx/include/public/team.php
Normal file
16
onyx/include/public/team.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
try
|
||||
{
|
||||
$team = new Team($TEAM);
|
||||
|
||||
$template->assign("team", $team);
|
||||
|
||||
return "public/team";
|
||||
}
|
||||
catch($e)
|
||||
{
|
||||
return "404";
|
||||
}
|
6
onyx/include/team/change.php
Normal file
6
onyx/include/team/change.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
|
||||
return "team/change";
|
6
onyx/include/team/exercice.php
Normal file
6
onyx/include/team/exercice.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
|
||||
return "team/exercice";
|
8
onyx/include/team/home.php
Normal file
8
onyx/include/team/home.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
$template->assign("teams", Team::get_teams());
|
||||
$template->assign("top", Team::get_top());
|
||||
|
||||
return "users/home";
|
6
onyx/include/team/summary.php
Normal file
6
onyx/include/team/summary.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
|
||||
return "team/summary";
|
16
onyx/include/team/team.php
Normal file
16
onyx/include/team/team.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
try
|
||||
{
|
||||
$team = new Team($TEAM);
|
||||
|
||||
$template->assign("team", $team);
|
||||
|
||||
return "team/team";
|
||||
}
|
||||
catch($e)
|
||||
{
|
||||
return "404";
|
||||
}
|
Loading…
Reference in New Issue
Block a user