Merge commit 'origin/platal-0.9.17'
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 27 Jul 2008 20:01:53 +0000 (22:01 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 27 Jul 2008 20:01:53 +0000 (22:01 +0200)
Conflicts:

modules/marketing.php

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
128 files changed:
.gitmodules [new file with mode: 0644]
ChangeLog
Makefile
bin/connect.db.inc.php
bin/csv2sql.php
bin/emails.broken.helper.php
bin/emails.broken.php
bin/lists.create_promo.php
bin/search.rebuild_db.php
classes/.gitignore [new file with mode: 0644]
classes/corelogger.php [deleted file]
classes/csvimporter.php [deleted file]
classes/env.php [deleted file]
classes/flagset.php [deleted file]
classes/miniwiki.php [deleted file]
classes/platal.php [deleted file]
classes/platalglobals.php.in [new file with mode: 0644]
classes/platalpage.php [deleted file]
classes/plbacktrace.php [deleted file]
classes/pliterator.php [deleted file]
classes/plmailer.php [deleted file]
classes/plmodule.php [deleted file]
classes/plprofiler.php [deleted file]
classes/plset.php [deleted file]
classes/pltableeditor.php [deleted file]
classes/plupload.php [deleted file]
classes/plwizard.php [deleted file]
classes/s.php [deleted file]
classes/session.php [deleted file]
classes/varstream.php [deleted file]
classes/xdb.php [deleted file]
classes/xmlrpcclient.php [deleted file]
classes/xnetpage.php [moved from include/xnet/page.inc.php with 93% similarity]
classes/xnetsession.php [moved from include/xnet/session.inc.php with 55% similarity]
classes/xorgpage.php [moved from classes/mmlist.php with 76% similarity]
classes/xorgsession.php [new file with mode: 0644]
core [new submodule]
htdocs/listes_redirect.php
htdocs/webredirect.php
htdocs/xnet.php
htdocs/xorg.php
include/.gitignore [deleted file]
include/applis.func.inc.php
include/banana/forum.inc.php
include/banana/hooks.inc.php
include/banana/moderate.inc.php
include/common.inc.php [moved from plugins/modifier.miniwiki.php with 79% similarity]
include/emails.inc.php
include/globals.inc.php.in [deleted file]
include/marketing.inc.php
include/massmailer.inc.php
include/notifs.inc.php
include/platal.inc.php [deleted file]
include/rss.inc.php
include/security.inc.php [new file with mode: 0644]
include/synchro_ax.inc.php
include/user.func.inc.php
include/userset.inc.php
include/validations.inc.php
include/validations/nomusage.inc.php
include/vcard.inc.php
include/wiki.inc.php [deleted file]
include/wiki/engine.php [deleted file]
include/xnet.inc.php
include/xorg.inc.php
include/xorg.misc.inc.php [deleted file]
include/xorg/session.inc.php [deleted file]
modules/admin.php
modules/auth.php
modules/axletter.php
modules/carnet.php
modules/core.php [deleted file]
modules/email.php
modules/events.php
modules/forums.php
modules/gadgets/gadgets.inc.php
modules/geoloc.php
modules/googleapps.php
modules/lists.php
modules/marketing.php
modules/newsletter.php
modules/payment.php
modules/payment/money.inc.php
modules/payment/money/cyberpaiement.inc.php
modules/payment/money/paypal.inc.php
modules/platal.php
modules/platal/review.inc.php
modules/profile.php
modules/profile/addresses.inc.php
modules/profile/decos.inc.php
modules/profile/general.inc.php
modules/profile/groups.inc.php
modules/profile/jobs.inc.php
modules/profile/mentor.inc.php
modules/profile/page.inc.php
modules/profile/skills.inc.php
modules/register.php
modules/register/register.inc.php
modules/search.php
modules/search/classes.inc.php
modules/search/search.inc.php
modules/xnet.php
modules/xnetevents.php
modules/xnetevents/xnetevents.inc.php
modules/xnetgrp.php
plugins/block.tidy.php [deleted file]
plugins/compiler.checkpasswd.php [deleted file]
plugins/compiler.icon.php
plugins/compiler.iterate.php [deleted file]
plugins/compiler.javascript.php [deleted file]
plugins/function.make_forlife.php
plugins/function.select_db_table.php [deleted file]
plugins/function.valid_date.php [deleted file]
plugins/function.xsrf_token.php [deleted file]
plugins/function.xsrf_token_field.php [deleted file]
plugins/modifier.date_format.php [deleted file]
plugins/modifier.htmlentities.php [deleted file]
plugins/modifier.number_format.php [deleted file]
plugins/modifier.uint_to_ip.php [deleted file]
templates/core/password_prompt.tpl
templates/payment/index.tpl
templates/platal/motdepasse.tpl
templates/search/adv.form.tpl
templates/search/index.tpl
templates/skin/common.content.tpl
templates/skin/common.header.tpl
templates/skin/common.triggers.tpl
templates/xnet/skin.tpl

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..7c16f52
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "core"]
+       path = core
+       url = ./
index 740a280..337309c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,13 @@
 ================================================================================
+VERSION 0.9.18                                                        XX XX XXXX
+
+Bug/Wish:
+
+    * Search:
+        - #691: Adds search on postcode and thus on "arrondissements"      -JAC
+        - #791: Adds the possibility to do an exact search                 -JAC
+
+================================================================================
 VERSION 0.9.17                                                        19 07 2008
 
 New:
index 0b6b37b..f2ca45e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -42,7 +42,7 @@ q:
 ## core
 ##
 
-core: spool/templates_c spool/mails_c include/globals.inc.php configs/platal.cron htdocs/.htaccess spool/conf spool/tmp
+core: spool/templates_c spool/mails_c classes/platalglobals.php configs/platal.cron htdocs/.htaccess spool/conf spool/tmp
 
 spool/templates_c spool/mails_c spool/uploads spool/conf spool/tmp:
        mkdir -p $@
