--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2006 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+class PLModule
+{
+ var $platal;
+
+ function PLModule(&$platal)
+ {
+ $this->platal =& $platal;
+ }
+
+ function handlers() { die("implement me"); }
+ function menu_entries() { die("implement me"); }
+
+ function make_hook($fun, $auth, $perms, $type = SKINNED)
+ {
+ return array('hook' => array($this, $fun),
+ 'auth' => $auth,
+ 'perms' => split('[ ,|]', $perms),
+ 'type' => $type);
+ }
+
+ /* static functions */
+
+ function factory(&$platal, $modname)
+ {
+ $mod_path = dirname(__FILE__).'/../modules/'.strtolower($modname).'.php';
+ $class = ucfirst($modname).'Module';
+
+ require_once $mod_path;
+ return new $class($site);
+ }
+}
+
+?>
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2006 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+define('PL_OK', 0);
+define('PL_NEEDLOGIN', 1);
+define('PL_FORBIDDEN', 403);
+define('PL_NOT_FOUND', 404);
+
+class Platal
+{
+ var $__mods;
+ var $__hooks;
+
+ var $path;
+ var $menu;
+ var $auth;
+
+ function Platal()
+ {
+ $this->path = Get::_get('p', null);
+
+ $this->__mods = array();
+ $this->__hooks = array();
+ $this->menu = array();
+
+ foreach (glob(dirname(__FILE__).'/../modules/*.php') as $module) {
+ $module = basename($module, '.php');
+ $m =& PLModule::factory($this, $module);
+ $this->__mods[$module] =& $m;
+ $this->__hooks += $m->handlers();
+ $this->menu = array_merge($this->menu, $m->menu_entries());
+ }
+
+ krsort($this->__hooks);
+ usort($this->menu, array($this, '_menu_cmp'));
+ }
+
+ function load_class($cls)
+ {
+ require_once dirname(__FILE__).'/../classes/'.$cls.'.php';
+ }
+
+ function _menu_cmp($a, $b)
+ {
+ return strcasecmp($a['path'], $b['path']);
+ }
+
+ function call_hook(&$page)
+ {
+ $p = $this->path;
+
+ while ($path) {
+ if (array_key_exists($p, $this->__hooks))
+ break;
+
+ $p = substr($p, 0, strrpos($p, '/'));
+ }
+ if (empty($this->__hooks[$p])) {
+ return PL_NOT_FOUND;
+ }
+
+ $args = array_merge(array(&$page),
+ explode('/', substr($this->path, strlen($p) + 1)));
+
+ $hook = $this->__hooks[$p];
+ if ($hook['auth'] > Session::get('auth', AUTH_PUBLIC)) {
+ $_SESSION['session']->doAuth($page);
+ }
+ return call_user_func_array($hook['hook'], $args);
+ }
+
+ function run()
+ {
+ global $page;
+
+ new_skinned_page('index.tpl', AUTH_PUBLIC);
+
+ if (empty($this->path)) {
+ $page->run();
+ }
+
+ switch ($this->call_hook($page)) {
+ case PL_FORBIDDEN:
+ $this->__mods['core']->handler_403($page);
+ break;
+
+ case PL_NOT_FOUND:
+ $this->__mods['core']->handler_404($page);
+ break;
+ }
+ $page->run();
+ }
+}
+
+?>
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2006 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+require_once 'xorg.inc.php';
+
+require_once dirname(__FILE__).'/../classes/Platal.php';
+require_once dirname(__FILE__).'/../classes/PLModule.php';
+
+$platal = new Platal();
+$platal->run();
+
+?>
function has_perms()
{
- return logged() && Session::get('perms')==PERMS_ADMIN;
+ return logged() && Session::get('perms') == PERMS_ADMIN;
}
// }}}
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2006 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+class CoreModule extends PLModule
+{
+ function menu_entries()
+ {
+ return array();
+ }
+
+ function handlers()
+ {
+ return array(
+ '403' => $this->make_hook('handler_403', AUTH_PUBLIC, ''),
+ '404' => $this->make_hook('handler_404', AUTH_PUBLIC, ''),
+ );
+ }
+
+ function handler_auth(&$page)
+ {
+ return PL_OK;
+ }
+
+ function handler_403(&$page)
+ {
+ header('HTTP/1.0 403 Forbidden');
+ $page->changeTpl('403.tpl');
+ return PL_OK;
+ }
+
+ function handler_404(&$page)
+ {
+ header('HTTP/1.0 404 Not Found');
+ $page->changeTpl('404.tpl');
+ return PL_OK;
+ }
+}
+
+?>
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2006 Polytechnique.org *}
+{* http://opensource.polytechnique.org/ *}
+{* *}
+{* This program is free software; you can redistribute it and/or modify *}
+{* it under the terms of the GNU General Public License as published by *}
+{* the Free Software Foundation; either version 2 of the License, or *}
+{* (at your option) any later version. *}
+{* *}
+{* This program is distributed in the hope that it will be useful, *}
+{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
+{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
+{* GNU General Public License for more details. *}
+{* *}
+{* You should have received a copy of the GNU General Public License *}
+{* along with this program; if not, write to the Free Software *}
+{* Foundation, Inc., *}
+{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
+{* *}
+{**************************************************************************}
+
+<h1 class="erreur">Tu n'as pas les permissions nécessaires pour accéder à cette page</h1>
+
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2006 Polytechnique.org *}
+{* http://opensource.polytechnique.org/ *}
+{* *}
+{* This program is free software; you can redistribute it and/or modify *}
+{* it under the terms of the GNU General Public License as published by *}
+{* the Free Software Foundation; either version 2 of the License, or *}
+{* (at your option) any later version. *}
+{* *}
+{* This program is distributed in the hope that it will be useful, *}
+{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
+{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
+{* GNU General Public License for more details. *}
+{* *}
+{* You should have received a copy of the GNU General Public License *}
+{* along with this program; if not, write to the Free Software *}
+{* Foundation, Inc., *}
+{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
+{* *}
+{**************************************************************************}
+
+<h1 class="erreur">Cette page n'existe pas !!!</h1>
+