@@ -134,7 +134,7 @@ JQUERY_PLUGINS_PATHES=$(addprefix htdocs/javascript/jquery.,$(addsuffix .js,$(JQ
 
 jquery: htdocs/javascript/jquery.js htdocs/javascript/jquery.autocomplete.js $(JQUERY_PLUGINS_PATHES)
 
-htdocs/javascript/jquery.js: DOWNLOAD_SRC = http://jquery.com/src/jquery-latest.pack.js
+htdocs/javascript/jquery.js: DOWNLOAD_SRC = http://jquery.com/src/jquery-latest.min.js
 htdocs/javascript/jquery.js:
        @$(download)
 
index f13dfa1..e2954f1 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-ini_set('include_path',dirname(__FILE__).'/../include:' . dirname(__FILE__).'/../classes:/usr/share/php');
-
+ini_set('include_path', dirname(__FILE__) . '/../core/include:'
+                      . dirname(__FILE__) . '/../include:'
+                      . dirname(__FILE__) . '/../core/classes:'
+                      . dirname(__FILE__) . '/../classes:'
+                      . '/usr/share/php');
 require_once('xorg.inc.php');
-require_once('xorg.misc.inc.php');
 
-require_once 'xdb.php';
+new Platal('core');
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index e768aab..9820fbf 100755 (executable)
@@ -20,7 +20,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once(dirname(__FILE__) . '/../classes/csvimporter.php');
+require_once(dirname(__FILE__) . '/../core/classes/csvimporter.php');
 
 // {{{ function showHelp()
 
@@ -86,7 +86,7 @@ $action          = CSV_INSERT;
 $keys            = 'id';
 
 processArgs();
-require_once(dirname(__FILE__) . '/../classes/xdb.php');
+require_once(dirname(__FILE__) . '/../core/classes/xdb.php');
 
 $source          = file_get_contents($sourceName);
 $insert_relation = null;
index c88db0b..9534e0e 100755 (executable)
@@ -23,7 +23,6 @@
 ini_set('include_path', '.:../include:/usr/share/php');
 
 require_once('connect.db.inc.php');
-require_once('xorg.inc.php');
 require_once('emails.inc.php');
 
 $opts = getopt('o:');
index 358fe0a..d371854 100755 (executable)
@@ -23,7 +23,6 @@
 ini_set('include_path', '.:../include:/usr/share/php');
 
 require_once('connect.db.inc.php');
-require_once('xorg.inc.php');
 require_once('emails.inc.php');
 require_once('../classes/plmailer.php');
 
index 7296798..34eb213 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
-require_once("xorg.inc.php");
+
+require_once(dirname(__FILE__) . '/connect.db.inc.php');
 require_once('validations.inc.php');
 
 global $globals;
index 3835a9d..c201f21 100755 (executable)
@@ -29,7 +29,7 @@ $globals->debug = 0; // Do not store backtraces
 XDB::execute('DELETE FROM search_name');
 $res = XDB::iterRow('SELECT  auth_user_md5.user_id, nom, prenom, nom_usage, profile_nick
                        FROM  auth_user_md5
-                  LEFT JOIN auth_user_quick USING(user_id)');
+                  LEFT JOIN  auth_user_quick USING(user_id)');
 $i = 0;
 $muls = array(1, 1, 1, 0.2);
 $pub  = array(true, true, true, false);
diff --git a/classes/.gitignore b/classes/.gitignore
new file mode 100644 (file)
index 0000000..b478258
--- /dev/null
@@ -0,0 +1 @@
+/platalglobals.php
diff --git a/classes/corelogger.php b/classes/corelogger.php
deleted file mode 100644 (file)
index 8d06056..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php
-/*
- * Copyright (C) 2003-2004 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 CoreLogger
-{
-    /** user id */
-    public $uid;
-    /** id of the session */
-    private $session;
-    /** list of available actions */
-    private $actions;
-
-    public $ip;
-    public $host;
-    public $proxy_ip;
-    public $proxy_host;
-
-    /** The constructor, creates a new entry in the sessions table
-     *
-     * @param $uid the id of the logged user
-     * @param $suid the id of the administrator who has just su'd to the user
-     * @return VOID
-     */
-    public function __construct($uid, $suid = 0)
-    {
-        // write the session entry
-        $this->uid     = $uid;
-        $this->session = $this->writeSession($uid, $suid);
-
-        // retrieve available actions
-        $res = XDB::iterRow("SELECT id, text FROM logger.actions");
-
-        while (list($action_id, $action_text) = $res->next()) {
-            $this->actions[$action_text] = $action_id;
-        }
-    }
-
-    /** Creates a new session entry in database and return its ID.
-     *
-     * @param $uid the id of the logged user
-     * @param $suid the id of the administrator who has just su'd to the user
-     * @return session the session id
-     */
-    private function writeSession($uid, $suid = 0)
-    {
-        $ip      = $_SERVER['REMOTE_ADDR'];
-        $host    = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR']));
-        $browser = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
-
-        @list($forward_ip,) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
-        $forward_host = $forward_ip;
-        if ($forward_host) {
-            $forward_host = strtolower(gethostbyaddr($forward_host));
-        }
-        $proxy = '';
-        if ($forward_ip || @$_SERVER['HTTP_VIA']) {
-            $proxy = 'proxy';
-        }
-
-        XDB::execute("INSERT INTO logger.sessions
-                         SET uid={?}, host={?}, ip={?}, forward_ip={?}, forward_host={?}, browser={?}, suid={?}, flags={?}",
-                     $uid, $host, ip_to_uint($ip), ip_to_uint($forward_ip), $forward_host, $browser, $suid, $proxy);
-        if ($forward_ip) {
-            $this->proxy_ip = $ip;
-            $this->proxy_host = $host;
-            $this->ip = $forward_ip;
-            $this->host = $forward_host;
-        } else {
-            $this->ip = $ip;
-            $this->host = $host;
-        }
-
-        return XDB::insertId();
-    }
-
-
-    /** Logs an action and its related data.
-     *
-     * @param $action le type d'action
-     * @param $data les données (id de liste, etc.)
-     * @return VOID
-     */
-    public function log($action, $data = null)
-    {
-        if (isset($this->actions[$action])) {
-            XDB::execute("INSERT INTO logger.events
-                             SET session={?}, action={?}, data={?}",
-                         $this->session, $this->actions[$action], $data);
-        } else {
-            trigger_error("CoreLogger: unknown action, $action", E_USER_WARNING);
-        }
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/csvimporter.php b/classes/csvimporter.php
deleted file mode 100644 (file)
index 571d227..0000000
+++ /dev/null
@@ -1,355 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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('CSV_INSERT',     'insert'); // INSERT IGNORE
-define('CSV_REPLACE',    'replace'); // REPLACE
-define('CSV_UPDATE',     'update'); // INSERT and UPDATE on error
-define('CSV_UPDATEONLY', 'updateonly'); // UPDATE
-
-class CSVImporter
-{
-    private $table;
-    private $key;
-    private $do_sql;
-
-    private $index;
-    private $data = array();
-
-    private $user_functions = array();
-    private $field_desc = array();
-    private $field_value = array();
-
-    public function __construct($table, $key = 'id', $do_sql = true)
-    {
-        $this->table     = $table;
-        $this->key       = explode(',', $key);
-        $this->do_sql    = $do_sql;
-    }
-
-    private function processLine(array $array)
-    {
-        if (is_null($this->index)) {
-            $this->index = array_map('strtolower', $array);
-            return true;
-        }
-
-        if (count($array) != count($this->index)) {
-            return false;
-        }
-        $assoc = array();
-        $i     = 0;
-        foreach ($this->index as $key) {
-            $assoc[$key] = $array[$i];
-            $i++;
-        }
-        $this->data[] = $assoc;
-        return true;
-    }
-
-    private function getValue($line, $key, $action)
-    {
-        if (@array_key_exists($action, $line)) {
-            $value = $line[$action];
-        } elseif (is_callable($action, false)) {
-            $value = call_user_func($action, $line, $key);
-        } else {
-            $value = $action;
-        }
-        if (is_null($value) || $value == 'NULL') {
-            $value = 'NULL';
-        }
-        return $value;
-    }
-
-    private function makeAssoc($line, $relation)
-    {
-        $ops = array();
-        foreach ($relation as $key=>$ref) {
-            $ops[$key] = $this->getValue($line, $key, $ref);
-        }
-        return $ops;
-    }
-
-    private function makeRequestArgs($line, $relation)
-    {
-        $ops = array();
-        foreach ($relation as $key=>$ref) {
-            $value = $this->getValue($line, $key, $ref);
-            if (!is_null($value) && $value != 'NULL') {
-                $value = "'" . addslashes($value) . "'";
-            }
-            $ops[$key] = "$key = $value";
-        }
-        return $ops;
-    }
-
-    private function makeRelation()
-    {
-        $relation = array();
-        foreach ($this->index as $title) {
-            $relation[$title] = $title;
-        }
-        return $relation;
-    }
-
-    private function execute($query)
-    {
-        if (!$this->do_sql) {
-            echo "$query;\n";
-            return false;
-        }
-        return XDB::execute($query);
-    }
-
-    private function getFieldList()
-    {
-        $res = XDB::query("SHOW COLUMNS FROM {$this->table}");
-        if ($res->numRows()) {
-            return $res->fetchColumn();
-        }
-        return null;
-    }
-
-    public function setCSV($csv, $index = null, $separator = ';')
-    {
-        require_once dirname(__FILE__) . '/varstream.php';
-        VarStream::init();
-        global $csv_source;
-        $this->index     = null;
-
-        $csv_source = $csv;
-        $res        = fopen('var://csv_source', 'r');
-
-        while (!feof($res)) {
-            $this->processLine(fgetcsv($res, 0, $separator));
-        }
-    }
-
-    public function run($action = CSV_UPDATE, $insert_relation = null, $update_relation = null)
-    {
-        if (is_null($insert_relation)) {
-            $insert_relation = $this->makeRelation();
-        }
-        if (is_null($update_relation)) {
-            $update_relation = $insert_relation;
-        }
-        foreach ($this->data as $line) {
-            $set = join(', ', $this->makeRequestArgs($line, $insert_relation));
-            switch ($action) {
-              case CSV_INSERT:
-                $this->execute("INSERT IGNORE INTO {$this->table} SET $set");
-                break;
-              case CSV_REPLACE:
-                $this->execute("REPLACE INTO {$this->table} SET $set");
-                break;
-              case CSV_UPDATE: case CSV_UPDATEONLY:
-                if ($action == CSV_UPDATEONLY || !$this->execute("INSERT INTO {$this->table} SET $set")) {
-                    $ops = $this->makeRequestArgs($line, $update_relation);
-                    $set = join(', ', $ops);
-                    $where = array();
-                    foreach ($this->key as $key) {
-                        $where[] = $ops[$key];
-                    }
-                    $where = join(' AND ', $where);
-                    $this->execute("UPDATE {$this->table} SET $set WHERE $where");
-                }
-                break;
-            }
-        }
-    }
-
-    static public function dynamicCond($line, $key)
-    {
-        static $fields, $conds, $values, $thens, $elses;
-
-        if (!isset($fields)) {
-            $fields = $_SESSION['csv_cond_field'];
-            $conds  = $_SESSION['csv_cond'];
-            $values = $_SESSION['csv_cond_value'];
-            $thens  = $_SESSION['csv_cond_then'];
-            $elses  = $_SESSION['csv_cond_else'];
-        }
-        $field = $line[$fields[$key]];
-        $cond  = $conds[$key];
-        $value = $values[$key];
-        if (is_numeric($field) && is_numeric($value)) {
-            $field = floatval($field);
-            $value = floatval($value);
-        }
-        switch ($cond) {
-            case 'defined':          $ok = (!empty($field)); break;
-            case 'equals':           $ok = ($field == $value); break;
-            case 'contains':         $ok = (strpos($field, $value) !== false); break;
-            case 'contained':        $ok = (strpos($value, $field) !== false); break;
-            case 'greater':          $ok = ($field > $value); break;
-            case 'greater_or_equal': $ok ($field >= $value); break;
-            case 'lower':            $ok = ($field < $value); break;
-            case 'lower_or_equal':   $ok = ($field <= $value); break;
-            default:                 $ok = false;
-        }
-        if ($ok) {
-            return $thens[$key];
-        } else {
-            return $elses[$key];
-        }
-    }
-
-    public function registerFunction($name, $desc, $callback)
-    {
-        if (is_callable($callback, false, $ref)) {
-            $this->user_functions['func_' . $name] = array('desc' => $desc, 'callback' => $callback);
-            return true;
-        }
-        return false;
-    }
-
-    public function describe($name, $desc)
-    {
-        $this->field_desc[$name] = $desc;
-    }
-
-    public function forceValue($name, $value)
-    {
-        $this->field_value[$name] = $value;
-    }
-
-    private function cleanSession($fields)
-    {
-        foreach ($fields as $field) {
-            unset($_SESSION[$field]);
-        }
-    }
-
-    /** Handle insertion form
-     * @param $page  PlatalPage to process
-     * @param $url   URI of the page
-     * @param $field Editable fields
-     */
-    public function apply(&$page, $url, $fields = null)
-    {
-        $sesfields = array('csv_value', 'csv_user_value', 'csv_cond_field',
-                           'csv_update', 'csv_action', 'csv_cond_field',
-                           'csv_cond', 'csv_cond_value', 'csv_cond_then',
-                           'csv_cond_else', 'csv', 'csv_separator', 'csv_url');
-        if ($url != @$_SESSION['csv_url']) {
-            $this->cleanSession($sesfields);
-            $_SESSION['csv_url'] = $url;
-        }
-
-        if (is_null($fields) || empty($fields)) {
-            $fields = $this->getFieldList();
-        }
-        if (is_null($fields)) {
-            return false;
-        }
-        foreach ($this->field_value as $key=>$value) {
-            $search = array_search($key, $fields);
-            unset($fields[$search]);
-        }
-
-        $current = Env::v('csv_page');
-        if (empty($current)) {
-            $current = 'source';
-        }
-        $next = Env::v('csv_next_page');
-        if (empty($next)) {
-            $next = $current;
-        }
-        $csv  = @$_SESSION['csv'];
-        if ($current == 'source' && Env::has('csv_valid')) {
-            $csv = Env::v('csv_source');
-            $_SESSION['csv'] = $csv;
-            $next = 'values';
-        }
-        if ($csv) {
-            if (Env::has('csv_separator')) {
-                $sep = Env::v('csv_separator');
-                if (empty($sep)) {
-                    $sep = ';';
-                }
-                $_SESSION['csv_separator'] = $sep;
-            }
-            $this->setCSV($csv, null, $_SESSION['csv_separator']);
-        }
-        if ($current == 'values' && Env::has('csv_valid')) {
-            $next = 'valid';
-        }
-        if (empty($csv)) {
-            $next = 'source';
-        }
-        if (Env::has('csv_action')) {
-            $_SESSION['csv_action'] = Env::v('csv_action');
-        }
-        if ($next == 'valid') {
-            if ($current != 'valid') {
-                $cpyfields = array('csv_value', 'csv_user_value', 'csv_cond_field',
-                                   'csv_update', 'csv_action', 'csv_cond_field',
-                                   'csv_cond', 'csv_cond_value', 'csv_cond_then',
-                                   'csv_cond_else');
-                foreach ($cpyfields as $field) {
-                    $_SESSION[$field] = Env::v($field);
-                }
-            }
-            $insert   = $_SESSION['csv_value'];
-            $values   = $_SESSION['csv_user_value'];
-            $update   = $_SESSION['csv_update'];
-            foreach ($insert as $key=>$value) {
-                if (empty($value)) {
-                    $insert[$key] = null;
-                } elseif ($value == 'user_value') {
-                    $insert[$key] = $values[$key];
-                } elseif ($value == 'cond_value') {
-                    $insert[$key] = array($this, 'dynamicCond');
-                } elseif (array_key_exists($value, $this->user_functions)) {
-                    $insert[$key] = $this->user_functions[$value]['callback'];
-                }
-                if (isset($update[$key])) {
-                    $update[$key] = $insert[$key];
-                }
-            }
-            foreach ($this->field_value as $key=>$value) {
-                $insert[$key] = $value;
-                $fields[]     = $key;
-            }
-            if ($current == 'valid' && Env::has('csv_valid')) {
-                S::assert_xsrf_token();
-                $this->run($_SESSION['csv_action'], $insert, $update);
-                $page->assign('csv_done', true);
-                $this->cleanSession($sesfields);
-            } else {
-                $preview = array();
-                foreach ($this->data as $line) {
-                    $preview[] = $this->makeAssoc($line, $insert);
-                }
-                $page->assign('csv_preview', $preview);
-            }
-        }
-        $page->assign('csv_index', $this->index);
-        $page->assign('csv_functions', $this->user_functions);
-        $page->assign('csv_field_desc', $this->field_desc);
-        $page->assign('csv_page', $next);
-        $page->assign('csv_path', $url);
-        $page->assign('csv_fields', $fields);
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/env.php b/classes/env.php
deleted file mode 100644 (file)
index e3bbd88..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 Env
-{
-    public static function _get($key, $default)
-    {
-        return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default;
-    }
-
-    public static function has($key)
-    {
-        return isset($_REQUEST[$key]);
-    }
-
-    public static function kill($key)
-    {
-        unset($_REQUEST[$key]);
-    }
-
-    public static function v($key, $default = null)
-    {
-        return Env::_get($key, $default);
-    }
-
-    public static function s($key, $default = '')
-    {
-        return (string)Env::_get($key, $default);
-    }
-
-    public static function b($key, $default = false)
-    {
-        return (bool)Env::_get($key, $default);
-    }
-
-    public static function i($key, $default = 0)
-    {
-        $i = Env::_get($key, $default);
-        return is_numeric($i) ? intval($i) : $default;
-    }
-
-    public static function l(array $keys)
-    {
-        return array_map(array('Env', 'v'), $keys);
-    }
-}
-
-class Post
-{
-    public static function _get($key, $default)
-    {
-        return isset($_POST[$key]) ? $_POST[$key] : $default;
-    }
-
-    public static function has($key)
-    {
-        return isset($_POST[$key]);
-    }
-
-    public static function kill($key)
-    {
-        unset($_POST[$key]);
-    }
-
-    public static function v($key, $default = null)
-    {
-        return Post::_get($key, $default);
-    }
-
-    public static function b($key, $default = false)
-    {
-        return (bool)Post::_get($key, $default);
-    }
-
-    public static function s($key, $default = '')
-    {
-        return (string)Post::_get($key, $default);
-    }
-
-    public static function i($key, $default = 0)
-    {
-        $i = Post::_get($key, $default);
-        return is_numeric($i) ? intval($i) : $default;
-    }
-
-     public static function l(array $keys)
-    {
-        return array_map(array('Post', 'v'), $keys);
-    }
-}
-
-class Get
-{
-    public static function _get($key, $default)
-    {
-        return isset($_GET[$key]) ? $_GET[$key] : $default;
-    }
-
-    public static function has($key)
-    {
-        return isset($_GET[$key]);
-    }
-
-    public static function kill($key)
-    {
-        unset($_GET[$key]);
-    }
-
-    public static function v($key, $default = null)
-    {
-        return Get::_get($key, $default);
-    }
-
-    public static function b($key, $default = false)
-    {
-        return (bool)Get::_get($key, $default);
-    }
-
-    public static function s($key, $default = '')
-    {
-        return (string)Get::_get($key, $default);
-    }
-
-    public static function i($key, $default = 0)
-    {
-        $i = Get::_get($key, $default);
-        return is_numeric($i) ? intval($i) : $default;
-    }
-
-    public static function l(array $keys)
-    {
-        return array_map(array('Get', 'v'), $keys);
-    }
-}
-
-class Cookie
-{
-    public static function _get($key, $default)
-    {
-        return isset($_COOKIE[$key]) ? $_COOKIE[$key] : $default;
-    }
-
-    public static function has($key)
-    {
-        return isset($_COOKIE[$key]);
-    }
-
-    public static function kill($key)
-    {
-        unset($_COOKIE[$key]);
-    }
-
-    public static function v($key, $default = null)
-    {
-        return Cookie::_get($key, $default);
-    }
-
-    public static function s($key, $default = '')
-    {
-        return (string)Cookie::_get($key, $default);
-    }
-
-    public static function b($key, $default = false)
-    {
-        return (bool)Cookie::_get($key, $default);
-    }
-
-    public static function i($key, $default = 0)
-    {
-        $i = Cookie::_get($key, $default);
-        return is_numeric($i) ? intval($i) : $default;
-    }
-
-    public static function l(array $keys)
-    {
-        return array_map(array('Cookie', 'v'), $keys);
-    }
-}
-
-function fix_gpc_magic(&$item, $key) {
-    if (is_array($item)) {
-        array_walk($item, 'fix_gpc_magic');
-    } else {
-        $item = stripslashes($item);
-    }
-}
-
-if (ini_get('magic_quotes_gpc') && empty($DONT_FIX_GPC)) {
-    array_walk($_GET, 'fix_gpc_magic');
-    array_walk($_POST, 'fix_gpc_magic');
-    array_walk($_COOKIE, 'fix_gpc_magic');
-    array_walk($_REQUEST, 'fix_gpc_magic');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/flagset.php b/classes/flagset.php
deleted file mode 100644 (file)
index ce3d558..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-/*
- * Copyright (C) 2003-2004 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 for describing flags
- */
-class Flagset
-{
-    /** string that holds the flagset */
-    private $value;
-
-    /** the boundary between flags */
-    private $sep = ",";
-
-
-    /** set flag
-     * @param $flags services FROM coupures
-     * @return VOID
-     */
-    public function __construct($flags = "")
-    {
-        $this->value = $flags;
-    }
-
-
-    /** add flag
-     * @param $flag XXX
-     * @return VOID
-     */
-    public function addFlag($flag)
-    {
-        if (!$flag) return;
-        if (!$this->hasflag($flag)) {
-            if ($this->value)
-                $this->value .= $this->sep;
-            $this->value .= $flag;
-        }
-    }
-
-
-    /** test si flag ou pas
-     * @param $flag XXX
-     * @return 1 || 0
-     */
-    public function hasFlag($flag)
-    {
-        $tok = strtok($this->value,$this->sep);
-        while ($tok) {
-            if ($tok==$flag) return 1;
-            $tok = strtok($this->sep);
-        }
-        return 0;
-    }
-
-    /** test flag combination
-     */
-    public function hasFlagCombination($flag)
-    {
-        $perms = explode(',', $flag);
-        foreach ($perms as $perm)
-        {
-            $ok = true;
-            $rights = explode(':', $perm);
-            foreach ($rights as $right) {
-                if (($right{0} == '!' && $this->hasFlag(substr($right, 1))) || !$this->hasFlag($right)) {
-                    $ok = false;
-                }
-            }
-            if ($ok) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /** remove flag
-     * @param $flag XXX
-     * @return VOID
-     */
-    public function rmFlag($flag)
-    {
-        if (!$flag) return;
-        $newvalue = "";
-        $tok = strtok($this->value,$this->sep);
-        while ($tok) {
-            if ($tok!=$flag) {
-                if ($newvalue)
-                    $newvalue .= $this->sep;
-                $newvalue .= $tok;
-            }
-            $tok = strtok($this->sep);
-        }
-        $this->value=$newvalue;
-    }
-
-    /** return the flagset
-     */
-    public function flags()
-    {
-        return $this->value;
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/miniwiki.php b/classes/miniwiki.php
deleted file mode 100644 (file)
index ab547e0..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-<?php
-
-class MiniWiki
-{
-
-    private static $patternsWiki = array();
-    private static $replacementHTML = array();
-    private static $replacementText = array();
-
-    private static $title_index = -1;
-    private static $info     = array();
-
-    public static function Markup($pattern, $replacement, $replacementTxt, $info = null)
-    {
-        $id = count(MiniWiki::$patternsWiki);
-        MiniWiki::$patternsWiki[$id] = $pattern;
-        MiniWiki::$replacementHTML[$id] = $replacement;
-        MiniWiki::$replacementText[$id] = $replacementTxt;
-        if ($info) {
-            MiniWiki::$info[$id] = $info;
-        }
-        return $id;
-    }
-
-    public static function init()
-    {
-        if (isset(MiniWiki::$patternsWiki[0])) {
-            return;
-        }
-        MiniWiki::Markup("/(\r\n|\r([^\n]))/", "\n$2", "\n$2");
-
-        // retours à la ligne avec \\
-        MiniWiki::Markup("/\\\\(?".">(\\\\*))\n/e", "str_repeat('<br />\n',mb_strlen('$1'))", "str_repeat('\n',mb_strlen('$1'))", "ligne1\\\\\nligne2");
-
-        // * unordered list
-        MiniWiki::Markup("/(^|\n)\*(([^\n]*(\n|$))(\*[^\n]*(\n|$))*)/se",
-                         "'</p><ul><li>'.str_replace(\"\\n*\",'</li><li>','$2').'</li></ul><p>'",
-                         "'$1 -' . str_replace(\"\\n*\", \"\\n -\", '$2')",
-                         "* element1\n* element2\n* element3");
-        // # unordered list
-        MiniWiki::Markup("/(^|\n)#(([^\n]*(\n|$))(#[^\n]*(\n|$))*)/se", "'<ol><li>'.str_replace(\"\\n#\",'</li><li>','$2').'</li></ol>'", "'$0'", "# element1\n# element2\n# element3");
-
-        // bold, italic and others
-        // ''' bold '''
-        MiniWiki::Markup("/'''(.*?)'''/",'<strong>$1</strong>','*$1*', "'''gras'''");
-        // '' italic ''
-        MiniWiki::Markup("/''(.*?)''/",'<em>$1</em>','/$1/', "''italique''");
-        // '+ big +'
-        MiniWiki::Markup("/'\\+(.*?)\\+'/",'<big>$1</big>','*$1*', "'+grand+'");
-        // '- small -'
-        MiniWiki::Markup("/'\\-(.*?)\\-'/",'<small>$1</small>','$1', "'-petit-'");
-        // '^superscript^'
-        MiniWiki::Markup("/'\\^(.*?)\\^'/",'<sup>$1</sup>','$1', "'^exposant^'");
-        // '_subscript_'
-        MiniWiki::Markup("/'_(.*?)_'/",'<sub>$1</sub>','$1', "'_indice_'");
-        // {+ underline +}
-        MiniWiki::Markup("/\\{\\+(.*?)\\+\\}/",'<ins>$1</ins>','_$1_', "{+insertion+}");
-        // {- strikeout -}
-        MiniWiki::Markup("/\\{-(.*?)-\\}/",'<del>$1</del>','-$1-', "{-suppression-}");
-        // {color| colored text |}
-        MiniWiki::Markup("/%([a-z]+|\#[0-9a-f]{3,6})%(.*?)%%/i", "<span style='color: $1;'>$2</span>", "$2",
-                         "%red% texte en rouge %%\\\\\n%#ff0% texte en jaune %%\\\\\n%#0000ff% texte en bleu %%");
-        // [+ big +] [++ bigger ++] [+++ even bigger +++] ...
-        MiniWiki::Markup("/\\[(([-+])+)(.*?)\\1\\]/e","'<span style=\'font-size:'.(round(pow(6/5,$2mb_strlen('$1'))*100,0)).'%\'>$3</span>'", "'$3'", "[+ grand +]\n\n[++ plus grand ++]\n\n[+++ encore plus grand +++]");
-
-        // ----- <hr/>
-        MiniWiki::Markup("/(\n|^)--(--+| \n)/s", '$1<hr/>', '$1-- '."\n", "----\n");
-        // titles
-        MiniWiki::$title_index = MiniWiki::Markup('/(\n|^)(!+)([^\n]*)/se',
-                                                  "'$1<h'.mb_strlen('$2').'>$3</h'.mb_strlen('$2').'>'",
-                                                  "'$1$3'", "!titre1\n\n!!titre2\n\n!!!titre3");
-
-        // links
-        MiniWiki::Markup('/((?:https?|ftp):\/\/(?:[\.\,\;\!\:]*[\w@~%$£µ&i#\-+=_\/\?])*)/ui',
-                         '<a href="\\0">\\0</a>', '<\\0>');
-        MiniWiki::Markup('/(\s|^|\[\[)www\.((?:[\.\,\;\!\:]*[\w@~%$£µ&i#\-+=_\/\?])*)/iu',
-                         '\\1<a href="http://www.\\2">www.\\2</a>', '\\1<http://www.\\2>');
-        MiniWiki::Markup('/(?:mailto:)?([a-z0-9.\-+_]+@([\-.+_]?[a-z0-9])+)/i', '<a href="mailto:\\0">\\0</a>', '<\\0>');
-        MiniWiki::Markup('/\[\[\s*<(?:a href=")?([^">]*?)(?:">.*?<\/a)?>\s*\|([^\]]+)\]\]/i',
-                         '<a href="\\1">\\2</a>', '\\2 <\\1>',
-                         "[[http://www.example.com|Mon site web]]\n\nhttp://www.example.com\n\ntest@example.com");
-
-        // paragraphs and empty lines
-        MiniWiki::Markup("/\n\n/", '</p><p>', "\n\n", "paragraphe1\n\nparagraphe2");
-        MiniWiki::Markup("/\n/", ' ', "\n");
-        MiniWiki::Markup("/^.*<\/p>.*<p>.*$/s", "<p>$0</p>", "$0");
-
-        // french typo rules, unbreakable spaces
-        MiniWiki::Markup("/ +([!?:;])/", "&nbsp;$1", "$0");
-    }
-
-    public static function WikiToHTML($wiki, $title = false)
-    {
-        if (!$title) {
-            $oldrule12 = MiniWiki::$replacementHTML[MiniWiki::$title_index];
-            MiniWiki::$replacementHTML[MiniWiki::$title_index] = "'$0'";
-        }
-        $html = preg_replace(MiniWiki::$patternsWiki,
-                             MiniWiki::$replacementHTML,
-                             htmlentities(trim($wiki), ENT_COMPAT, 'UTF-8'));
-        if (!$title) {
-            MiniWiki::$replacementHTML[MiniWiki::$title_index] = $oldrule12;
-        }
-        return $html;
-    }
-
-    private static function justify($text, $n)
-    {
-        $arr = explode("\n", wordwrap($text, $n));
-        $arr = array_map('trim', $arr);
-        $res = '';
-        foreach ($arr as $key => $line) {
-            $nxl       = isset($arr[$key+1]) ? trim($arr[$key+1]) : '';
-            $nxl_split = preg_split('! +!u', $nxl);
-            $nxw_len   = count($nxl_split) ? mb_strlen($nxl_split[0]) : 0;
-            $line      = trim($line);
-
-            if (mb_strlen($line)+1+$nxw_len < $n) {
-                $res .= "$line\n";
-                continue;
-            }
-
-            if (preg_match('![.:;]$!u',$line)) {
-                $res .= "$line\n";
-                continue;
-            }
-
-            $tmp   = preg_split('! +!u', trim($line));
-            $words = count($tmp);
-            if ($words <= 1) {
-                $res .= "$line\n";
-                continue;
-            }
-
-            $len   = array_sum(array_map('mb_strlen', $tmp));
-            $empty = $n - $len;
-            $sw    = floatval($empty) / floatval($words-1);
-
-            $cur = 0;
-            $l   = '';
-            foreach ($tmp as $word) {
-                $l   .= $word;
-                $cur += $sw + strlen($word); // Use strlen here instead of mb_strlen because it is used by str_pad
-                                             // which is not multibyte compatible
-                $l   = str_pad($l, intval($cur + 0.5));
-            }
-            $res .= trim($l)."\n";
-        }
-        return trim($res);
-    }
-
-
-    public static function WikiToText($wiki, $just=false, $indent=0, $width=68, $title=false)
-    {
-        if (!$title) {
-            $oldrule12 = MiniWiki::$replacementHTML[MiniWiki::$title_index];
-            MiniWiki::$replacementHTML[MiniWiki::$title_index] = "'$0'";
-        }
-        //$text = trim($wiki);
-        //foreach (MiniWiki::$patternsWiki as $key=>$pattern) {
-        //    echo $key . " -  " . $pattern . "\n";
-        //    $text = preg_replace($pattern, MiniWiki::$replacementText[$key], $text);
-        //}
-        $text = preg_replace(MiniWiki::$patternsWiki, MiniWiki::$replacementText, trim($wiki));
-        if (!$title) {
-            MiniWiki::$replacementHTML[MiniWiki::$title_index] = $oldrule12;
-        }
-        $text = $just ? MiniWiki::justify($text, $width - $indent) :  wordwrap($text, $width - $indent);
-        if($indent) {
-            $ind = str_pad('',$indent);
-            $text = $ind.str_replace("\n","\n$ind",$text);
-        }
-        return $text;
-    }
-
-    static public function help($with_title = false)
-    {
-        if (!$with_title) {
-            $info12 = MiniWiki::$info[MiniWiki::$title_index];
-            unset(MiniWiki::$info[MiniWiki::$title_index]);
-        }
-
-        $res = array();
-        foreach (MiniWiki::$info as $value) {
-            $res[$value] = MiniWiki::wikiToHtml($value, true);
-        }
-
-        if (!$with_title) {
-            MiniWiki::$info[MiniWiki::$title_index] = $info12;
-        }
-        return $res;
-    }
-}
-
-MiniWiki::init();
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/platal.php b/classes/platal.php
deleted file mode 100644 (file)
index 4c1f60a..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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_DO_AUTH',   300);
-define('PL_FORBIDDEN', 403);
-define('PL_NOT_FOUND', 404);
-
-class Platal
-{
-    private $__mods;
-    private $__hooks;
-
-    protected $https;
-
-    public $ns;
-    public $path;
-    public $argv;
-
-    public function __construct()
-    {
-        $modules    = func_get_args();
-        if (is_array($modules[0])) {
-            $modules = $modules[0];
-        }
-        $this->path = trim(Get::_get('n', null), '/');
-
-        $this->__mods  = array();
-        $this->__hooks = array();
-
-        array_unshift($modules, 'core');
-        foreach ($modules as $module) {
-            $module = strtolower($module);
-            $this->__mods[$module] = $m = PLModule::factory($module);
-            $this->__hooks += $m->handlers();
-        }
-
-        global $globals;
-        if ($globals->mode == '') {
-            pl_redirect('index.html');
-        }
-    }
-
-    public function pl_self($n = null)
-    {
-        if (is_null($n))
-            return $this->path;
-
-        if ($n >= 0)
-            return join('/', array_slice($this->argv, 0, $n + 1));
-
-        if ($n <= -count($this->argv))
-            return $this->argv[0];
-
-        return join('/', array_slice($this->argv, 0, $n));
-    }
-
-    protected function find_hook()
-    {
-        $p = $this->path;
-
-        while ($p) {
-            if (array_key_exists($p, $this->__hooks))
-                break;
-
-            $p = substr($p, 0, strrpos($p, '/'));
-        }
-
-        if (empty($this->__hooks[$p])) {
-            return null;
-        }
-
-        $hook = $this->__hooks[$p];
-
-        if (!is_callable($hook['hook'])) {
-            return null;
-        }
-
-        $this->https = ($hook['type'] & NO_HTTPS) ? false : true;
-        $this->argv    = explode('/', substr($this->path, strlen($p)));
-        $this->argv[0] = $p;
-
-        return $hook;
-    }
-
-    protected function find_nearest_key($key, array &$array)
-    {
-        $keys    = array_keys($array);
-        if (in_array($key, $keys)) {
-            return $key;
-        }
-
-        if (($pos = strpos($key, '.php')) !== false) {
-            $key = substr($key, 0, $pos);
-        }
-
-        $has_end = in_array("#final#", $keys);
-        if (strlen($key) > 24 && $has_end) {
-            return "#final#";
-        }
-
-        foreach ($keys as $k) {
-            if ($k == "#final#") {
-                continue;
-            }
-            $lev = levenshtein($key, $k);
-
-            if ((!isset($val) || $lev < $val)
-                && ($lev <= strlen($k)/2 || strpos($k, $key) !== false || strpos($key, $k) !== false)) {
-                $val  = $lev;
-                $best = $k;
-            }
-        }
-        if (!isset($best) && $has_end) {
-            return "#final#";
-        } else if (isset($best)) {
-            return $best;
-        }
-        return null;
-    }
-
-    public function near_hook()
-    {
-        $hooks = array();
-        $leafs = array();
-        foreach ($this->__hooks as $hook=>$handler) {
-            if (!$this->check_perms($handler['perms'])) {
-                continue;
-            }
-            $parts = split('/', $hook);
-            $place =& $hooks;
-            foreach ($parts as $part) {
-                if (!isset($place[$part])) {
-                    $place[$part] = array();
-                }
-                $place =& $place[$part];
-            }
-            $leaf = $parts[count($parts)-1];
-            if (!isset($leafs[$leaf])) {
-                $leafs[$leaf] = $hook;
-            } else if (is_array($leafs[$leaf])) {
-                $leafs[$leaf][] = $hook;
-            } else {
-                $leafs[$leaf] = array($hook, $leafs[$leaf]);
-            }
-            $place["#final#"] = array();
-        }
-
-        // search for the nearest full path
-        $p = split('/', $this->path);
-        $place =& $hooks;
-        $link  = '';
-        foreach ($p as $k) {
-            if (!isset($ended)) {
-                $key = $this->find_nearest_key($k, $place);
-            } else {
-                $key = $k;
-            }
-            if ($key == "#final#") {
-                if (!array_key_exists($link, $this->__hooks)) {
-                    $link = '';
-                    break;
-                }
-                $key = $k;
-                $ended = true;
-            }
-            if (!is_null($key)) {
-                if (!empty($link)) {
-                    $link .= '/';
-                }
-                $link .= $key;
-                $place =& $place[$key];
-            } else {
-                $link = '';
-                break;
-            }
-        }
-        if ($link == $this->path) {
-            $link = '';
-        }
-        if ($link && levenshtein($link, $this->path) < strlen($link)/3) {
-            return $link;
-        }
-
-        // search for missing namespace (the given name is a leaf)
-        $leaf = array_shift($p);
-        $args = count($p) ? '/' . implode('/', $p) : '';
-        if (isset($leafs[$leaf]) && !is_array($leafs[$leaf]) && $leafs[$leaf] != $this->path) {
-            return $leafs[$leaf] . $args;
-        }
-        unset($val);
-        $best = null;
-        foreach ($leafs as $k=>&$path) {
-            if (is_array($path)) {
-                continue;
-            }
-            $lev = levenshtein($leaf, $k);
-
-            if ((!isset($val) || $lev < $val)
-                && ($lev <= strlen($k)/2 || strpos($k, $leaf) !== false || strpos($leaf, $k) !== false)) {
-                $val  = $lev;
-                $best = $path;
-            }
-        }
-        return $best == null ? ( $link ? $link : null ) : $best . $args;
-    }
-
-    protected function check_perms($perms)
-    {
-        if (!$perms) { // No perms, no check
-            return true;
-        }
-        $s_perms = S::v('perms');
-        return $s_perms->hasFlagCombination($perms);
-    }
-
-    private function call_hook(PlatalPage &$page)
-    {
-        $hook = $this->find_hook();
-        if (empty($hook)) {
-            return PL_NOT_FOUND;
-        }
-        global $globals;
-        if ($this->https && !$_SERVER['HTTPS'] && $globals->core->secure_domain) {
-            http_redirect('https://' . $globals->core->secure_domain . $_SERVER['REQUEST_URI']);
-        }
-
-        $args    =  $this->argv;
-        $args[0] =& $page;
-
-        if ($hook['auth'] > S::v('auth', AUTH_PUBLIC)) {
-            if ($hook['type'] & DO_AUTH) {
-                if (!call_user_func(array($globals->session, 'doAuth'))) {
-                    $this->force_login($page);
-                }
-            } else {
-                return PL_FORBIDDEN;
-            }
-        }
-        if ($hook['auth'] != AUTH_PUBLIC && !$this->check_perms($hook['perms'])) {
-            return PL_FORBIDDEN;
-        }
-
-        $val = call_user_func_array($hook['hook'], $args);
-        if ($val == PL_DO_AUTH) {
-            // The handler need a better auth with the current args
-            if (!call_user_func(array($globals->session, 'doAuth'))) {
-                $this->force_login($page);
-            }
-            $val = call_user_func_array($hook['hook'], $args);
-        }
-        return $val;
-    }
-
-    public function force_login(PlatalPage &$page)
-    {
-        header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
-        if (S::logged()) {
-            $page->changeTpl('core/password_prompt_logged.tpl');
-            $page->addJsLink('do_challenge_response_logged.js');
-        } else {
-            $page->changeTpl('core/password_prompt.tpl');
-            $page->addJsLink('do_challenge_response.js');
-        }
-        $page->assign('platal', $this);
-        $page->run();
-    }
-
-    public function run()
-    {
-        global $page;
-
-        new_skinned_page('platal/index.tpl');
-
-        if (empty($this->path)) {
-            $this->path = 'index';
-        }
-
-        $page->assign('platal', $this);
-        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->assign('platal', $this);
-        $page->run();
-    }
-
-    public function on_subscribe($forlife, $uid, $promo, $pass)
-    {
-        $args = func_get_args();
-        foreach ($this->__mods as $mod) {
-            if (!is_callable($mod, 'on_subscribe'))
-                continue;
-            call_user_func_array(array($mod, 'on_subscribe'), $args);
-        }
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/platalglobals.php.in b/classes/platalglobals.php.in
new file mode 100644 (file)
index 0000000..43140c6
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 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 PlatalGlobals extends PlGlobals
+{
+    /** The x.org version */
+    public $version = '@VERSION@';
+
+    /** db params */
+    public $dbdb               = 'x4dat';
+    public $dbhost             = 'localhost';
+    public $dbuser             = 'x4dat';
+    public $dbpwd              = 'x4dat';
+    public $dbcharset          = 'utf8';
+
+    /** default skin */
+    public $skin;
+    public $register_skin;
+
+    public function __construct()
+    {
+        parent::__construct(array('platal.ini', 'platal.conf'));
+    }
+
+    public function init()
+    {
+        $this->bootstrap(array('NbIns'), array($this, 'updateNbIns'));
+        $this->bootstrap(array('NbValid'), array($this, 'updateNbValid'));
+    }
+
+    public function asso($key=null)
+    {
+        static $aid = null;
+
+        if (is_null($aid)) {
+            $gp = Get::v('n');
+            if ($p = strpos($gp, '/')) {
+                $gp = substr($gp, 0, $p);
+            }
+
+            if ($gp) {
+                $res = XDB::query('SELECT  a.*, d.nom AS domnom,
+                                           FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc,
+                                           FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub
+                                     FROM  groupex.asso AS a
+                                LEFT JOIN  groupex.dom  AS d ON d.id = a.dom
+                                    WHERE  diminutif = {?}', $gp);
+                if (!($aid = $res->fetchOneAssoc())) {
+                    $aid = array();
+                }
+            } else {
+                $aid = array();
+            }
+        }
+        if (empty($key)) {
+            return $aid;
+        } elseif ( isset($aid[$key]) ) {
+            return $aid[$key];
+        } else {
+            return null;
+        }
+    }
+
+
+    public function updateNbIns()
+    {
+        $res = XDB::query("SELECT  COUNT(*)
+                             FROM  auth_user_md5
+                            WHERE  perms IN ('admin','user') AND deces=0");
+        $cnt = $res->fetchOneCell();
+        $this->changeDynamicConfig(array('NbIns' => $cnt));
+    }
+
+    public function updateNbValid()
+    {
+        $res = XDB::query("SELECT  COUNT(*)
+                             FROM  requests");
+        $this->changeDynamicConfig(array('NbValid' => $res->fetchOneCell()));
+    }
+}
+
+
+/******************************************************************************
+ * Dynamic configuration update/edition stuff
+ *****************************************************************************/
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
diff --git a/classes/platalpage.php b/classes/platalpage.php
deleted file mode 100644 (file)
index f3bb2fa..0000000
+++ /dev/null
@@ -1,445 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 'smarty/libs/Smarty.class.php';
-
-abstract class PlatalPage extends Smarty
-{
-    private $_page_type;
-    private $_tpl;
-    private $_errors;
-    private $_failure;
-    private $_jsonVars;
-
-    // {{{ function PlatalPage()
-
-    public function __construct($tpl, $type = SKINNED)
-    {
-        parent::Smarty();
-
-        global $globals;
-
-        $this->caching       = false;
-        $this->config_overwrite = false;
-        $this->use_sub_dirs  = false;
-        $this->template_dir  = $globals->spoolroot."/templates/";
-        $this->compile_dir   = $globals->spoolroot."/spool/templates_c/";
-        array_unshift($this->plugins_dir, $globals->spoolroot."/plugins/");
-        $this->config_dir    = $globals->spoolroot."/configs/";
-
-        $this->compile_check = !empty($globals->debug);
-
-        $this->changeTpl($tpl, $type);
-        $this->_errors    = array('errors' => array());
-        $this->_jsonVars  = array();
-        $this->_failure   = false;
-
-        if ($globals->mode != 'rw') {
-            $this->trigError("En raison d'une maintenance, une partie des fonctionnalités du site sont"
-                      . " actuellement désactivée, en particuliers aucune donnée ne sera sauvegardée");
-        }
-        $this->register_prefilter('at_to_globals');
-        $this->addJsLink('xorg.js');
-        $this->addJsLink('jquery.js');
-    }
-
-    // }}}
-    // {{{ function changeTpl()
-
-    public function changeTpl($tpl, $type = SKINNED)
-    {
-      $this->_tpl       = $tpl;
-      $this->_page_type = $type;
-      $this->assign('xorg_tpl', $tpl);
-    }
-
-    // }}}
-    // {{{ function raw()
-
-    public function raw()
-    {
-        global $globals;
-        $this->assign('globals', $globals);
-        return $this->fetch($this->_tpl);
-    }
-
-    // }}}
-    // {{{ function _run()
-
-    protected function _run($skin)
-    {
-        global $globals, $TIME_BEGIN;
-
-        session_write_close();
-
-        $this->register_prefilter('trimwhitespace');
-        $this->register_prefilter('form_force_encodings');
-        $this->register_prefilter('wiki_include');
-        $this->register_prefilter('if_has_perms');
-        $this->assign('xorg_triggers', $this->_errors);
-        $this->assign('xorg_errors', $this->nb_errs());
-        $this->assign('xorg_failure', $this->_failure);
-        $this->assign('globals', $globals);
-
-        if (Env::has('json') && count($this->_jsonVars)) {
-            return $this->jsonDisplay();
-        }
-
-        if (Env::v('display') == 'light') {
-            $this->_page_type = SIMPLE;
-        } elseif (Env::v('display') == 'raw') {
-            $this->_page_type = NO_SKIN;
-        } elseif (Env::v('display') == 'full') {
-            $this->_page_typ = SKINNED;
-        }
-
-        switch ($this->_page_type) {
-          case NO_SKIN:
-            if (!($globals->debug & DEBUG_SMARTY)) {
-                error_reporting(0);
-            }
-            $this->display($this->_tpl);
-            exit;
-
-          case SIMPLE:
-            $this->assign('simple', true);
-
-          case SKINNED:
-            $this->register_modifier('escape_html', 'escape_html');
-            $this->default_modifiers = Array('@escape_html');
-        }
-        if (S::i('auth') <= AUTH_PUBLIC) {
-            $this->register_outputfilter('hide_emails');
-        }
-        $this->addJsLink('wiki.js');
-        header("Accept-Charset: utf-8");
-        if (Env::v('forceXml')) {
-            header("Content-Type: text/xml; charset=utf-8");
-        }
-
-        if (!$globals->debug) {
-            error_reporting(0);
-            $this->display($skin);
-            exit;
-        }
-
-        $this->assign('validate', true);
-        if (!($globals->debug & DEBUG_SMARTY)) {
-            error_reporting(0);
-        }
-        $START_SMARTY = microtime(true);
-        $result = $this->fetch($skin);
-        $ttime  = sprintf('Temps total: %.02fs (Smarty %.02fs) - Mémoire totale : %dKo<br />',
-                          microtime(true) - $TIME_BEGIN, microtime(true) - $START_SMARTY,
-                          memory_get_peak_usage(true) / 1024);
-        if ($globals->debug & DEBUG_BT) {
-            PlBacktrace::clean();
-            $this->assign_by_ref('backtraces', PlBacktrace::$bt);
-            $result = str_replace('@@BACKTRACE@@', $this->fetch('skin/common.backtrace.tpl'), $result);
-        } else {
-            $result = str_replace('@@BACKTRACE@@', '', $result);
-        }
-
-        $replc  = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />";
-        if ($globals->debug & DEBUG_VALID) {
-            $fd = fopen($this->compile_dir."/valid.html","w");
-            fwrite($fd, $result);
-            fclose($fd);
-
-            exec($globals->spoolroot."/bin/devel/xhtml.validate.pl ".$this->compile_dir."/valid.html", $val);
-            foreach ($val as $h) {
-                if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) {
-                    $replc = '<span style="color: #080;">HTML OK</span><br />';
-                    if ($m[1]) {
-                        $replc = "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}"
-                            ."/valid.html&amp;ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />";
-                    }
-                    break;
-                }
-            }
-        }
-
-        echo str_replace("@HOOK@", $ttime.$replc, $result);
-        exit;
-    }
-
-    abstract public function run();
-
-    // }}}
-    // {{{ function nb_errs()
-
-    public function nb_errs()
-    {
-        return count($this->_errors['errors']);
-    }
-
-    // }}}
-    // {{{ function trig()
-
-    private function trig($msg, $type = 'errors')
-    {
-        if (!isset($this->_errors[$type])) {
-            $this->_errors[$type] = array();
-        }
-        $this->_errors[$type][] = $msg;
-    }
-
-    public function trigError($msg)
-    {
-        $this->trig($msg, 'errors');
-    }
-
-    public function trigWarning($msg)
-    {
-        $this->trig($msg, 'warnings');
-    }
-
-    public function trigSuccess($msg)
-    {
-        $this->trig($msg, 'success');
-    }
-
-    // }}}
-    // {{{ function kill()
-
-    public function kill($msg)
-    {
-        global $platal;
-
-        $this->assign('platal', $platal);
-        $this->trigError($msg);
-        $this->_failure = true;
-        $this->run();
-    }
-
-    // }}}
-    // {{{ function addJsLink
-
-    public function addJsLink($path)
-    {
-        $this->append('xorg_js', $path);
-    }
-
-    // }}}
-    // {{{ function addCssLink
-
-    public function addCssLink($path)
-    {
-        $this->append('xorg_css', $path);
-    }
-
-    // }}}
-    // {{{ function addCssInline
-
-    public function addCssInline($css)
-    {
-        if (!empty($css)) {
-            $this->append('xorg_inline_css', $css);
-        }
-    }
-
-    // }}}
-    // {{{ function setRssLink
-
-    public function setRssLink($title, $path)
-    {
-        $this->assign('xorg_rss', array('title' => $title, 'href' => $path));
-    }
-
-    // }}}
-    // {{{ function jsonDisplay
-    protected function jsonDisplay()
-    {
-        header("Content-type: text/javascript; charset=utf-8");
-        array_walk_recursive($this->_jsonVars, "escape_xorgDB");
-        $jsonbegin = Env::v('jsonBegin');
-        $jsonend = Env::v('jsonEnd');
-        if (Env::has('jsonVar')) {
-            $jsonbegin = Env::v('jsonVar').' = ';
-            $jsonend = ';';
-        } elseif (Env::has('jsonFunc')) {
-            $jsonbegin = Env::v('jsonFunc').'(';
-            $jsonend = ');';
-        }
-        echo $jsonbegin, json_encode($this->_jsonVars), $jsonend;
-        exit;
-    }
-    // }}}
-    // {{{ function jsonAssign
-    public function jsonAssign($var, $value)
-    {
-        $this->_jsonVars[$var] = $value;
-    }
-
-    // }}}
-}
-
-function escape_xorgDB(&$item, $key)
-{
-    if (is_a($item, 'XOrgDBIterator')) {
-        $expanded = array();
-        while ($a = $item->next()) {
-            $expanded[] = $a;
-        }
-        $item = $expanded;
-    }
-}
-
-// {{{ function escape_html ()
-
-/**
- * default smarty plugin, used to auto-escape dangerous html.
- *
- * < --> &lt;
- * > --> &gt;
- * " --> &quot;
- * & not followed by some entity --> &amp;
- */
-function escape_html($string)
-{
-    if (is_string($string)) {
-        return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
-    } else {
-        return $string;
-    }
-}
-
-// }}}
-// {{{ function at_to_globals()
-
-/**
- * helper
- */
-
-function _to_globals($s) {
-    global $globals;
-    $t = explode('.',$s);
-    if (count($t) == 1) {
-        return var_export($globals->$t[0],true);
-    } else {
-        return var_export($globals->$t[0]->$t[1],true);
-    }
-}
-
-/**
- * compilation plugin used to import $globals confing through #globals.foo.bar# directives
- */
-
-function at_to_globals($tpl_source, &$smarty)
-{
-    return preg_replace('/#globals\.([a-zA-Z0-9_.]+?)#/e', '_to_globals(\'\\1\')', $tpl_source);
-}
-
-// }}}
-// {{{  function trimwhitespace
-
-function trimwhitespace($source, &$smarty)
-{
-    $tags = '(script|pre|textarea)';
-    preg_match_all("!<$tags.*?>.*?</(\\1)>!ius", $source, $tagsmatches);
-    $source = preg_replace("!<$tags.*?>.*?</(\\1)>!ius", "&&&tags&&&", $source);
-
-    // remove all leading spaces, tabs and carriage returns NOT
-    // preceeded by a php close tag.
-    $source = preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source);
-    $source = preg_replace("!&&&tags&&&!e",  'array_shift($tagsmatches[0])', $source);
-
-    return $source;
-}
-
-// }}}
-// {{{ function wiki_include
-
-function wiki_include($source, &$smarty)
-{
-    return preg_replace('/\{include( [^}]*)? wiki=([^} ]+)(.*?)\}/ui',
-                        '{include\1 file="../spool/wiki.d/cache_\2.tpl"\3 included=1}',
-                        $source);
-}
-
-// }}}
-//{{{ function hasPerm
-
-function if_has_perms($source, &$smarty)
-{
-    $source = preg_replace('/\{if([^}]*) (\!?)hasPerms\(([^)]+)\)([^}]*)\}/',
-                           '{if\1 \2$smarty.session.perms->hasFlagCombination(\3)\4}',
-                           $source);
-    return preg_replace('/\{if([^}]*) (\!?)hasPerm\(([^)]+)\)([^}]*)\}/',
-                        '{if\1 \2($smarty.session.perms && $smarty.session.perms->hasFlag(\3))\4}',
-                        $source);
-}
-
-// }}}
-// {{{
-
-function form_force_encodings($source, &$smarty)
-{
-    return preg_replace('/<form[^\w]/',
-                        '\0 accept-charset="utf-8" ',
-                        $source);
-}
-
-// }}}
-// {{{ function hide_emails
-
-function _hide_email($source)
-{
-    $source = str_replace("\n", '', $source);
-    return '<script type="text/javascript">//<![CDATA[' . "\n" .
-           'Nix.decode("' . addslashes(str_rot13($source)) . '");' . "\n" .
-           '//]]></script>';
-}
-
-function hide_emails($source, &$smarty)
-{
-    if (!strpos($source, '@')) {
-        return $source;
-    }
-
-    //prevent email replacement in <script> and <textarea>
-    $tags = '(script|textarea|select)';
-    preg_match_all("!<$tags.*?>.*?</(\\1)>!ius", $source, $tagsmatches);
-    $source = preg_replace("!<$tags.*?>.*?</(\\1)>!ius", "&&&tags&&&", $source);
-
-    //catch all emails in <a href="mailto:...">
-    preg_match_all("!<a[^>]+href=[\"'][^\"']*[-a-z0-9+_.]+@[-a-z0-9_.]+[^\"']*[\"'].*?>.*?</a>!ius", $source, $ahref);
-    $source = preg_replace("!<a[^>]+href=[\"'][^\"']*[-a-z0-9+_.]+@[-a-z0-9_.]+[^\"']*[\"'].*?>.*?</a>!ius", '&&&ahref&&&', $source);
-
-    //prevant replacement in tag attributes
-    preg_match_all("!<[^>]+[-a-z0-9_+.]+@[-a-z0-9_.]+.+?>!ius", $source, $misc);
-    $source = preg_replace("!<[^>]+[-a-z0-9_+.]+@[-a-z0-9_.]+.+?>!ius", '&&&misc&&&', $source);
-
-    //catch !
-    $source = preg_replace('!([-a-z0-9_+.]+@[-a-z0-9_.]+)!iue', '_hide_email("\1")', $source);
-    $source = preg_replace('!&&&ahref&&&!e', '_hide_email(array_shift($ahref[0]))', $source);
-
-    // restore data
-    $source = preg_replace('!&&&misc&&&!e', 'array_shift($misc[0])', $source);
-    $source = preg_replace("!&&&tags&&&!e",  'array_shift($tagsmatches[0])', $source);
-
-    return $source;
-}
-
-// }}}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plbacktrace.php b/classes/plbacktrace.php
deleted file mode 100644 (file)
index 9fb80ec..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-/** Ligth debugging tool to generate execution backtrace
- */
-class PlBacktrace
-{
-    static public $bt = array();
-
-    public $traces    = array();
-    public $totaltime = 0.0;
-    public $error     = false;
-
-    function __construct($name, array $init = array(), $sizef = 'rows', $timef = 'exectime', $errorf = 'error')
-    {
-        PlBacktrace::$bt[$name] = $this;
-        foreach ($init as &$entry) {
-            $this->add($entry, $sizef, $timef, $errorf);
-        }
-    }
-
-    private function fixCharset($action)
-    {
-        if (!is_string($action)) {
-            return $action;
-        } else {
-            return is_utf8($action) ? $action : utf8_encode($action);
-        }
-    }
-
-    private function add(array &$entry, $sizef = 'rows', $timef = 'exectime', $errorf = 'error')
-    {
-        $trace = array();
-        $trace['action'] = $this->fixCharset($entry['action']);
-        unset($entry['action']);
-        $trace['exectime'] = @$entry[$timef];
-        $this->totaltime += $trace['exectime'];
-        unset($entry[$timef]);
-        $trace['rows'] = @$entry[$sizef];
-        unset($entry[$sizef]);
-        $trace['error'] = $this->fixCharset(@$entry[$errorf]);
-        unset($entry[$errorf]);
-        if ($trace['error']) {
-            $this->error = true;
-        }
-        $trace['data'] = array($this->fixCharset($entry));
-        $this->traces[] =& $trace;
-    }
-
-    public function newEvent($action, $rows = 0, $error = null, array $userdata = array())
-    {
-        $trace = array('action' => $this->fixCharset($action), 'time' => 0);
-        $this->traces[] =& $trace;
-        $this->update($rows, $error, $userdata);
-    }
-
-    public function start($action)
-    {
-        $this->traces[] =  array('action' => $this->fixCharset($action), 'starttime' => microtime(true));;
-    }
-
-    public function stop($rows = 0, $error = null, array $userdata = array())
-    {
-        $time = microtime(true);
-        if (!$this->traces) {
-            return;
-        }
-        $trace =& $this->traces[count($this->traces) - 1];
-        $trace['exectime'] = $time - $trace['starttime'];
-        unset($trace['starttime']);
-        $this->totaltime += $trace['exectime'];
-        $this->update($rows, $error, $userdata);
-    }
-
-    public function update($rows = 0, $error = null, array $userdata = array())
-    {
-        $trace =& $this->traces[count($this->traces) - 1];
-        $trace['rows']  = $rows;
-        $trace['error'] = $this->fixCharset($error);
-        array_walk_recursive($userdata, array($this, 'fixCharset'));
-        $trace['data']  = $userdata;
-        if ($trace['error']) {
-            $this->error = true;
-        }
-    }
-
-    public static function clean()
-    {
-        foreach (PlBacktrace::$bt as $name=>&$entry) {
-            if (!$entry->traces) {
-                unset(PlBacktrace::$bt[$name]);
-            }
-        }
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/pliterator.php b/classes/pliterator.php
deleted file mode 100644 (file)
index 0b5f254..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-interface PlIterator
-{
-    public function next();
-    public function total();
-    public function first();
-    public function last();
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plmailer.php b/classes/plmailer.php
deleted file mode 100644 (file)
index 2106d50..0000000
+++ /dev/null
@@ -1,336 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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('smarty/libs/Smarty.class.php');
-
-/** Classe de mail avec corps en templates.
- */
-class PlMail extends Smarty
-{
-    private $tpl;
-    private $mailer = null;
-
-    function __construct($tpl)
-    {
-        global $globals;
-        $this->tpl           = $tpl;
-        $this->caching       = false;
-        $this->compile_check = true;
-
-        $this->template_dir  = $globals->spoolroot . "/templates/";
-        $this->compile_dir   = $globals->spoolroot . "/spool/mails_c/";
-        $this->config_dir    = $globals->spoolroot . "/configs/";
-        array_unshift($this->plugins_dir, $globals->spoolroot."/plugins/");
-
-        $this->register_outputfilter(Array($this, 'mail_format'));
-        $this->register_function('from',    Array($this, 'setFrom'));
-        $this->register_function('to',      Array($this, 'addTo'));
-        $this->register_function('cc',      Array($this, 'addCc'));
-        $this->register_function('bcc',     Array($this, 'addBcc'));
-        $this->register_function('subject', Array($this, 'setSubject'));
-        $this->register_function('add_header', Array($this, 'addHeader'));
-        $this->assign_by_ref('globals', $globals);
-    }
-
-    public static function &get(&$mailer, $tpl)
-    {
-        static $plmail;
-        if (!isset($plmail) || $plmail->tpl != $tpl) {
-            $plmail = new PlMail($tpl);
-        }
-        $plmail->mailer =& $mailer;
-        return $plmail;
-    }
-
-    public function run($version)
-    {
-        $this->assign('mail_part', $version);
-        $text = $this->fetch($this->tpl);
-        if ($version == 'text') {
-            return wordwrap($text, 78);
-        }
-        return $text;
-    }
-
-    /** used to remove the empty lines due to {from ...}, {to ...} ... functions */
-    static public function mail_format($output, &$smarty)
-    {
-        return "\n".trim($output)."\n";
-    }
-
-    static protected function format_addr(&$params)
-    {
-        if (isset($params['full'])) {
-            return $params['full'];
-        } elseif (empty($params['text'])) {
-            return $params['addr'];
-        } else {
-            return $params['text'].' <'.$params['addr'].'>';
-        }
-    }
-
-    /** template function : from.
-     * {from full=...} for an already formatted address
-     * {from addr=... [text=...]} else
-     */
-    public function setFrom($params, &$smarty)
-    {
-        $smarty->mailer->setFrom(PlMail::format_addr($params));
-    }
-
-    /** template function : to.
-     * {to full=...} for an already formatted address
-     * {to addr=... [text=...]} else
-     */
-    public function addTo($params, &$smarty)
-    {
-        $smarty->mailer->addTo(PlMail::format_addr($params));
-    }
-
-    /** template function : cc.
-     * {cc full=...} for an already formatted address
-     * {cc addr=... [text=...]} else
-     */
-    public function addCc($params, &$smarty)
-    {
-        $smarty->mailer->addCc(PlMail::format_addr($params));
-    }
-
-    /** template function : bcc.
-     * {bcc full=...} for an already formatted address
-     * {bcc addr=... [text=...]} else
-     */
-    public function addBcc($params, &$smarty)
-    {
-        $smarty->mailer->addBcc(PlMail::format_addr($params));
-    }
-
-    /** template function : subject.
-     * {subject text=...}
-     */
-    public function setSubject($params, &$smarty)
-    {
-        $smarty->mailer->setSubject($params['text']);
-    }
-
-    /** template function : add_header.
-     * {add_header name=... value=...}
-     */
-    public function addHeader($params, &$smarty)
-    {
-        $smarty->mailer->addHeader($params['name'], $params['value']);
-    }
-}
-
-require_once('Mail.php');
-require_once('Mail/mime.php');
-
-/** Class for sending inline or multipart-emails.
- * Based on Diogenes' HermesMailer
- */
-class PlMailer extends Mail_Mime {
-
-    private $mail;
-    private $page    = null;
-    private $charset;
-    private $wiki    = null;
-
-    function __construct($tpl = null, $charset = "UTF-8")
-    {
-        $this->charset = $charset;
-        $this->Mail_Mime("\n");
-        $this->mail = Mail::factory('sendmail', Array('sendmail_args' => '-oi'));
-        if (!is_null($tpl)) {
-            $this->page =& PlMail::get($this, $tpl);
-        }
-    }
-
-    /**
-     * converts all : Foo Bar Baz <quux@foobar.org> into "Foo Bar Baz" <quux@foobar.org> which is RFC compliant
-     */
-    private function correct_emails($email)
-    {
-        return preg_replace('!(^|, *)([^<"]+?) *(<[^>]*>)!u', '\1"\2" \3', $email);
-    }
-
-    public function addTo($email)
-    {
-        $email = $this->correct_emails($email);
-        if (isset($this->_headers['To'])) {
-            $this->_headers['To'] .= ", $email";
-        } else {
-            $this->_headers['To'] = $email;
-        }
-    }
-
-    public function addCc($email)
-    {
-        return parent::addCc($this->correct_emails($email));
-    }
-
-    public function addBcc($email)
-    {
-        return parent::addBcc($this->correct_emails($email));
-    }
-
-    public function setFrom($email)
-    {
-        return parent::setFrom($this->correct_emails($email));
-    }
-
-    public function addHeader($hdr,$val)
-    {
-        switch($hdr) {
-            case 'From':
-                $this->setFrom($val);
-                break;
-
-            case 'To':
-                unset($this->_headers[$hdr]);
-                $this->addTo($val);
-                break;
-
-            case 'Cc':
-                unset($this->_headers[$hdr]);
-                $this->addCc($val);
-                break;
-
-            case 'Bcc':
-                unset($this->_headers[$hdr]);
-                $this->addBcc($val);
-                break;
-
-            default:
-                $this->headers(Array($hdr=>$val));
-        }
-    }
-
-    public function addUploadAttachment(PlUpload &$upload, $name)
-    {
-        $encoding = $upload->isType('text') ? 'quoted-printable' : 'base64';
-        $this->addAttachment($upload->getContents(), $upload->contentType(), $name, false, $encoding);
-    }
-
-    public function assign($var, $value)
-    {
-        if (!is_null($this->page)) {
-            $this->page->assign($var, $value);
-        }
-    }
-
-    public function assign_by_ref($var, &$value)
-    {
-        if (!is_null($this->page)) {
-            $this->page->assign_by_ref($var, $value);
-        }
-    }
-
-    public function register_modifier($var, $callback)
-    {
-        if (!is_null($this->page)) {
-            $this->page->register_modifier($var, $callback);
-        }
-    }
-
-    public function register_function($var, $callback)
-    {
-        if (!is_null($this->page)) {
-            $this->page->register_function($var, $callback);
-        }
-    }
-
-    public function setWikiBody($wiki)
-    {
-        $this->wiki = $wiki;
-    }
-
-    private function processPage($with_html = true)
-    {
-        if (!is_null($this->page)) {
-            global $globals;
-            if (!($globals->debug & DEBUG_SMARTY)) {
-                $level = error_reporting(0);
-            }
-            $this->page->run('head'); // process page headers
-            $this->wiki = trim($this->page->run('wiki')); // get wiki
-            if (!$this->wiki) {
-                $this->setTxtBody($this->page->run('text'));
-                if ($with_html) {
-                    $html = trim($this->page->run('html'));
-                    if (!empty($html)) {
-                        $this->setHtmlBody($html);
-                    }
-                }
-            }
-            if (!($globals->debug & DEBUG_SMARTY)) {
-                error_reporting($level);
-            }
-        }
-        if ($this->wiki) {
-            $this->setTxtBody(MiniWiki::WikiToText($this->wiki, false, 0, 78));
-            if ($with_html) {
-                $this->setHtmlBody('<html><body>' . MiniWiki::WikiToHtml($this->wiki, true) . '</body></html>');
-            }
-        }
-    }
-
-    public function send($with_html = true)
-    {
-        $this->processPage($with_html);
-        if (S::v('forlife')) {
-            global $globals;
-            $this->addHeader('X-Org-Mail', S::v('forlife') . '@' . $globals->mail->domain);
-        }
-        $addrs = Array();
-        foreach(Array('To', 'Cc', 'Bcc') as $hdr) {
-            if(isset($this->_headers[$hdr])) {
-                require_once 'Mail/RFC822.php';
-                $parsed = @Mail_RFC822::parseAddressList($this->_headers[$hdr]);
-                if (is_array($parsed)) {
-                    $addrs = array_merge($addrs, $parsed);
-                }
-            }
-        }
-        if(empty($addrs)) {
-            return false;
-        }
-
-        $dests = Array();
-        foreach($addrs as $a) {
-            $dests[] = "{$a->mailbox}@{$a->host}";
-        }
-
-        // very important to do it in THIS order very precisely.
-        $body = $this->get(array('text_charset' => $this->charset,
-                                 'text_encoding' => '8bit',
-                                 'html_charset' => $this->charset,
-                                 'head_charset' => $this->charset));
-        $hdrs = $this->headers();
-        if (empty($hdrs['From'])) {
-            trigger_error('Empty "From", mail not sent', E_USER_WARNING);
-            return false;
-        }
-        return $this->mail->send($dests, $hdrs, $body);
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plmodule.php b/classes/plmodule.php
deleted file mode 100644 (file)
index 06e5da8..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-abstract class PLModule
-{
-    abstract function handlers();
-
-    /** Register a hook
-     * @param fun name of the handler (the exact name will be handler_$fun)
-     * @param auth authentification level of needed to run this handler
-     * @param perms permission required to run this handler
-     * @param type additionnal flags
-     *
-     * Perms syntax is the following:
-     * perms = rights(,rights)*
-     * rights = right(:right)*
-     * right is an atomic right permission (like 'admin', 'user', 'groupadmin', 'groupmember'...)
-     *
-     * If type is set to NO_AUTH, the system will return 403 instead of asking auth data
-     * this is useful for Ajax handler
-     * If type is not set to NO_SKIN, the system will consider redirecting the user to https
-     */
-    public function make_hook($fun, $auth, $perms = 'user', $type = DO_AUTH)
-    {
-        return array('hook'  => array($this, 'handler_'.$fun),
-                     'auth'  => $auth,
-                     'perms' => $perms,
-                     'type'  => $type);
-    }
-
-    /* static functions */
-
-    public static function factory($modname)
-    {
-        $mod_path = dirname(__FILE__) . '/../modules/' . $modname . '.php';
-        $class    = ucfirst($modname) . 'Module';
-
-        require_once $mod_path;
-        return new $class();
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plprofiler.php b/classes/plprofiler.php
deleted file mode 100644 (file)
index 1734ff5..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 PlProfiler
-{
-    static public function start($name, $info = "action")
-    {
-        global $globals;
-        if (!($globals->debug & DEBUG_BT)) {
-            return false;
-        }
-        if (!isset(PlBacktrace::$bt[$name])) {
-            new PlBacktrace($name);
-        }
-        PlBacktrace::$bt[$name]->start($info);
-        return true;
-    }
-
-    static public function step($name, $info = "action")
-    {
-        PlProfiler::stop($name);
-        PlProfiler::start($name, $info);
-    }
-
-    static public function stop($name)
-    {
-        global $globals;
-        if (!($globals->debug & DEBUG_BT)) {
-            return false;
-        }
-        PlBacktrace::$bt[$name]->stop();
-        return true;
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plset.php b/classes/plset.php
deleted file mode 100644 (file)
index 71bd5ee..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-/** UserSet is a light-weight Model/View tool for displaying a set of items
- */
-class PlSet
-{
-    private $from    = null;
-    private $groupby = null;
-    private $joins   = null;
-    private $where   = null;
-
-    private $count   = null;
-
-    private $mods      = array();
-    private $modParams = array();
-    private $mod       = null;
-    private $default   = null;
-
-    public function __construct($from, $joins = '', $where = '', $groupby = '')
-    {
-        $this->from    = $from;
-        $this->joins   = $joins;
-        $this->where   = $where;
-        $this->groupby = $groupby;
-    }
-
-    public function addMod($name, $description, $default = false, array $params = array())
-    {
-        $name = strtolower($name);
-        $this->mods[$name]      = $description;
-        $this->modParams[$name] = $params;
-        if ($default) {
-            $this->default = $name;
-        }
-    }
-
-    public function rmMod($name)
-    {
-        $name = strtolower($name);
-        unset($this->mods[$name]);
-    }
-
-    private function &query($fields, $from, $joins, $where, $groupby, $order, $limit)
-    {
-        if (trim($order)) {
-            $order = "ORDER BY $order";
-        }
-        if (trim($where)) {
-            $where = "WHERE $where";
-        }
-        if (trim($groupby)) {
-            $groupby = "GROUP BY $groupby";
-        }
-        $query = "SELECT  SQL_CALC_FOUND_ROWS
-                          $fields
-                    FROM  $from
-                          $joins
-                          $where
-                          $groupby
-                          $order
-                          $limit";
-//        echo $query;
-//        print_r($this);
-        $it    = XDB::query($query);
-        $it    = $it->fetchAllAssoc();
-        $count = XDB::query('SELECT FOUND_ROWS()');
-        $this->count = intval($count->fetchOneCell());
-        return $it;
-    }
-
-    public function args()
-    {
-        $get = $_GET;
-        unset($get['n']);
-        return $get;
-    }
-
-    protected function encodeArgs(array $args, $encode = false)
-    {
-        $qs = '?';
-        $sep = '&';
-        foreach ($args as $k=>$v) {
-            if (!$encode) {
-                $k = urlencode($k);
-                $v = urlencode($v);
-            }
-            $qs .= "$k=$v$sep";
-        }
-        return $encode ? urlencode($qs) : $qs;
-    }
-
-    public function &get($fields, $joins, $where, $groupby, $order, $limitcount = null, $limitfrom = null)
-    {
-        if (!is_null($limitcount)) {
-            if (!is_null($limitfrom)) {
-                $limitcount = "$limitfrom,$limitcount";
-            }
-            $limitcount = "LIMIT $limitcount";
-        }
-        $joins  = $this->joins . ' ' . $joins;
-        if (trim($this->where)) {
-            if (trim($where)) {
-                $where .= ' AND ';
-            }
-            $where .= $this->where;
-        }
-        if (!$groupby) {
-            $groupby = $this->groupby;
-        }
-        return $this->query($fields, $this->from, $joins, $where, $groupby, $order, $limitcount);
-    }
-
-    public function count()
-    {
-        return $this->count;
-    }
-
-    private function &buildView($view, $data)
-    {
-        $view = strtolower($view);
-        if (!$view || !class_exists($view . 'View') || !isset($this->mods[$view])) {
-            reset($this->mods);
-            $view = $this->default ? $this->default : key($this->mods);
-        }
-        $this->mod = $view;
-        $class = $view . 'View';
-        if (!class_exists($class)) {
-            $view = null;
-        } else {
-            $view = new $class($this, $data, $this->modParams[$this->mod]);
-            if (!$view instanceof PlView) {
-                $view = null;
-            }
-        }
-        return $view;
-    }
-
-    public function apply($baseurl, PlatalPage &$page, $view = null, $data = null)
-    {
-        $view =& $this->buildView($view, $data);
-        if (is_null($view)) {
-            return false;
-        }
-        $args = $view->args();
-        if (!isset($args['rechercher'])) {
-            $args['rechercher'] = 'Chercher';
-        }
-        $page->changeTpl('core/plset.tpl');
-        $page->assign('plset_base', $baseurl);
-        $page->assign('plset_mods', $this->mods);
-        $page->assign('plset_mod', $this->mod);
-        $page->assign('plset_search', $this->encodeArgs($args));
-        $page->assign('plset_search_enc', $this->encodeArgs($args, true));
-        foreach ($this->modParams[$this->mod] as $param=>$value) {
-            $page->assign($this->mod . '_' . $param, $value);
-        }
-        $page->assign('plset_content', $view->apply($page));
-        $page->assign('plset_count', $this->count);
-        return true;
-    }
-}
-
-interface PlView
-{
-    public function __construct(PlSet &$set, $data, array $params);
-    public function apply(PlatalPage &$page);
-    public function args();
-}
-
-abstract class MultipageView implements PlView
-{
-    protected $set;
-
-    public $pages  = 1;
-    public $page   = 1;
-    public $offset = 0;
-
-    protected $entriesPerPage = 20;
-    protected $params = array();
-
-    protected $sortkeys = array();
-    protected $defaultkey = null;
-
-    protected $bound_field = null;
-
-    public function __construct(PlSet &$set, $data, array $params)
-    {
-        $this->set   =& $set;
-        $this->page   = Env::i('page', 1);
-        $this->offset = $this->entriesPerPage * ($this->page - 1);
-        $this->params = $params;
-    }
-
-    public function joins()
-    {
-        return null;
-    }
-
-    public function where()
-    {
-        return null;
-    }
-
-    public function groupBy()
-    {
-        return null;
-    }
-
-    public function bounds()
-    {
-        return null;
-    }
-
-    protected function addSortKey($name, array $keys, $desc, $default = false)
-    {
-        $this->sortkeys[$name] = array('keys' => $keys, 'desc' => $desc);
-        if (!$this->defaultkey || $default) {
-            $this->defaultkey = $name;
-        }
-    }
-
-    public function order()
-    {
-        $order = Env::v('order', $this->defaultkey);
-        $invert = ($order{0} == '-');
-        if ($invert) {
-            $order = substr($order, 1);
-        }
-        $list = array();
-        foreach ($this->sortkeys[$order]['keys'] as $item) {
-            $desc = ($item{0} == '-');
-            if ($desc) {
-                $item = substr($item, 1);
-            }
-            if ($desc xor $invert) {
-                $item .= ' DESC';
-            }
-            $list[] = $item;
-        }
-        return implode(', ', $list);
-    }
-
-    abstract public function templateName();
-
-    public function apply(PlatalPage &$page)
-    {
-        $res = $this->set->get($this->fields(),
-                               $this->joins(),
-                               $this->where(),
-                               $this->groupBy(),
-                               $this->order(),
-                               $this->entriesPerPage,
-                               $this->offset);
-        $show_bounds = $this->bounds();
-        $end         = end($res);
-        if ($show_bounds) {
-            if ($show_bounds == 1) {
-                $first = $res[0][$this->bound_field];
-                $last  = $end[$this->bound_field];
-            } elseif ($show_bounds == -1) {
-                $first = $end[$this->bound_field];
-                $last  = $res[0][$this->bound_field];
-            }
-            $page->assign('first', $first);
-            $page->assign('last', $last);
-        }
-
-        $page->assign('show_bounds', $show_bounds);
-        $page->assign('order', Env::v('order', $this->defaultkey));
-        $page->assign('orders', $this->sortkeys);
-        $page->assign_by_ref('plview', $this);
-        $page->assign_by_ref('set', $res);
-        $count = $this->set->count();
-        $this->pages = intval(ceil($count / $this->entriesPerPage));
-        return 'include/plview.multipage.tpl';
-    }
-
-    public function args()
-    {
-        $list = $this->set->args();
-        unset($list['page']);
-        unset($list['order']);
-        return $list;
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/pltableeditor.php b/classes/pltableeditor.php
deleted file mode 100644 (file)
index d42d6b8..0000000
+++ /dev/null
@@ -1,324 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 PLTableEditor
-{
-    // the plat/al name of the page
-    public $pl;
-    // the table name
-    public $table;
-    // joint tables to delete when deleting an entry
-    public $jtables = array();
-    // sorting field
-    public $sort = array();
-    // the id field
-    public $idfield;
-    // possibility to edit the field
-    public $idfield_editable;
-    // vars
-    public $vars;
-    // number of displayed fields
-    public $nbfields;
-    // a where clause to restrict table
-    public $whereclause;
-    // the field for sorting entries
-    public $sortfield;
-    public $sortdesc = false;
-    // action to do to delete row:
-    // null => delete effectively, false => no deletion, SQL
-    public $delete_action;
-    public $delete_message;
-    // Should "Save" button return to the list view
-    public $auto_return = true;
-
-    /* table editor for platal
-     * $plname : the PLname of the page, ex: admin/payments
-     * $table : the table to edit, ex: profile_medals
-     * $idfield : the field of the table which is the id, ex: id
-     * $editid : is the id editable or not (if not, it is considered as an int)
-     */
-    public function __construct($plname, $table, $idfield, $editid=false)
-    {
-        $this->pl = $plname;
-        $this->table = $table;
-        $this->idfield = $idfield;
-        $this->sortfield = $idfield;
-        $this->idfield_editable = $editid;
-        $this->whereclause = '1';
-        $r = XDB::iterator("SHOW FULL COLUMNS FROM $table");
-        $this->vars = array();
-        while ($a = $r->next()) {
-            // desc will be the title of the column
-            $a['desc'] = $a['Field'];
-            $a['display'] = true;
-
-            if (substr($a['Type'],0,8) == 'varchar(') {
-                // limit editing box size
-                $a['Size'] = $a['Maxlength'] = substr($a['Type'], 8, strlen($a['Type']) - 9);
-                if ($a['Size'] > 40) $a['Size'] = 40;
-                // if too big, put a textarea
-                $a['Type'] = ($a['Maxlength']<200)?'varchar':'varchar200';
-            }
-            elseif ($a['Type'] == 'text' || $a['Type'] == 'mediumtext')
-                $a['Type'] = 'textarea';
-            elseif (substr($a['Type'],0,4) == 'set(') {
-                // get the list of options
-                $a['List'] = explode('§',str_replace("','","§",substr($a['Type'], 5, strlen($a['Type']) - 7)));
-                if (count($a['List']) == 1) {
-                    $a['Type'] = 'checkbox';
-                    $a['Value'] = $a['List'][0];
-                } else {
-                    $a['Type'] = 'set';
-                }
-            }
-            elseif (substr($a['Type'],0,5) == 'enum(') {
-                // get the list of options
-                $a['List'] = explode('§',str_replace("','","§",substr($a['Type'], 6, strlen($a['Type']) - 8)));
-                $a['Type'] = 'enum';
-            }
-            elseif (substr($a['Type'],0,10) == 'timestamp(' || $a['Type'] == 'datetime') {
-                $a['Type'] = 'timestamp';
-            }
-            elseif ($a['Comment'] == 'ip_address') {
-                $a['Type']='ip_address';
-            }
-
-            $this->vars[$a['Field']] = $a;
-        }
-        $this->vars[$idfield]['desc'] = 'id';
-    }
-
-    // called before creating a new entry
-    private function prepare_new()
-    {
-        $entry = array();
-        foreach ($this->vars as $field => $descr) {
-            $entry[$field] = $descr['Default'];
-        }
-        return $this->prepare_edit($entry);
-    }
-
-    // called before editing $entry
-    private function prepare_edit(&$entry)
-    {
-        foreach ($this->vars as $field => $descr) {
-            if ($descr['Type'] == 'set') {
-                // get the list of options selected
-                $selected = explode(',', $entry[$field]);
-                $entry[$field] = array();
-                foreach ($selected as $option)
-                    $entry[$field][$option] = 1;
-            }
-            if ($descr['Type'] == 'timestamp') {
-                // set readable timestamp
-                $date =& $entry[$field];
-                $date = preg_replace('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', '\3/\2/\1 \4:\5:\6', $date);
-            }
-            if ($descr['Type'] == 'date') {
-                $date =& $entry[$field];
-                $date = preg_replace('/([0-9]{4})-?([0-9]{2})-?([0-9]{2})/', '\3/\2/\1', $date);
-            }
-            if ($descr['Type'] == 'ip_address') {
-                $ip = & $entry[$field];
-                $ip = long2ip($ip);
-            }
-        }
-        return $entry;
-    }
-
-    // set whether the save button show redirect to list view or edit view
-    public function list_on_edit($var)
-    {
-        $this->auto_return = $var;
-    }
-
-    // change display of a field
-    public function describe($name, $desc, $display)
-    {
-        $this->vars[$name]['desc'] = $desc;
-        $this->vars[$name]['display'] = $display;
-    }
-
-    // add a join table, when deleting a row corresponding entries will be deleted in these tables
-    public function add_join_table($name,$joinid,$joindel,$joinextra="")
-    {
-        if ($joindel)
-            $this->jtables[$name] = array("joinid" => $joinid,"joinextra" => $joinextra?(" AND ".$joinextra):"");
-    }
-
-    // add a sort key
-    public function add_sort_field($key, $desc = false, $default = false)
-    {
-        if ($default) {
-            $this->sortfield = $key . ($desc ? ' DESC' : '');
-        } else {
-            $this->sort[] = $key . ($desc ? ' DESC' : '');
-        }
-    }
-
-    // add a where clause to limit table listing
-    public function set_where_clause($whereclause="1")
-    {
-        $this->whereclause = $whereclause;
-    }
-    
-    // set an action when trying to delete row
-    public function on_delete($action = NULL, $message = NULL)
-    {
-        $this->delete_action = $action;
-        $this->delete_message = $message;
-    }
-
-    // call when done
-    public function apply(PlatalPage &$page, $action, $id = false)
-    {
-        $page->changeTpl('core/table-editor.tpl');
-        $list = true;
-        if ($action == 'delete') {
-            S::assert_xsrf_token();
-
-            if (!isset($this->delete_action)) {
-                foreach ($this->jtables as $table => $j)
-                    XDB::execute("DELETE FROM {$table} WHERE {$j['joinid']} = {?}{$j['joinextra']}", $id);
-                XDB::execute("DELETE FROM {$this->table} WHERE {$this->idfield} = {?}",$id);
-                $page->trigSuccess("L'entrée ".$id." a été supprimée.");
-            } else if ($this->delete_action) {
-                XDB::execute($this->delete_action, $id);
-                if (isset($this->delete_message)) {
-                    $page->trigSuccess($this->delete_message);
-                } else {
-                    $page->trigSuccess("L'entrée ".$id." a été supprimée.");
-                }
-            } else {
-                $page->trigError("Impossible de supprimer l'entrée.");
-            }
-        }
-        if ($action == 'edit') {
-            $r = XDB::query("SELECT * FROM {$this->table} WHERE {$this->idfield} = {?} AND {$this->whereclause}",$id);
-            $entry = $r->fetchOneAssoc();
-            $page->assign('entry', $this->prepare_edit($entry));
-            $page->assign('id', $id);
-            $list = false;
-        }
-        if ($action == 'massadd') {
-            $importer = new CSVImporter($this->table, $this->idfield_editable ? $this->idfield : null);
-            $fields   = array();
-            foreach ($this->vars as $field=>$descr) {
-                if ($this->idfield_editable || $field != $this->idfield) {
-                    $fields[] = $field;
-                    $importer->describe($field, @$descr['desc']);
-                }
-            }
-            $page->assign('massadd', true);
-            $importer->apply($page, $this->pl . '/massadd', $fields);
-            $list = false;
-        }
-        if ($action == 'new') {
-            if (!$this->idfield_editable) {
-                $r = XDB::query("SELECT MAX({$this->idfield})+1 FROM {$this->table}");
-                $page->assign('id', $r->fetchOneCell());
-                $page->assign('entry', $this->prepare_new());
-            }
-            $list = false;
-        }
-        if ($action == 'update') {
-            S::assert_xsrf_token();
-
-            $values = "";
-            $cancel = false;
-            foreach ($this->vars as $field => $descr) {
-                if ($values) $values .= ',';
-                if (($field == $this->idfield) && !$this->idfield_editable)
-                    $val = "'".addslashes($id)."'";
-                elseif ($descr['Type'] == 'set') {
-                    $val = "";
-                    if (Post::has($field)) foreach (Post::v($field) as $option) {
-                        if ($val) $val .= ',';
-                        $val .= $option;
-                    }
-                    $val = "'".addslashes($val)."'";
-                } elseif ($descr['Type'] == 'checkbox') {
-                    $val = Post::has($field)?"'".addslashes($descr['Value'])."'":"''";
-                } elseif (Post::has($field)) {
-                    $val = Post::v($field);
-                    if ($descr['Type'] == 'timestamp') {
-                        $val = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/', '\3\2\1\4\5\6', $val);
-                    }
-                    elseif ($descr['Type'] == 'date') {
-                        $val = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/', '\3-\2-\1', $val);
-                    }
-                    elseif ($descr['Type'] == 'ip_address') {
-                        $val = ip2long($val);
-                    }
-                    $val = "'".addslashes($val)."'";
-                } else {
-                    $cancel = true;
-                    $page->trigError("Il manque le champ ".$field);
-                }
-                $values .= $val;
-            }
-            if (!$cancel) {
-                if ($this->idfield_editable && ($id != Post::v($this->idfield)) && $action != 'new')
-                    XDB::execute("UPDATE {$this->table} SET {$this->idfield} = {?} WHERE {$this->idfield} = {?} AND {$this->whereclause}", Post::v($this->idfield), $id);
-                XDB::execute("REPLACE INTO {$this->table} VALUES ($values)");
-                if ($id !== false)
-                    $page->trigSuccess("L'entrée ".$id." a été mise à jour.");
-                else {
-                    $page->trigSuccess("Une nouvelle entrée a été créée.");
-                    $id = XDB::insertId();
-                }
-            } else
-                $page->trigError("Impossible de mettre à jour.");
-            if (!$this->auto_return) {
-                return $this->apply($page, 'edit', $id);
-            }
-        }
-        if ($action == 'sort') {
-            $this->sortfield = $id;
-        }
-        if ($action == 'sortdesc') {
-            $this->sortfield = $id.' DESC';
-        }
-        if ($list) {
-            // user can sort by field by clicking the title of the column
-            if (isset($this->sortfield)) {
-                // add this sort order after the others (chosen by dev)
-                $this->add_sort_field($this->sortfield);
-                if (substr($this->sortfield,-5) == ' DESC') {
-                    $this->sortfield = substr($this->sortfield,0,-5);
-                    $this->sortdesc = true;
-                }
-            }
-            if (count($this->sort) > 0) {
-                $sort = 'ORDER BY ' . join($this->sort, ',');
-            }
-            $it = XDB::iterator("SELECT * FROM {$this->table} WHERE {$this->whereclause} $sort");
-            $this->nbfields = 0;
-            foreach ($this->vars as $field => $descr)
-                if ($descr['display']) $this->nbfields++;
-            $page->assign('list', $it);
-        }
-        $page->assign('t', $this);
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plupload.php b/classes/plupload.php
deleted file mode 100644 (file)
index ea192f0..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 to store per user and per category files
- */
-class PlUpload
-{
-    private $forlife;
-    private $category;
-    private $file_id;
-
-    private $filename;
-    private $type;
-
-    static public $lastError;
-
-    /** For images
-     */
-    private $x;
-    private $y;
-
-    public function __construct($forlife, $category, $filename = null)
-    {
-        $this->file_id  = $filename;
-        $this->category = $category;
-        $this->forlife  = $forlife;
-        $this->filename = $this->makeFilename($this->file_id);
-        $this->checkContentType();
-    }
-
-    private function makeFilename($file_id)
-    {
-        global $globals;
-        $filename = $globals->spoolroot . '/spool/tmp/';
-        if (!file_exists($filename)) {
-            if (!mkdir($filename)) {
-                trigger_error('can\'t create upload directory: ' . $filename, E_USER_ERROR);
-            }
-        }
-        $filename .= $this->forlife . '--' . $this->category;
-        if ($file_id) {
-            $filename .= '--' . $file_id;
-        }
-        return $filename;
-    }
-
-    private function checkContentType()
-    {
-        if ($this->exists()) {
-            $this->type = trim(mime_content_type($this->filename));
-            if ($this->type == 'text/plain') { // Workaround a bug of php 5.2.0+etch10 (mime_content_type fallback is 'text/plain')
-                $this->type = preg_replace('/;.*/', '', trim(shell_exec('file -bi ' . escapeshellarg($this->filename))));
-            }
-        }
-    }
-
-    public function upload(array &$file)
-    {
-        if (@$file['error']) {
-            PlUpload::$lastError = 'Erreur de téléchargement de ' . $file['name'] . ' : ';
-            switch ($file['error']) {
-              case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE:
-                PlUpload::$lastError .= 'le fichier est trop gros (limite : ' . ini_get('upload_max_filesize') . ')';
-                break;
-              case UPLOAD_ERR_PARTIAL: case UPLOAD_ERR_NO_FILE:
-                PlUpload::$lastError .= 'le fichier n\'a pas été transmis intégralement';
-                break;
-              default:
-                PlUpload::$lastError .= 'erreur interne';
-                break;
-            }
-            return false;
-        }
-        if (!is_uploaded_file($file['tmp_name'])) {
-            return false;
-        } else if (!move_uploaded_file($file['tmp_name'], $this->filename)) {
-            return false;
-        }
-        $this->checkContentType();
-        return true;
-    }
-
-    public function copyFrom($filename)
-    {
-        if (!copy($filename, $this->filename)) {
-            return false;
-        }
-        $this->checkContentType();
-        return true;
-    }
-
-    public function download($url)
-    {
-        if (!$url || @parse_url($url) === false) {
-            trigger_error('malformed URL given', E_USER_NOTICE);
-            return false;
-        }
-        $data = file_get_contents($url);
-        if (!$data) {
-            return false;
-        }
-        if (!file_put_contents($this->filename, $data)) {
-            return false;
-        }
-        $this->checkContentType();
-        return true;
-    }
-
-    static public function &get(array &$file, $forlife, $category, $uniq = false)
-    {
-        $upload = new PlUpload($forlife, $category, $uniq ? null : $file['name']);
-        if (!$upload->upload($file)) {
-            $upload = null;
-        }
-        return $upload;
-    }
-
-    public function rm()
-    {
-        @unlink($this->filename);
-        @clearstatcache();
-    }
-
-    public function rename($fn)
-    {
-        if (!$this->file_id) {
-            return false;
-        }
-        $filename = $this->makeFilename($fn);
-        if (rename($this->filename)) {
-            $this->filename = $filename;
-            $this->file_id  = $fn;
-            clearstatcache();
-            return true;
-        }
-        return false;
-    }
-
-    public function exists()
-    {
-        return file_exists($this->filename);
-    }
-
-    static public function listRawFiles($forlife = '*', $category = '*', $uniq = false, $basename = false)
-    {
-        global $globals;
-        $filename = $globals->spoolroot . '/spool/tmp/';
-        $filename .= $forlife . '--' . $category;
-        if (!$uniq) {
-            $filename .= '--*';
-        }
-        $files = glob($filename);
-        if ($basename) {
-            $files = array_map('basename', $files);
-        }
-        return $files;
-    }
-
-    static public function listFilenames($forlife = '*', $category = '*')
-    {
-        $files = PlUpload::listRawFiles($forlife, $category, false, true);
-        foreach ($files as &$name) {
-            list($forlife, $cat, $fn) = explode('--', $name, 3);
-            $name = $fn;
-        }
-        return $files;
-    }
-
-    static public function &listFiles($forlife = '*', $category = '*', $uniq = false)
-    {
-        $res   = array();
-        $files = PlUpload::listRawFiles($forlife, $category, $uniq, true);
-        foreach ($files as $name) {
-            list($forlife, $cat, $fn) = explode('--', $name, 3);
-            $res[$fn] = new PlUpload($forlife, $cat, $fn);
-        }
-        return $res;
-    }
-
-    static public function clear($user = '*', $category = '*', $uniq = false)
-    {
-        $files = PlUpload::listRawFiles($user, $category, $uniq, false);
-        array_map('unlink', $files);
-    }
-
-    public function contentType()
-    {
-        return $this->type;
-    }
-
-    public function isType($type, $subtype = null)
-    {
-        list($mytype, $mysubtype) = explode('/', $this->type);
-        if ($mytype != $type || ($subtype && $mysubtype != $subtype)) {
-            return false;
-        }
-        return true;
-    }
-
-    public function imageInfo()
-    {
-        static $map;
-        if (!isset($map)) {
-            $tmpmap = array (IMG_GIF => 'gif', IMG_JPG => 'jpeg', IMG_PNG => 'png', IMG_WBMP => 'bmp', IMG_XPM => 'xpm');
-            $map = array();
-            $supported = imagetypes();
-            foreach ($tmpmap as $type=>$mime) {
-                if ($supported & $type) {
-                    $map[$type] = $mime;
-                }
-            }
-        }
-        $array = getimagesize($this->filename);
-        $array[2] = @$map[$array[2]];
-        if (!$array[2]) {
-            list($image, $type) = explode('/', $array['mime']);
-            $array[2] = $type;
-        }
-        if (!$array[2]) {
-            trigger_error('unknown image type', E_USER_NOTICE);
-            return null;
-        }
-        return $array;
-    }
-
-    public function resizeImage($max_x = -1, $max_y = -1, $min_x = 0, $min_y = 0, $maxsize = -1)
-    {
-        if (!$this->exists() || strpos($this->type, 'image/') !== 0) {
-            trigger_error('not an image', E_USER_NOTICE);
-            return false;
-        }
-        $image_infos = $this->imageInfo();
-        if (!$image_infos) {
-            trigger_error('invalid image', E_USER_NOTICE);
-            return false;
-        }
-        list($this->x, $this->y, $mimetype) = $image_infos;
-        if ($max_x == -1) {
-            $max_x = $this->x;
-        }
-        if ($max_y == -1) {
-            $max_y = $this->y;
-        }
-        if ($maxsize == -1) {
-            $maxsize = filesize($this->filename);
-        }
-        if (filesize($this->filename) > $maxsize || $this->x > $max_x || $this->y > $max_y
-                                                 || $this->x < $min_x || $this->y < $min_y) {
-            $img = imagecreatefromstring(file_get_contents($this->filename));
-            if (!$img) {
-                trigger_error('too large image, can\'t be resized', E_USER_NOTICE);
-                return false;
-            }
-
-            $nx = $this->x;
-            $ny = $this->y;
-            if ($nx > $max_x) {
-                $ny = intval($ny*$max_x/$nx);
-                $nx = $max_x;
-            }
-            if ($ny > $max_y) {
-                $nx = intval($nx*$max_y/$ny);
-                $ny = $max_y;
-            }
-            if ($nx < $min_x) {
-                $ny = intval($ny*$min_x/$nx);
-                $nx = $min_x;
-            }
-            if ($ny < $min_y) {
-                $nx = intval($nx * $min_y/$ny);
-                $ny = $min_y;
-            }
-
-            $comp = 90;
-            do {
-                $img2 = imagecreatetruecolor($nx, $ny);
-                imagecopyresampled($img2, $img, 0, 0, 0, 0, $nx, $ny, $this->x, $this->y);
-                imagejpeg($img2, $this->filename, $comp);
-                $comp --;
-                clearstatcache();
-            } while (filesize($this->filename) > $maxsize && $comp > 0);
-            $this->type = 'image/jpeg';
-            $this->x    = $nx;
-            $this->y    = $ny;
-        }
-        return true;
-    }
-
-    public function getContents()
-    {
-        if ($this->exists()) {
-            return file_get_contents($this->filename);
-        }
-        return null;
-    }
-}
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plwizard.php b/classes/plwizard.php
deleted file mode 100644 (file)
index fecf881..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- **************************************************************************/
-
-/** A Wizard Page is a page of a wizard. It is a self-contained step which
- * handles both the creation and initialisation of the step (by using the
- * Wizard global state, if needed) and the processing of the action the
- * user made on it.
- */
-interface PlWizardPage
-{
-    /** Build a new instance of the class
-     * associated with the given wizard master.
-     */
-    public function __construct(PlWizard &$wiz);
-
-    /** Return the name of the templace describing the page.
-     */
-    public function template();
-
-    /** Prepare the page by assigning to it any useful value.
-     */
-    public function prepare(PlatalPage &$page, $id);
-
-    /** Process information resulting of the application of the page.
-     * This function must return a clue indicating the next page to show.
-     * This clue can be either a page id, a page number or a navigation
-     * id (PlWizard::FIRST_PAGE, PlWizard::NEXT_PAGE, PlWizard::CURRENT_PAGE
-     *  PlWizard::PREVIOUS_PAGE, PlWizard::LAST_PAGE).
-     */
-    public function process();
-}
-
-/** A PlWizard is a set of pages through which the user can navigate,
- * his action on a page determining which the next one will be.
- *
- * A Wizard can either a stateless wizard (which is only a set of
- * independent pages through which the user can easily navigate) or
- * stateful (a suite of steps where each step gives clue for the next
- * one).
- */
-class PlWizard
-{
-    const FIRST_PAGE    = 'bt_first';
-    const NEXT_PAGE     = 'bt_next';
-    const CURRENT_PAGE  = 'bt_current';
-    const PREVIOUS_PAGE = 'bt_previous';
-    const LAST_PAGE     = 'bt_last';
-
-    protected $name;
-    protected $layout;
-    protected $stateless;
-    protected $ajax;
-
-    protected $pages;
-    protected $titles;
-    protected $lookup;
-    protected $inv_lookup;
-
-    public function __construct($name, $layout, $stateless = false, $ajax = true)
-    {
-        $this->name      = 'wiz_' . $name;
-        $this->layout    = $layout;
-        $this->stateless = $stateless;
-        $this->pages  = array();
-        $this->lookup = array();
-        $this->titles = array();
-        $this->ajax   = $ajax;
-        if (!isset($_SESSION[$this->name])) {
-            $_SESSION[$this->name] = array();
-            $_SESSION[$this->name . '_page']  = null;
-            $_SESSION[$this->name . '_stack'] = array();
-        }
-    }
-
-    public function addPage($class, $title, $id = null)
-    {
-        if ($id == null) {
-            $id = count($this->pages);
-        }
-        $this->lookup[$id]  = count($this->pages);
-        $this->inv_lookup[] = $id;
-        $this->pages[]      = $class;
-        $this->titles[]     = $title;
-    }
-
-    public function set($varname, $value)
-    {
-        $_SESSION[$this->name][$varname] = $value;
-    }
-
-    public function get($varname, $default = null)
-    {
-        return isset($_SESSION[$this->name][$varname]) ?
-                    $_SESSION[$this->name][$varname] : $default;
-    }
-
-    public function v($varname, $default = "")
-    {
-        return $this->get($varname, $default);
-    }
-
-    public function i($varname, $default = 0)
-    {
-        return (int)$this->get($varname, $default);
-    }
-
-    public function clear($varname = null)
-    {
-        if (is_null($varname)) {
-            $_SESSION[$this->name] = array();
-        } else {
-            unset($_SESSION[$this->name][$varname]);
-        }
-        $_SESSION[$this->name . '_page'] = null;
-    }
-
-    private function getPage($id)
-    {
-        $page = $this->pages[$id];
-        return new $page($this);
-    }
-
-    public function apply(PlatalPage &$smarty, $baseurl, $pgid = null, $mode = 'normal')
-    {
-        if ($this->stateless && (isset($this->lookup[$pgid]) || isset($this->pages[$pgid]))) { 
-            $curpage = is_numeric($pgid) ? $pgid : $this->lookup[$pgid]; 
-        } else if ($this->stateless && is_null($pgid)) {
-            $curpage = 0;
-        } else {
-            $curpage = $_SESSION[$this->name . '_page'];
-        }
-        $oldpage = $curpage;
-
-        // Process the previous page
-        if (Post::has('valid_page')) {
-            S::assert_xsrf_token();
-
-            $page = $this->getPage(Post::i('valid_page'));
-            $curpage = Post::i('valid_page');
-            $next = $page->process();
-            $last = $curpage;
-            switch ($next) {
-              case PlWizard::FIRST_PAGE:
-                $curpage = 0;
-                break;
-              case PlWizard::PREVIOUS_PAGE:
-                if (!$this->stateless && count($_SESSION[$this->name . '_stack'])) {
-                    $curpage = array_pop($_SESSION[$this->name . '_stack']);
-                } elseif ($curpage && $this->stateless) {
-                    $curpage--;
-                } else {
-                    $curpage = 0;
-                }
-                break;
-              case PlWizard::NEXT_PAGE:
-                if ($curpage < count($this->pages) - 1) {
-                    $curpage++;
-                }
-                break;
-              case PlWizard::LAST_PAGE:
-                $curpage = count($this->pages) - 1;
-                break;
-              case PlWizard::CURRENT_PAGE: break; // don't change the page
-              default:
-                $curpage = is_numeric($next) ? $next : $this->lookup[$next];
-                break;
-            }
-            if (!$this->stateless) {
-                array_push($_SESSION[$this->name . '_stack'], $last);
-            }
-        }
-        if (is_null($curpage)) {
-            $curpage = 0;
-        }
-
-        // Prepare the page
-        $_SESSION[$this->name . '_page'] = $curpage;
-        if ($curpage != $oldpage) {
-            pl_redirect($baseurl . '/' . $this->inv_lookup[$curpage]);
-        } else if (!isset($page)) {
-            $page = $this->getPage($curpage);
-        }
-        if ($mode == 'ajax') {
-            header('Content-Type: text/html; charset=utf-8');
-            $smarty->changeTpl($page->template(), NO_SKIN);
-        } else {
-            $smarty->changeTpl($this->layout);
-        }
-        $smarty->assign('pages', $this->titles);
-        $smarty->assign('current', $curpage);
-        $smarty->assign('lookup', $this->inv_lookup);
-        $smarty->assign('stateless', $this->stateless);
-        $smarty->assign('wiz_baseurl', $baseurl);
-        $smarty->assign('wiz_ajax', $this->ajax);
-        $smarty->assign('tab_width', (int)(99 / count($this->pages)));
-        $smarty->assign('wiz_page', $page->template());
-        $smarty->assign('xorg_no_errors', true);
-        $page->prepare($smarty, isset($this->inv_lookup[$curpage]) ? $this->inv_lookup[$curpage] : $curpage);
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/s.php b/classes/s.php
deleted file mode 100644 (file)
index 338a437..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 S extends Session {
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/session.php b/classes/session.php
deleted file mode 100644 (file)
index 6eb5b30..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 Session
-{
-    public static function init()
-    {
-        @session_start();
-        if (empty($_SESSION['challenge'])) {
-            $_SESSION['challenge'] = sha1(uniqid(rand(), true));
-        }
-        if (empty($_SESSION['xsrf_token'])) {
-            require_once 'xorg.misc.inc.php';
-            $_SESSION['xsrf_token'] = rand_url_id();
-        }
-        if (!isset($_SESSION['perms']) || !($_SESSION['perms'] instanceof FlagSet)) {
-            $_SESSION['perms'] = new FlagSet();
-        }
-    }
-
-    public static function destroy()
-    {
-        @session_destroy();
-        unset($_SESSION);
-    }
-
-    public static function has($key)
-    {
-        return isset($_SESSION[$key]);
-    }
-
-    public static function kill($key)
-    {
-        unset($_SESSION[$key]);
-    }
-
-    public static function v($key, $default = null)
-    {
-        return isset($_SESSION[$key]) ? $_SESSION[$key] : $default;
-    }
-
-    public static function s($key, $default = '')
-    {
-        return (string)Session::v($key, $default);
-    }
-
-    public static function i($key, $default = 0)
-    {
-        $i = Session::v($key, $default);
-        return is_numeric($i) ? intval($i) : $default;
-    }
-
-    public static function l(array $keys)
-    {
-        return array_map(array('Session', 'v'), $keys);
-    }
-
-    public static function has_perms()
-    {
-        return Session::logged() && Session::v('perms')->hasFlag(PERMS_ADMIN);
-    }
-
-    public static function logged()
-    {
-        return Session::v('auth', AUTH_PUBLIC) >= AUTH_COOKIE;
-    }
-
-    public static function identified()
-    {
-        return Session::v('auth', AUTH_PUBLIC) >= AUTH_MDP;
-    }
-
-    // Anti-XSRF protections.
-    public static function has_xsrf_token()
-    {
-        return Session::has('xsrf_token') && Session::v('xsrf_token') == Env::v('token');
-    }
-
-    public static function assert_xsrf_token()
-    {
-        if (!Session::has_xsrf_token()) {
-            global $page;
-            if ($page instanceof PlatalPage) {
-                $page->kill("L'opération n'a pas pu aboutir, merci de réessayer.");
-            }
-        }
-    }
-
-    public static function rssActivated()
-    {
-        return Session::has('core_rss_hash') && Session::v('core_rss_hash');
-    }
-}
-
-// {{{ function check_perms()
-
-/** verifie si un utilisateur a les droits pour voir une page
- ** si ce n'est pas le cas, on affiche une erreur
- * @return void
- */
-function check_perms()
-{
-    global $page;
-    if (!S::has_perms()) {
-        if ($_SESSION['log']) {
-            $_SESSION['log']->log("noperms",$_SERVER['PHP_SELF']);
-        }
-        $page->kill("Tu n'as pas les permissions nécessaires pour accéder à cette page.");
-    }
-}
-
-// }}}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/varstream.php b/classes/varstream.php
deleted file mode 100644 (file)
index e57b60f..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 VarStream
-{
-    // Stream handler to read from global variables
-    private $varname;
-    private $position;
-
-    public function stream_open($path, $mode, $options, &$opened_path)
-    {
-        $url            = parse_url($path);
-        $this->varname  = $url['host'];
-        $this->position = 0;
-        if (!isset($GLOBALS[$this->varname]))
-        {
-            trigger_error('Global variable '.$this->varname.' does not exist', E_USER_WARNING);
-            return false;
-        }
-        return true;
-    }
-
-    public function stream_close()
-    {
-    }
-
-    public function stream_read($count)
-    {
-        $ret = substr($GLOBALS[$this->varname], $this->position, $count);
-        $this->position += strlen($ret);
-        return $ret;
-    }
-
-    public function stream_write($data)
-    {
-        $len = strlen($data);
-        if ($len > $this->position + strlen($GLOBALS[$this->varname])) {
-            str_pad($GLOBALS[$this->varname], $len);
-        }
-
-        $GLOBALS[$this->varname] = substr_replace($GLOBALS[$this->varname], $data, $this->position, $len);
-        $this->position += $len;
-    }
-
-    public function stream_eof()
-    {
-        return $this->position >= strlen($GLOBALS[$this->varname]);
-    }
-
-    public function stream_tell()
-    {
-        return $this->position;
-    }
-
-    public function stream_seek($offs, $whence)
-    {
-        switch ($whence) {
-            case SEEK_SET:
-                $final = $offs;
-                break;
-
-            case SEEK_CUR:
-                $final += $offs;
-                break;
-
-            case SEEK_END:
-                $final = strlen($GLOBALS[$this->varname]) + $offs;
-                break;
-        }
-
-        if ($final < 0) {
-            return -1;
-        }
-        $this->position = $final;
-        return 0;
-    }
-
-    public function stream_flush()
-    {
-    }
-
-    static public function init()
-    {
-        stream_wrapper_register('var','VarStream');
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/xdb.php b/classes/xdb.php
deleted file mode 100644 (file)
index ad63364..0000000
+++ /dev/null
@@ -1,366 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 XDB
-{
-    private static $mysqli = null;
-
-    public static function connect()
-    {
-        global $globals;
-        XDB::$mysqli = new mysqli($globals->dbhost, $globals->dbuser, $globals->dbpwd, $globals->dbdb);
-        if ($globals->debug & DEBUG_BT) {
-            $bt = new PlBacktrace('MySQL');
-            if (mysqli_connect_errno()) {
-                $bt->newEvent("MySQLI connection", 0, mysqli_connect_error());
-                return false;
-            }
-        }
-        XDB::$mysqli->autocommit(true);
-        XDB::$mysqli->set_charset($globals->dbcharset);
-        return true;
-    }
-
-    public static function _prepare($args)
-    {
-        $query    = array_map(Array('XDB', 'escape'), $args);
-        $query[0] = str_replace('{?}', '%s', str_replace('%',   '%%', $args[0]));
-        return call_user_func_array('sprintf', $query);
-    }
-
-    public static function _reformatQuery($query)
-    {
-        $query  = preg_split("/\n\\s*/", trim($query));
-        $length = 0;
-        foreach ($query as $key=>$line) {
-            $local = -2;
-            if (preg_match('/^([A-Z]+(?:\s+(?:JOIN|BY|FROM|INTO))?)\s+(.*)/u', $line, $matches)
-            && $matches[1] != 'AND' && $matches[1] != 'OR')
-            {
-                $local  = strlen($matches[1]);
-                $line   = $matches[1] . '  ' . $matches[2];
-                $length = max($length, $local);
-            }
-            $query[$key] = array($line, $local);
-        }
-        $res = '';
-        foreach ($query as $array) {
-            list($line, $local) = $array;
-            $local   = max(0, $length - $local);
-            $res    .= str_repeat(' ', $local) . $line . "\n";
-            $length += 2 * (substr_count($line, '(') - substr_count($line, ')'));
-        }
-        return $res;
-    }
-
-    public static function _query($query)
-    {
-        global $globals;
-
-        if (!XDB::$mysqli && !XDB::connect()) {
-            return false;
-        }
-
-        if ($globals->debug & DEBUG_BT) {
-            $explain = array();
-            if (strpos($query, 'FOUND_ROWS()') === false) {
-                $res = XDB::$mysqli->query("EXPLAIN $query");
-                if ($res) {
-                    while ($row = $res->fetch_assoc()) {
-                        $explain[] = $row;
-                    }
-                    $res->free();
-                }
-            }
-            PlBacktrace::$bt['MySQL']->start(XDB::_reformatQuery($query));
-        }
-
-        $res = XDB::$mysqli->query($query);
-
-        if ($globals->debug & DEBUG_BT) {
-            PlBacktrace::$bt['MySQL']->stop(@$res->num_rows ? $res->num_rows : XDB::$mysqli->affected_rows,
-                                            XDB::$mysqli->error,
-                                            $explain);
-        }
-        return $res;
-    }
-
-    public static function query()
-    {
-        return new XOrgDBResult(XDB::_prepare(func_get_args()));
-    }
-
-    public static function execute()
-    {
-        global $globals;
-        $args = func_get_args();
-        if ($globals->mode != 'rw' && !strpos($args[0], 'logger')) {
-            return;
-        }
-        return XDB::_query(XDB::_prepare($args));
-    }
-
-    public static function iterator()
-    {
-        return new XOrgDBIterator(XDB::_prepare(func_get_args()));
-    }
-
-    public static function iterRow()
-    {
-        return new XOrgDBIterator(XDB::_prepare(func_get_args()), MYSQL_NUM);
-    }
-
-    public static function insertId()
-    {
-        return XDB::$mysqli->insert_id;
-    }
-
-    public static function errno()
-    {
-        return XDB::$mysqli->errno;
-    }
-
-    public static function error()
-    {
-        return XDB::$mysqli->error;
-    }
-
-    public static function affectedRows()
-    {
-        return XDB::$mysqli->affected_rows;
-    }
-
-    public static function escape($var)
-    {
-        switch (gettype($var)) {
-          case 'boolean':
-            return $var ? 1 : 0;
-
-          case 'integer':
-          case 'double':
-          case 'float':
-            return $var;
-
-          case 'string':
-            return "'".addslashes($var)."'";
-
-          case 'NULL':
-            return 'NULL';
-
-          case 'object':
-            if ($var instanceof FlagSet) {
-                return "'" . addslashes($var->flags()) . "'";
-            }
-          case 'array':
-            return "'".addslashes(serialize($var))."'";
-
-          default:
-            die(var_export($var, true).' is not a valid for a database entry');
-        }
-    }
-}
-
-class XOrgDBResult
-{
-
-    private $_res;
-
-    public function __construct($query)
-    {
-        $this->_res = XDB::_query($query);
-    }
-
-    public function free()
-    {
-        if ($this->_res) {
-            $this->_res->free();
-        }
-        unset($this);
-    }
-
-    protected function _fetchRow()
-    {
-        return $this->_res ? $this->_res->fetch_row() : null;
-    }
-
-    protected function _fetchAssoc()
-    {
-        return $this->_res ? $this->_res->fetch_assoc() : null;
-    }
-
-    public function fetchAllRow()
-    {
-        $result = Array();
-        if (!$this->_res) {
-            return $result;
-        }
-        while ($result[] = $this->_res->fetch_row());
-        array_pop($result);
-        $this->free();
-        return $result;
-    }
-
-    public function fetchAllAssoc()
-    {
-        $result = Array();
-        if (!$this->_res) {
-            return $result;
-        }
-        while ($result[] = $this->_res->fetch_assoc());
-        array_pop($result);
-        $this->free();
-        return $result;
-    }
-
-    public function fetchOneAssoc()
-    {
-        $tmp = $this->_fetchAssoc();
-        $this->free();
-        return $tmp;
-    }
-
-    public function fetchOneRow()
-    {
-        $tmp = $this->_fetchRow();
-        $this->free();
-        return $tmp;
-    }
-
-    public function fetchOneCell()
-    {
-        $tmp = $this->_fetchRow();
-        $this->free();
-        return $tmp[0];
-    }
-
-    public function fetchColumn($key = 0)
-    {
-        $res = Array();
-        if (is_numeric($key)) {
-            while($tmp = $this->_fetchRow()) {
-                $res[] = $tmp[$key];
-            }
-        } else {
-            while($tmp = $this->_fetchAssoc()) {
-                $res[] = $tmp[$key];
-            }
-        }
-        $this->free();
-        return $res;
-    }
-
-    public function fetchOneField()
-    {
-        return $this->_res ? $this->_res->fetch_field() : null;
-    }
-
-    public function fetchFields()
-    {
-        $res = array();
-        while ($res[] = $this->fetchOneField());
-        return $res;
-    }
-
-    public function numRows()
-    {
-        return $this->_res ? $this->_res->num_rows : 0;
-    }
-
-    public function fieldCount()
-    {
-        return $this->_res ? $this->_res->field_count : 0;
-    }
-}
-
-require_once dirname(__FILE__) . '/pliterator.php';
-
-class XOrgDBIterator extends XOrgDBResult implements PlIterator
-{
-    private $_result;
-    private $_pos;
-    private $_total;
-    private $_fpos;
-    private $_fields;
-    private $_mode = MYSQL_ASSOC;
-
-    public function __construct($query, $mode = MYSQL_ASSOC)
-    {
-        parent::__construct($query);
-        $this->_pos    = 0;
-        $this->_total  = $this->numRows();
-        $this->_fpost  = 0;
-        $this->_fields = $this->fieldCount();
-        $this->_mode   = $mode;
-    }
-
-    public function next()
-    {
-        $this->_pos ++;
-        if ($this->_pos > $this->_total) {
-            $this->free();
-            unset($this);
-            return null;
-        }
-        return $this->_mode != MYSQL_ASSOC ? $this->_fetchRow() : $this->_fetchAssoc();
-    }
-
-    public function first()
-    {
-        return $this->_pos == 1;
-    }
-
-    public function last()
-    {
-        return $this->_pos == $this->_total;
-    }
-
-    public function total()
-    {
-        return $this->_total;
-    }
-
-    public function nextField()
-    {
-        $this->_fpos++;
-        if ($this->_fpos > $this->_fields) {
-            return null;
-        }
-        return $this->fetchOneField();
-    }
-
-    public function firstField()
-    {
-        return $this->_fpos == 1;
-    }
-
-    public function lastField()
-    {
-        return $this->_fpos == $this->_fields;
-    }
-
-    public function totalFields()
-    {
-        return $this->_fields;
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/xmlrpcclient.php b/classes/xmlrpcclient.php
deleted file mode 100644 (file)
index be47a70..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-/* taken from : http://fr2.php.net/xml-rpc
- * Author mboeren@php.net
- *
- * Usage:
- * $client = new xmlrpc_client("http://localhost:7080");
- * print $client->echo('x')."\n";
- * print $client->add(1, 3)."\n";
- */
-
-class XmlrpcClient
-{
-    private $url;
-    private $urlparts;
-    public $bt = null;
-
-    public function __construct($url)
-    {
-        $this->url = $url;
-        $this->urlparts = parse_url($this->url);
-
-        if (empty($this->urlparts['port'])) {
-            $this->urlparts['port'] = 80;
-        }
-
-        if (empty($this->urlparts['path'])) {
-            $this->urlparts['path'] = '/';
-        }
-    }
-
-    private function http_post($request)
-    {
-        $host = $path = $port = $user = $pass = null;
-        extract($this->urlparts);
-
-        if ($scheme == 'https') {
-            $host = 'ssl://'.$host;
-        }
-
-        $query_fd    = fsockopen($host, $port, $errno, $errstr, 10);
-        if (!$query_fd)
-            return null;
-
-        $auth = '';
-        if ($user) {
-            $auth = 'Authorization: Basic ' . base64_encode("$user:$pass") . "\r\n";
-        }
-
-        $content_len = strlen($request);
-        $http_request =
-            "POST $path HTTP/1.0\r\n" .
-            $auth .
-            "Content-Type: text/xml\r\n" .
-            "Content-Length: $content_len\r\n" .
-            "Connection: Close\r\n" .
-            "Host: $host:$port\r\n" .
-            "\r\n" .
-            $request;
-
-        fputs($query_fd, $http_request, strlen($http_request));
-
-        $buf = '';
-        while (!feof($query_fd)) {
-            $buf .= fread($query_fd, 8192);
-        }
-
-        fclose($query_fd);
-        return $buf;
-    }
-
-    private function find_and_decode_xml($buf)
-    {
-        $pos = strpos($buf, '<?xml');
-        if ($pos !== false) {
-            return xmlrpc_decode(substr($buf, $pos));
-        }
-        trigger_error("Cannot parse XML\n".$buf);
-    }
-
-    public function __call($method, $args)
-    {
-        $query  = xmlrpc_encode_request($method, $args);
-        if ($this->bt) {
-            $this->bt->start($method . "\n" . var_export($args, true));
-        }
-        $answer = $this->http_post($query, $this->urlparts);
-        if ($this->bt) {
-            $this->bt->stop();
-        }
-        $result = $this->find_and_decode_xml($answer);
-        if ($this->bt) {
-            if (is_array($result) && isset($result['faultCode'])) {
-                $this->bt->update(0, $result['faultString']);
-            } else {
-                $this->bt->update(count($result));
-            }
-        }
-
-        if (is_array($result) && isset($result['faultCode'])) {
-            trigger_error("Error in xmlrpc call $function\n".
-                          "  code   : {$result['faultCode']}\n".
-                          "  message: {$result['faultString']}\n");
-            return null;
-        }
-        return $result;
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 enc=utf-8:
-?>
similarity index 93%
rename from include/xnet/page.inc.php
rename to classes/xnetpage.php
index b32adc4..77ca8cb 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class XnetPage extends PlatalPage
+class XnetPage extends PlPage
 {
     public $nomenu = false;
 
     // {{{ function XnetPage()
 
-    public function __construct($tpl, $type=SKINNED)
+    public function __construct()
     {
-        parent::__construct($tpl, $type);
+        parent::__construct();
 
         $this->register_function('list_all_my_groups', 'list_all_my_groups');
         $this->register_modifier('cat_pp', 'cat_pp');
         $this->assign('it_is_xnet', true);
 
-        if (!S::logged() && Get::has('auth')) {
-            XnetSession::doAuthX();
+        global $globals;
+        $this->assign('is_logged', S::logged());
+        if ($globals->asso('id')) {
+            $this->assign('asso', $globals->asso());
+            $this->setType($globals->asso('cat'));
+            $this->assign('is_admin', may_update());
+            $this->assign('is_member', is_member());
         }
     }
 
@@ -50,22 +55,6 @@ class XnetPage extends PlatalPage
     }
 
     // }}}
-    // {{{ function changeTpl()
-
-    public function changeTpl($tpl, $type = SKINNED)
-    {
-        global $globals;
-        parent::changeTpl($tpl, $type);
-        $this->assign('is_logged', S::logged());
-        if ($globals->asso('id')) {
-            $this->assign('asso', $globals->asso());
-            $this->setType($globals->asso('cat'));
-            $this->assign('is_admin', may_update());
-            $this->assign('is_member', is_member());
-        }
-    }
-
-    // }}}
     // {{{ function setType
 
     public function setType($type)
similarity index 55%
rename from include/xnet/session.inc.php
rename to classes/xnetsession.php
index 92c189a..3f9dca1 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class XnetSession
+class XnetSession extends PlSession
 {
-    // {{{ function init
+    public function __construct()
+    {
+        parent::__construct();
+        S::bootstrap('perms_backup', new PlFlagSet());
+    }
 
-    public static function init()
+    public function startAvailableAuth()
     {
-        global $globals;
+        if (!(S::v('perms') instanceof PlFlagSet)) {
+            S::set('perms', S::v('perms_backup'));
+        }
 
-        S::init();
+        if (!S::logged() && Get::has('auth')) {
+            if (!$this->start(AUTH_MDP)) {
+                return false;
+            }
+        }
 
+        global $globals;
         if (!S::logged()) {
-            // prevent connexion to be linked to deconnexion
+            // prevent connection to be linked to disconnection
             if (($i = strpos($_SERVER['REQUEST_URI'], 'exit')) !== false)
                 $returl = "http://{$_SERVER['SERVER_NAME']}".substr($_SERVER['REQUEST_URI'], 0, $i);
             else
@@ -40,7 +51,7 @@ class XnetSession
             $url .= "&challenge=" . S::v('challenge');
             $url .= "&pass=" . md5(S::v('challenge') . $globals->xnet->secret);
             $url .= "&url=".urlencode($returl);
-            $_SESSION['loginX'] = $url;
+            S::set('loginX', $url);
         }
 
         if (S::logged() && $globals->asso()) {
@@ -62,123 +73,134 @@ class XnetSession
             if ($globals->asso('cat') == 'Promotions') {
                 $perms->addFlag('groupannu');
             }
-            $_SESSION['perms'] = $perms;
+            S::set('perms', $perms);
+            S::set('perms_backup', $perms);
         }
+        return true;
     }
 
-    // }}}
-    // {{{ public static function destroy()
-
-    public static function destroy() {
-        S::destroy();
-        XnetSession::init();
-    }
-
-    // }}}
-    // {{{ public static function doAuth()
-
-    /** Try to do an authentication.
-     *
-     * @param page the calling page (by reference)
-     */
-    public static function doAuth()
+    protected function doAuth($level)
     {
-       if (S::identified()) { // ok, c'est bon, on n'a rien à faire
-               return true;
-       }
-
-        if (Get::has('auth')) {
-            return XnetSession::doAuthX();
+        if (S::identified()) { // ok, c'est bon, on n'a rien à faire
+            return S::i('uid');
         }
-
-        return false;
-    }
-
-    // }}}
-    // {{{ doAuthCookie
-
-    public static function doAuthCookie() {
-        return XnetSession::doAuth();
+        if (!Get::has('auth')) {
+            return null;
+        }
+        global $globals;
+        if (md5('1' . S::v('challenge') . $globals->xnet->secret . Get::i('uid') . '1') != Get::v('auth')) {
+            return null;
+        }
+        Get::kill('auth');
+        S::set('auth', AUTH_MDP);
+        return Get::i('uid');
     }
 
-    // }}}
-    // {{{ doAuthX
-
-    public static function doAuthX()
+    protected function startSessionAs($user, $level)
     {
-        global $globals, $page;
+        global $globals;
 
-        if (md5('1'.S::v('challenge').$globals->xnet->secret.Get::i('uid').'1') != Get::v('auth')) {
-            Get::kill('auth');
-            if (!$page) {
-                require_once 'xnet.inc.php';
-                new_skinned_page('platal/index.tpl');
-            }
-            $page->kill("Erreur d'authentification avec polytechnique.org !");
+        if ($level == -1) {
+            S::set('auth', AUTH_MDP);
         }
-
-        $res  = XDB::query("
-            SELECT  u.user_id AS uid, prenom, nom, perms, promo, password, FIND_IN_SET('femme', u.flags) AS femme,
-                    a.alias AS forlife, a2.alias AS bestalias, q.core_mail_fmt AS mail_fmt, q.core_rss_hash
-              FROM  auth_user_md5   AS u
-        INNER JOIN  auth_user_quick AS q  USING(user_id)
-        INNER JOIN  aliases         AS a  ON (u.user_id = a.id AND a.type='a_vie')
-        INNER JOIN  aliases         AS a2 ON (u.user_id = a2.id AND FIND_IN_SET('bestalias',a2.flags))
-             WHERE  u.user_id = {?} AND u.perms IN('admin','user')
-             LIMIT  1", Get::i('uid'));
-        $_SESSION = array_merge($_SESSION, $res->fetchOneAssoc());
-        $_SESSION['auth'] = AUTH_MDP;
-        require_once 'xorg/session.inc.php';
-        $_SESSION['perms'] =& XorgSession::make_perms(S::v('perms'));
+        $res  = XDB::query('SELECT  u.user_id AS uid, prenom, nom, perms, promo, password, FIND_IN_SET(\'femme\', u.flags) AS femme,
+                                    a.alias AS forlife, a2.alias AS bestalias, q.core_mail_fmt AS mail_fmt, q.core_rss_hash
+                              FROM  auth_user_md5   AS u
+                        INNER JOIN  auth_user_quick AS q  USING(user_id)
+                        INNER JOIN  aliases         AS a  ON (u.user_id = a.id AND a.type = \'a_vie\')
+                        INNER JOIN  aliases         AS a2 ON (u.user_id = a2.id AND FIND_IN_SET(\'bestalias\', a2.flags))
+                             WHERE  u.user_id = {?} AND u.perms IN(\'admin\', \'user\')
+                             LIMIT  1', $user);
+        $sess = $res->fetchOneAssoc();
+        $perms = $sess['perms'];
+        unset($sess['perms']);
+        $_SESSION = array_merge($_SESSION, $sess);
+        $this->makePerms($perms);
         S::kill('challenge');
         S::kill('loginX');
         S::kill('may_update');
         S::kill('is_member');
-        Get::kill('auth');
         Get::kill('uid');
-        $path = Get::v('n');
-        Get::kill('n');
         Get::kill('PHPSESSID');
 
         $args = array();
         foreach($_GET as $key => $val) {
-            $args[] = urlencode($key).'='.urlencode($val);
+            $args[] = urlencode($key). '=' .urlencode($val);
         }
-
-        http_redirect($globals->baseurl . '/' . $path, join('&', $args));
+        return true;
     }
 
-    // }}}
-    // {{{ doSelfSuid
-
-    public static function doSelfSuid()
+    public function tokenAuth($login, $token)
     {
-        if (!S::has('suid')) {
-            $_SESSION['suid'] = $_SESSION;
+        // FIXME: we broke the session here because some RSS feeds (mainly wiki feeds) require
+        // a valid nome and checks the permissions. When the PlUser object will be ready, we'll
+        // be able to return a simple 'PlUser' object here without trying to alterate the
+        // session.
+        $res = XDB::query('SELECT  u.user_id AS uid, u.perms, u.nom, u.nom_usage, u.prenom, u.promo, FIND_IN_SET(\'femme\', u.flags) AS sexe
+                             FROM  aliases         AS a
+                       INNER JOIN  auth_user_md5   AS u ON (a.id = u.user_id AND u.perms IN ("admin", "user"))
+                       INNER JOIN  auth_user_quick AS q ON (a.id = q.user_id AND q.core_rss_hash = {?})
+                            WHERE  a.alias = {?} AND a.type != "homonyme"', $token, $login);
+        if ($res->numRows() == 1) {
+            $sess = $res->fetchOneAssoc();
+            if (!S::has('uid')) {
+                $_SESSION = $sess;
+                $this->makePerms($sess['perms']);
+                return S::i('uid');
+            } else if (S::i('uid') == $sess['uid']) {
+                return S::i('uid');
+            } else {
+                Platal::page()->kill('Invalid state. To be fixed when hruid is ready');
+            }
         }
-        require_once 'xorg/session.inc.php';
-        $_SESSION['perms'] =& XorgSession::make_perms('user');
+        return null;
     }
 
-    // }}}
-    // {{{ killSuid
-
-    public static function killSuid()
+    public function doSelfSuid()
     {
-        if (!S::has('suid')) {
-            return;
+        if (!$this->startSUID(S::i('uid'))) {
+            return false;
         }
+        $this->makePerms('user');
+        return true;
+    }
+
+    public function stopSUID()
+    {
         $suid = S::v('suid');
+        if (!parent::stopSUID()) {
+            return false;
+        }
         S::kill('suid');
         S::kill('may_update');
         S::kill('is_member');
-        $_SESSION['perms'] = $suid['perms'];
+        S::set('perms', $suid['perms']);
+        S::set('perms_backup', $suid['perms_backup']);
+        return true;
     }
 
-    // }}}
+    public function makePerms($perm)
+    {
+        $flags = new PlFlagSet();
+        if ($perm == 'disabled' || $perm == 'ext') {
+            S::set('perms', $flags);
+            S::set('perms_backup', $flags);
+            return;
+        }
+        $flags->addFlag(PERMS_USER);
+        if ($perm == 'admin') {
+            $flags->addFlag(PERMS_ADMIN);
+        }
+        S::set('perms', $flags);
+        S::set('perms_backup', $flags);
+    }
+
+    public function sureLevel()
+    {
+        return AUTH_MDP;
+    }
 }
 
-// }}}
 // {{{ function may_update
 
 /** Return administration rights for the current asso
similarity index 76%
rename from classes/mmlist.php
rename to classes/xorgpage.php
index a16b1c6..f0d42ea 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class MMList extends XmlrpcClient
+class XorgPage extends PlPage
 {
-    public function __construct($uid, $pass, $fqdn = null)
+    public function __construct()
     {
-        global $globals;
+        parent::__construct();
 
-        $dom = is_null($fqdn) ? $globals->mail->domain : $fqdn;
-        $url = "http://$uid:$pass@{$globals->lists->rpchost}:{$globals->lists->rpcport}/$dom";
-        parent::__construct($url);
-        if ($globals->debug & DEBUG_BT) {
-            $this->bt = new PlBacktrace('MMList');
+        // Set the default page
+        $this->changeTpl('platal/index.tpl');
+    }
+
+    public function run()
+    {
+        global $globals, $platal;
+        if (isset($platal) && $platal->path == 'register') {
+            $skin = $globals->register_skin . ".tpl";
+        } else {
+            $skin = S::v('skin', $globals->skin . ".tpl");
         }
+        $this->_run('skin/' . $skin);
     }
 }
 
diff --git a/classes/xorgsession.php b/classes/xorgsession.php
new file mode 100644 (file)
index 0000000..48a2664
--- /dev/null
@@ -0,0 +1,340 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 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 XorgSession extends PlSession
+{
+    public function __construct()
+    {
+        parent::__construct();
+        S::bootstrap('perms_backup', new PlFlagSet());
+    }
+
+    public function startAvailableAuth()
+    {
+        if (!(S::v('perms') instanceof PlFlagSet)) {
+            S::set('perms', S::v('perms_backup'));
+        }
+        if (!S::logged()) {
+            $cookie = $this->tryCookie();
+            if ($cookie == 0) {
+                return $this->start(AUTH_COOKIE);
+            } else if ($cookie == 1 || $cookie == -2) {
+                return false;
+            }
+        }
+        if ((check_ip('dangerous') && S::has('uid')) || check_account()) {
+            $_SESSION['log']->log("view_page", $_SERVER['REQUEST_URI']);
+        }
+        return true;
+    }
+
+    /** Check the cookie and set the associated user_id in the auth_by_cookie session variable.
+     */
+    private function tryCookie()
+    {
+        S::kill('auth_by_cookie');
+        if (Cookie::v('ORGaccess') == '' || !Cookie::has('ORGuid')) {
+            return -1;
+        }
+
+        $res = XDB::query('SELECT  user_id, password
+                             FROM  auth_user_md5
+                            WHERE  user_id = {?} AND perms IN(\'admin\', \'user\')',
+                         Cookie::i('ORGuid'));
+        if ($res->numRows() != 0) {
+            list($uid, $password) = $res->fetchOneRow();
+            require_once 'secure_hash.inc.php';
+            $expected_value = hash_encrypt($password);
+            if ($expected_value == Cookie::v('ORGaccess')) {
+                S::set('auth_by_cookie', $uid);
+                return 0;
+            } else {
+                return 1;
+            }
+        }
+        return -2;
+    }
+
+    private function checkPassword($uname, $login, $response, $login_type)
+    {
+        $res = XDB::query('SELECT  u.user_id, u.password
+                             FROM  auth_user_md5 AS u
+                       INNER JOIN  aliases       AS a ON (a.id = u.user_id AND type != \'homonyme\')
+                             WHERE  a.' . $login_type . ' = {?} AND u.perms IN(\'admin\', \'user\')',
+                          $login);
+        if (list($uid, $password) = $res->fetchOneRow()) {
+            require_once 'secure_hash.inc.php';
+            $expected_response = hash_encrypt("$uname:$password:" . S::v('challenge'));
+            if ($response != $expected_response) {
+                $new_password = hash_xor(Env::v('xorpass'), $password);
+                $expected_response = hash_encrypt("$uname:$new_password:" . S::v('challenge'));
+                if ($response == $expected_response) {
+                      XDB::execute('UPDATE  auth_user_md5
+                                       SET  password = {?}
+                                     WHERE  user_id = {?}',
+                                   $new_password, $uid);
+                }
+            }
+            if ($response != $expected_response) {
+                S::logger($uid)->log('auth_fail', 'bad password');
+                return null;
+            }
+            return $uid;
+        }
+        return null;
+    }
+
+
+    /** Check auth.
+     */
+    protected function doAuth($level)
+    {
+        global $globals;
+
+        /* Cookie authentication
+         */
+        if ($level == AUTH_COOKIE && !S::has('auth_by_cookie')) {
+            $this->tryCookie();
+        }
+        if ($level == AUTH_COOKIE && S::has('auth_by_cookie')) {
+            if (!S::logged()) {
+                S::set('auth', AUTH_COOKIE);
+            }
+            return S::i('auth_by_cookie');
+        }
+
+
+        /* We want to do auth... we must have infos from a form.
+         */
+        if (!Post::has('username') || !Post::has('response') || !S::has('challenge')) {
+            return null;
+        }
+
+        /** We come from an authentication form.
+         */
+        if (S::has('suid')) {
+            $suid  = S::v('suid');
+            $login = $uname = $suid['forlife'];
+            $redirect = false;
+        } else {
+            $uname = Env::v('username');
+
+            if (Env::v('domain') == "alias") {
+                $res = XDB::query('SELECT  redirect
+                                     FROM  virtual
+                               INNER JOIN  virtual_redirect USING(vid)
+                                    WHERE  alias LIKE {?}',
+                                   $uname . '@' . $globals->mail->alias_dom);
+                $redirect = $res->fetchOneCell();
+                if ($redirect) {
+                    $login = substr($redirect, 0, strpos($redirect, '@'));
+                } else {
+                    $login = '';
+                }
+            } else {
+                $login = $uname;
+                $redirect = false;
+            }
+        }
+
+        $uid = $this->checkPassword($uname, $login, Post::v('response'), (!$redirect && preg_match('/^\d*$/', $uname)) ? 'id' : 'alias');
+        if (!is_null($uid)) {
+            S::set('auth', AUTH_MDP);
+            if (Post::has('domain')) {
+                if (($domain = Post::v('domain', 'login')) == 'alias') {
+                    setcookie('ORGdomain', "alias", (time() + 25920000), '/', '', 0);
+                } else {
+                    setcookie('ORGdomain', '', (time() - 3600), '/', '', 0);
+                }
+                // pour que la modification soit effective dans le reste de la page
+                $_COOKIE['ORGdomain'] = $domain;
+            }
+            S::kill('challenge');
+            S::logger($uid)->log('auth_ok');
+        }
+        return $uid;
+    }
+
+    protected function startSessionAs($uid, $level)
+    {
+        if ((!is_null(S::v('user')) && S::i('user') != $uid) || (S::has('uid') && S::i('uid') != $uid)) {
+            return false;
+        } else if (S::has('uid')) {
+            return true;
+        }
+        if ($level == -1) {
+            S::set('auth', AUTH_COOKIE);
+        }
+        unset($_SESSION['log']);
+
+        // Retrieves main user properties.
+        $res  = XDB::query('SELECT  u.user_id AS uid, prenom, prenom_ini, nom, nom_ini, nom_usage, perms, promo, promo_sortie,
+                                    matricule, password, FIND_IN_SET(\'femme\', u.flags) AS femme,
+                                    a.alias AS forlife, a2.alias AS bestalias,
+                                    q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash,
+                                    FIND_IN_SET(\'watch\', u.flags) AS watch_account, q.last_version, g.g_account_name IS NOT NULL AS googleapps
+                              FROM  auth_user_md5   AS u
+                        INNER JOIN  auth_user_quick AS q  USING(user_id)
+                        INNER JOIN  aliases         AS a  ON (u.user_id = a.id AND a.type = \'a_vie\')
+                        INNER JOIN  aliases         AS a2 ON (u.user_id = a2.id AND FIND_IN_SET(\'bestalias\', a2.flags))
+                         LEFT JOIN  gapps_accounts  AS g  ON (u.user_id = g.l_userid AND g.g_status = \'active\')
+                             WHERE  u.user_id = {?} AND u.perms IN(\'admin\', \'user\')', $uid);
+        $sess = $res->fetchOneAssoc();
+        $perms = $sess['perms'];
+        unset($sess['perms']);
+
+        // Retrieves account usage information (last login, last host).
+        $res = XDB::query('SELECT  UNIX_TIMESTAMP(s.start) AS lastlogin, s.host
+                             FROM  logger.sessions AS s
+                            WHERE  s.uid = {?} AND s.suid = 0
+                         ORDER BY  s.start DESC
+                            LIMIT  1', $uid);
+        if ($res->numRows()) {
+            $sess = array_merge($sess, $res->fetchOneAssoc());
+        }
+
+        // Loads the data into the real session.
+        $_SESSION = array_merge($_SESSION, $sess);
+
+        // Starts the session's logger, and sets up the permanent cookie.
+        if (S::has('suid')) {
+            $suid = S::v('suid');
+            $logger = S::logger($uid);
+            $logger->log("suid_start", S::v('forlife') . " by " . $suid['uid']);
+        } else {
+            $logger = S::logger($uid);
+            setcookie('ORGuid', $uid, (time() + 25920000), '/', '', 0);
+            if (Post::v('remember', 'false') == 'true') {
+                $cookie = hash_encrypt($sess['password']);
+                setcookie('ORGaccess', $cookie, (time() + 25920000), '/', '', 0);
+                if ($logger) {
+                    $logger->log("cookie_on");
+                }
+            } else {
+                setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
+                if ($logger) {
+                    $logger->log("cookie_off");
+                }
+            }
+        }
+
+        // Finalizes the session setup.
+        $this->makePerms($perms);
+        $this->securityChecks();
+        $this->setSkin();
+        $this->updateNbNotifs();
+        check_redirect();
+        return true;
+    }
+
+    private function securityChecks()
+    {
+        $mail_subject = array();
+        if (check_account()) {
+            $mail_subject[] = 'Connexion d\'un utilisateur surveillé';
+        }
+        if (check_ip('unsafe')) {
+            $mail_subject[] = 'Une IP surveillee a tente de se connecter';
+            if (check_ip('ban')) {
+                send_warning_mail(implode(' - ', $mail_subject));
+                $this->destroy();
+                Platal::page()->kill('Une erreur est survenue lors de la procédure d\'authentification. '
+                                    . 'Merci de contacter au plus vite '
+                                    . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>');
+                return false;
+            }
+        }
+        if (count($mail_subject)) {
+            send_warning_mail(implode(' - ', $mail_subject));
+        }
+    }
+
+    public function tokenAuth($login, $token)
+    {
+        // FIXME: we broke the session here because some RSS feeds (mainly wiki feeds) require
+        // a valid nome and checks the permissions. When the PlUser object will be ready, we'll
+        // be able to return a simple 'PlUser' object here without trying to alterate the
+        // session.
+        $res = XDB::query('SELECT  u.user_id AS uid, u.perms, u.nom, u.nom_usage, u.prenom, u.promo, FIND_IN_SET(\'femme\', u.flags) AS sexe
+                             FROM  aliases         AS a
+                       INNER JOIN  auth_user_md5   AS u ON (a.id = u.user_id AND u.perms IN ("admin", "user"))
+                       INNER JOIN  auth_user_quick AS q ON (a.id = q.user_id AND q.core_rss_hash = {?})
+                            WHERE  a.alias = {?} AND a.type != "homonyme"', $token, $login);
+        if ($res->numRows() == 1) {
+            $sess = $res->fetchOneAssoc();
+            if (!S::has('uid')) {
+                $_SESSION = $sess;
+                $this->makePerms($sess['perms']);
+                return S::i('uid');
+            } else if (S::i('uid') == $sess['uid']) {
+                return S::i('uid');
+            } else {
+                Platal::page()->kill('Invalid state. To be fixed when hruid is ready');
+            }
+        }
+        return null;
+    }
+
+    public function makePerms($perm)
+    {
+        $flags = new PlFlagSet();
+        if ($perm == 'disabled' || $perm == 'ext') {
+            S::set('perms', $flags);
+            S::set('perms_backup', $flags);
+            return;
+        }
+        $flags->addFlag(PERMS_USER);
+        if ($perm == 'admin') {
+            $flags->addFlag(PERMS_ADMIN);
+        }
+        S::set('perms', $flags);
+        S::set('perms_backup', $flags);
+    }
+
+    public function setSkin()
+    {
+        global $globals;
+        if (S::logged() && (!S::has('skin') || S::has('suid'))) {
+            $uid = S::v('uid');
+            $res = XDB::query("SELECT  skin_tpl
+                                 FROM  auth_user_quick AS a
+                           INNER JOIN  skins           AS s ON a.skin = s.id
+                                WHERE  user_id = {?} AND skin_tpl != ''", $uid);
+            S::set('skin', $res->fetchOneCell());
+        }
+    }
+
+    public function sureLevel()
+    {
+        return AUTH_MDP;
+    }
+
+
+    public function updateNbNotifs()
+    {
+        require_once 'notifs.inc.php';
+        $n = select_notifs(false, S::i('uid'), S::v('watch_last'), false);
+        S::set('notifs', $n->numRows());
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
diff --git a/core b/core
new file mode 160000 (submodule)
index 0000000..ec53789
--- /dev/null
+++ b/core
@@ -0,0 +1 @@
+Subproject commit ec537891a3f18af89489062c0907523d3d57cced
index 739c58d..432ca6f 100644 (file)
@@ -19,7 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once dirname(__FILE__).'/../include/xorg.inc.php';
+require_once 'xorg.inc.php';
 
 preg_match('!^/(moderate|admin|members|archives)/(.*)_([^_]*)(/.*)?$!', $_SERVER['REQUEST_URI'], $matches);
 
index cca10b1..0de8baa 100644 (file)
@@ -19,7 +19,9 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once dirname(__FILE__).'/../include/xorg.inc.php';
+require_once 'xorg.inc.php';
+
+new Platal('core');
 
 global $globals;
 list($username, $path) = preg_split('/\//', $_SERVER["REQUEST_URI"], 2, PREG_SPLIT_NO_EMPTY);
@@ -53,5 +55,7 @@ header("HTTP/1.0 404 Not Found");
     <hr>
     <address>Apache Server at www.carva.org Port 80</address>
   </body>
+</html>
+<?php
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 592ba18..b1363f0 100644 (file)
  ***************************************************************************/
 
 $GLOBALS['IS_XNET_SITE'] = true;
-global $platal, $globals, $page;
 
 require_once dirname(__FILE__).'/../include/xnet.inc.php';
 
+$platal = new Xnet('xnet', 'xnetgrp', 'xnetlists', 'xnetevents', 'geoloc', 'payment', 'bandeau');
 if (!($path = Env::v('n')) || substr($path, 0, 4) != 'Xnet') {
-    $platal = new Xnet('xnet', 'xnetgrp', 'xnetlists', 'xnetevents', 'geoloc', 'payment', 'bandeau');
     $platal->run();
-
     exit;
 }
 
 /*** WIKI CODE ***/
 
-include 'wiki/engine.php';
+include dirname(__FILE__) . '/../core/include/wiki.engine.inc.php'; 
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 93226b9..affbb37 100644 (file)
  ***************************************************************************/
 
 require_once dirname(__FILE__).'/../include/xorg.inc.php';
-global $globals, $platal, $page;
 
-if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) {
+$platal = new Platal('auth', 'carnet', 'email', 'events', 'forums',
+                     'geoloc', 'lists', 'marketing', 'payment', 'platal',
+                     'profile', 'register', 'search', 'stats', 'admin',
+                     'newsletter', 'axletter', 'bandeau', 'survey',
+                     'gadgets', 'googleapps');
 
-    $platal = new Platal('auth', 'carnet', 'email', 'events', 'forums',
-                         'geoloc', 'lists', 'marketing', 'payment', 'platal',
-                         'profile', 'register', 'search', 'stats', 'admin',
-                         'newsletter', 'axletter', 'bandeau', 'survey',
-                         'gadgets', 'googleapps');
+if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) {
     $platal->run();
-
     exit;
 }
 
 /*** WIKI CODE ***/
 
-include 'wiki/engine.php';
+include dirname(__FILE__) . '/../core/include/wiki.engine.inc.php';
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
diff --git a/include/.gitignore b/include/.gitignore
deleted file mode 100644 (file)
index c68a431..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/globals.inc.php
index 849adc3..82235db 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-global $page;
-
 function applis_options($current=0) {
     $html = '<option value="-1"></option>';
     $res  = XDB::iterator("select * from applis_def order by text");
@@ -38,7 +36,7 @@ function _applis_options_smarty($params){
         $params['selected'] = 0;
     return applis_options($params['selected']);
 }
-$page->register_function('applis_options','_applis_options_smarty');
+Platal::page()->register_function('applis_options','_applis_options_smarty');
 
 
 /** affiche un Array javascript contenant les types de chaque appli
@@ -54,7 +52,7 @@ function applis_type(){
     }
     return $html;
 }
-$page->register_function('applis_type','applis_type');
+Platal::page()->register_function('applis_type','applis_type');
 
 /** affiche tous les types possibles d'applis
  */
@@ -63,7 +61,7 @@ function applis_type_all(){
     $arr_appli = $res->fetchOneAssoc();
     return str_replace(")","",str_replace("set(","",$arr_appli["Type"]));
 }
-$page->register_function('applis_type_all','applis_type_all');
+Platal::page()->register_function('applis_type_all','applis_type_all');
 
 /** formatte une ecole d'appli pour l'affichage
  */
@@ -87,7 +85,7 @@ function _applis_fmt($params, &$smarty) {
     extract($params);
     return applis_fmt($type, $text, $url);
 }
-$page->register_function('applis_fmt','_applis_fmt');
+Platal::page()->register_function('applis_fmt','_applis_fmt');
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 3e14a78..53d01c6 100644 (file)
@@ -179,7 +179,8 @@ class ForumsBanana extends Banana
 
     protected function action_updateProfile()
     {
-        global $page, $globals;
+        global $globals;
+        $page = Platal::page();
 
         $colors = glob(dirname(__FILE__) . '/../../htdocs/images/banana/m2*.gif');
         foreach ($colors as $key=>$path) {
index f0a2362..aa44917 100644 (file)
@@ -200,8 +200,7 @@ function hook_getXFace($headers)
 
 function hook_makeJs($src)
 {
-    global $page;
-    $page->addJsLink("$src.js");
+    Platal::page()->addJsLink("$src.js");
     return ' ';
 }
 
@@ -290,12 +289,12 @@ class PlatalBananaPage extends BananaPage
     protected function prepare()
     {
         $tpl = parent::prepare();
-        global $wiz, $page;
+        global $wiz;
         $wiz = new PlWizard('Banana', 'core/plwizard.tpl', true, false);
         foreach ($this->pages as $name=>&$mpage) {
             $wiz->addPage($this->handler, $mpage['text'], $name);
         }
-        $wiz->apply($page, $this->base, $this->page);
+        $wiz->apply(Platal::page(), $this->base, $this->page);
         return $tpl;
     }
 }
@@ -311,7 +310,7 @@ class BananaHandler
         return 'banana/index.tpl';
     }
 
-    public function prepare(PlatalPage &$page, $id)
+    public function prepare(PlPage &$page, $id)
     {
     }
 
index a410cbf..9e5588a 100644 (file)
@@ -91,10 +91,7 @@ class ModerationPage extends BananaPage
 
     public function trig($msg)
     {
-        global $page;
-        if ($page) {
-            $page->trigError($msg);
-        }
+        Platal::page()->trigError($msg);
         return true;
     }
 }
similarity index 79%
rename from plugins/modifier.miniwiki.php
rename to include/common.inc.php
index d47e221..35296b4 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once 'platal.inc.php';
-
-function smarty_modifier_miniwiki($string, $format = 'no_title', $type = 'html')
+function __autoload($cls)
 {
-    if ($type == 'html') {
-        return MiniWiki::wikiToHTML($string, $format == 'title');
-    } else {
-        return MiniWiki::wikiToText($string, false, 0, 80, $format == 'title');
+    if (!pl_autoload($cls)) {
+        $cls = strtolower($cls);
+        if (substr($cls, -3, 3) == 'req') {
+            @include 'validations.inc.php';
+            return;
+        } else if (substr($cls, 0, 6) == 'banana') {
+            require_once 'banana/banana.inc.php';
+            Banana::load(substr($cls, 6));
+            return;
+        }
+        @include "$cls.inc.php";
     }
 }
 
index 7f4f17d..be0b6fd 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once("xorg.misc.inc.php");
-
 define("SUCCESS", 1);
 define("ERROR_INACTIVE_REDIRECTION", 2);
 define("ERROR_INVALID_EMAIL", 3);
@@ -186,7 +184,7 @@ class EmailRedirection extends Email
                              SET  panne_level = IF(flags = 'panne', panne_level - 1, panne_level),
                                   flags = 'active'
                            WHERE  uid={?} AND email={?}", $this->uid, $this->email);
-            $_SESSION['log']->log("email_on", $this->email.($this->uid!=S::v('uid') ? "(admin on {$this->uid})" : ""));
+            S::logger()->log("email_on", $this->email.($this->uid!=S::v('uid') ? "(admin on {$this->uid})" : ""));
             $this->active = true;
             $this->broken = false;
         }
@@ -199,7 +197,7 @@ class EmailRedirection extends Email
         if ($this->active) {
             XDB::execute("UPDATE  emails SET flags =''
                            WHERE  uid={?} AND email={?}", $this->uid, $this->email);
-            $_SESSION['log']->log("email_off",$this->email.($this->uid != S::v('uid') ? "(admin on {$this->uid})" : "") );
+            S::logger()->log("email_off",$this->email.($this->uid != S::v('uid') ? "(admin on {$this->uid})" : "") );
             $this->active = false;
         }
     }
@@ -273,7 +271,7 @@ class EmailStorage extends Email
         $res = XDB::query("SELECT  mail_storage
                              FROM  auth_user_md5
                             WHERE  user_id = {?}", $this->uid);
-        return new FlagSet($res->fetchOneCell());
+        return new PlFlagSet($res->fetchOneCell());
     }
 
     // Updates the list of active storages.
@@ -411,7 +409,7 @@ class Redirect
             return ERROR_INACTIVE_REDIRECTION;
         }
         XDB::execute('DELETE FROM emails WHERE uid={?} AND email={?}', $this->uid, $email);
-        $_SESSION['log']->log('email_del',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
+        S::logger()->log('email_del',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
         foreach ($this->emails as $i => $mail) {
             if ($email == $mail->email) {
                 unset($this->emails[$i]);
@@ -434,7 +432,7 @@ class Redirect
         }
         XDB::execute('REPLACE INTO emails (uid,email,flags) VALUES({?},{?},"active")', $this->uid, $email);
         if ($logger = S::v('log', null)) { // may be absent --> step4.php
-            $logger->log('email_add',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
+            S::logger()->log('email_add',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
         }
         foreach ($this->emails as $mail) {
             if ($mail->email == $email_stripped) {
diff --git a/include/globals.inc.php.in b/include/globals.inc.php.in
deleted file mode 100644 (file)
index f052c6b..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 PlatalGlobals
-{
-    public $session;
-
-    /** The x.org version */
-    public $version = '@VERSION@';
-    public $debug   = 0;
-    public $mode    = 'rw';    // 'rw' => read/write,
-                               // 'r'  => read/only
-                               // ''   => site down
-
-    /** db params */
-    public $dbdb               = 'x4dat';
-    public $dbhost             = 'localhost';
-    public $dbuser             = 'x4dat';
-    public $dbpwd              = 'x4dat';
-    public $dbcharset          = 'utf8';
-
-    /** default skin */
-    public $skin;
-    public $register_skin;
-
-    /** paths */
-    public $baseurl;
-    public $baseurl_http;
-    public $spoolroot;
-
-    public $locale;
-    public $timezone;
-
-    public function __construct($sess)
-    {
-        $this->session   = $sess;
-        $this->spoolroot = dirname(dirname(__FILE__));
-
-        $this->read_config();
-        if (isset($_SERVER) && isset($_SERVER['SERVER_NAME'])) {
-            $base = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
-            $this->baseurl      = @trim($base    .$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
-            $this->baseurl_http = @trim('http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
-        }
-
-        $this->setlocale();
-    }
-
-    private function read_ini_file($filename)
-    {
-        $array = parse_ini_file($filename, true);
-        if (!is_array($array)) {
-            return;
-        }
-        foreach ($array as $cat => $conf) {
-            $c = strtolower($cat);
-            foreach ($conf as $k => $v) {
-                if ($c == 'core' && property_exists($this, $k)) {
-                    $this->$k=$v;
-                } else {
-                    if (!isset($this->$c)) {
-                        $this->$c = new stdClass;
-                    }
-                    $this->$c->$k = $v;
-                }
-            }
-        }
-    }
-
-    private function read_config()
-    {
-        $this->read_ini_file($this->spoolroot.'/configs/platal.ini');
-        $this->read_ini_file($this->spoolroot.'/configs/platal.conf');
-        if (file_exists($this->spoolroot.'/spool/conf/platal.dynamic.conf')) {
-            $this->read_ini_file($this->spoolroot.'/spool/conf/platal.dynamic.conf');
-        }
-    }
-
-    /** Writes an ini file separated in categories
-     * @param filename the name of the file to write (overwrite existing)
-     * @param categories an array of categories (array of keys and values)
-     */              
-    private static function write_ini_file($filename, &$categories)
-    {
-        // [category]
-        // key = value
-        $f = fopen($filename, 'w');
-        foreach ($categories as $cat => $conf) {
-            fwrite($f, '; {{{ '.$cat."\n\n");
-            fwrite($f, '['.$cat.']'."\n\n");
-            foreach ($conf as $k => $v) {
-                fwrite($f, $k.' = "'.str_replace('"','\\"',$v).'"'."\n");
-            }
-            fwrite($f, "\n".'; }}}'."\n");
-        }
-        fwrite($f, '; vim:set syntax=dosini foldmethod=marker:'."\n");
-        fclose($f);
-    }
-
-    /** Change dynamic config file
-     * @param conf array of keys and values to add or replace
-     * @param category name of category to change
-     * 
-     * Opens the dynamic conf file and set values from conf in specified
-     * category. Updates config vars too.
-     */ 
-    public function change_dynamic_config($conf, $category = 'Core')
-    {
-        $dynamicfile = $this->spoolroot.'/spool/conf/platal.dynamic.conf';
-        if (file_exists($dynamicfile)) {
-            $array = parse_ini_file($dynamicfile, true);
-        } else {
-            $array = null;
-        }
-        if (!is_array($array)) {
-            // dynamic conf is empty
-            $array = array($category => $conf);
-        } else {
-            // looks for a category that looks the same (case insensitive)
-            $same = false;
-            foreach ($array as $m => &$c) {
-                if (strtolower($m) == strtolower($category)) {
-                    $same = $m;
-                    break;
-                }
-            }
-            if (!$same) {
-                // this category doesn't exist yet
-                $array[$category] = $conf;
-            } else {
-                // this category already exists
-                $conflower = array();
-                foreach ($conf as $k => $v) {
-                    $conflower[strtolower($k)] = $v;
-                }
-                // $conflower is now same as $conf but with lower case keys
-                // replaces values of keys that already exists
-                foreach ($array[$same] as $k => $v) {
-                    if (isset($conflower[strtolower($k)])) {
-                        $array[$same][$k] = $conflower[strtolower($k)];
-                        unset($conflower[strtolower($k)]);
-                    }
-                }
-                // add new keys
-                foreach ($conf as $k => $v) {
-                    if (isset($conflower[strtolower($k)])) {
-                        $array[$same][$k] = $v;
-                    }
-                } 
-            }
-        }
-        // writes the file over
-        PlatalGlobals::write_ini_file($dynamicfile, $array);
-        // rereads the new config to correctly set vars
-        $this->read_ini_file($dynamicfile);
-    }
-
-    public function bootstrap($conf, $callback, $category = 'Core')
-    {
-        $bootstrap = false;
-        $category = strtolower($category);
-        foreach ($conf as $key) {
-            if (!isset($this->$category->$key)) {
-                $bootstrap = true;
-                break;
-            }
-        }
-        if ($bootstrap) {
-            call_user_func($callback);
-        }
-    }
-
-    private function setlocale()
-    {
-        setlocale(LC_MESSAGES, $this->locale);
-        setlocale(LC_TIME,     $this->locale);
-        setlocale(LC_CTYPE,    $this->locale);
-        date_default_timezone_set($this->timezone);
-        mb_internal_encoding("UTF-8");
-    }
-
-    public function asso($key=null)
-    {
-        static $aid = null;
-
-        if (is_null($aid)) {
-            $gp = Get::v('n');
-            if ($p = strpos($gp, '/')) {
-                $gp = substr($gp, 0, $p);
-            }
-
-            if ($gp) {
-                $res = XDB::query('SELECT  a.*, d.nom AS domnom,
-                                           FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc,
-                                           FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub
-                                     FROM  groupex.asso AS a
-                                LEFT JOIN  groupex.dom  AS d ON d.id = a.dom
-                                    WHERE  diminutif = {?}', $gp);
-                if (!($aid = $res->fetchOneAssoc())) {
-                    $aid = array();
-                }
-            } else {
-                $aid = array();
-            }
-        }
-        if (empty($key)) {
-            return $aid;
-        } elseif ( isset($aid[$key]) ) {
-            return $aid[$key];
-        } else {
-            return null;
-        }
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index f6dd15d..f397ad0 100644 (file)
@@ -53,7 +53,6 @@ class Marketing
 
     private function getUser($uid, $email)
     {
-        require_once("xorg.misc.inc.php");
         $res = XDB::query("SELECT  FIND_IN_SET('femme', flags) AS sexe, nom, prenom, promo
                              FROM  auth_user_md5
                             WHERE  user_id = {?}", $uid);
@@ -276,7 +275,7 @@ class AnnuaireMarketing implements MarketingEngine
         return $this->signature;
     }
 
-    protected function prepareText(PlatalPage &$page, array $user)
+    protected function prepareText(PlPage &$page, array $user)
     {
         $page->assign('intro', $this->getIntro());
         $page->assign('u', $user);
@@ -287,7 +286,8 @@ class AnnuaireMarketing implements MarketingEngine
 
     public function getText(array $user)
     {
-        $page = new XorgPage('marketing/marketing.mail.tpl', NO_SKIN);
+        $page = new XorgPage();
+        $page->changeTpl('marketing/marketing.mail.tpl', NO_SKIN);
         $this->prepareText($page, $user);
         return $page->raw();
     }
index 19996fe..a1d49f3 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once("xorg.misc.inc.php");
-
 // {{{ class MassMailer
 
 abstract class MassMailer
index 0bcf655..d48f010 100644 (file)
@@ -54,8 +54,7 @@ function register_watch_op($uid, $cid, $date='', $info='')
                              WHERE  ni_id={?}', $uid);
         XDB::execute('DELETE FROM watch_nonins WHERE ni_id={?}', $uid);
     }
-    require_once 'xorg.misc.inc.php';
-    update_NbNotifs();
+    Platal::session()->updateNbNotifs();
 }
 
 // }}}
diff --git a/include/platal.inc.php b/include/platal.inc.php
deleted file mode 100644 (file)
index 6bfd24f..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-$TIME_BEGIN = microtime(true);
-
-define('AUTH_PUBLIC', 0);
-define('AUTH_COOKIE', 1);
-define('AUTH_MDP',    2);
-
-define('PERMS_EXT',   'ext');
-define('PERMS_USER',  'user');
-define('PERMS_ADMIN', 'admin');
-
-define('SKINNED', 0);
-define('SIMPLE',  1);
-define('NO_SKIN', 2);
-
-define('NO_AUTH', 0);
-define('DO_AUTH', 1);
-define('NO_HTTPS', 2);
-
-define('DEBUG_BT', 1);
-define('DEBUG_VALID', 2);
-define('DEBUG_SMARTY', 4);
-
-function __autoload($cls)
-{
-    $cls  = strtolower($cls);
-    $path = dirname(dirname(__FILE__));
-    if (!@include "$path/classes/$cls.php") {
-        if (substr($cls, -3, 3) == 'req') {
-            @include 'validations.inc.php';
-            return;
-        } else if (substr($cls, 0, 6) == 'banana') {
-            require_once 'banana/banana.inc.php';
-            Banana::load(substr($cls, 6));
-            return;
-        }
-        @include "$cls.inc.php";
-    }
-}
-__autoload('Env');
-
-function pl_error_handler($errno, $errstr, $errfile, $errline)
-{
-    static $errortype;
-    if (!error_reporting())
-        return;
-
-    if (!isset($errortype)) {
-        $errortype = array (
-            E_ERROR           => "Error",
-            E_WARNING         => "Warning",
-            E_PARSE           => "Parsing Error",
-            E_NOTICE          => "Notice",
-            E_CORE_ERROR      => "Core Error",
-            E_CORE_WARNING    => "Core Warning",
-            E_COMPILE_ERROR   => "Compile Error",
-            E_COMPILE_WARNING => "Compile Warning",
-            E_USER_ERROR      => "User Error",
-            E_USER_WARNING    => "User Warning",
-            E_USER_NOTICE     => "User Notice",
-            E_STRICT          => "Runtime Notice",
-            E_RECOVERABLE_ERROR => "Recoverable Error"
-        );
-    }
-
-    global $globals;
-    if (isset($globals) && !$globals->debug) {
-        if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) {
-            return;
-        }
-    }
-
-    $type = isset($errortype[$errno]) ? $errortype[$errno] : $errno;
-    $errstr = utf8_encode(htmlentities($errstr));
-    $GLOBALS['pl_errors'][] =
-        "<div class='phperror'>".
-        "<strong>{$type}</strong> <em>$errstr</em><br />".
-        "<tt>$errfile : $errline</tt>".
-        "</div>";
-}
-
-function pl_clear_errors()
-{
-    unset($GLOBALS['pl_errors']);
-}
-
-function pl_dump_env()
-{
-    echo "<div class='phperror'><pre>";
-    echo "\nSESSION: "; var_export($_SESSION);
-    echo "\nPOST:    "; var_export($_POST);
-    echo "\nGET:     "; var_export($_GET);
-    echo "\nCOOKIE:  "; var_export($_COOKIE);
-    echo "</pre></div>";
-}
-
-function pl_print_errors()
-{
-    if (!empty($GLOBALS['pl_errors'])) {
-        print join("\n", $GLOBALS['pl_errors']);
-    }
-}
-
-set_error_handler('pl_error_handler', E_ALL | E_STRICT);
-register_shutdown_function('pl_print_errors');
-// register_shutdown_function('pl_dump_env');
-
-/** Check if the string is utf8
- */
-function is_utf8($s)
-{
-    return @iconv('utf-8', 'utf-8', $s) == $s;
-}
-
-/** vérifie si une adresse email est bien formatée  * ATTENTION, cette fonction ne doit pas être appelée sur une chaîne ayant subit un addslashes (car elle accepte le "'" qui it alors un "\'"
- * @param $email l'adresse email a verifier
- * @return BOOL  */
-function isvalid_email($email)
-{
-    // la rfc2822 authorise les caractères "a-z", "0-9", "!", "#", "$", "%", "&", "'", "*", "+", "-", "/", "=", "?", "^",  `", "{", "|", "}", "~" aussi bien dans la partie locale que dans le domaine.
-    // Pour la partie locale, on réduit cet ensemble car il n'est pas utilisé.
-    // Pour le domaine, le système DNS limite à [a-z0-9.-], on y ajoute le "_" car il est parfois utilisé.
-    return preg_match("/^[a-z0-9_.'+-]+@[a-z0-9._-]+\.[a-z]{2,6}$/i", $email);
-}
-
-function pl_url($path, $query = null, $fragment = null)
-{
-    global $platal;
-
-    $base = $platal->ns . $path . ($query ? '?'.$query : '');
-    return $fragment ? $base.'#'.$fragment : $base;
-}
-
-function pl_self($n = null) {
-    global $platal;
-    return $platal->pl_self($n);
-}
-
-function http_redirect($fullurl)
-{
-    if (count($_SESSION)) {
-        session_write_close();
-    }
-    header('Location: '.$fullurl);
-    exit;
-}
-
-function pl_redirect($path, $query = null, $fragment = null)
-{
-    global $globals;
-    http_redirect($globals->baseurl . '/' . pl_url($path, $query, $fragment));
-}
-
-function pl_entities($text, $mode = ENT_COMPAT)
-{
-    return htmlentities($text, $mode, 'UTF-8');
-}
-
-function pl_entity_decode($text, $mode = ENT_COMPAT)
-{
-    return html_entity_decode($text, $mode, 'UTF-8');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index 0117fc0..9d38d31 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-function _rss_encode_date($d) {
-    if (preg_match('/^\d{14}$/', $d)) {
-        $t = mktime(substr($d,8,2), substr($d,10,2), substr($d,12,2), substr($d,4,2), substr($d,6,2), substr($d,0,4));
-    } else {
-        $t = strtotime($d);
-    }
-    return date('r', $t);
-}
-
 function init_rss($template, $alias, $hash, $require_uid = true)
 {
-    global $page;
+    $page =& Platal::page();
     $page->changeTpl($template, NO_SKIN);
-    $page->register_modifier('rss_date', '_rss_encode_date');
-
-    $res = XDB::query(
-        'SELECT  a.id
-           FROM  aliases         AS a
-     INNER JOIN  auth_user_md5   AS u ON (a.id = u.user_id AND u.perms IN ("admin", "user"))
-     INNER JOIN  auth_user_quick AS q ON (a.id = q.user_id AND q.core_rss_hash = {?})
-          WHERE  a.alias = {?} AND a.type != "homonyme"', $hash, $alias);
-    $uid = $res->fetchOneCell();
-
+    $uid = Platal::session()->tokenAuth($alias, $hash);
     if (empty($uid)) {
         if ($require_uid) {
             exit;
diff --git a/include/security.inc.php b/include/security.inc.php
new file mode 100644 (file)
index 0000000..e0b1d14
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 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                *
+ ***************************************************************************/
+
+/******************************************************************************
+ * Security functions
+ *****************************************************************************/
+
+function check_ip($level)
+{
+    if (empty($_SERVER['REMOTE_ADDR'])) {
+        return false;
+    }
+    if (empty($_SESSION['check_ip'])) {
+        $ips = array();
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+            $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
+        }
+        $ips[] = $_SERVER['REMOTE_ADDR'];
+        foreach ($ips as &$ip) {
+            $ip = '(ip & mask) = (' . ip_to_uint($ip) . '& mask)';
+        }
+        $res = XDB::query('SELECT  state, description
+                             FROM  ip_watch
+                            WHERE  ' . implode(' OR ', $ips) . '
+                         ORDER BY  state DESC');
+        if ($res->numRows()) {
+            $state = $res->fetchOneAssoc();
+            $_SESSION['check_ip'] = $state['state'];
+            $_SESSION['check_ip_desc'] = $state['description'];
+        } else {
+            $_SESSION['check_ip'] = 'safe';
+        }
+    }
+    $test = array();
+    switch ($level) {
+      case 'unsafe': $test[] = 'unsafe';
+      case 'dangerous': $test[] = 'dangerous';
+      case 'ban': $test[] = 'ban'; break;
+      default: return false;
+    }
+    return in_array($_SESSION['check_ip'], $test);
+}
+
+function check_email($email, $message)
+{
+    $res = XDB::query("SELECT state, description
+        FROM emails_watch
+        WHERE state != 'safe' AND email = {?}", $email);
+    if ($res->numRows()) {
+        send_warning_mail($message);
+        return true;
+    }
+    return false;
+}
+
+function check_account()
+{
+    return S::v('watch_account');
+}
+
+function check_redirect($red = null)
+{
+    require_once 'emails.inc.php';
+    if (is_null($red)) {
+        $red = new Redirect(S::v('uid'));
+    }
+    if ($red->get_uid() == S::v('uid')) {
+        $_SESSION['no_redirect'] = !$red->other_active('');
+        $_SESSION['mx_failures'] = $red->get_broken_mx();
+    }
+}
+
+function send_warning_mail($title)
+{
+    global $globals;
+    $mailer = new PlMailer();
+    $mailer->setFrom("webmaster@" . $globals->mail->domain);
+    $mailer->addTo($globals->core->admin_email);
+    $mailer->setSubject("[Plat/al Security Alert] $title");
+    $mailer->setTxtBody("Identifiants de session :\n" . var_export($_SESSION, true) . "\n\n"
+        ."Identifiants de connexion :\n" . var_export($_SERVER, true));
+    $mailer->send();
+}
+
+function kill_sessions()
+{
+    assert(S::has_perms());
+    shell_exec('sudo -u root ' . dirname(dirname(__FILE__)) . '/bin/kill_sessions.sh');
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index 208272f..6b06c12 100644 (file)
@@ -19,9 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-
-require_once("xorg.inc.php");
-
 require_once('user.func.inc.php');
 
 function is_ax_key_missing() {
index a7b422c..21bcbb5 100644 (file)
@@ -87,8 +87,7 @@ function user_clear_all_subs($user_id, $really_del=true)
 // Defaut callback to call when a login is not found
 function _default_user_callback($login)
 {
-    global $page;
-    $page->trigError("Il n'y a pas d'utilisateur avec l'identifiant : $login");
+    Platal::page()->trigError("Il n'y a pas d'utilisateur avec l'identifiant : $login");
     return;
 }
 
@@ -99,7 +98,7 @@ function _silent_user_callback($login)
 
 function get_user_login($data, $get_forlife = false, $callback = '_default_user_callback')
 {
-    global $globals, $page;
+    global $globals;
 
     if (is_numeric($data)) {
         $res = XDB::query("SELECT alias FROM aliases WHERE type='a_vie' AND id={?}", $data);
@@ -171,7 +170,7 @@ function get_user_login($data, $get_forlife = false, $callback = '_default_user_
             default:
                 if (S::has_perms()) {
                     $aliases = $res->fetchColumn();
-                    $page->trigError("Il y a $i utilisateurs avec cette adresse email : ".join(', ', $aliases));
+                    Platal::page()->trigError("Il y a $i utilisateurs avec cette adresse mail : ".join(', ', $aliases));
                 } else {
                     $res->free();
                 }
index 0a4a95f..f45cf48 100644 (file)
@@ -19,7 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once('xorg.misc.inc.php');
 require_once('user.func.inc.php');
 
 global $globals;
@@ -321,7 +320,7 @@ class TrombiView extends MultipageView
         return 'include/plview.trombi.tpl';
     }
 
-    public function apply(PlatalPage &$page)
+    public function apply(PlPage &$page)
     {
         if (!empty($GLOBALS['IS_XNET_SITE'])) {
             global $globals;
@@ -358,7 +357,7 @@ class GeolocView implements PlView
         return $args;
     }
 
-    public function apply(PlatalPage &$page)
+    public function apply(PlPage &$page)
     {
         require_once 'geoloc.inc.php';
         require_once '../modules/search/search.inc.php';
@@ -456,7 +455,7 @@ class GadgetView implements PlView
                  : "");
     }
 
-    public function apply(PlatalPage &$page)
+    public function apply(PlPage &$page)
     {
         $page->assign_by_ref('set',
           $this->set->get($this->fields(), $this->joins(), null, null, null, 5, 0));
index 9ef58e6..2f11046 100644 (file)
@@ -21,7 +21,8 @@
 
 define('SIZE_MAX', 32768);
 
-require_once dirname(__FILE__) . '/../classes/xdb.php';
+global $globals;
+require_once $globals->spoolroot . '/core/classes/xdb.php';
 
 /**
  * Iterator class, that lists objects through the database
@@ -116,7 +117,7 @@ abstract class Validate
                 $this->uid, $this->type, $this, $this->stamp);
 
         global $globals;
-        update_NbValid();
+        $globals->updateNbValid();
         return true;
     }
 
@@ -146,7 +147,7 @@ abstract class Validate
             $success =  XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?} AND stamp={?}',
                                       $this->uid, $this->type, $this->stamp);
         }
-        update_NbValid();
+        $globals->updateNbValid();
         return $success;
     }
 
@@ -258,20 +259,17 @@ abstract class Validate
 
     protected function trigError($msg)
     {
-        global $page;
-        $page->trigError($msg);
+        Platal::page()->trigError($msg);
     }
 
     protected function trigWarning($msg)
     {
-        global $page;
-        $page->trigWarning($msg);
+        Platal::page()->trigWarning($msg);
     }
 
     protected function trigSuccess($msg)
     {
-        global $page;
-        $page->trigSuccess($msg);
+        Platal::page()->trigSuccess($msg);
     }
 
     // }}}
index 952c0c1..788d7c6 100644 (file)
@@ -49,7 +49,6 @@ class UsageReq extends Validate
         parent::__construct($_uid, true, 'usage');
         $this->nom_usage  = $_usage;
         $this->reason = $_reason;
-        require_once 'xorg.misc.inc.php';
         $this->alias   = make_username($this->prenom, $this->nom_usage);
         if (!$this->nom_usage) $this->alias = "";
 
index b11f878..6083b25 100644 (file)
@@ -19,7 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once('xorg.misc.inc.php');
 require_once('user.func.inc.php');
 
 class VCardIterator implements PlIterator
diff --git a/include/wiki.inc.php b/include/wiki.inc.php
deleted file mode 100644 (file)
index 906c0e1..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-function wiki_pagename()
-{
-    if (!Get::v('n')) {
-        return null;
-    }
-
-    $words = explode('/', trim(Get::v('n'), '/'));
-    if (count($words) == 2) {
-        return join('.', $words);
-    }
-
-    array_unshift($words, $words[0]);
-    $b = array_pop($words);
-    $a = array_pop($words);
-
-    pl_redirect($a.'/'.$b);
-}
-
-function wiki_filename($s)
-{
-    if (@iconv('utf-8', 'utf-8', $s) == $s) {
-        return $s;
-    }
-    return utf8_encode($s);
-}
-
-function wiki_work_dir()
-{
-    global $globals;
-    return $globals->spoolroot.'/spool/wiki.d';
-}
-
-function wiki_clear_all_cache()
-{
-    system('rm -f '.wiki_work_dir().'/cache_*');
-}
-
-function wiki_perms_options() {
-    return array('public' => 'Public', 'logged' => 'Connecté',
-                  'mdp' => 'Authentifié', 'admin' => 'Admin');
-}
-
-function wiki_get_perms($n)
-{
-    $file  = wiki_work_dir().'/'.wiki_filename(str_replace('/', '.', $n));
-    $lines = explode("\n", @file_get_contents($file));
-    foreach ($lines as $line) {
-        @list($k, $v) = explode('=', $line, 2);
-        if ($k == 'platal_perms') {
-            return explode(':', $v);
-        }
-    }
-    return array('logged', 'admin');
-}
-
-function wiki_putfile($f, $s)
-{
-    $fp = fopen($f, 'w');
-    fputs($fp, $s);
-    fclose($fp);
-}
-
-function wiki_set_perms($n, $pr, $pw)
-{
-    $file  = wiki_work_dir().'/'.wiki_filename(str_replace('/', '.', $n));
-    if (!file_exists($file)) {
-        return false;
-    }
-
-    $p = $pr . ':' . $pw;
-
-    $lines = explode("\n", file_get_contents($file));
-    foreach ($lines as $i => $line) {
-        list($k, $v) = explode('=', $line, 2);
-        if ($k == 'platal_perms') {
-            $lines[$i] = 'platal_perms='.$p;
-            wiki_putfile($file, join("\n", $lines));
-            return true;
-        }
-    }
-
-    array_splice($lines, 1, 0, array('platal_perms='.$p));
-    wiki_putfile($file, join("\n", $lines));
-    return true;
-}
-
-function wiki_may_have_perms($perm) {
-    switch ($perm) {
-      case 'public': return true;
-      case 'logged': return S::logged();
-      case 'mdp':    return S::logged();
-      default:       return S::has_perms();
-    }
-}
-
-function wiki_apply_feed_perms($perm)
-{
-    if ($perm == 'public') {
-        return;
-    }
-
-    require_once 'rss.inc.php';
-    $uid = init_rss(null, Env::v('user'), Env::v('hash'));
-    $res = XDB::query('SELECT user_id AS uid, IF (nom_usage <> \'\', nom_usage, nom) AS nom, prenom, perms
-                         FROM auth_user_md5
-                        WHERE user_id = {?}', $uid);
-    if (!$res->numRows()) {
-        exit;
-    }
-    $table = $res->fetchOneAssoc();
-    $_SESSION = array_merge($_SESSION, $table, array('forlife' => Env::v('user')));
-    require_once 'xorg/session.inc.php';
-    $_SESSION['perms'] =& XorgSession::make_perms($_SESSION['perms']);
-    if ($perm == 'logged' || $_SESSION['perms']->hasFlag('admin')) {
-        return;
-    }
-    exit;
-}
-
-function wiki_apply_perms($perm) {
-    global $page, $platal, $globals;
-
-    switch ($perm) {
-      case 'public':
-        return;
-
-      case 'logged':
-        if (!call_user_func(array($globals->session, 'doAuthCookie'))) {
-            $platal =  empty($GLOBALS['IS_XNET_SITE']) ? new Platal() : new Xnet();
-            $platal->force_login($page);
-        }
-        return;
-
-      default:
-        if (!call_user_func(array($globals->session, 'doAuth'))) {
-            $platal = empty($GLOBALS['IS_XNET_SITE']) ? new Platal() : new Xnet();
-            $platal->force_login($page);
-        }
-        if ($perm == 'admin') {
-            check_perms();
-        }
-        return;
-    }
-}
-
-function wiki_require_page($pagename)
-{
-    global $globals;
-    $pagename_slashes = str_replace('.','/',$pagename);
-    $pagename_dots = str_replace('/','.',$pagename);
-    if (is_file(wiki_work_dir().'/cache_'.$pagename_dots.'.tpl')) {
-        return;
-    }
-    system('wget --no-check-certificate '. escapeshellarg($globals->baseurl.'/'.$pagename_slashes) . ' -O /dev/null');
-}
-
-function wiki_delete_page($pagename)
-{
-    $pagename_dots = str_replace('/','.',$pagename);
-    if (!strpos($pagename_dots, '.')) {
-        return false;
-    }
-    $file  = wiki_work_dir().'/'.wiki_filename($pagename_dots);
-    $cachefile = wiki_work_dir().'/cache_'.$pagename_dots.'.tpl';
-    if (is_file($cachefile)) {
-        unlink($cachefile);
-    }
-    if (!is_file($file)) {
-        return false;
-    }
-    unlink($file);
-    return true;
-}
-
-function wiki_links_in_line($line, $groupname)
-{
-    $links = array();
-    if (preg_match_all('@\[\[([^~][^\]\|\?#]*)((\?|#)[^\]\|]+)?(\\|[^\]]+)?\]\]@', $line, $matches, PREG_OFFSET_CAPTURE)) {
-        foreach ($matches[1] as $j => $link) if (!preg_match('@http://@', $link[0])) {
-            $mylink = str_replace('/','.',trim($link[0]));
-            $sup = trim(substr($matches[2][$j][0],1));
-            $alt = trim(substr($matches[4][$j][0],1));
-            $newlink = str_replace(' ','',ucwords($mylink));
-            if (strpos($newlink,'.') === false) {
-                $newlink = $groupname.'.'.$newlink;
-            }
-            if (!$alt && $mylink != $newlink) {
-                $alt = trim($link[0]);
-            }
-            $links[] = array(
-              'pos' => $matches[0][$j][1],
-              'size' => strlen($matches[0][$j][0]),
-              'href' => $newlink,
-              'sup' => $sup,
-              'alt' => $alt,
-              'group' => substr($mylink, 0, strpos($mylink, '.')));
-        }
-    }
-    return $links;
-}
-
-function wiki_rename_page($pagename, $newname, $changeLinks = true)
-{
-    $pagename_dots = str_replace('/','.',$pagename);
-    $newname_dots = str_replace('/','.',$newname);
-    if (!strpos($pagename_dots, '.') || !strpos($newname_dots, '.')) {
-        return false;
-    }
-    $groupname = substr($pagename_dots, 0, strpos($pagename_dots,'.'));
-    $newgroupname = substr($newname_dots, 0, strpos($pagename_dots,'.'));
-
-    $file  = wiki_work_dir().'/'.wiki_filename($pagename_dots);
-    $newfile  = wiki_work_dir().'/'.wiki_filename($newname_dots);
-    if (!is_file($file)) {
-        // old page doesn't exist
-        return false;
-    }
-    if (!rename($file, $newfile)) {
-        // impossible to renama page
-        return false;
-    }
-
-    if (!$changeLinks) {
-        return true;
-    }
-
-    $changedLinks = 0;
-    // change name inside this folder and ingroup links if changing group
-    $lines = explode("\n", file_get_contents($newfile));
-    $changed = false;
-    foreach ($lines as $i => $line) {
-        list($k, $v) = explode('=', $line, 2);
-        if ($k == 'name' && $v == $pagename_dots) {
-            $lines[$i] = 'name='.$newname_dots;
-            $changed = true;
-        } else if ($groupname != $newgroupname) {
-            $links = wiki_links_in_line($line, $groupname);
-            $newline = ''; $last = 0;
-            foreach ($links as $link) if ($link['group'] == $groupname) {
-                $newline .= substr($line, $last, $link['pos']);
-                $newline .= '[['.$link['href'].$link['sup'].($link['alt']?(' |'.$link['alt']):'').']]';
-                $last = $link['pos']+$link['size'];
-                $changedLinks++;
-            }
-            if ($last != 0) {
-                $newline .= substr($line, $last);
-                $lines[$i] = $newline;
-                $changed = true;
-            }
-        }
-    }
-    wiki_putfile($newfile, join("\n", $lines));
-
-    // change wiki links in all wiki pages
-    $endname = substr($pagename_dots, strpos($pagename_dots,'.')+1);
-    $pages = array();
-    exec("grep ".$endname."  ".wiki_work_dir()."/* -sc", $pages);
-    foreach($pages as $line) {
-        if (preg_match('%/([^/:]+):([0-9]+)$%', $line, $vals) && $vals[2] > 0) {
-            $inpage = $vals[1];
-            $lines = explode("\n", file_get_contents(wiki_work_dir().'/'.$inpage));
-            $changed = false;
-            // find all wiki links in page and change if linked to this page
-            foreach ($lines as $i => $line) {
-                $links = wiki_links_in_line($line, substr($inpage, 0, strpos($inpage, '.')));
-                $newline = ''; $last = 0;
-                foreach ($links as $link) {
-                    if ($link['href'] == $pagename_dots) {
-                        $newline .= substr($line, $last, $link['pos']);
-                        $newline .= '[['.$newname_dots.$link['sup'].($link['alt']?(' |'.$link['alt']):'').']]';
-                        $last = $link['pos']+$link['size'];
-                        $changedLinks++;
-                    }
-                }
-                if ($last != 0) {
-                    $newline .= substr($line, $last);
-                    $lines[$i] = $newline;
-                    $changed = true;
-                }
-            }
-            if ($changed)
-            {
-                wiki_putfile(wiki_work_dir().'/'.$inpage, join("\n", $lines));
-            }
-        }
-    }
-    if ($changedLinks > 0) {
-        return $changedLinks;
-    }
-    return true;
-}
-
-function wiki_rename_folder($pagename, $newname, $changeLinks = true)
-{
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/include/wiki/engine.php b/include/wiki/engine.php
deleted file mode 100644 (file)
index f8c01fc..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 'wiki.inc.php';
-
-$n    = wiki_pagename();
-if (!$n) {
-    pl_redirect('');
-}
-
-new_skinned_page('core/wiki.tpl');
-$perms = wiki_get_perms($n);
-$feed  = false;
-
-// Check user perms
-switch (Env::v('action')) {
-  case 'rss': case 'atom': case 'sdf': case 'dc':
-    wiki_apply_feed_perms($perms[0]);
-    $feed = true;
-  case '': case 'search':
-    break;
-
-  case 'edit':
-    wiki_apply_perms($perms[1]);
-    break;
-
-  default:
-    wiki_apply_perms('admin');
-    break;
-}
-
-if ($p = Post::v('setrperms')) {
-    wiki_apply_perms('admin');
-    if (wiki_set_perms($n, $p, $perms[1])) {
-        $perms = wiki_get_perms($n);
-        $page->trigSuccess('Permissions mises à jour');
-    }
-}
-
-if ($p = Post::v('setwperms')) {
-    wiki_apply_perms('admin');
-    if (wiki_set_perms($n, $perms[0], $p)) {
-        $perms = wiki_get_perms($n);
-        $page->trigSuccess('Permissions mises à jour');
-    }
-}
-
-// Generate cache even if we don't have access rights
-$wiki_cache   = wiki_work_dir().'/cache_'.wiki_filename($n).'.tpl';
-$cache_exists = file_exists($wiki_cache);
-if (Env::v('action') || !$cache_exists) {
-    if ($cache_exists && !$feed) {
-        unlink($wiki_cache);
-        $files = glob($globals->spoolroot . '/spool/templates_c/*cache_' . wiki_filename($n) . '.tpl*');
-        foreach ($files as $file) {
-            unlink($file);
-        }
-    }
-
-    // we leave pmwiki do whatever it wants and store everything
-    ob_start();
-    require_once($globals->spoolroot.'/wiki/pmwiki.php');
-
-    $wikiAll = ob_get_clean();
-    pl_clear_errors();
-
-    // the pmwiki skin we are using (almost empty) has these keywords:
-    $i = strpos($wikiAll, "<!--/HeaderText-->");
-    $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
-}
-
-$wiki_exists = file_exists(wiki_work_dir() . '/' . wiki_filename($n));
-
-if ($feed) {
-    $wikiAll = str_replace('dc:contributor', 'author', $wikiAll);
-    $wikiAll = preg_replace('!<author>.*?\..*?\.(\d{4})\|(.*?)</author>!u', '<author>$2 (X$1)</author>', $wikiAll);
-    $wikiAll = str_replace('<link>./', '<link>' . $globals->baseurl . '/' . $platal->ns, $wikiAll);
-    echo $wikiAll;
-    pl_clear_errors();
-    exit;
-} elseif (Env::v('action')) {
-    $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
-    $wikiAll = substr($wikiAll, $j);
-} else {
-    if (!$cache_exists && $wiki_exists) {
-        $wikiAll = substr($wikiAll, $j);
-        wiki_putfile($wiki_cache, $wikiAll);
-    } elseif ($cache_exists) {
-        $wikiAll = file_get_contents($wiki_cache);
-    } elseif (S::has_perms()) {
-        $wikiAll = "<p>La page de wiki $n n'existe pas. "
-                 . "Il te suffit de <a href='" . str_replace('.', '/', $n) . "?action=edit'>l'éditer</a></p>";
-    } else {
-        $page->changeTpl('core/404.tpl');
-    }
-}
-
-// Check user perms
-wiki_apply_perms($perms[0]);
-
-$page->assign('perms', $perms);
-$page->assign('perms_opts', wiki_perms_options());
-
-$page->assign('canedit',    wiki_may_have_perms($perms[1]));
-$page->assign('has_perms',  wiki_may_have_perms('admin'));
-
-$page->assign('wikipage', str_replace('.', '/', $n));
-if (!$feed && $perms[1] == 'admin' && !Env::v('action') && $wiki_exists) {
-    $page->assign('pmwiki_cache', $wiki_cache);
-} else {
-    $page->assign('pmwiki',   $wikiAll);
-    $page->assign('text', true);
-}
-$page->addCssLink('wiki.css');
-$page->addJsLink('wiki.js');
-if (!Env::v('action')) {
-    $url = '/' . str_replace('.', '/', $n) . '?action=rss';
-    if (S::logged()) {
-        $url .= '&user=' . S::v('forlife') . '&hash=' . S::v('core_rss_hash');
-    }
-    $page->setRssLink($n, $url);
-}
-
-$page->run();
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index e9689e3..a8431e3 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once('platal.inc.php');
-require_once('globals.inc.php');
-require_once('xnet/session.inc.php');
-$globals = new PlatalGlobals('XnetSession');
-XnetSession::init();
+define('PL_GLOBALS_CLASS', 'PlatalGlobals');
+define('PL_SESSION_CLASS', 'XnetSession');
+define('PL_PAGE_CLASS', 'XnetPage');
 
-function new_skinned_page($tpl_name)
-{
-    global $page;
-    require_once("xnet/page.inc.php");
-    if (!$page instanceof XnetPage) {
-        $page = new XnetPage($tpl_name);
-    } else {
-        $page->changeTpl($tpl_name);
-    }
-}
+require_once dirname(dirname(__FILE__)) . '/core/include/platal.inc.php';
+require_once 'common.inc.php';
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 0d4274c..b67126b 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once('platal.inc.php');
-require_once('globals.inc.php');
-require_once('xorg/session.inc.php');
-$globals = new PlatalGlobals('XorgSession');
-$globals->bootstrap(array('NbIns'), 'update_NbIns');
-$globals->bootstrap(array('NbValid'), 'update_NbValid');
+define('PL_GLOBALS_CLASS', 'PlatalGlobals');
+define('PL_SESSION_CLASS', 'XorgSession');
+define('PL_PAGE_CLASS', 'XorgPage');
 
-// {{{ class XorgPage
-
-class XorgPage extends PlatalPage
-{
-    public function __construct($tpl, $type = SKINNED)
-    {
-        parent::__construct($tpl, $type);
-    }
-
-    public function run()
-    {
-        global $globals, $platal;
-        $this->assign('globals', $globals);
-        if (isset($platal) && $platal->path == 'register') {
-            $skin = $globals->register_skin . ".tpl";
-        } else {
-            $skin = S::v('skin', $globals->skin . ".tpl");
-        }
-        $this->_run('skin/' . $skin);
-    }
-}
-
-// {{{ function new_skinned_page()
-
-function new_skinned_page($tpl_name)
-{
-    global $page;
-    if (!$page instanceof XorgPage) {
-        $page = new XorgPage($tpl_name);
-    } else {
-        $page->changeTpl($tpl_name);
-    }
-}
-
-XorgSession::init();
+require_once dirname(dirname(__FILE__)) . '/core/include/platal.inc.php';
+require_once 'security.inc.php';
+require_once 'common.inc.php';
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
diff --git a/include/xorg.misc.inc.php b/include/xorg.misc.inc.php
deleted file mode 100644 (file)
index eefbfb2..0000000
+++ /dev/null
@@ -1,376 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-function quoted_printable_encode($input, $line_max = 76)
-{
-    $lines = preg_split("/(?:\r\n|\r|\n)/", $input);
-    $eol = "\n";
-    $linebreak = "=0D=0A=\n    ";
-    $escape = "=";
-    $output = "";
-
-    foreach ($lines as $j => $line) {
-        $linlen = strlen($line);
-        $newline = "";
-        for($i = 0; $i < $linlen; $i++) {
-            $c = $line{$i};
-            $dec = ord($c);
-            if ( ($dec == 32) && ($i == ($linlen - 1)) ) {
-                // convert space at eol only
-                $c = "=20";
-            } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) {
-                // always encode "\t", which is *not* required
-                $c = $escape.strtoupper(sprintf("%02x",$dec));
-            }
-            if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
-                $output .= $newline.$escape.$eol;
-                $newline = "    ";
-            }
-            $newline .= $c;
-        } // end of for
-        $output .= $newline;
-        if ($j<count($lines)-1) $output .= $linebreak;
-    }
-    return trim($output);
-}
-
-/** vérifie si une adresse email convient comme adresse de redirection
- * @param $email l'adresse email a verifier
- * @return BOOL
- */
-function isvalid_email_redirection($email)
-{
-    return isvalid_email($email) &&
-        !preg_match("/@(polytechnique\.(org|edu)|melix\.(org|net)|m4x\.org)$/", $email);
-}
-
-/** genere une chaine aleatoire de 22 caracteres ou moins
- * @param $len longueur souhaitée, 22 par défaut
- * @return la chaine aleatoire qui contient les caractères [A-Za-z0-9+/]
- */
-function rand_token($len = 22)
-{
-    $len = max(2, $len);
-    $len = min(50, $len);
-    $fp = fopen('/dev/urandom', 'r');
-    // $len * 2 is certainly an overkill,
-    // but HEY, reading 40 bytes from /dev/urandom is not that slow !
-    $token = fread($fp, $len * 2);
-    fclose($fp);
-    $token = base64_encode($token);
-    $token = preg_replace("![Il10O+/]!", "", $token);
-    $token = substr($token,0,$len);
-    return $token;
-}
-
-/** genere une chaine aleatoire convenable pour une url
- * @param $len longueur souhaitée, 22 par défaut
- * @return la chaine aleatoire
- */
-function rand_url_id($len = 22)
-{
-    return rand_token($len);
-}
-
-
-/** genere une chaine aleatoire convenable pour un mot de passe
- * @return la chaine aleatoire
- */
-function rand_pass()
-{
-    return rand_token(8);
-}
-
-/** Remove accent from a string and replace them by the nearest letter
- */
-global $lc_convert, $uc_convert;
-$lc_convert = array('é' => 'e', 'è' => 'e', 'ë' => 'e', 'ê' => 'e',
-    'á' => 'a', 'à' => 'a', 'ä' => 'a', 'â' => 'a', 'å' => 'a', 'ã' => 'a',
-    'ï' => 'i', 'î' => 'i', 'ì' => 'i', 'í' => 'i',
-    'ô' => 'o', 'ö' => 'o', 'ò' => 'o', 'ó' => 'o', 'õ' => 'o', 'ø' => 'o',
-    'ú' => 'u', 'ù' => 'u', 'û' => 'u', 'ü' => 'u',
-    'ç' => 'c', 'ñ' => 'n');
-$uc_convert = array('É' => 'E', 'È' => 'E', 'Ë' => 'E', 'Ê' => 'E',
-    'Á' => 'A', 'À' => 'A', 'Ä' => 'A', 'Â' => 'A', 'Å' => 'A', 'Ã' => 'A',
-    'Ï' => 'I', 'Î' => 'I', 'Ì' => 'I', 'Í' => 'I',
-    'Ô' => 'O', 'Ö' => 'O', 'Ò' => 'O', 'Ó' => 'O', 'Õ' => 'O', 'Ø' => 'O',
-    'Ú' => 'U', 'Ù' => 'U', 'Û' => 'U', 'Ü' => 'U',
-    'Ç' => 'C', 'Ñ' => 'N');
-
-function replace_accent($string)
-{
-    global $lc_convert, $uc_convert;
-    $string = strtr($string, $lc_convert);
-    return strtr($string, $uc_convert);
-}
-
-/** creates a username from a first and last name
- *
- * @param $prenom the firstname
- * @param $nom the last name
- *
- * return STRING the corresponding username
- */
-function make_username($prenom,$nom)
-{
-    /* on traite le prenom */
-    $prenomUS=replace_accent(trim($prenom));
-    $prenomUS=stripslashes($prenomUS);
-
-    /* on traite le nom */
-    $nomUS=replace_accent(trim($nom));
-    $nomUS=stripslashes($nomUS);
-
-    // calcul du login
-    $username = strtolower($prenomUS.".".$nomUS);
-    $username = str_replace(" ","-",$username);
-    $username = str_replace("'","",$username);
-    return $username;
-}
-
-/* Un soundex en français posté par Frédéric Bouchery
-   Voici une adaptation en PHP de la fonction soundex2 francisée de Frédéric BROUARD (http://sqlpro.developpez.com/Soundex/).
-   C'est une bonne démonstration de la force des expressions régulières compatible Perl.
-trouvé sur http://expreg.com/voirsource.php?id=40&type=Chaines%20de%20caract%E8res */
-function soundex_fr($sIn)
-{
-    static $convVIn, $convVOut, $convGuIn, $convGuOut, $accents;
-    if (!isset($convGuIn)) {
-        global $uc_convert, $lc_convert;
-        $convGuIn  = array( 'GUI', 'GUE', 'GA', 'GO', 'GU', 'SCI', 'SCE', 'SC', 'CA', 'CO',
-                            'CU', 'QU', 'Q', 'CC', 'CK', 'G', 'ST', 'PH');
-        $convGuOut = array( 'KI', 'KE', 'KA', 'KO', 'K', 'SI', 'SE', 'SK', 'KA', 'KO',
-                            'KU', 'K', 'K', 'K', 'K', 'J', 'T', 'F');
-        $convVIn   = array( '/E?(AU)/', '/([EA])?[UI]([NM])([^EAIOUY]|$)/', '/[AE]O?[NM]([^AEIOUY]|$)/',
-            '/[EA][IY]([NM]?[^NM]|$)/', '/(^|[^OEUIA])(OEU|OE|EU)([^OEUIA]|$)/', '/OI/',
-            '/(ILLE?|I)/', '/O(U|W)/', '/O[NM]($|[^EAOUIY])/', '/(SC|S|C)H/',
-            '/([^AEIOUY1])[^AEIOUYLKTPNR]([UAO])([^AEIOUY])/', '/([^AEIOUY]|^)([AUO])[^AEIOUYLKTP]([^AEIOUY1])/', '/^KN/',
-            '/^PF/', '/C([^AEIOUY]|$)/',
-            '/C/', '/Z$/', '/(?<!^)Z+/', '/ER$/', '/H/', '/W/');
-        $convVOut  = array( 'O', '1\3', 'A\1',
-            'E\1', '\1E\3', 'O',
-            'Y', 'U', 'O\1', '9',
-            '\1\2\3', '\1\2\3', 'N',
-            'F', 'K\1',
-            'S', 'SE', 'S', 'E', '', 'V');
-        $accents = $uc_convert + $lc_convert;
-        $accents['Ç'] = 'S';
-        $accents['¿'] = 'E';
-    }
-    // Si il n'y a pas de mot, on sort immédiatement
-    if ( $sIn === '' ) return '    ';
-    // On supprime les accents
-    $sIn = strtr( $sIn, $accents);
-    // On met tout en minuscule
-    $sIn = strtoupper( $sIn );
-    // On supprime tout ce qui n'est pas une lettre
-    $sIn = preg_replace( '`[^A-Z]`', '', $sIn );
-    // Si la chaîne ne fait qu'un seul caractère, on sort avec.
-    if ( strlen( $sIn ) === 1 ) return $sIn . '   ';
-    // on remplace les consonnances primaires
-    $sIn = str_replace( $convGuIn, $convGuOut, $sIn );
-    // on supprime les lettres répétitives
-    $sIn = preg_replace( '`(.)\1`', '$1', $sIn );
-    // on réinterprète les voyelles
-    $sIn = preg_replace( $convVIn, $convVOut, $sIn);
-    // on supprime les terminaisons T, D, S, X (et le L qui précède si existe)
-    $sIn = preg_replace( '`L?[TDX]S?$`', '', $sIn );
-    // on supprime les E, A et Y qui ne sont pas en première position
-    $sIn = preg_replace( '`(?!^)Y([^AEOU]|$)`', '\1', $sIn);
-    $sIn = preg_replace( '`(?!^)[EA]`', '', $sIn);
-    return substr( $sIn . '    ', 0, 4);
-}
-
-/** met les majuscules au debut de chaque atome du prénom
- * @param $prenom le prénom à formater
- * return STRING le prénom avec les majuscules
- */
-function make_firstname_case($prenom)
-{
-    $prenom = strtolower($prenom);
-    $pieces = explode('-',$prenom);
-
-    foreach ($pieces as $piece) {
-        $subpieces = explode("'",$piece);
-        $usubpieces="";
-        foreach ($subpieces as $subpiece)
-            $usubpieces[] = ucwords($subpiece);
-        $upieces[] = implode("'",$usubpieces);
-    }
-    return implode('-',$upieces);
-}
-
-
-function make_forlife($prenom, $nom, $promo)
-{
-    $prenomUS = replace_accent(trim($prenom));
-    $nomUS    = replace_accent(trim($nom));
-
-    $forlife = strtolower($prenomUS.".".$nomUS.".".$promo);
-    $forlife = str_replace(" ","-",$forlife);
-    $forlife = str_replace("'","",$forlife);
-    return $forlife;
-}
-
-/** Convert ip to uint (to store it in a database)
- */
-function ip_to_uint($ip)
-{
-    $part = explode('.', $ip);
-    if (count($part) != 4) {
-        return null;
-    }
-    $v = 0;
-    $fact = 0x1000000;
-    for ($i = 0 ; $i < 4 ; ++$i) {
-        $v += $fact * $part[$i];
-        $fact >>= 8;
-    }
-    return $v;
-}
-
-/** Convert uint to ip (to build a human understandable ip)
- */
-function uint_to_ip($uint)
-{
-    return long2ip($uint);
-}
-
-
-/******************************************************************************
- * Security functions
- *****************************************************************************/
-
-function check_ip($level)
-{
-    if (empty($_SERVER['REMOTE_ADDR'])) {
-        return false;
-    }
-    if (empty($_SESSION['check_ip'])) {
-        $ips = array();
-        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
-            $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
-        }
-        $ips[] = $_SERVER['REMOTE_ADDR'];
-        foreach ($ips as &$ip) {
-            $ip = '(ip & mask) = (' . ip_to_uint($ip) . '& mask)';
-        }
-        $res = XDB::query('SELECT  state, description
-                             FROM  ip_watch
-                            WHERE  ' . implode(' OR ', $ips) . '
-                         ORDER BY  state DESC');
-        if ($res->numRows()) {
-            $state = $res->fetchOneAssoc();
-            $_SESSION['check_ip'] = $state['state'];
-            $_SESSION['check_ip_desc'] = $state['description'];
-        } else {
-            $_SESSION['check_ip'] = 'safe';
-        }
-    }
-    $test = array();
-    switch ($level) {
-      case 'unsafe': $test[] = 'unsafe';
-      case 'dangerous': $test[] = 'dangerous';
-      case 'ban': $test[] = 'ban'; break;
-      default: return false;
-    }
-    return in_array($_SESSION['check_ip'], $test);
-}
-
-function check_email($email, $message)
-{
-    $res = XDB::query("SELECT state, description
-        FROM emails_watch
-        WHERE state != 'safe' AND email = {?}", $email);
-    if ($res->numRows()) {
-        send_warning_mail($message);
-        return true;
-    }
-    return false;
-}
-
-function check_account()
-{
-    return S::v('watch_account');
-}
-
-function check_redirect($red = null)
-{
-    require_once 'emails.inc.php';
-    if (is_null($red)) {
-        $red = new Redirect(S::v('uid'));
-    }
-    if ($red->get_uid() == S::v('uid')) {
-        $_SESSION['no_redirect'] = !$red->other_active('');
-        $_SESSION['mx_failures'] = $red->get_broken_mx();
-    }
-}
-
-function send_warning_mail($title)
-{
-    global $globals;
-    $mailer = new PlMailer();
-    $mailer->setFrom("webmaster@" . $globals->mail->domain);
-    $mailer->addTo($globals->core->admin_email);
-    $mailer->setSubject("[Plat/al Security Alert] $title");
-    $mailer->setTxtBody("Identifiants de session :\n" . var_export($_SESSION, true) . "\n\n"
-        ."Identifiants de connexion :\n" . var_export($_SERVER, true));
-    $mailer->send();
-}
-
-function kill_sessions()
-{
-    assert(S::has_perms());
-    shell_exec('sudo -u root ' . dirname(dirname(__FILE__)) . '/bin/kill_sessions.sh');
-}
-
-
-/******************************************************************************
- * Dynamic configuration update/edition stuff
- *****************************************************************************/
-
-function update_NbIns()
-{
-    global $globals;
-    $res = XDB::query("SELECT  COUNT(*)
-                         FROM  auth_user_md5
-                        WHERE  perms IN ('admin','user') AND deces=0");
-    $cnt = $res->fetchOneCell();
-    $globals->change_dynamic_config(array('NbIns' => $cnt));
-}
-
-function update_NbValid()
-{
-    global $globals;
-    $res = XDB::query("SELECT  COUNT(*)
-                         FROM  requests");
-    $globals->change_dynamic_config(array('NbValid' => $res->fetchOneCell()));
-}
-
-function update_NbNotifs()
-{
-    require_once 'notifs.inc.php';
-    $n = select_notifs(false, S::i('uid'), S::v('watch_last'), false);
-    $_SESSION['notifs'] = $n->numRows();
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/include/xorg/session.inc.php b/include/xorg/session.inc.php
deleted file mode 100644 (file)
index 9ce9c2f..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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.misc.inc.php';
-
-class XorgSession
-{
-    // {{{ public static function init
-
-    public static function init()
-    {
-        S::init();
-        if (!S::has('uid')) {
-            try_cookie();
-        }
-        if ((check_ip('dangerous') && S::has('uid')) || check_account()) {
-            $_SESSION['log']->log("view_page", $_SERVER['REQUEST_URI']);
-        }
-    }
-
-    // }}}
-    // {{{ public static function destroy()
-
-    public static function destroy()
-    {
-        S::destroy();
-        XorgSession::init();
-    }
-
-    // }}}
-    // {{{ public static function doAuth()
-
-    public static function doAuth($new_name = false)
-    {
-        global $globals;
-        if (S::identified()) { // ok, c'est bon, on n'a rien à faire
-            return true;
-        }
-
-        if (!Env::has('username') || !Env::has('response')
-        ||  !S::has('challenge'))
-        {
-            return false;
-        }
-
-        // si on vient de recevoir une identification par passwordpromptscreen.tpl
-        // ou passwordpromptscreenlogged.tpl
-        if (S::has('suid')) {
-            $suid = S::v('suid');
-            $login = $uname = $suid['forlife'];
-            $redirect = false;
-        } else {
-            $uname = Env::v('username');
-
-            if (Env::v('domain') == "alias") {
-                $res = XDB::query(
-                    "SELECT redirect
-                       FROM virtual
-                 INNER JOIN virtual_redirect USING(vid)
-                      WHERE alias LIKE {?}", $uname."@".$globals->mail->alias_dom);
-                $redirect = $res->fetchOneCell();
-                if ($redirect) {
-                    $login = substr($redirect, 0, strpos($redirect, '@'));
-                } else {
-                    $login = "";
-                }
-            } else {
-                $login = $uname;
-                $redirect = false;
-            }
-        }
-
-        $field = (!$redirect && preg_match('/^\d*$/', $uname)) ? 'id' : 'alias';
-        $res   = XDB::query(
-                    "SELECT  u.user_id, u.password
-                       FROM  auth_user_md5 AS u
-                 INNER JOIN  aliases       AS a ON ( a.id=u.user_id AND type!='homonyme' )
-                      WHERE  a.$field = {?} AND u.perms IN('admin','user')", $login);
-
-        $logger = S::v('log');
-        if (list($uid, $password) = $res->fetchOneRow()) {
-            require_once('secure_hash.inc.php');
-            $expected_response = hash_encrypt("$uname:$password:".S::v('challenge'));
-            // le password de la base est peut-être encore encodé en md5
-            if (Env::v('response') != $expected_response) {
-                $new_password = hash_xor(Env::v('xorpass'), $password);
-                $expected_response = hash_encrypt("$uname:$new_password:".S::v('challenge'));
-                if (Env::v('response') == $expected_response) {
-                      XDB::execute("UPDATE auth_user_md5 SET password = {?} WHERE user_id = {?}",
-                                   $new_password, $uid);
-                }
-            }
-            if (Env::v('response') == $expected_response) {
-                if (Env::has('domain')) {
-                    if (($domain = Env::v('domain', 'login')) == 'alias') {
-                        setcookie('ORGdomain', "alias", (time()+25920000), '/', '', 0);
-                    } else {
-                        setcookie('ORGdomain', '', (time()-3600), '/', '', 0);
-                    }
-                    // pour que la modification soit effective dans le reste de la page
-                    $_COOKIE['ORGdomain'] = $domain;
-                }
-
-                S::kill('challenge');
-                if ($logger) {
-                    $logger->log('auth_ok');
-                }
-                if (!start_connexion($uid, true)) {
-                    return false;
-                }
-                if (Env::v('remember', 'false') == 'true') {
-                    $cookie = hash_encrypt(S::v('password'));
-                    setcookie('ORGaccess',$cookie,(time()+25920000),'/','',0);
-                    if ($logger) {
-                        $logger->log("cookie_on");
-                    }
-                } else {
-                    setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
-
-                    if ($logger) {
-                        $logger->log("cookie_off");
-                    }
-                }
-                return true;
-            } elseif ($logger) {
-                $logger->log('auth_fail','bad password');
-            }
-        } elseif ($logger) {
-            $logger->log('auth_fail','bad login');
-        }
-
-        return false;
-    }
-
-    // }}}
-    // {{{ public static function doAuthCookie()
-
-    /** Try to do a cookie-based authentication.
-     *
-     * @param page the calling page (by reference)
-     */
-    public static function doAuthCookie()
-
-    {
-        if (S::logged()) {
-            return true;
-        }
-
-        if (Env::has('username') and Env::has('response')) {
-            return XorgSession::doAuth();
-        }
-
-        if ($r = try_cookie()) {
-            return XorgSession::doAuth(($r > 0));
-        }
-
-        return false;
-    }
-
-    // }}}
-    // {{{ public static function make_perms()
-
-    public static function &make_perms($perm)
-    {
-        $flags = new FlagSet();
-        if ($perm == 'disabled' || $perm == 'ext') {
-            return $flags;
-        }
-        $flags->addFlag(PERMS_USER);
-        if ($perm == 'admin') {
-            $flags->addFlag(PERMS_ADMIN);
-        }
-        return $flags;
-    }
-
-    // }}}
-}
-
-// {{{ function try_cookie()
-
-/** réalise la récupération de $_SESSION pour qqn avec cookie
- * @return  int     0 if all OK, -1 if no cookie, 1 if cookie with bad hash,
- *                  -2 should not happen
- */
-function try_cookie()
-{
-    if (Cookie::v('ORGaccess') == '' or !Cookie::has('ORGuid')) {
-        return -1;
-    }
-
-    $res = @XDB::query(
-            "SELECT user_id,password FROM auth_user_md5
-              WHERE user_id = {?} AND perms IN('admin','user')",
-            Cookie::i('ORGuid'));
-
-    if ($res->numRows() != 0) {
-        list($uid, $password) = $res->fetchOneRow();
-        require_once('secure_hash.inc.php');
-        $expected_value       = hash_encrypt($password);
-        if ($expected_value == Cookie::v('ORGaccess')) {
-            if (!start_connexion($uid, false)) {
-                return -3;
-            }
-            return 0;
-        } else {
-            return 1;
-        }
-    }
-
-    return -2;
-}
-
-// }}}
-// {{{ function start_connexion()
-
-/** place les variables de session dépendants de auth_user_md5
- * et met à jour les dates de dernière connexion si nécessaire
- * @return void
- * @see controlpermanent.inc.php controlauthentication.inc.php
- */
-function start_connexion ($uid, $identified)
-{
-    $res  = XDB::query("
-        SELECT  u.user_id AS uid, prenom, prenom_ini, nom, nom_ini, nom_usage, perms, promo, promo_sortie,
-                matricule, password, FIND_IN_SET('femme', u.flags) AS femme,
-                a.alias AS forlife, a2.alias AS bestalias,
-                q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash,
-                FIND_IN_SET('watch', u.flags) AS watch_account, q.last_version, g.g_account_name IS NOT NULL AS googleapps
-          FROM  auth_user_md5   AS u
-    INNER JOIN  auth_user_quick AS q  USING(user_id)
-    INNER JOIN  aliases         AS a  ON (u.user_id = a.id AND a.type='a_vie')
-    INNER JOIN  aliases         AS a2 ON (u.user_id = a2.id AND FIND_IN_SET('bestalias',a2.flags))
-     LEFT JOIN  gapps_accounts  AS g  ON (u.user_id = g.l_userid AND g.g_status = 'active')
-         WHERE  u.user_id = {?} AND u.perms IN('admin','user')", $uid);
-    $sess = $res->fetchOneAssoc();
-    $res = XDB::query("SELECT  UNIX_TIMESTAMP(s.start) AS lastlogin, s.host
-                         FROM  logger.sessions AS s
-                        WHERE  s.uid = {?} AND s.suid = 0
-                     ORDER BY  s.start DESC
-                        LIMIT  1", $uid);
-    if ($res->numRows()) {
-        $sess = array_merge($sess, $res->fetchOneAssoc());
-    }
-    $suid = S::v('suid');
-
-    if ($suid) {
-        $logger = new CoreLogger($uid, $suid['uid']);
-        $logger->log("suid_start", S::v('forlife')." by {$suid['uid']}");
-        $sess['suid'] = $suid;
-    } else {
-        $logger = S::v('log', new CoreLogger($uid));
-        $logger->log("connexion", Env::v('n'));
-        setcookie('ORGuid', $uid, (time()+25920000), '/', '', 0);
-    }
-
-    $_SESSION         = array_merge($_SESSION, $sess);
-    $_SESSION['log']  = $logger;
-    $_SESSION['auth'] = ($identified ? AUTH_MDP : AUTH_COOKIE);
-    $_SESSION['perms'] =& XorgSession::make_perms($_SESSION['perms']);
-    $mail_subject = null;
-    if (check_account()) {
-        $mail_subject = "Connexion d'un utilisateur surveillé";
-    }
-    if (check_ip('unsafe')) {
-        if ($mail_subject) {
-            $mail_subject .= ' - ';
-        }
-        $mail_subject .= "Une IP surveillee a tente de se connecter";
-        if (check_ip('ban')) {
-            send_warning_mail($mail_subject);
-            $_SESSION = array();
-            $_SESSION['perms'] = new FlagSet();
-            global $page;
-            $newpage = false;
-            if (!$page) {
-                require_once 'xorg.inc.php';
-                new_skinned_page('platal/index.tpl');
-                $newpage = true;
-            }
-            $page->trigError("Une erreur est survenue lors de la procédure d'authentification. "
-                       ."Merci de contacter au plus vite "
-                       ."<a href='mailto:support@polytechnique.org'>support@polytechnique.org</a>");
-            if ($newpage) {
-                $page->run();
-            }
-            return false;
-        }
-    }
-    if ($mail_subject) {
-        send_warning_mail($mail_subject);
-    }
-    set_skin();
-    update_NbNotifs();
-    check_redirect();
-    return true;
-}
-
-// }}}
-
-function set_skin()
-{
-    global $globals;
-    if (S::logged() && (!S::has('skin') || S::has('suid'))) {
-        $uid = S::v('uid');
-        $res = XDB::query("SELECT  skin_tpl
-                          FROM  auth_user_quick AS a
-                          INNER JOIN  skins           AS s ON a.skin = s.id
-                          WHERE  user_id = {?} AND skin_tpl != ''", $uid);
-        if ($_SESSION['skin'] = $res->fetchOneCell()) {
-            return;
-        }
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index a4ee8fd..e48e167 100644 (file)
@@ -59,13 +59,13 @@ class AdminModule extends PLModule
     function handler_default(&$page)
     {
         $page->changeTpl('admin/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration');
+        $page->setTitle('Polytechnique.org - Administration');
     }
 
     function handler_postfix_delayed(&$page)
     {
         $page->changeTpl('admin/postfix_delayed.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés');
+        $page->setTitle('Polytechnique.org - Administration - Postfix : Retardés');
 
         if (Env::has('del')) {
             $crc = Env::v('crc');
@@ -90,7 +90,7 @@ class AdminModule extends PLModule
 
     function handler_postfix_regexpsbounces(&$page, $new = null) {
         $page->changeTpl('admin/emails_bounces_re.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Regexps Bounces');
+        $page->setTitle('Polytechnique.org - Administration - Postfix : Regexps Bounces');
         $page->assign('new', $new);
 
         if (Post::has('submit')) {
@@ -347,14 +347,14 @@ class AdminModule extends PLModule
 
         $page->changeTpl('admin/logger-view.tpl');
 
-        $page->assign('xorg_title','Polytechnique.org - Administration - Logs des sessions');
+        $page->setTitle('Polytechnique.org - Administration - Logs des sessions');
     }
 
     function handler_user(&$page, $login = false)
     {
         global $globals;
         $page->changeTpl('admin/utilisateurs.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Edit/Su/Log');
+        $page->setTitle('Polytechnique.org - Administration - Edit/Su/Log');
         require_once("emails.inc.php");
         require_once("user.func.inc.php");
 
@@ -380,12 +380,17 @@ class AdminModule extends PLModule
         }
 
         if(Env::has('suid_button') && $login) {
-            $_SESSION['log']->log("suid_start", "login by ".S::v('forlife'));
-            $_SESSION['suid'] = $_SESSION;
-            $r = XDB::query("SELECT id FROM aliases WHERE alias={?}", $login);
+            S::logger()->log("suid_start", "login by ".S::v('forlife'));
+            $r = XDB::query("SELECT  id
+                               FROM  aliases
+                              WHERE  alias={?}", $login);
             if($uid = $r->fetchOneCell()) {
-                start_connexion($uid, true);
-                pl_redirect("");
+                if (!Platal::session()->startSUID($uid)) {
+                    $page->trigError('Impossible d\'effectuer un SUID sur ' . $uid);
+                } else {
+                    $page->kill("coucou");
+                    pl_redirect("");
+                }
             }
         }
 
@@ -573,12 +578,11 @@ class AdminModule extends PLModule
                             $mailer->send();
 
                             // update number of subscribers (perms or deceased may have changed)
-                            update_NbIns();
+                            $globals->updateNbIns();
 
                             $page->trigSuccess("updaté correctement.");
                         }
                         if (Env::v('nomusageN') != $mr['nom_usage']) {
-                            require_once "xorg.misc.inc.php";
                             set_new_usage($mr['user_id'], Env::v('nomusageN'), make_username(Env::v('prenomN'), Env::v('nomusageN')));
                         }
                         if (Env::v('decesN') != $mr['deces']) {
@@ -617,7 +621,7 @@ class AdminModule extends PLModule
                     case "u_kill":
                         user_clear_all_subs($mr['user_id']);
                         // update number of subscribers (perms or deceased may have changed)
-                        update_NbIns();
+                        $globals->updateNbIns();
                         $page->trigSuccess("'{$mr['user_id']}' a été désinscrit !");
                         $mailer = new PlMailer("admin/useredit.mail.tpl");
                         $mailer->assign("admin", S::v('forlife'));
@@ -728,7 +732,7 @@ class AdminModule extends PLModule
 
     function handler_homonyms(&$page, $op = 'list', $target = null) {
         $page->changeTpl('admin/homonymes.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Homonymes');
+        $page->setTitle('Polytechnique.org - Administration - Homonymes');
         require_once("homonymes.inc.php");
 
         if ($target) {
@@ -791,7 +795,7 @@ class AdminModule extends PLModule
 
     function handler_ax_xorg(&$page) {
         $page->changeTpl('admin/ax-xorg.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - AX/X.org');
+        $page->setTitle('Polytechnique.org - Administration - AX/X.org');
 
         // liste des différences
         $res = XDB::query(
@@ -819,7 +823,7 @@ class AdminModule extends PLModule
 
     function handler_deaths(&$page, $promo = 0, $validate = false) {
         $page->changeTpl('admin/deces_promo.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Deces');
+        $page->setTitle('Polytechnique.org - Administration - Deces');
 
         if (!$promo)
             $promo = Env::i('promo');
@@ -859,7 +863,7 @@ class AdminModule extends PLModule
 
     function handler_dead_but_active(&$page) {
         $page->changeTpl('admin/dead_but_active.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Décédés');
+        $page->setTitle('Polytechnique.org - Administration - Décédés');
 
         $res = XDB::iterator(
                 "SELECT  u.promo, u.nom, u.prenom, u.deces, u.matricule_ax, a.alias, DATE(MAX(s.start)) AS last
@@ -874,7 +878,7 @@ class AdminModule extends PLModule
 
     function handler_synchro_ax(&$page, $user = null, $action = null) {
         $page->changeTpl('admin/synchro_ax.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Synchro AX');
+        $page->setTitle('Polytechnique.org - Administration - Synchro AX');
 
         require_once('synchro_ax.inc.php');
 
@@ -922,7 +926,7 @@ class AdminModule extends PLModule
     function handler_validate(&$page, $action = 'list', $id = null)
     {
         $page->changeTpl('admin/valider.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Valider une demande');
+        $page->setTitle('Polytechnique.org - Administration - Valider une demande');
                 $page->addCssLink('nl.css');
         $page->addJsLink('ajax.js');
         require_once("validations.inc.php");
@@ -964,12 +968,13 @@ class AdminModule extends PLModule
 
         // Update the count of item to validate here... useful in development configuration
         // where several copies of the site use the same DB, but not the same "dynamic configuration"
-        update_NbValid();
+        global $globals;
+        $globals->updateNbValid();
         $page->assign('vit', new ValidateIterator());
     }
 
     function handler_validate_answers(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Réponses automatiques de validation');
+        $page->setTitle('Polytechnique.org - Administration - Réponses automatiques de validation');
         $page->assign('title', 'Gestion des réponses automatiques');
         $table_editor = new PLTableEditor('admin/validate/answers','requests_answers','id');
         $table_editor->describe('category','catégorie',true);
@@ -978,7 +983,7 @@ class AdminModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_skins(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Skins');
+        $page->setTitle('Polytechnique.org - Administration - Skins');
         $page->assign('title', 'Gestion des skins');
         $table_editor = new PLTableEditor('admin/skins','skins','id');
         $table_editor->describe('name','nom',true);
@@ -991,7 +996,7 @@ class AdminModule extends PLModule
     }
 
     function handler_postfix_blacklist(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Blacklist');
+        $page->setTitle('Polytechnique.org - Administration - Postfix : Blacklist');
         $page->assign('title', 'Blacklist de postfix');
         $table_editor = new PLTableEditor('admin/postfix/blacklist','postfix_blacklist','email', true);
         $table_editor->describe('reject_text','Texte de rejet',true);
@@ -999,14 +1004,14 @@ class AdminModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_postfix_whitelist(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Whitelist');
+        $page->setTitle('Polytechnique.org - Administration - Postfix : Whitelist');
         $page->assign('title', 'Whitelist de postfix');
         $table_editor = new PLTableEditor('admin/postfix/whitelist','postfix_whitelist','email', true);
         $table_editor->describe('email','email',true);
         $table_editor->apply($page, $action, $id);
     }
     function handler_mx_broken(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title', 'Polytechnique.org - Administration - MX Défaillants');
+        $page->setTitle('Polytechnique.org - Administration - MX Défaillants');
         $page->assign('title', 'MX Défaillant');
         $table_editor = new PLTableEditor('admin/mx/broken', 'mx_watch', 'host', true);
         $table_editor->describe('host', 'Masque', true);
@@ -1015,7 +1020,7 @@ class AdminModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_logger_actions(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Actions');
+        $page->setTitle('Polytechnique.org - Administration - Actions');
         $page->assign('title', 'Gestion des actions de logger');
         $table_editor = new PLTableEditor('admin/logger/actions','logger.actions','id');
         $table_editor->describe('text','intitulé',true);
@@ -1023,7 +1028,7 @@ class AdminModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_downtime(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Coupures');
+        $page->setTitle('Polytechnique.org - Administration - Coupures');
         $page->assign('title', 'Gestion des coupures');
         $table_editor = new PLTableEditor('admin/downtime','coupures','id');
         $table_editor->describe('debut','date',true);
@@ -1034,10 +1039,8 @@ class AdminModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
 
-    function handler_wiki(&$page, $action='list', $wikipage='', $wikipage2='')
+    function handler_wiki(&$page, $action = 'list', $wikipage = null, $wikipage2 = null)
     {
-        require_once 'wiki.inc.php';
-
         if (S::v('core_rss_hash')) {
            $page->setRssLink('Changement Récents',
                              '/Site/AllRecentChanges?action=rss&user=' . S::v('forlife') . '&hash=' . S::v('core_rss_hash'));
@@ -1048,62 +1051,47 @@ class AdminModule extends PLModule
             S::assert_xsrf_token();
 
             $perms_read = Post::v('read');
-            $perms_edot = Post::v('edit');
+            $perms_edit = Post::v('edit');
             if ($perms_read || $perms_edit) {
-                foreach ($_POST as $wiki_page => $val) if ($val == 'on') {
-                    $wiki_page = str_replace('_', '/', $wiki_page);
-                    if (!$perms_read || !$perms_edit)
-                        list($perms0, $perms1) = wiki_get_perms($wiki_page);
-                    if ($perms_read)
-                        $perms0 = $perms_read;
-                    if ($perms_edit)
-                        $perms1 = $perms_edit;
-                    wiki_set_perms($wiki_page, $perms0, $perms1);
+                foreach ($_POST as $wiki_page => $val) {
+                    if ($val == 'on') {
+                        $wp = new PlWikiPage(str_replace(array('_', '/'), '.', $wiki_page));
+                        if ($wp->setPerms($perms_read ? $perms_read : $wp->readPerms(),
+                                          $perms_edit ? $perms_edit : $wp->writePerms())) {
+                            $page->trigSuccess("Permission de la page $wiki_page mises à jour");
+                        } else {
+                            $page->trigError("Impossible de mettre les permissions de la page $wiki_page à jour");
+                        }
+                    }
                 }
             }
-        }
-
-        if ($action == 'delete' && $wikipage != '') {
-            S::assert_xsrf_token();
-
-            if (wiki_delete_page($wikipage)) {
-                $page->trigSuccess("La page ".$wikipage." a été supprimée.");
-            } else {
-                $page->trigError("Impossible de supprimer la page ".$wikipage.".");
-            }
-        }
-
-        if ($action == 'rename' && $wikipage != '' && $wikipage2 != '' && $wikipage != $wikipage2) {
+        } else if ($action != 'list' && !empty($wikipage)) {
+            $wp = new PlWikiPage($wikipage);
             S::assert_xsrf_token();
 
-            if ($changedLinks = wiki_rename_page($wikipage, $wikipage2)) {
-                $s = 'La page <em>'.$wikipage.'</em> a été déplacée en <em>'.$wikipage2.'</em>.';
-                if (is_numeric($changedLinks)) {
-                    $s .= $changedLinks.' lien'.(($changedLinks>1)?'s ont été modifiés.':' a été modifié.');
+            if ($action == 'delete') {
+                if ($wp->delete()) {
+                    $page->trigSuccess("La page ".$wikipage." a été supprimée.");
+                } else {
+                    $page->trigError("Impossible de supprimer la page ".$wikipage.".");
+                }
+            } else if ($action == 'rename' && !empty($wikipage2) && $wikipage != $wikipage2) {
+                if ($changedLinks = $wp->rename($wikipage2)) {
+                    $s = 'La page <em>'.$wikipage.'</em> a été déplacée en <em>'.$wikipage2.'</em>.';
+                    if (is_numeric($changedLinks)) {
+                        $s .= $changedLinks.' lien'.(($changedLinks>1)?'s ont été modifiés.':' a été modifié.');
+                    }
+                    $page->trigSuccess($s);
+                } else {
+                    $page->trigError("Impossible de déplacer la page ".$wikipage);
                 }
-                $page->trigSuccess($s);
-            } else {
-                $page->trigError("Impossible de déplacer la page ".$wikipage);
             }
         }
 
-        $perms = wiki_perms_options();
+        $perms = PlWikiPage::permOptions();
 
         // list wiki pages and their perms
-        $wiki_pages = array();
-        $dir = wiki_work_dir();
-        if (is_dir($dir)) {
-            if ($dh = opendir($dir)) {
-                while (($file = readdir($dh)) !== false) if (substr($file,0,1) >= 'A' && substr($file,0,1) <= 'Z') {
-                    list($read,$edit) = wiki_get_perms($file);
-                    $wiki_pages[$file] = array('read' => $perms[$read], 'edit' => $perms[$edit]);
-                    if (is_file($dir . '/cache_' . wiki_filename($file) . '.tpl')) {
-                        $wiki_pages[$file]['cached'] = true;
-                    }
-                }
-                closedir($dh);
-            }
-        }
+        $wiki_pages = PlWikiPage::listPages();
         ksort($wiki_pages);
         $wiki_tree = array();
         foreach ($wiki_pages as $file => $desc) {
index ca07e32..0b767c3 100644 (file)
@@ -153,9 +153,9 @@ class AuthModule extends PLModule
         $uid = S::i('uid');
         if (!isset($_SESSION['suid'])) {
             $logger = (isset($_SESSION['log']) && $_SESSION['log']->uid == $uid)
-                            ? $_SESSION['log'] : new CoreLogger($uid);
+                            ? $_SESSION['log'] : new PlLogger($uid);
             global $platal;
-            $logger->log('connexion_auth_ext', $platal->path);
+            S::logger()->log('connexion_auth_ext', $platal->path);
         }
 
         /* on parcourt les entrees de groupes_auth */
@@ -174,7 +174,7 @@ class AuthModule extends PLModule
 
     function handler_admin_authgroupesx(&$page, $action = 'list', $id = null)
     {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Auth groupes X');
+        $page->setTitle('Polytechnique.org - Administration - Auth groupes X');
         $page->assign('title', 'Gestion de l\'authentification centralisée');
         $table_editor = new PLTableEditor('admin/auth-groupes-x','groupesx_auth','id');
         $table_editor->describe('name','nom',true);
index 6914e52..d78311c 100644 (file)
@@ -53,7 +53,7 @@ class AXLetterModule extends PLModule
         require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
 
         $page->changeTpl('axletter/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Envois de l\'AX');
+        $page->setTitle('Polytechnique.org - Envois de l\'AX');
 
         switch ($action) {
           case 'in':  AXLetter::subscribe(); break;
index 65aae6c..74dd23f 100644 (file)
@@ -56,7 +56,7 @@ class CarnetModule extends PLModule
     function handler_index(&$page)
     {
         $page->changeTpl('carnet/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Mon carnet');
+        $page->setTitle('Polytechnique.org - Mon carnet');
         $this->_add_rss_link($page);
     }
 
@@ -65,8 +65,8 @@ class CarnetModule extends PLModule
         $page->changeTpl('carnet/panel.tpl');
 
         if (Get::has('read')) {
-            $_SESSION['watch_last'] = Get::v('read');
-            update_NbNotifs();
+            S::set('watch_last', Get::v('read'));
+            Platal::session()->updateNbNotifs();
             pl_redirect('carnet/panel');
         }
 
@@ -195,14 +195,14 @@ class CarnetModule extends PLModule
     }
 
     function searchErrorHandler($explain) {
-        global $page;
+        $page =& Platal::page();
         $page->trigError($explain);
         $this->handler_contacts($page);
     }
 
     function handler_contacts(&$page, $action = null, $subaction = null, $ssaction = null)
     {
-        $page->assign('xorg_title','Polytechnique.org - Mes contacts');
+        $page->setTitle('Polytechnique.org - Mes contacts');
         $this->_add_rss_link($page);
 
         $uid  = S::v('uid');
@@ -281,7 +281,7 @@ class CarnetModule extends PLModule
         require_once dirname(__FILE__).'/carnet/contacts.pdf.inc.php';
         require_once 'user.func.inc.php';
 
-        session_write_close();
+        Platal::session()->close();
 
         $sql = "SELECT  a.alias
                   FROM  aliases       AS a
@@ -329,7 +329,6 @@ class CarnetModule extends PLModule
             if (!$uid) {
                 $uid = S::i('uid');
             } else if ($uid != S::i('uid')) {
-                require_once 'xorg.misc.inc.php';
                 send_warning_email("Récupération d\'un autre utilisateur ($uid)");
             }
         } else if (!$uid) {
diff --git a/modules/core.php b/modules/core.php
deleted file mode 100644 (file)
index 67da706..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 handlers()
-    {
-        return array(
-            '403'         => $this->make_hook('403', AUTH_PUBLIC),
-            '404'         => $this->make_hook('404', AUTH_PUBLIC),
-            'login'       => $this->make_hook('login',      AUTH_COOKIE),
-            'send_bug'    => $this->make_hook('bug', AUTH_COOKIE),
-            'purge_cache' => $this->make_hook('purge_cache', AUTH_COOKIE, 'admin'),
-            'kill_sessions' => $this->make_hook('kill_sessions', AUTH_COOKIE, 'admin'),
-            'get_rights'  => $this->make_hook('get_rights', AUTH_MDP, 'admin'),
-
-            'wiki_help'    => $this->make_hook('wiki_help', AUTH_PUBLIC),
-            'wiki_preview' => $this->make_hook('wiki_preview', AUTH_COOKIE, 'user', NO_AUTH),
-
-            'valid.html'  => $this->make_hook('valid', AUTH_PUBLIC),
-            'favicon.ico' => $this->make_hook('favicon', AUTH_PUBLIC),
-            'robots.txt'  => $this->make_hook('robotstxt', AUTH_PUBLIC, 'user', NO_HTTPS),
-        );
-    }
-
-    function handler_valid(&$page)
-    {
-        readfile($page->compile_dir.'/valid.html');
-        exit;
-    }
-
-    function handler_403(&$page)
-    {
-        global $globals;
-        header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
-        $page->changeTpl('core/403.tpl');
-    }
-
-    function handler_404(&$page)
-    {
-        global $globals, $platal;
-        header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
-        $page->changeTpl('core/404.tpl');
-        $page->assign('near', $platal->near_hook());
-    }
-
-    function handler_login(&$page)
-    {
-        $allkeys = func_get_args();
-        unset($allkeys[0]);
-        $url = join('/',$allkeys);
-        pl_redirect($url);
-    }
-
-    function handler_favicon(&$page)
-    {
-        $data = file_get_contents(dirname(__FILE__).'/../htdocs/images/favicon.ico');
-        header('Content-Type: image/x-icon');
-        echo $data;
-        exit;
-    }
-
-    function handler_robotstxt(&$page)
-    {
-        global $globals;
-        if (!$globals->core->restricted_platal) {
-            return PL_NOT_FOUND;
-        }
-
-        header('Content-Type: text/plain');
-        echo "User-agent: *\n";
-        echo "Disallow: /\n";
-        exit;
-    }
-
-    function handler_purge_cache(&$page)
-    {
-        require_once 'wiki.inc.php';
-        S::assert_xsrf_token();
-
-        $page->clear_compiled_tpl();
-        wiki_clear_all_cache();
-
-        http_redirect(empty($_SERVER['HTTP_REFERER']) ? './' : $_SERVER['HTTP_REFERER']);
-    }
-
-    function handler_kill_sessions(&$page)
-    {
-        kill_sessions();
-    }
-
-    function handler_get_rights(&$page, $level)
-    {
-        if (S::has('suid')) {
-            $page->kill('Déjà en SUID');
-        }
-
-        if (isset($_SESSION['log'])) {
-            $_SESSION['log']->log("suid_start", "login by ".S::v('forlife'));
-        }
-        $_SESSION['suid'] = $_SESSION;
-        $_SESSION['perms'] =& XorgSession::make_perms($level);
-
-        pl_redirect('/');
-    }
-
-    function handler_bug(&$page)
-    {
-        global $globals;
-
-        if (empty($_SERVER['HTTP_REFERER'])) {
-            // We don't have a valid referer, we need to use the url
-            list($currentPage, $location) = explode('//', $_SERVER['REQUEST_URI'], 2);
-
-            $location = 'http'.(empty($_SERVER['HTTPS']) ? '' : 's').'://'.$_SERVER['SERVER_NAME'].'/'.$location;
-        } else {
-            $location = $_SERVER['HTTP_REFERER'];
-        }
-
-        $page->changeTpl('core/bug.tpl', SIMPLE);
-        $page->assign('location', $location);
-        $page->addJsLink('close_on_esc.js');
-
-        if (Env::has('send') && trim(Env::v('detailed_desc'))) {
-            S::assert_xsrf_token();
-
-            $body = wordwrap(Env::v('detailed_desc'), 78) . "\n\n"
-                  . "----------------------------\n"
-                  . "Page        : " . Env::v('page') . "\n\n"
-                  . "Utilisateur : " . S::v('forlife') . "\n"
-                  . "Navigateur  : " . $_SERVER['HTTP_USER_AGENT'] . "\n"
-                  . "Skin        : " . S::v('skin') . "\n";
-            $page->assign('bug_sent',1);
-            $mymail = new PlMailer();
-            $mymail->setFrom('"'.S::v('prenom').' '.S::v('nom').'" <'.S::v('bestalias').'@' . $globals->mail->domain . '>');
-            $mymail->addTo('support+platal@' . $globals->mail->domain);
-            $mymail->addCc('"'.S::v('prenom').' '.S::v('nom').'" <'.S::v('bestalias').'@' . $globals->mail->domain . '>');
-            $mymail->setSubject('Plat/al '.Env::v('task_type').' : '.Env::v('item_summary'));
-            $mymail->setTxtBody($body);
-            $mymail->send();
-        } elseif (Env::has('send')) {
-            $page->trigError("Merci de remplir une explication du problème rencontré");
-        }
-    }
-
-    function handler_wiki_help(&$page, $action = 'title')
-    {
-        $page->changeTpl('core/wiki.help.tpl', SIMPLE);
-        $page->assign('wiki_help', MiniWiki::help($action == 'title'));
-    }
-
-    /// Shared handler for wiki syntax result preview
-    function handler_wiki_preview(&$page, $action = 'title')
-    {
-        header('Content-Type: text/html; charset=utf-8');
-        $text = Get::v('text');
-        echo MiniWiki::wikiToHtml($text, $action == 'title');
-        exit;
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index 3576030..380316b 100644 (file)
@@ -47,7 +47,7 @@ class EmailModule extends PLModule
         require_once 'emails.inc.php';
 
         $page->changeTpl('emails/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Mes emails');
+        $page->setTitle('Polytechnique.org - Mes emails');
 
         $uid = S::v('uid');
 
@@ -98,7 +98,7 @@ class EmailModule extends PLModule
         global $globals;
 
         $page->changeTpl('emails/alias.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Alias melix.net');
+        $page->setTitle('Polytechnique.org - Alias melix.net');
 
         $uid     = S::v('uid');
         $forlife = S::v('forlife');
@@ -277,8 +277,8 @@ class EmailModule extends PLModule
     function handler_antispam(&$page, $statut_filtre = null)
     {
         require_once 'emails.inc.php';
-        require_once('wiki.inc.php');
-        wiki_require_page('Xorg.Antispam');
+        $wp = new PlWikiPage('Xorg.Antispam');
+        $wp->buildCache();
 
         $page->changeTpl('emails/antispam.tpl');
 
@@ -291,8 +291,8 @@ class EmailModule extends PLModule
 
     function handler_submit(&$page)
     {
-        require_once('wiki.inc.php');
-        wiki_require_page('Xorg.Mails');
+        $wp = new PlWikiPage('Xorg.Mails');
+        $wp->buildCache();
         $page->changeTpl('emails/submit_spam.tpl');
 
         if (Post::has('send_email')) {
@@ -328,7 +328,7 @@ class EmailModule extends PLModule
         $page->changeTpl('emails/send.tpl');
         $page->addJsLink('ajax.js');
 
-        $page->assign('xorg_title','Polytechnique.org - Envoyer un email');
+        $page->setTitle('Polytechnique.org - Envoyer un email');
 
         // action si on recoit un formulaire
         if (Post::has('save')) {
@@ -499,8 +499,8 @@ class EmailModule extends PLModule
     function handler_broken(&$page, $warn = null, $email = null)
     {
         require_once 'emails.inc.php';
-        require_once('wiki.inc.php');
-        wiki_require_page('Xorg.PatteCassée');
+        $wp = new PlWikiPage('Xorg.PatteCassée');
+        $wp->buildCache();
 
         global $globals;
 
index 12ac485..f900687 100644 (file)
@@ -81,7 +81,7 @@ class EventsModule extends PLModule
         return $res->fetchOneAssoc();
     }
 
-    private function upload_image(PlatalPage &$page, PlUpload &$upload)
+    private function upload_image(PlPage &$page, PlUpload &$upload)
     {
         if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) {
             return true;
@@ -272,8 +272,8 @@ class EventsModule extends PLModule
         $page->changeTpl('events/submit.tpl');
         $page->addJsLink('ajax.js');
 
-        require_once('wiki.inc.php');
-        wiki_require_page('Xorg.Annonce');
+        $wp = new PlWikiPage('Xorg.Annonce');
+        $wp->buildCache();
 
         $titre      = Post::v('titre');
         $texte      = Post::v('texte');
@@ -329,7 +329,7 @@ class EventsModule extends PLModule
 
     function handler_admin_tips(&$page, $action = 'list', $id = null)
     {
-        $page->assign('xorg_title', 'Polytechnique.org - Administration - Astuces');
+        $page->setTitle('Polytechnique.org - Administration - Astuces');
         $page->assign('title', 'Gestion des Astuces');
         $table_editor = new PLTableEditor('admin/tips', 'tips', 'id');
         $table_editor->describe('peremption', 'date de péremption', true);
@@ -350,7 +350,7 @@ class EventsModule extends PLModule
     {
         $page->changeTpl('events/admin.tpl');
         $page->addJsLink('ajax.js');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Evenements');
+        $page->setTitle('Polytechnique.org - Administration - Evenements');
         $page->register_modifier('hde', 'html_entity_decode');
 
         $arch = $action == 'archives';
@@ -382,7 +382,7 @@ class EventsModule extends PLModule
                 $action = 'edit';
             } else {
                 $res = XDB::query('SELECT flags FROM evenements WHERE id = {?}', $eid);
-                $flags = new FlagSet($res->fetchOneCell());
+                $flags = new PlFlagSet($res->fetchOneCell());
                 $flags->addFlag('wiki');
                 if (Post::v('important')) {
                     $flags->addFlag('important');
index c9538c9..4e5d009 100644 (file)
@@ -59,7 +59,7 @@ class ForumsModule extends PLModule
     function handler_banana(&$page, $group = null, $action = null, $artid = null)
     {
         $page->changeTpl('banana/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Forums & PA');
+        $page->setTitle('Polytechnique.org - Forums & PA');
 
         $get = Array();
         if (Post::has('updateall')) {
@@ -97,7 +97,7 @@ class ForumsModule extends PLModule
 
     function handler_forums_bans(&$page, $action = 'list', $id = null)
     {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Bannissements des forums');
+        $page->setTitle('Polytechnique.org - Administration - Bannissements des forums');
         $page->assign('title', 'Gestion des mises au ban');
         $table_editor = new PLTableEditor('admin/forums','forums.innd','id_innd');
         $table_editor->add_sort_field('priority', true, true);
@@ -113,7 +113,7 @@ class ForumsModule extends PLModule
     static function run_banana(&$page, $params = null)
     {
         $page->changeTpl('banana/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Forums & PA');
+        $page->setTitle('Polytechnique.org - Forums & PA');
 
         require_once 'banana/forum.inc.php';
         run_banana($page, 'ForumsBanana', $params);
index 613c2df..a778b3f 100644 (file)
 // iGoogle gadgets helpers.
 function init_igoogle_xml($template)
 {
-    global $page;
-    $page->changeTpl($template, NO_SKIN);
+    Platal::page()->changeTpl($template, NO_SKIN);
 
     header('Content-Type: application/xml; charset=utf-8');
 }
 
 function init_igoogle_html($template, $auth = AUTH_PUBLIC)
 {
-    global $page;
+    $page =& Platal::page();
     $page->changeTpl('gadgets/ig-skin.tpl', NO_SKIN);
     $page->register_modifier('escape_html', 'escape_html');
     $page->default_modifiers = Array('@escape_html');
index 895c5f4..9fb091a 100644 (file)
@@ -42,7 +42,7 @@ class GeolocModule extends PLModule
     function handler_admin(&$page, $action = false) {
         $page->changeTpl('geoloc/admin.tpl');
         require_once("geoloc.inc.php");
-        $page->assign('xorg_title','Polytechnique.org - Administration - Geolocalisation');
+        $page->setTitle('Polytechnique.org - Administration - Geolocalisation');
 
         $nb_synchro = 0;
 
@@ -100,7 +100,7 @@ class GeolocModule extends PLModule
         $noCoordinates = $countNoCoordinates->fetchOneCell();
 
         if (isset($refresh) && $missing) {
-            $page->assign("xorg_extra_header", "<meta http-equiv='Refresh' content='3'/>");
+            $page->assign("pl_extra_header", "<meta http-equiv='Refresh' content='3'/>");
         }
         $page->assign("nb_cities_not_on_map", $missing);
         $page->assign("no_smallest", $noSmallest);
index fcfb153..d7871d6 100644 (file)
@@ -42,7 +42,7 @@ class GoogleAppsModule extends PLModule
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/index.tpl');
         $page->addJsLink('motdepasse.js');
-        $page->assign('xorg_title', 'Polytechnique.org - Compte Google Apps');
+        $page->setTitle('Polytechnique.org - Compte Google Apps');
 
         $account = new GoogleAppsAccount(S::v('uid'), S::v('forlife'));
 
@@ -117,7 +117,7 @@ class GoogleAppsModule extends PLModule
     function handler_admin(&$page, $action = null) {
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/admin.tpl');
-        $page->assign('xorg_title', 'Polytechnique.org - Administration Google Apps');
+        $page->setTitle('Polytechnique.org - Administration Google Apps');
         $page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
 
         if ($action == 'ack') {
@@ -163,7 +163,7 @@ class GoogleAppsModule extends PLModule
     function handler_admin_job(&$page, $job = null) {
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/admin.job.tpl');
-        $page->assign('xorg_title', 'Polytechnique.org - Administration Google Apps');
+        $page->setTitle('Polytechnique.org - Administration Google Apps');
         $page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
 
         if ($job) {
@@ -183,7 +183,7 @@ class GoogleAppsModule extends PLModule
         require_once("emails.inc.php");
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/admin.user.tpl');
-        $page->assign('xorg_title', 'Polytechnique.org - Administration Google Apps');
+        $page->setTitle('Polytechnique.org - Administration Google Apps');
         $page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
 
         if (!$user && Post::has('login')) {
index 0333db8..6a65763 100644 (file)
@@ -94,7 +94,7 @@ class ListsModule extends PLModule
 
         $page->changeTpl('lists/index.tpl');
         $page->addJsLink('ajax.js');
-        $page->assign('xorg_title','Polytechnique.org - Listes de diffusion');
+        $page->setTitle('Polytechnique.org - Listes de diffusion');
 
 
         if (Get::has('del')) {
@@ -884,7 +884,7 @@ class ListsModule extends PLModule
 
     function handler_admin_all(&$page) {
         $page->changeTpl('lists/admin_all.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists');
+        $page->setTitle('Polytechnique.org - Administration - Mailing lists');
 
         $client = new MMList(S::v('uid'), S::v('password'));
         $listes = $client->get_all_lists();
index b40c90a..11a34f9 100644 (file)
@@ -40,7 +40,7 @@ class MarketingModule extends PLModule
     {
         $page->changeTpl('marketing/index.tpl');
 
-        $page->assign('xorg_title','Polytechnique.org - Marketing');
+        $page->setTitle('Polytechnique.org - Marketing');
 
         // Quelques statistiques
 
@@ -268,8 +268,6 @@ class MarketingModule extends PLModule
 
             if (Post::has('valide')) {
                 S::assert_xsrf_token();
-
-                require_once('xorg.misc.inc.php');
                 $email = trim(Post::v('mail'));
 
                 if (!isvalid_email_redirection($email)) {
index 5a41e9a..31face1 100644 (file)
@@ -38,7 +38,7 @@ class NewsletterModule extends PLModule
         require_once 'newsletter.inc.php';
 
         $page->changeTpl('newsletter/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Lettres mensuelles');
+        $page->setTitle('Polytechnique.org - Lettres mensuelles');
 
         switch ($action) {
           case 'out': Newsletter::unsubscribe(); break;
@@ -76,8 +76,8 @@ class NewsletterModule extends PLModule
         $page->changeTpl('newsletter/submit.tpl');
 
         require_once 'newsletter.inc.php';
-        require_once 'wiki.inc.php';
-        wiki_require_page('Xorg.LettreMensuelle');
+        $wp = new PlWikiPage('Xorg.LettreMensuelle');
+        $wp->buildCache();
 
         if (Post::has('see') || (Post::has('valid') && (!trim(Post::v('title')) || !trim(Post::v('body'))))) {
             if (!Post::has('see')) {
@@ -97,7 +97,7 @@ class NewsletterModule extends PLModule
 
     function handler_admin_nl(&$page, $new = false) {
         $page->changeTpl('newsletter/admin.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : liste');
+        $page->setTitle('Polytechnique.org - Administration - Newsletter : liste');
         require_once("newsletter.inc.php");
 
         if($new) {
@@ -111,7 +111,7 @@ class NewsletterModule extends PLModule
     function handler_admin_nl_edit(&$page, $nid = 'last', $aid = null, $action = 'edit') {
         $page->changeTpl('newsletter/edit.tpl');
         $page->addCssLink('nl.css');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Edition');
+        $page->setTitle('Polytechnique.org - Administration - Newsletter : Edition');
         require_once("newsletter.inc.php");
 
         $nl  = new NewsLetter($nid);
@@ -157,7 +157,7 @@ class NewsletterModule extends PLModule
     }
 
     function handler_admin_nl_cat(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Catégories');
+        $page->setTitle('Polytechnique.org - Administration - Newsletter : Catégories');
         $page->assign('title', 'Gestion des catégories de la newsletter');
         $table_editor = new PLTableEditor('admin/newsletter/categories','newsletter_cat','cid');
         $table_editor->describe('titre','intitulé',true);
index 9de57d1..3924071 100644 (file)
@@ -34,7 +34,7 @@ function cb_erreur($text) {
 /* sort en affichant une erreur */
 function paypal_erreur($text, $send=true)
 {
-    global $page, $erreur, $globals;
+    global $erreur, $globals;
     if ($erreur) return;
     $erreur = $text;
     if (!$send) return;
@@ -46,7 +46,7 @@ function paypal_erreur($text, $send=true)
     $mymail->setTxtBody("\n\n".var_export($_REQUEST,true));
     $mymail->send();
 
-    $page->trigError($text);
+    Platal::page()->trigError($text);
 }
 
 /* http://fr.wikipedia.org/wiki/Formule_de_Luhn */
@@ -120,7 +120,7 @@ class PaymentModule extends PLModule
             }
         }
         $page->changeTpl('payment/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Télépaiements');
+        $page->setTitle('Polytechnique.org - Télépaiements');
 
         // initialisation
         $op   = Env::v('op', 'select');
@@ -467,7 +467,7 @@ class PaymentModule extends PLModule
     }
 
     function handler_admin(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Paiements');
+        $page->setTitle('Polytechnique.org - Administration - Paiements');
         $page->assign('title', 'Gestion des télépaiements');
         $table_editor = new PLTableEditor('admin/payments','paiement.paiements','id');
         $table_editor->add_join_table('paiement.transactions','ref',true);
index 65cdf6a..c38d1c3 100644 (file)
@@ -49,7 +49,7 @@ class Payment
 
         $this->montant_min = (float)$this->montant_min;
         $this->montant_max = (float)$this->montant_max;
-        $this->flags       = new Flagset($flags);
+        $this->flags       = new PlFlagSet($flags);
     }
 
     // }}}
index 407fa18..c79935c 100644 (file)
@@ -55,7 +55,6 @@ class CyberPayment
         $name = $req->fetchOneCell();
 
         // on constuit la reference de la transaction
-        require_once 'xorg.misc.inc.php';
         $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id();
         $fullref = substr("$prefix-xorg-{$pay->id}",-15);
 
index 48e740f..e1b4d0f 100644 (file)
@@ -89,7 +89,6 @@ class PayPal
         $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
 
         // on constuit la reference de la transaction
-        require_once 'xorg.misc.inc.php';
         $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id();
         $fullref = substr("$prefix-xorg-{$pay->id}",-15);
 
index 14f5bc0..f89c57c 100644 (file)
@@ -122,7 +122,7 @@ class PlatalModule extends PLModule
     function handler_prefs(&$page)
     {
         $page->changeTpl('platal/preferences.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Mes préférences');
+        $page->setTitle('Polytechnique.org - Mes préférences');
 
         if (Post::has('mail_fmt')) {
             $fmt = Post::v('mail_fmt');
@@ -143,7 +143,7 @@ class PlatalModule extends PLModule
     {
         $page->changeTpl('platal/webredirect.tpl');
 
-        $page->assign('xorg_title','Polytechnique.org - Redirection de page WEB');
+        $page->setTitle('Polytechnique.org - Redirection de page WEB');
 
         $log =& S::v('log');
         $url = Env::v('url');
@@ -152,14 +152,14 @@ class PlatalModule extends PLModule
             XDB::execute('UPDATE auth_user_quick
                                        SET redirecturl = {?} WHERE user_id = {?}',
                                    $url, S::v('uid'));
-            $log->log('carva_add', 'http://'.Env::v('url'));
+            S::logger()->log('carva_add', 'http://'.Env::v('url'));
             $page->trigSuccess("Redirection activée vers <a href='http://$url'>$url</a>");
         } elseif (Env::v('submit') == "Supprimer") {
             XDB::execute("UPDATE auth_user_quick
                                        SET redirecturl = ''
                                      WHERE user_id = {?}",
                                    S::v('uid'));
-            $log->log("carva_del", $url);
+            S::logger()->log("carva_del", $url);
             Post::kill('url');
             $page->trigSuccess('Redirection supprimée');
         }
@@ -209,7 +209,7 @@ class PlatalModule extends PLModule
             }
 
             $log =& S::v('log');
-            $log->log('passwd', '');
+            S::logger()->log('passwd', '');
 
             if (Cookie::v('ORGaccess')) {
                 setcookie('ORGaccess', hash_encrypt($password), (time()+25920000), '/', '' ,0);
@@ -221,17 +221,18 @@ class PlatalModule extends PLModule
 
         $page->changeTpl('platal/motdepasse.tpl');
         $page->addJsLink('motdepasse.js');
-        $page->assign('xorg_title','Polytechnique.org - Mon mot de passe');
+        $page->setTitle('Polytechnique.org - Mon mot de passe');
     }
 
     function handler_smtppass(&$page)
     {
         $page->changeTpl('platal/acces_smtp.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Acces SMTP/NNTP');
+        $page->setTitle('Polytechnique.org - Acces SMTP/NNTP');
 
-        require_once 'wiki.inc.php';
-        wiki_require_page('Xorg.SMTPSécurisé');
-        wiki_require_page('Xorg.NNTPSécurisé');
+        $wp = new PlWikiPage('Xorg.SMTPSécurisé');
+        $wp->buildCache();
+        $wp = new PlWikiPage('Xorg.NNTPSécurisé');
+        $wp->buildCache();
 
         $uid  = S::v('uid');
         $pass = Env::v('smtppass1');
@@ -243,12 +244,12 @@ class PlatalModule extends PLModule
             XDB::execute('UPDATE auth_user_md5 SET smtppass = {?}
                                      WHERE user_id = {?}', $pass, $uid);
             $page->trigSuccess('Mot de passe enregistré');
-            $log->log("passwd_ssl");
+            S::logger()->log("passwd_ssl");
         } elseif (Env::v('op') == "Supprimer") {
             XDB::execute('UPDATE auth_user_md5 SET smtppass = ""
                                      WHERE user_id = {?}', $uid);
             $page->trigSuccess('Compte SMTP et NNTP supprimé');
-            $log->log("passwd_del");
+            S::logger()->log("passwd_del");
         }
 
         $res = XDB::query("SELECT IF(smtppass != '', 'actif', '')
@@ -334,8 +335,8 @@ Adresse de secours : " . Post::v('email') : ""));
             $mymail->send();
 
             // on cree un objet logger et on log l'evenement
-            $logger = $_SESSION['log'] = new CoreLogger($uid);
-            $logger->log('recovery', $mails);
+            $logger = $_SESSION['log'] = new PlLogger($uid);
+            S::logger()->log('recovery', $mails);
         } else {
             $page->trigError('Les informations que tu as rentrées ne permettent pas de récupérer ton mot de passe.<br />'.
                         'Si tu as un homonyme, utilise prenom.nom.promo comme login');
@@ -373,8 +374,8 @@ Adresse de secours : " . Post::v('email') : ""));
                 }
             }
 
-            $logger = new CoreLogger($uid);
-            $logger->log("passwd","");
+            $logger = new PlLogger($uid);
+            S::logger()->log("passwd","");
             $page->changeTpl('platal/tmpPWD.success.tpl');
         } else {
             $page->changeTpl('platal/motdepasse.tpl');
@@ -387,14 +388,14 @@ Adresse de secours : " . Post::v('email') : ""));
         global $globals;
 
         $page->changeTpl('platal/skins.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Skins');
+        $page->setTitle('Polytechnique.org - Skins');
 
         if (Env::has('newskin'))  {  // formulaire soumis, traitons les données envoyées
             XDB::execute('UPDATE auth_user_quick
                              SET skin={?} WHERE user_id={?}',
                          Env::i('newskin'), S::v('uid'));
             S::kill('skin');
-            set_skin();
+            Platal::session()->setSkin();
         }
 
         $res = XDB::query('SELECT id FROM skins WHERE skin_tpl={?}', S::v('skin'));
@@ -414,9 +415,8 @@ Adresse de secours : " . Post::v('email') : ""));
             $a4l  = S::v('forlife');
             $suid = S::v('suid');
             $log  = S::v('log');
-            $log->log("suid_stop", S::v('forlife') . " by " . $suid['forlife']);
-            $_SESSION = $suid;
-            S::kill('suid');
+            S::logger()->log("suid_stop", S::v('forlife') . " by " . $suid['forlife']);
+            Platal::session()->stopSUID();
             pl_redirect('admin/user/' . $a4l);
         }
 
@@ -424,7 +424,7 @@ Adresse de secours : " . Post::v('email') : ""));
             setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
             Cookie::kill('ORGaccess');
             if (isset($_SESSION['log']))
-                $_SESSION['log']->log("cookie_off");
+                S::logger()->log("cookie_off");
         }
 
         if ($level == 'forgetuid' || $level == 'forgetall') {
@@ -436,10 +436,9 @@ Adresse de secours : " . Post::v('email') : ""));
 
         if (isset($_SESSION['log'])) {
             $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
-            $_SESSION['log']->log('deconnexion',$ref);
+            S::logger()->log('deconnexion',$ref);
         }
-
-        XorgSession::destroy();
+        Platal::session()->destroy();
 
         if (Get::has('redirect')) {
             http_redirect(rawurldecode(Get::v('redirect')));
@@ -450,21 +449,13 @@ Adresse de secours : " . Post::v('email') : ""));
 
     function handler_review(&$page, $action = null, $mode = null) 
     {
-        require_once 'wiki.inc.php';
         require_once dirname(__FILE__) . '/platal/review.inc.php';
-        $dir = wiki_work_dir();
         $dom = 'Review';
         if (@$GLOBALS['IS_XNET_SITE']) {
             $dom .= 'Xnet';
         }
-        if (!is_dir($dir)) {
-            $page->kill("Impossible de trouver le wiki");
-        }
-        if (!file_exists($dir . '/' . $dom . '.Admin')) {
-            $page->kill("Impossible de trouver la page d'administration");
-        }
-        $conf = preg_grep('/^text=/', explode("\n", file_get_contents($dir . '/' . $dom . '.Admin')));
-        $conf = preg_split('/(text\=|\%0a)/', array_shift($conf), -1, PREG_SPLIT_NO_EMPTY);
+        $wp = new PlWikiPage($dom . '.Admin');
+        $conf = explode('%0a', $wp->getField('text'));
         $wiz = new PlWizard('Tour d\'horizon', 'core/plwizard.tpl', true);
         foreach ($conf as $line) {
             $list = preg_split('/\s*[*|]\s*/', $line, -1, PREG_SPLIT_NO_EMPTY);
index 96e6aab..2b48319 100644 (file)
@@ -27,13 +27,12 @@ class ReviewPage implements PlWizardPage
     public function template() { return 'platal/review.tpl'; }
     public function process() { }
 
-    public function prepare(PlatalPage &$page, $id)
+    public function prepare(PlPage &$page, $id)
     {
-        require_once 'wiki.inc.php';
-        $dom = (@$GLOBALS['IS_XNET_SITE'] ? 'ReviewXnet' : 'Review') . '.' . ucfirst($id);
-        wiki_require_page($dom);
-        $page->assign('cacheExists', wiki_work_dir() . '/cache_' . $dom . '.tpl');
-        $page->assign('article', $dom);
+        $wp = new PlWikiPage((@$GLOBALS['IS_XNET_SITE'] ? 'ReviewXnet' : 'Review') . '.' . ucfirst($id));
+        $wp->buildCache();
+        $page->assign('cacheExists', $wp->cacheFilename());
+        $page->assign('article', $wp->name);
     }
 }
 
index f663dc1..123ccb7 100644 (file)
@@ -125,6 +125,7 @@ class ProfileModule extends PLModule
 
     function handler_photo_change(&$page)
     {
+        global $globals;
         $page->changeTpl('profile/trombino.tpl');
 
         require_once('validations.inc.php');
@@ -164,14 +165,14 @@ class ProfileModule extends PLModule
             XDB::execute('DELETE FROM  requests
                                 WHERE  user_id = {?} AND type="photo"',
                          S::v('uid'));
-            update_NbValid();
+            $globals->updateNbValid();
         } elseif (Env::v('cancel')) {
             S::assert_xsrf_token();
 
             $sql = XDB::query('DELETE FROM  requests
                                      WHERE  user_id={?} AND type="photo"',
                               S::v('uid'));
-            update_NbValid();
+            $globals->updateNbValid();
         }
 
         $sql = XDB::query('SELECT  COUNT(*)
@@ -225,11 +226,11 @@ class ProfileModule extends PLModule
         }
 
         if (S::logged()) {
-            $_SESSION['log']->log('view_profile', $login);
+            S::logger()->log('view_profile', $login);
         }
 
         $title = $user['prenom'] . ' ' . ( empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage'] );
-        $page->assign('xorg_title', $title);
+        $page->setTitle($title);
 
         // photo
 
@@ -336,7 +337,7 @@ class ProfileModule extends PLModule
                       . " la procédure de récupération de mot de passe si un jour tu le perdais");
         }
 
-       $page->assign('xorg_title', 'Polytechnique.org - Mon Profil');
+       $page->setTitle('Polytechnique.org - Mon Profil');
     }
 
     function handler_applis_js(&$page)
@@ -455,7 +456,6 @@ class ProfileModule extends PLModule
         $page->changeTpl('profile/orange.tpl');
 
         require_once 'validations.inc.php';
-        require_once 'xorg.misc.inc.php';
 
         $res = XDB::query(
                 "SELECT  u.promo, u.promo_sortie
@@ -568,9 +568,10 @@ class ProfileModule extends PLModule
 
     function handler_ref_search(&$page, $action = null, $subaction = null)
     {
-        require_once 'wiki.inc.php';
-        wiki_require_page('Docs.Emploi');
-        $page->assign('xorg_title', 'Polytechnique.org - Conseil Pro');
+        $wp = new PlWikiPage('Docs.Emploi');
+        $wp->buildCache();
+
+        $page->setTitle('Polytechnique.org - Conseil Pro');
 
         //recuperation des noms de secteurs
         $res = XDB::iterRow("SELECT id, label FROM emploi_secteur");
@@ -654,7 +655,6 @@ class ProfileModule extends PLModule
         $page->changeTpl('profile/nomusage.tpl');
 
         require_once 'validations.inc.php';
-        require_once 'xorg.misc.inc.php';
 
         $res = XDB::query(
                 "SELECT  u.nom, u.nom_usage, u.flags, e.alias
@@ -664,7 +664,7 @@ class ProfileModule extends PLModule
                   WHERE  user_id={?}", S::v('uid'));
 
         list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
-        $flags = new flagset($flags);
+        $flags = new PlFlagSet($flags);
         $page->assign('usage_old', $usage_old);
         $page->assign('alias_old',  $alias_old);
 
@@ -694,7 +694,7 @@ class ProfileModule extends PLModule
     function handler_xnet(&$page)
     {
         $page->changeTpl('profile/groupesx.tpl');
-        $page->assign('xorg_title', 'Polytechnique.org - Promo, Groupes X, Binets');
+        $page->setTitle('Polytechnique.org - Promo, Groupes X, Binets');
 
         $req = XDB::query('
             SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
@@ -724,7 +724,7 @@ class ProfileModule extends PLModule
 
     function handler_admin_trombino(&$page, $uid = null, $action = null) {
         $page->changeTpl('profile/admin_trombino.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Trombino');
+        $page->setTitle('Polytechnique.org - Administration - Trombino');
         $page->assign('uid', $uid);
 
         $q   = XDB::query(
@@ -763,7 +763,7 @@ class ProfileModule extends PLModule
         $page->assign('forlife', $forlife);
     }
     function handler_admin_binets(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Binets');
+        $page->setTitle('Polytechnique.org - Administration - Binets');
         $page->assign('title', 'Gestion des binets');
         $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
         $table_editor->add_join_table('binets_ins','binet_id',true);
@@ -771,7 +771,7 @@ class ProfileModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_formations(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Formations');
+        $page->setTitle('Polytechnique.org - Administration - Formations');
         $page->assign('title', 'Gestion des formations');
         $table_editor = new PLTableEditor('admin/formations','applis_def','id');
         $table_editor->add_join_table('applis_ins','aid',true);
@@ -780,21 +780,21 @@ class ProfileModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_sections(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Sections');
+        $page->setTitle('Polytechnique.org - Administration - Sections');
         $page->assign('title', 'Gestion des sections');
         $table_editor = new PLTableEditor('admin/sections','sections','id');
         $table_editor->describe('text','intitulé',true);
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title', 'Polytechnique.org - Administration - Sous-secteurs');
+        $page->setTitle('Polytechnique.org - Administration - Sous-secteurs');
         $page->assign('title', 'Gestion des sous-secteurs');
         $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true);
         $table_editor->describe('label', 'intitulé', true);
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_fonctions(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title', 'Polytechnique.org - Administration - Fonctions');
+        $page->setTitle('Polytechnique.org - Administration - Fonctions');
         $page->assign('title', 'Gestion des fonctions');
         $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true);
         $table_editor->describe('fonction_fr', 'intitulé', true);
@@ -803,14 +803,14 @@ class ProfileModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_secteurs(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title', 'Polytechnique.org - Administration - Secteurs');
+        $page->setTitle('Polytechnique.org - Administration - Secteurs');
         $page->assign('title', 'Gestion des secteurs');
         $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true);
         $table_editor->describe('label', 'intitulé', true);
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_medals(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Distinctions');
+        $page->setTitle('Polytechnique.org - Administration - Distinctions');
         $page->assign('title', 'Gestion des Distinctions');
         $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
         $table_editor->describe('text', 'intitulé',  true);
index ec0f031..780ee03 100644 (file)
@@ -117,7 +117,7 @@ class ProfileAddress extends ProfileGeoloc
 
     private function saveAddress($adrid, array &$address)
     {
-        $flags = new FlagSet();
+        $flags = new PlFlagSet();
         if ($address['secondaire']) {
             $flags->addFlag('res-secondaire');
         }
index 0753966..df97147 100644 (file)
@@ -114,7 +114,7 @@ class ProfileDecos extends ProfilePage
         }
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         $res    = XDB::iterator("SELECT  *, FIND_IN_SET('validation', flags) AS validate
                                    FROM  profile_medals
index 1382658..8227f36 100644 (file)
@@ -52,9 +52,8 @@ class ProfileNom implements ProfileSetting
                 || $this->matchWord($ini, $new, $newLen)
                 || ($field == 'nom' && $new == 'DE ' . $old);
         if (!$success) {
-            global $page;
-            $page->trigError("Le $field que tu as choisi ($value) est trop loin de ton $field initial ($init)"
-                       . (($init == $current)? "" : " et de ton prénom précédent ($current)"));
+            Platal::page()->trigError("Le $field que tu as choisi ($value) est trop loin de ton $field initial ($init)"
+                                    . (($init == $current)? "" : " et de ton prénom précédent ($current)"));
         }
         return $success ? $value : $current;
     }
@@ -197,7 +196,7 @@ class ProfileGeneral extends ProfilePage
         }
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         require_once "applis.func.inc.php";
     }
index cd2b705..cd2c447 100644 (file)
@@ -106,7 +106,7 @@ class ProfileGroups extends ProfilePage
         $this->watched['section'] = $this->watched['binets'] = true;
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         $page->assign('mygroups', XDB::iterator("SELECT  a.nom, a.site, a.diminutif, a.unsub_url, a.pub, m.perms
                                                    FROM  groupex.asso    AS a
index 33690c4..ad1e921 100644 (file)
@@ -202,7 +202,7 @@ class ProfileJobs extends ProfilePage
         }
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         $page->assign('secteurs', XDB::iterator("SELECT  id, label
                                                    FROM  emploi_secteur"));
index cbe6a23..bf577d9 100644 (file)
@@ -42,8 +42,7 @@ class ProfileSecteurs implements ProfileSetting
         } else if (!is_array($value)) {
             $value = array();
         } else if (count($value) > 10) {
-            global $page;
-            $page->trigError("Le nombre de secteurs d'expertise est limité à 10");
+            Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10");
             $success = false;
         }
         ksort($value);
@@ -90,8 +89,7 @@ class ProfileCountry implements ProfileSetting
         } else if (!is_array($value)) {
             $value = array();
         } else if (count($value) > 10) {
-            global $page;
-            $page->trigError("Le nombre de secteurs d'expertise est limité à 10");
+            Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10");
             $success = false;
         }
         ksort($value);
@@ -151,7 +149,7 @@ class ProfileMentor extends ProfilePage
         }
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         $page->assign('secteurs_sel', XDB::iterator("SELECT  id, label
                                                        FROM  emploi_secteur"));
index 139178e..433947e 100644 (file)
@@ -53,9 +53,8 @@ class ProfileWeb extends ProfileNoSave
         $value = trim($value);
         $success = empty($value) || preg_match("{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i", $value);
         if (!$success) {
-            global $page;
-            $page->trigError('URL Incorrecte : une url doit commencer par http:// ou https:// ou ftp://'
-                      . ' et ne pas contenir de caractères interdits');
+            Platal::page()->trigError('URL Incorrecte : une url doit commencer par http:// ou https:// ou ftp://'
+                                    . ' et ne pas contenir de caractères interdits');
         }
         return $value;
     }
@@ -69,11 +68,9 @@ class ProfileEmail extends ProfileNoSave
             return isset($page->values[$field]) ? $page->values[$field] : S::v($field);
         }
         $value = trim($value);
-        require_once 'xorg.misc.inc.php';
         $success = empty($value) || isvalid_email($value);
         if (!$success) {
-            global $page;
-            $page->trigError('Adresse Email invalide');
+            Platal::page()->trigError('Adresse Email invalide');
         }
         return $value;
     }
@@ -89,8 +86,7 @@ class ProfileTel extends ProfileNoSave
         }
         $success = !preg_match('/[<>{}@&#~\/:;?,!§*_`\[\]|%$^=]/', $value, $matches);
         if (!$success) {
-            global $page;
-            $page->trigError('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0]));
+            Platal::page()->trigError('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0]));
         }
         return $value;
     }
@@ -135,16 +131,14 @@ class ProfileDate extends ProfileNoSave
         } else {
             $success = preg_match('@(\d{2})/(\d{2})/(\d{4})@', $value, $matches);
             if (!$success) {
-                global $page;
-                $page->trigError("Les dates doivent être au format jj/mm/aaaa");
+                Platal::page()->trigError("Les dates doivent être au format jj/mm/aaaa");
            } else {
                 $day   = (int)$matches[1];
                 $month = (int)$matches[2];
                 $year  = (int)$matches[3];
                 $success = ($day > 0 && $day <= 31) && ($month > 0 && $month <= 12) && ($year > 1900 && $year <= 2020);
                 if (!$success) {
-                    global $page;
-                    $page->trigError("La date n'a pas une valeur valide");
+                    Platal::page()->trigError("La date n'a pas une valeur valide");
                 }
             }
         }
@@ -260,7 +254,7 @@ abstract class ProfilePage implements PlWizardPage
         }
         global $platal;
         $log =& $_SESSION['log'];
-        $log->log('profil', $platal->pl_self(1));
+        S::logger()->log('profil', $platal->pl_self(1));
     }
 
     protected function checkChanges()
@@ -290,11 +284,11 @@ abstract class ProfilePage implements PlWizardPage
         return 'profile/base.tpl';
     }
 
-    protected function _prepare(PlatalPage &$page, $id)
+    protected function _prepare(PlPage &$page, $id)
     {
     }
 
-    public function prepare(PlatalPage &$page, $id)
+    public function prepare(PlPage &$page, $id)
     {
         if (count($this->values) == 0) {
             $this->fetchData();
@@ -329,9 +323,8 @@ abstract class ProfilePage implements PlWizardPage
             }
             return Post::has('next_page') ? PlWizard::NEXT_PAGE : PlWizard::CURRENT_PAGE;
         }
-        global $page;
-        $page->trigError("Certains champs n'ont pas pu être validés, merci de corriger les informations "
-                  . "de ton profil et de revalider ta demande");
+        Platal::page()->trigError("Certains champs n'ont pas pu être validés, merci de corriger les informations "
+                                . "de ton profil et de revalider ta demande");
         return PlWizard::CURRENT_PAGE;
     }
 }
index 8f0ec5e..c3da4f9 100644 (file)
@@ -89,7 +89,7 @@ class ProfileSkills extends ProfilePage
         $this->settings['langues'] = new ProfileSkill('langues', 'lid', 'langue_fr');
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         $page->assign('comp_list', XDB::iterator("SELECT  id, text_fr, FIND_IN_SET('titre',flags) AS title
                                                     FROM  competences_def"));
index 2b04a7e..6f351c6 100644 (file)
@@ -83,8 +83,8 @@ class RegisterModule extends PLModule
 
         switch ($sub_state['step']) {
             case 0:
-                require_once('wiki.inc.php');
-                wiki_require_page('Reference.Charte');
+                $wp = new PlWikiPage('Reference.Charte');
+                $wp->buildCache();
                 if (Post::has('step1')) {
                     $sub_state['step'] = 1;
                     if (isset($sub_state['hash'])) {
@@ -300,8 +300,8 @@ class RegisterModule extends PLModule
         $redirect->add_email($email);
 
         // on cree un objet logger et on log l'inscription
-        $logger = new CoreLogger($uid);
-        $logger->log('inscription', $email);
+        $logger = new PlLogger($uid);
+        S::logger()->log('inscription', $email);
 
         XDB::execute('UPDATE register_pending SET hash="INSCRIT" WHERE uid={?}', $uid);
 
@@ -317,7 +317,7 @@ class RegisterModule extends PLModule
         user_reindex($uid);
 
         // update number of subscribers (perms has changed)
-        update_NbIns();
+        $globals->updateNbIns();
 
         if (!start_connexion($uid, false)) {
             return PL_FORBIDDEN;
@@ -416,7 +416,7 @@ class RegisterModule extends PLModule
             }
 
             $log = S::v('log');
-            $log->log('passwd', '');
+            S::logger()->log('passwd', '');
 
             if (Cookie::v('ORGaccess')) {
                 require_once('secure_hash.inc.php');
index 2d9a3c2..4839e36 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once 'xorg.misc.inc.php';
-
 // {{{ function user_cmp
 
 function user_cmp($prenom, $nom, $_prenom, $_nom)
@@ -151,7 +149,6 @@ function create_aliases (&$sub)
     global $globals;
     extract ($sub);
 
-    require_once "xorg.misc.inc.php";
     $mailorg  = make_username($prenom, $nom);
     $mailorg2 = $mailorg.sprintf(".%02u", ($promo%100));
     $forlife  = make_forlife($prenom, $nom, $promo);
index c97996c..b287c01 100644 (file)
@@ -47,9 +47,7 @@ class SearchModule extends PLModule
 
     function form_prepare()
     {
-        global $page;
-
-        $page->assign('formulaire',1);
+        Platal::page()->assign('formulaire',1);
     }
 
     function get_diplomas($school = null)
@@ -72,8 +70,7 @@ class SearchModule extends PLModule
             $types = explode('(',$row[1]);
             $types = str_replace("'","",substr($types[1],0,-1));
         }
-        global $page;
-        $page->assign('choix_diplomas', explode(',',$types));
+        Platal::page()->assign('choix_diplomas', explode(',',$types));
     }
 
     function handler_quick(&$page, $action = null, $subaction = null)
@@ -90,7 +87,7 @@ class SearchModule extends PLModule
         if (Env::has('quick') || $action == 'geoloc') {
             $quick = trim(Env::v('quick'));
             if (S::logged() && !Env::has('page')) {
-                $_SESSION['log']->log('search', 'quick=' . $quick);
+                S::logger()->log('search', 'quick=' . $quick);
             }
             $list = 'profile|prf|fiche|fic|referent|ref|mentor';
             if (S::has_perms()) {
@@ -157,7 +154,7 @@ class SearchModule extends PLModule
 
         require_once dirname(__FILE__) . '/search/search.inc.php';
         $page->changeTpl('search/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Annuaire');
+        $page->setTitle('Polytechnique.org - Annuaire');
     }
 
     function handler_advanced(&$page, $action = null, $subaction = null)
@@ -185,7 +182,7 @@ class SearchModule extends PLModule
                 'city' => array('table' => 'geoloc_city', 'text' => 'name', 'exact' => false)
             );
             if (!Env::has('page')) {
-                $_SESSION['log']->log('search', 'adv=' . var_export($_GET, true));
+                S::logger()->log('search', 'adv=' . var_export($_GET, true));
             }
             foreach ($textFields as $field=>&$query) {
                 if (!Env::v($field) && Env::v($field . 'Txt')) {
index 91c924d..5f01c97 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once("xorg.misc.inc.php");
-
 // {{{ Global variables used for the search Queries
 
 @$globals->search->result_fields = '
@@ -92,9 +90,10 @@ class ThrowError
      */
     private static function defaultHandler($explain)
     {
-        global $page, $globals;
+        global $globals;
+        $page =& Platal::page();
         $page->changeTpl('search/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Annuaire');
+        $page->setTitle('Polytechnique.org - Annuaire');
         $page->assign('baseurl', $globals->baseurl);
         $page->trigError($explain);
         $page->run();
@@ -253,8 +252,7 @@ class QuickSearch extends SField
         $s = preg_replace('!\d+!', ' ', $s);
         $this->strings = preg_split("![^a-zA-Z%]+!",$s, -1, PREG_SPLIT_NO_EMPTY);
         if (count($this->strings) > 5) {
-            global $page;
-            $page->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
+            Platal::page()->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
             $this->strings = array_slice($this->strings, 0, 5);
         }
 
@@ -279,6 +277,8 @@ class QuickSearch extends SField
             if (Env::i('with_soundex') && strlen($s) > 1) {
                 $t = soundex_fr($s);
                 $where[] = "sn$i.soundex = '$t'";
+            } elseif (Env::i('exact')) {
+                $where[] = "sn$i.token = '$s'";
             } else {
                 $t = str_replace('*', '%', $s).'%';
                 $t = str_replace('%%', '%', $t);
@@ -445,6 +445,7 @@ class RefSField extends SField
     function compare()
     {
         $val = addslashes($this->value);
+        if (Env::i('exact')) return "='$val'";
         return $this->exact ? "='$val'" : " LIKE '%$val%'";
     }
 
@@ -583,7 +584,9 @@ class StringSField extends SField
      * @param field nom de champ de la bdd concerné par la clause */
     function get_single_where_statement($field)
     {
-        $regexp = strtr(addslashes($this->value), '-*', '_%');
+        $val = addslashes($this->value);
+        if (Env::i('exact')) return "$field = '$val'";
+        $regexp = strtr($val, '-*', '_%');
         return "$field LIKE '$regexp%'";
     }
 
@@ -614,7 +617,9 @@ class NameSField extends StringSField
 
     function get_single_where_statement($field)
     {
-        $regexp = strtr(addslashes($this->value), '-*', '_%');
+        $val = addslashes($this->value);
+        if (Env::i('exact')) return "$field = '$val'";
+        $regexp = strtr($val, '-*', '_%');
         return "$field LIKE '$regexp%' OR $field LIKE '% $regexp%' OR $field LIKE '%-$regexp%'";
     }
 
index 0d23a78..985a398 100644 (file)
@@ -48,9 +48,9 @@ function advancedSearchFromInput()
     }
 
     if (!Env::i('cityid')) {
-        $townField      = new RefSField('city',array('ac.city'),'adresses','ac',getadr_join('ac'),false);
+        $townField  = new RefSField('city',array('ac.city', 'ac.postcode'),'adresses','ac',getadr_join('ac'),false);
     } else {
-        $townField    = new RefSField('cityid',array('av.cityid'),'adresses','av',getadr_join('av'));
+        $townField  = new RefSField('cityid',array('av.cityid', 'av.postcode'),'adresses','av',getadr_join('av'));
     }
     $countryField   = new RefSField('country',array('ap.country'),'adresses','ap',getadr_join('ap'));
     $regionField    = new RefSField('region',array('ar.region'),'adresses','ar',getadr_join('ar'));
index b0d0151..d3c9c4e 100644 (file)
@@ -65,8 +65,8 @@ class XnetModule extends PLModule
 
     function handler_exit(&$page)
     {
-        XnetSession::killSuid();
-        XnetSession::destroy();
+        Platal::session()->stopSUID();
+        Platal::session()->destroy();
         $page->changeTpl('xnet/deconnexion.tpl');
     }
 
index 77abf91..6ee5456 100644 (file)
@@ -98,7 +98,7 @@ class XnetEventsModule extends PLModule
             XDB::execute("DELETE FROM requests
                                     WHERE type = 'paiements' AND data LIKE {?}",
                                    PayReq::same_event($eid, $globals->asso('id')));
-            update_NbValid();
+            $globals->updateNbValid();
         }
 
         if ($action == 'archive') {
index 1303d9c..4a69b7a 100644 (file)
@@ -202,7 +202,8 @@ function get_event_participants(&$evt, $item_id, $tri, $limit = '') {
 function subscribe_lists_event($participate, $uid, $evt)
 {
     require_once('user.func.inc.php');
-    global $globals,$page;
+    global $globals;
+    $page =& Platal::page();
 
     $participant_list = $evt['participant_list'];
     $absent_list      = $evt['absent_list'];
@@ -215,7 +216,7 @@ function subscribe_lists_event($participate, $uid, $evt)
         $res = XDB::query("SELECT email
                              FROM groupex.membres
                             WHERE uid = {?} AND asso_id = {?}",
-                            S::v('uid'), $globals->asso('id'));
+                          $uid, $globals->asso('id'));
         $email = $res->fetchOneCell();
     }
 
index 232b2c6..56da844 100644 (file)
@@ -233,7 +233,7 @@ class XnetGrpModule extends PLModule
         if (Post::has('submit')) {
             S::assert_xsrf_token();
 
-            $flags = new FlagSet('wiki_desc');
+            $flags = new PlFlagSet('wiki_desc');
             if (Post::has('notif_unsub') && Post::i('notif_unsub') == 1) {
                 $flags->addFlag('notif_unsub');
             }
@@ -708,25 +708,26 @@ class XnetGrpModule extends PLModule
         if (Env::has('right') && (may_update() || S::has('suid'))) {
             switch (Env::v('right')) {
               case 'admin':
-                XnetSession::killSuid();
+                Platal::session()->stopSUID();
                 break;
               case 'anim':
-                XnetSession::doSelfSuid();
+                Platal::session()->doSelfSuid();
                 may_update(true);
                 is_member(true);
                 break;
               case 'member':
-                XnetSession::doSelfSuid();
+                Platal::session()->doSelfSuid();
                 may_update(false, true);
                 is_member(true);
                 break;
               case 'logged':
-                XnetSession::doSelfSuid();
+                Platal::session()->doSelfSuid();
                 may_update(false, true);
                 is_member(false, true);
                 break;
             }
         }
+//        var_dump($_SESSION);
         http_redirect($_SERVER['HTTP_REFERER']);
     }
 
@@ -811,7 +812,6 @@ class XnetGrpModule extends PLModule
                 $page->trigError($email." n'est pas un alias polytechnique.org valide.");
             }
         } else {
-            require_once 'xorg.misc.inc.php';
             if (isvalid_email($email)) {
                 if (Env::v('x') && Env::has('userid') && Env::i('userid')) {
                     $uid = Env::i('userid');
@@ -884,7 +884,7 @@ class XnetGrpModule extends PLModule
 
     function unsubscribe(&$user)
     {
-        global $globals, $page;
+        global $globals;
         XDB::execute(
                 "DELETE FROM  groupex.membres WHERE uid={?} AND asso_id={?}",
                 $user['uid'], $globals->asso('id'));
@@ -928,9 +928,9 @@ class XnetGrpModule extends PLModule
                     $mmlist->unsubscribe($liste['list']);
                 }
             } elseif ($liste['sub']) {
-                $page->trigWarning("{$user['prenom']} {$user['nom']} a une"
-                                  ." demande d'inscription en cours sur la"
-                                  ." liste {$liste['list']}@ !");
+                Platal::page()->trigWarning("{$user['prenom']} {$user['nom']} a une"
+                                           ." demande d'inscription en cours sur la"
+                                           ." liste {$liste['list']}@ !");
                 $warning = true;
             }
         }
@@ -989,7 +989,7 @@ class XnetGrpModule extends PLModule
         }
     }
 
-    private function changeLogin(PlatalPage &$page, array &$user, MMList &$mmlist, $login)
+    private function changeLogin(PlPage &$page, array &$user, MMList &$mmlist, $login)
     {
         require_once 'user.func.inc.php';
         // Search the uid of the user...
@@ -1208,7 +1208,7 @@ class XnetGrpModule extends PLModule
         $page->assign('rss', $rss);
     }
 
-    private function upload_image(PlatalPage &$page, PlUpload &$upload)
+    private function upload_image(PlPage &$page, PlUpload &$upload)
     {
         if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) {
             return true;
@@ -1316,7 +1316,7 @@ class XnetGrpModule extends PLModule
         if (Post::v('valid') == 'Enregistrer') {
             $promo_min = ($art['public'] ? 0 : $art['promo_min']);
             $promo_max = ($art['public'] ? 0 : $art['promo_max']);
-            $flags = new FlagSet();
+            $flags = new PlFlagSet();
             if ($art['public']) {
                 $flags->addFlag('public');
             }
diff --git a/plugins/block.tidy.php b/plugins/block.tidy.php
deleted file mode 100644 (file)
index d74de2f..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-global $tidy_config;
-$tidy_config = array(
-    'drop-empty-paras' => true,
-    'drop-font-tags' => true,
-    'drop-proprietary-attributes' => true,
-    'hide-comments' => true,
-    'logical-emphasis' => true,
-    'output-xhtml' => true,
-    'replace-color' => true,
-    'show-body-only' => true,
-    'clean' => false,
-    'join-styles' => false,
-    'join-classes' => false,
-    'alt-text' => '[ inserted by TIDY ]',
-    'wrap' => '120');
-
-/*
- * Smarty plugin
- * -------------------------------------------------------------
- * File:     block.min_perms.php
- * Type:     block
- * Name:     min_perms
- * Purpose:
- * -------------------------------------------------------------
- */
-function smarty_block_tidy($params, $content, &$smarty)
-{
-    global $tidy_config;
-    return tidy_repair_string($content, $tidy_config, 'utf8');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/compiler.checkpasswd.php b/plugins/compiler.checkpasswd.php
deleted file mode 100644 (file)
index 5c10a2a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 'platal.inc.php';
-
-function smarty_compiler_checkpasswd($tag_attrs, &$compiler)
-{
-    extract($compiler->_parse_attrs($tag_attrs));
-    if (!isset($width)) {
-      $width = '230px';
-    }
-    if (!isset($prompt)) {
-      $prompt = "'nouveau'";
-    }
-    if (!isset($submit)) {
-      $submit = "'submitn'";
-    }
-
-    return '?><script type="text/javascript" src="javascript/jquery.js" ></script>
-              <script type="text/javascript" src="javascript/jquery.color.js" ></script>
-              <script type="text/javascript">//<![CDATA[
-                var passwordprompt_name = '.  $prompt . ';
-                var passwordprompt_submit = ' . $submit . ';
-                $(":input[@name=' . $prompt . ']").keyup(function(event) { checkPassword(event.target); });
-                $(document).ready(function() {
-                  checkPassword($(":input[@name=' . $prompt . ']").get(0));
-                });
-              //]]></script>
-              <div>
-                <div style="border: 1px solid white; width: ' . $width . '; height: 7px; background-color: #444; margin-top: 4px; float: left">
-                  <div id="passwords_measure" style="height: 100%; background-color: red; width: 0px"></div>
-                </div>
-                <a href="Xorg/MDP?display=light" style="display: block; float: left; margin-left: 4px;" class="popup_600x800">
-                  <img src="images/icons/information.gif" alt="Aide" title="Comment construire un mot de passe fort..." />
-                </a>
-              </div><?php';
-}
-
-/* vim: set expandtab enc=utf-8: */
-
-?>
index c675903..d464900 100644 (file)
@@ -18,7 +18,6 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
-require_once 'platal.inc.php';
 
 function smarty_compiler_icon($tag_attrs, &$compiler)
 {
diff --git a/plugins/compiler.iterate.php b/plugins/compiler.iterate.php
deleted file mode 100644 (file)
index 1ab1a01..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-function iterate_end($tag_attrs, &$compiler) {
-    return 'endwhile;';
-}
-
-function smarty_compiler_iterate($tag_attrs, &$compiler)
-{
-    static $reg = false;
-    if (!$reg) {
-        $reg = true;
-        $compiler->register_compiler_function("/iterate", 'iterate_end');
-    }
-
-    $_params = $compiler->_parse_attrs($tag_attrs);
-
-    if (!isset($_params['from'])) {
-        $compiler->_syntax_error("iterate: missing 'from' parameter", E_USER_ERROR, __FILE__, __LINE__);
-        return;
-    }
-
-    if (empty($_params['item'])) {
-        $compiler->_syntax_error("iterate: missing 'item' attribute", E_USER_ERROR, __FILE__, __LINE__);
-        return;
-    }
-
-    $_from = $compiler->_dequote($_params['from']);
-    $_item = $compiler->_dequote($_params['item']);
-
-    return "\$_iterate_$_item = $_from;\n"
-        .  "while ((\$this->_tpl_vars['$_item'] = \$_iterate_{$_item}->next()) !== null):";
-}
-
-/* vim: set expandtab enc=utf-8: */
-
-?>
diff --git a/plugins/compiler.javascript.php b/plugins/compiler.javascript.php
deleted file mode 100644 (file)
index b17d370..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 'platal.inc.php';
-
-function smarty_compiler_javascript($tag_attrs, &$compiler)
-{
-    extract($compiler->_parse_attrs($tag_attrs));
-
-    if (!isset($name)) {
-        return null;
-    }
-    $name = pl_entities(trim($name, '\'"'), ENT_QUOTES);
-    $name = "javascript/$name.js";
-    if ($full) {
-        global $globals;
-        $name = $globals->baseurl . '/' . $name;
-    }
-
-    return "?><script type='text/javascript' src='$name'></script><?php";
-}
-
-/* vim: set expandtab enc=utf-8: */
-
-?>
index a9c94e7..faa8684 100644 (file)
@@ -18,7 +18,6 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
-require_once 'platal.inc.php';
 
 function smarty_function_make_forlife($params, &$smarty)
 {
diff --git a/plugins/function.select_db_table.php b/plugins/function.select_db_table.php
deleted file mode 100644 (file)
index 41d1bae..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 'platal.inc.php';
-
-function select_options($table,$valeur,$champ="text",$pad=false,
-                        $where="",$join="",$group="")
-{
-    $fields = 't.id,' . $champ;
-    $order = $champ;
-    if ($group) {
-        $fields .= ',' . $group;
-        $order = $group . ',' . $order;
-    }
-    $sql = "SELECT $fields FROM $table AS t $join $where ORDER BY $order";
-    $res = XDB::iterRow($sql);
-    $sel = ' selected="selected"';
-
-    // on ajoute une entree vide si $pad est vrai
-    $html = "";
-    if ($pad) {
-        $html.= '<option value="0"'.($valeur==0?$sel:"")."></option>\n";
-    }
-    $optgrp = null;
-    while (list($my_id,$my_text,$my_grp) = $res->next()) {
-        if ($my_grp != $optgrp) {
-            if (!is_null($optgrp)) {
-                $html .= '</optgroup>';
-            }
-            $html .= '<optgroup label="' . pl_entities($my_grp, ENT_QUOTES) . '">';
-            $optgrp = $my_grp;
-        }
-        $html .= sprintf("<option value=\"%s\" %s>%s</option>\n",
-                         $my_id, $valeur==$my_id ? $sel : "", pl_entities($my_text));
-    }
-    if (!is_null($optgrp)) {
-        $html .= '</optgroup>';
-    }
-    return $html;
-}
-
-function smarty_function_select_db_table($params, &$smarty) {
-    if(empty($params['table']))
-        return;
-    if(empty($params['champ']))
-        $params['champ'] = 'text';
-    if(empty($params['pad']) || !($params['pad']))
-        $pad = false;
-    else
-        $pad = true;
-    if(empty($params['where']))
-        $params['where'] = '';
-    return select_options($params['table'], $params['valeur'], $params['champ'], $pad,
-                          $params['where'], $params['join'], $params['group']);
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/function.valid_date.php b/plugins/function.valid_date.php
deleted file mode 100644 (file)
index 8613c3a..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 'platal.inc.php';
-
-function smarty_function_valid_date($params, &$smarty)
-{
-    extract($params);
-
-    if (!isset($name)) {
-        $name = 'valid_date';
-    }
-    $text = "<select name=\"$name\">";
-    if (!isset($from)) {
-        $from = 1;
-    }
-    if (!isset($to)) {
-        $to = 30;
-    }
-    $value = strtr($value, array('-' => ''));
-    $time = time() + 3600 * 24 * $from;
-    $mth  = '';
-    for ($i = $from ; $i <= $to ; $i++) {
-        $p_stamp = date('Ymd', $time);
-        $date    = date('d / m / Y', $time);
-        $select  = ($p_stamp == $value) ? 'selected="selected"' : '';
-        $month   = pl_entities(strftime('%B', $time), ENT_QUOTES);
-        if ($mth != $month) {
-            if ($i != $from) {
-                $text .= '</optgroup>';
-            }
-            $text .= "<optgroup label=\"$month\">";
-            $mth = $month;
-        }
-        $time += 3600 * 24;
-        $text .= "<option value=\"$p_stamp\" $select>$date</option>";
-    }
-    return $text . "</optgroup></select>";
-}
-
-/* vim: set expandtab enc=utf-8: */
-?>
diff --git a/plugins/function.xsrf_token.php b/plugins/function.xsrf_token.php
deleted file mode 100644 (file)
index caa0a10..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-function smarty_function_xsrf_token($params, &$smarty) {
-    return S::v('xsrf_token', '');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/function.xsrf_token_field.php b/plugins/function.xsrf_token_field.php
deleted file mode 100644 (file)
index 3b6932e..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-function smarty_function_xsrf_token_field($params, &$smarty) {
-    if (S::has('xsrf_token')) {
-        return '<div style="display: none"><input type="hidden" name="token" value="' . S::v('xsrf_token') . '" /></div>';
-    }
-    return '';
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/modifier.date_format.php b/plugins/modifier.date_format.php
deleted file mode 100644 (file)
index 7714f16..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-function smarty_modifier_date_format($string, $format = '%x', $default_date=null)
-{
-    $d = empty($string) ? $default_date : $string;
-    if (empty($format) || preg_match('/^[ 0\-]*$/', $d)) return;
-    $f = str_replace('%X', '%T', str_replace('%x', '%e %B %Y', $format));
-
-    if (preg_match('/^\d{14}$/', $d)) {
-        $t = mktime(substr($d,8,2), substr($d,10,2), substr($d,12,2), substr($d,4,2), substr($d,6,2), substr($d,0,4));
-    } elseif (preg_match('/^\d{8}$/', $d)) {
-        $t = mktime(0, 0, 0, substr($d,4,2), substr($d,6,2), substr($d,0,4));
-    } elseif (is_numeric($d)) {
-        $t = intval($d);
-    } else {
-        $t = strtotime($d);
-    }
-
-    if ( $t != -1 ) {
-        return strftime($f , $t);
-    } else {
-        require_once('Date.php');
-        $date = new Date($d);
-        return $date->format($f);
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/modifier.htmlentities.php b/plugins/modifier.htmlentities.php
deleted file mode 100644 (file)
index 01dae76..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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 'platal.inc.php';
-
-function smarty_modifier_htmlentities($string, $format = ENT_COMPAT)
-{
-    return pl_entities($string, $format);
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/modifier.number_format.php b/plugins/modifier.number_format.php
deleted file mode 100644 (file)
index 4b09833..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-function smarty_modifier_number_format($string, $decimal = 0)
-{
-    return number_format($string, $decimal, ',', '.');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/modifier.uint_to_ip.php b/plugins/modifier.uint_to_ip.php
deleted file mode 100644 (file)
index a7076fa..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 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                *
- ***************************************************************************/
-
-function smarty_modifier_uint_to_ip($string)
-{
-    return uint_to_ip($string);
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index 4bc7bb4..f3be2ff 100644 (file)
@@ -172,6 +172,7 @@ Si tu n'es pas {insert name="getName"}, change le login ci-dessous, ou rends-toi
 <!-- Set up the form with the challenge value and an empty reply value //-->
 <form action="{$smarty.server.REQUEST_URI}" method="post" id="loginsub">
   <div>
+    {xsrf_token_field}
     <input type="hidden" name="challenge" value="{$smarty.session.challenge}" />
     <input type="hidden" name="response"  value="" />
     <input type="hidden" name="xorpass"  value="" />
index 156a1eb..e7b0a49 100644 (file)
@@ -23,7 +23,7 @@
 
 <h1>Télépaiements</h1>
 
-{if $smarty.request.op eq "submit" and !$xorg_errors}
+{if $smarty.request.op eq "submit" and !$pl_errors}
 
 <table class="bicol">
   <tr>
index 10ec28f..983dbdb 100644 (file)
@@ -31,7 +31,7 @@
 </p>
 <p>
   Pour une sécurité optimale, ton mot de passe circule de manière chiffrée (https) et est
-  stocké chiffrée irréversiblement sur nos serveurs.
+  stocké chiffré irréversiblement sur nos serveurs.
 </p>
 <br />
 <form action="{$smarty.server.REQUEST_URI}" method="post" id="changepass">
index 3c6a5ba..00dcde1 100644 (file)
@@ -36,7 +36,9 @@
           return '...';
         }
 
-        return name + '<em>&nbsp;&nbsp;-&nbsp;&nbsp;' + row[1] + ' camarades<\/em>';
+        camarades = (row[1] > 1) ? "camarades" : "camarade";
+
+        return name + '<em>&nbsp;&nbsp;-&nbsp;&nbsp;' + row[1] + '&nbsp;' + camarades + '<\/em>';
       };
   }
 
       <th colspan="2">Géographie</th>
     </tr>
     <tr>
-      <td>Ville</td>
+      <td>Ville ou code postal</td>
       <td><input type="text" class="autocomplete" name="city" size="32" value="{$smarty.request.city}" /></td>
     </tr>
     <tr>
@@ -415,6 +417,12 @@ checked="checked"{/if}/>Chercher uniquement les adresses où les camarades sont
           <label for="order">Mettre les fiches modifiées récemment en premier.</label>
       </td>
     </tr>
+    <tr>
+      <td colspan="2">
+           <input type='checkbox' name='exact' id="exact" {if $smarty.request.exact}checked='checked'{/if} value='1'/>
+           <label for="exact">Faire une recherche exacte.</label>
+      </td>
+    </tr>
         {/if}
     <tr><td colspan="2"></td></tr>
     <tr>
index 0f6d2c9..99471bd 100644 (file)
@@ -21,7 +21,7 @@
 {**************************************************************************}
 
 
-{if $formulaire eq 0 and !$xorg_errors}
+{if $formulaire eq 0 and !$pl_errors}
   {if !$simple}
     {if !$advanced}
     {include file=search/quick.form.tpl show_js=1}
index fdd8ddb..4781db6 100644 (file)
@@ -37,10 +37,10 @@ Nous conseillons très vivement d'utiliser des navigateurs récents, tels
 <br />
 {/if}
 
-{if !$xorg_no_errors || $xorg_failure}
+{if !$pl_no_errors || $pl_failure}
 {include file="skin/common.triggers.tpl"}
 {/if}
 
-{if !$xorg_failure && $xorg_tpl}{include file=$xorg_tpl}{/if}
+{if !$pl_failure && $pl_tpl}{include file=$pl_tpl}{/if}
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index da39c5e..568297d 100644 (file)
     <link rel="bookmark" href="http://www.polytechnique.fr/eleves/" title="| Site d'élèves" />
 
     <link rel="stylesheet" type="text/css" href="css/base.css" media="all"/>
-    {foreach from=$xorg_css item=css}
+    {foreach from=$pl_css item=css}
     <link rel="stylesheet" type="text/css" href="css/{$css}" media="all"/>
     {/foreach}
-    {foreach from=$xorg_inline_css item=css}
+    {foreach from=$pl_inline_css item=css}
     <style type="text/css">
     {$css|smarty:nodefaults}
     </style>
@@ -53,7 +53,7 @@
     <script type="text/javascript">
       var platal_baseurl = "{$globals->baseurl}/";
     </script>
-    {foreach from=$xorg_js item=js}
+    {foreach from=$pl_js item=js}
     <script type="text/javascript" src="javascript/{$js}"></script>
     {/foreach}
     {javascript name=overlib}
     {javascript name=sha1}
     {javascript name=secure_hash}
 
-    {if $xorg_rss}
-    <link rel="alternate" type="application/rss+xml" title="{$xorg_rss.title}" href="{$xorg_rss.href}" />
+    {if $pl_rss}
+    <link rel="alternate" type="application/rss+xml" title="{$pl_rss.title}" href="{$pl_rss.href}" />
     {/if}
 
-    {if $xorg_extra_header}
-    {$xorg_extra_header|smarty:nodefaults}
+    {if $pl_extra_header}
+    {$pl_extra_header|smarty:nodefaults}
     {/if}
 
-    <title>{$xorg_title|default:"Polytechnique.org&nbsp;: le site des élèves et anciens élèves de l'École polytechnique"}</title>
+    <title>{$pl_title|default:"Polytechnique.org&nbsp;: le site des élèves et anciens élèves de l'École polytechnique"}</title>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 5a310a3..9a507a2 100644 (file)
@@ -20,7 +20,7 @@
 {*                                                                        *}
 {**************************************************************************}
 
-{foreach from=$xorg_triggers key=type item=triggers}
+{foreach from=$pl_triggers key=type item=triggers}
 {if $triggers|@count}
 <div class="{$type}">
   <ul>
index c671dd7..a602df0 100644 (file)
     <link rel="bookmark" href="http://www.polytechnique.org/"       title="| Polytechnique.org" />
     <link rel="bookmark" href="http://www.polytechnique.fr/eleves/" title="| Site d'élèves" />
 
-    {foreach from=$xorg_css item=css}
+    {foreach from=$pl_css item=css}
     <link rel="stylesheet" type="text/css" href="css/{$css}" />
     {/foreach}
-    {foreach from=$xorg_inline_css item=css} 
+    {foreach from=$pl_inline_css item=css} 
     <style type="text/css"> 
     {$css|smarty:nodefaults} 
     </style> 
     if (window.top != window)
       document.write('<link rel="stylesheet" type="text/css" href="css/onlycontent.css" media="all"/>');
     </script>
-    {foreach from=$xorg_js item=js}
+    {foreach from=$pl_js item=js}
     <script type="text/javascript" src="javascript/{$js}"></script>
     {/foreach}
     {javascript name=overlib}
 
-    {if $xorg_rss}
-    <link rel="alternate" type="application/rss+xml" title="{$xorg_rss.title}" href="{$xorg_rss.href}" />
+    {if $pl_rss}
+    <link rel="alternate" type="application/rss+xml" title="{$pl_rss.title}" href="{$pl_rss.href}" />
     {/if}
 
-    {if $xorg_extra_header}
-    {$xorg_extra_header|smarty:nodefaults}
+    {if $pl_extra_header}
+    {$pl_extra_header|smarty:nodefaults}
     {/if}
 
     <title>Les associations polytechniciennes</title>