Initial revision
authorx2000habouzit <x2000habouzit>
Sun, 25 Jan 2004 17:19:21 +0000 (17:19 +0000)
committerx2000habouzit <x2000habouzit>
Sun, 25 Jan 2004 17:19:21 +0000 (17:19 +0000)
27 files changed:
.cvsignore [new file with mode: 0644]
.htaccess [new file with mode: 0644]
htdocs/css/default.css [new file with mode: 0644]
htdocs/images/favicon.png [new file with mode: 0644]
htdocs/images/sk_default_ban.jpg [new file with mode: 0644]
htdocs/images/sk_default_headlogo.jpg [new file with mode: 0644]
htdocs/images/sk_default_lesX.gif [new file with mode: 0644]
htdocs/images/sk_default_titre.gif [new file with mode: 0644]
htdocs/index.php [new file with mode: 0644]
htdocs/javascript/getnow.js [new file with mode: 0644]
include/auto.prepend.inc.php [new file with mode: 0644]
include/menu.inc.php [new file with mode: 0644]
include/xorg.common.inc.php [new file with mode: 0644]
include/xorg.globals.inc.php [new file with mode: 0644]
include/xorg.page.inc.php [new file with mode: 0644]
include/xorg.session.inc.php [new file with mode: 0644]
plugins/block.min_auth.php [new file with mode: 0644]
plugins/block.min_perms.php [new file with mode: 0644]
plugins/insert.getNbIns.php [new file with mode: 0644]
plugins/insert.mkStats.php [new file with mode: 0644]
templates/index.head.tpl [new file with mode: 0644]
templates/index.tpl [new file with mode: 0644]
templates/skin/common.bandeau.head.tpl [new file with mode: 0644]
templates/skin/common.bandeau.tpl [new file with mode: 0644]
templates/skin/common.footer.tpl [new file with mode: 0644]
templates/skin/common.header.tpl [new file with mode: 0644]
templates/skin/default.tpl [new file with mode: 0644]

diff --git a/.cvsignore b/.cvsignore
new file mode 100644 (file)
index 0000000..0c6726a
--- /dev/null
@@ -0,0 +1,2 @@
+cache/
+templates_c/
diff --git a/.htaccess b/.htaccess
new file mode 100644 (file)
index 0000000..85c38b2
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,2 @@
+php_value auto_prepend_file "include/auto.prepend.inc.php"
+php_value include_path ".:..:./include:../include/:/home/x2000habouzit/dev/diogenes/lib/"
diff --git a/htdocs/css/default.css b/htdocs/css/default.css
new file mode 100644 (file)
index 0000000..b992a4a
--- /dev/null
@@ -0,0 +1,124 @@
+/** DEFAULTS **/
+
+body {
+    background-color: #ffffff;
+    font-family: "Arial", sans-serif;
+    color: #000000;
+}
+
+a:link, a:visited, a:active, a:hover {
+    background-color: inherit;
+    color: #003399;
+}
+
+a img { border: 0px; }
+
+td { vertical-align: top; }
+
+p.normal {
+       margin-bottom: 0.5em;
+       text-align: justify;
+}
+
+p.erreur, span.erreur {
+       font-weight: bold;
+       background-color: inherit;
+       color: #ff0000;
+}
+       
+div.rubrique {
+       color: #555555;
+       background: url('/images/sk_default_titre.gif');
+       background-repeat: no-repeat;
+    
+       text-indent: 0.2em;
+       text-align: left;
+       font-family: "helvetica", sans-serif;
+       font-weight: bolder;
+       font-size: 120%;
+       
+    margin-top: 1em;
+       margin-bottom: 1em;
+       padding-left: 0.5em;
+}
+
+div.ssrubrique {
+       padding-top: 0.5em;
+       font-weight: bold;
+}
+
+
+/**************
+    LAYOUTS 
+***************/
+
+    #suid {
+        color: white;
+        background: red;
+        width: 100%;
+    }
+    
+    #body {
+        width: 740px;
+        margin-left: auto;
+        margin-right: auto;
+    }
+
+    #body-left {
+        width: 140px;
+        border-right: 1px solid gray;
+        text-align: center;
+        font-family: "MS Sans Serif", sans-serif;
+    }
+
+    #body-top {
+        border-bottom: 1px solid gray;
+        text-align: center;
+        font-size: 75%;
+        font-weight: bold;
+        padding: 4px;
+        padding-bottom: 16px;
+        font-family: "MS Sans Serif", sans-serif;
+    }
+
+    #body-top table { width: 100%; padding: 4px; }
+    #body-top .date-heure { text-align: left; }
+    #body-top .inscrits { text-align: right; }
+    
+    #body-bottom {
+        border-top: 1px solid gray;
+        text-align: center;
+        padding: 4px;
+        font-size: 75%;
+        font-family: "MS Sans Serif", sans-serif;
+    }
+
+    #menu {
+        width: 100%;
+        margin-top: 16px;
+        
+        font-size: 75%;
+        font-weight: bold;
+    }
+    
+    #menu .menu_item {
+        padding-left: 4px;
+        padding: 2px;
+        text-align: left;
+    }
+    
+    #menu .menu_title {
+        color: gray;
+        background: #eeeeee;
+        border-top: 1px solid gray;
+        border-bottom: 1px solid gray;
+        padding: 1px;
+        margin-top: 4px;
+        text-align: center;
+    }
+    
+    #content {
+        width: 600px;
+        padding: 4px 10px 4px 10px;
+        font-size: 95%;
+    }
diff --git a/htdocs/images/favicon.png b/htdocs/images/favicon.png
new file mode 100644 (file)
index 0000000..0e4b1d1
Binary files /dev/null and b/htdocs/images/favicon.png differ
diff --git a/htdocs/images/sk_default_ban.jpg b/htdocs/images/sk_default_ban.jpg
new file mode 100644 (file)
index 0000000..8b96d8f
Binary files /dev/null and b/htdocs/images/sk_default_ban.jpg differ
diff --git a/htdocs/images/sk_default_headlogo.jpg b/htdocs/images/sk_default_headlogo.jpg
new file mode 100644 (file)
index 0000000..35a296e
Binary files /dev/null and b/htdocs/images/sk_default_headlogo.jpg differ
diff --git a/htdocs/images/sk_default_lesX.gif b/htdocs/images/sk_default_lesX.gif
new file mode 100644 (file)
index 0000000..bdb5285
Binary files /dev/null and b/htdocs/images/sk_default_lesX.gif differ
diff --git a/htdocs/images/sk_default_titre.gif b/htdocs/images/sk_default_titre.gif
new file mode 100644 (file)
index 0000000..0900c86
Binary files /dev/null and b/htdocs/images/sk_default_titre.gif differ
diff --git a/htdocs/index.php b/htdocs/index.php
new file mode 100644 (file)
index 0000000..def3da0
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+require("auto.prepend.inc.php");
+new_skinned_page('index.tpl', AUTH_PUBLIC);
+
+$page->display();
+?>
diff --git a/htdocs/javascript/getnow.js b/htdocs/javascript/getnow.js
new file mode 100644 (file)
index 0000000..b7a50b8
--- /dev/null
@@ -0,0 +1,17 @@
+function getNow() {
+    dt=new Date();
+    dy=dt.getDay();
+    mh=dt.getMonth();
+    wd=dt.getDate();
+    yr=dt.getYear();
+    if (yr<1000) yr += 1900;
+    hr=dt.getHours();
+    mi=dt.getMinutes();
+    if (mi<10)
+        time=hr+":0"+mi;
+    else
+        time=hr+":"+mi;
+    days=new Array ("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
+    months=new Array ("janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre");
+    return days[dy]+" "+wd+" "+months[mh]+" "+yr+"<br />"+time;
+}
diff --git a/include/auto.prepend.inc.php b/include/auto.prepend.inc.php
new file mode 100644 (file)
index 0000000..92047b4
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+ini_set('include_path', ".:..:./include:../include/:/home/x2000habouzit/dev/diogenes/lib/:/home/x2000habouzit/dev/smarty/");
+require("xorg.common.inc.php");
+
+function _new_page($type, $tpl_name, $tpl_head, $min_auth, $admin=false) {
+    global $page;
+    require("xorg.page.inc.php");
+    if(!empty($admin)) {
+        $page = new XorgAdmin($tpl_name, $type);
+    } else switch($min_auth) {
+        case AUTH_PUBLIC:
+            $page = new XorgPage($tpl_name, $type);
+            break;
+        case AUTH_COOKIE:
+            $page = new XorgCookie($tpl_name, $type);
+        case AUTH_MDP:
+            $page = new XorgAuth($tpl_name, $type);
+    }
+
+    $page->assign('xorg_head', $tpl_head);
+    $page->assign('xorg_tpl', $tpl_name);
+}
+
+function new_skinned_page($tpl_name, $min_auth, $tpl_head="") {
+    _new_page(SKINNED, $tpl_name, $tpl_head, $min_auth);
+}
+
+function new_popup_page($tpl_name, $min_auth, $tpl_head="") {
+    _new_page(SKINNED, $tpl_name, $tpl_head, $min_auth);
+}
+
+function new_admin_page($tpl_name, $tpl_head="") {
+    require("xorg.page.inc.php");
+    _new_page(SKINNED, $tpl_name, $tpl_head, AUTH_MDP, true);
+}
+
+?>
diff --git a/include/menu.inc.php b/include/menu.inc.php
new file mode 100644 (file)
index 0000000..2dbb66f
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+
+if(logged()) {
+    $menu = Array(
+        0 => Array( 'Page d\'accueil' => '###url###' ),
+        'Personnaliser' => Array(
+            'Mes emails' => '###url###' ,
+            'Mon profil' => '###url###' ,
+            'Mes contacts' => '###url###' ,
+            'Mon mot de passe' => '###url###' ,
+            'Mes préférences' => '###url###' 
+        ),
+        'Services' => Array (
+            'Envoyer un mail' => '###url###' ,
+            'Forums & PA' => '###url###' ,
+            'Listes de diffusion' => '###url###' ,
+            'Micropaiements' => '###url###' ,
+            'Patte cassée' => '###url###' ,
+            'Sondages' => '###url###'
+        ),
+        'Communauté X' => Array (
+            'Annuaire' => '###url###',
+            'Trombi promo' => '###url###',
+            'Groupes X' => '###url###',
+            'Sites Polytechniciens' => '###url###'
+        ),
+        'Informations' => Array (
+            'Lettres mensuelles' => '###url###',
+            'Documentation' => '###url###',
+            'Nous contacter' => '###url###',
+            'Emploi' => '###url###'
+        )
+    );
+
+    if(identified()) {
+        $array = array_merge( Array('Déconnexion' => '###url###'),  $menu[0] );
+    }
+
+    if(has_perms()) {
+        $menu['***'] = Array (
+            'Marketing' => '###url###',
+            'Administration' => '###url###',
+            'Trackers' => '###url###',
+            'Documentations' => '###url###'
+        );
+    } elseif(has_perms($marketing_admin)) {
+        $menu['***'] = Array (
+            'Marketing' => '###url###'
+        );
+    }
+} else {
+    $menu = Array(
+        'Polytechniciens' => Array(
+            'Me connecter !' => "###url###",
+            'M\'inscrire' => "###url###"
+        ),
+        'Visiteurs' => Array(
+            'Annuaire de l\'X' => "###url###",
+            'Associations X' => "###url###",
+            'Recrutement' => "###url###"
+        ),
+        'Informations' => Array(
+            'A propos du site' => "###url###",
+            'Nous contacter ' => "###url###",
+            'FAQ' => "###url###"
+        )
+    );
+}
+$this->assign_by_ref('menu', $menu);
+?>
diff --git a/include/xorg.common.inc.php b/include/xorg.common.inc.php
new file mode 100644 (file)
index 0000000..07a9c74
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+$i=0;
+define("AUTH_PUBLIC", $i++);
+define("AUTH_COOKIE", $i++);
+define("AUTH_MDP", $i++);
+
+define("PERMS_EXT", "ext");
+define("PERMS_USER", "user");
+define("PERMS_ADMIN", "admin");
+
+define('SKIN_COMPATIBLE','default.tpl');
+define('SKIN_POPUP_COMPATIBLE','default.popup.tpl');
+define('SKIN_STOCHASKIN_ID','254');
+
+define('SKINNED', 0);
+define('POPUP', 1);
+
+// import class definitions
+require("diogenes.database.inc.php");
+require("xorg.globals.inc.php");
+require("xorg.session.inc.php");
+
+$globals = new XorgGlobals;
+require("config.xorg.inc.php");
+
+session_start();
+
+// connect to database
+$globals->dbconnect();
+$conn = $globals->db->connect_id;
+?>
diff --git a/include/xorg.globals.inc.php b/include/xorg.globals.inc.php
new file mode 100644 (file)
index 0000000..c0884c3
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+require("diogenes.core.globals.inc.php");
+
+class XorgGlobals extends DiogenesCoreGlobals {
+  var $page = 'XorgPage';
+  var $session = 'XorgSession';
+
+  var $dbdb = 'x4dat';
+  var $table_auth = 'auth_user_md5';
+  var $table_log_actions = 'logger.actions';
+  var $table_log_sessions = 'logger.sessions';
+  var $table_log_events = 'logger.events';
+
+}
+?>
diff --git a/include/xorg.page.inc.php b/include/xorg.page.inc.php
new file mode 100644 (file)
index 0000000..35064b6
--- /dev/null
@@ -0,0 +1,154 @@
+<?php
+require("diogenes.core.page.inc.php");
+
+class XorgPage extends DiogenesCorePage {
+  var $_page_type;
+  var $_tpl;
+  
+  function XorgPage($tpl, $type=SKINNED) {
+    global $site_dev,$marketing_admin;
+
+    $this->_page_type = SKINNED;
+    $this->_tpl = $tpl;
+
+    $this->DiogenesCorePage();
+
+    // if necessary, construct new session
+    if (!session_is_registered('session')) {
+      session_register('session');
+      $_SESSION['session'] = new XorgSession;
+    }
+
+    $this->assign('site_dev',$site_dev);
+
+    // si necessaire, c'est *ici* que se fait l'authentification
+    $_no_legacy = true;
+    $this->doAuth();
+    $this->set_skin();
+  }
+
+  function display() {
+      if($this->_page_type == POPUP)
+          parent::display('skin/'.$_SESSION['skin_popup'], $this->make_id());
+      else
+          parent::display('skin/'.$_SESSION['skin'], $this->make_id());
+  }
+
+  function make_id() {
+      $auth = (empty($_SESSION['auth']) ? 0 : $_SESSION['auth']);
+      $perms = (empty($_SESSION['perms']) ? 0 : $_SESSION['perms']);
+      return $this->_tpl."|$auth|$perms";
+  }
+
+  function doAuth() { }
+  
+  function set_skin() {
+    if(logged()) {
+      $result = mysql_query("SELECT skin FROM auth_user_md5 WHERE username = '{$_SESSION['uid']}'");
+      if(list($skin) = mysql_fetch_row($result)) {
+        $sql = "SELECT normal,popup FROM skins WHERE ";
+        if ($_SESSION['skin'] == SKIN_STOCHASKIN_ID) {
+          $sql .= " !FIND_IN_SET('cachee',type) order by rand() limit 1";
+        } else {
+          $sql .= "id='$skin'";
+        }
+        $res = mysql_query($sql);
+        list($_SESSION['skin'], $_SESSION['skin_popup']) = mysql_fetch_row($res);
+        mysql_free_result($res);
+      } else {
+        $_SESSION['skin'] = SKIN_COMPATIBLE;
+        $_SESSION['skin_popup'] = SKIN_COMPATIBLE;
+      }
+      mysql_free_result($result);
+    }
+
+    if( !logged() || !isset($_SERVER['HTTP_USER_AGENT'])
+        || ereg("Mozilla/4\.[0-9]{1,2} \[",$_SERVER['HTTP_USER_AGENT']) )
+    {
+      $_SESSION['skin'] = SKIN_COMPATIBLE;
+      $_SESSION['skin_popup'] = SKIN_COMPATIBLE;
+    }
+  }
+
+}
+
+
+/** Une classe pour les pages nécessitant l'authentification.
+ * (equivalent de controlauthentification.inc.php)
+ */
+class XorgAuth extends XorgPage
+{
+  function XorgAuth($tpl, $type=SKINNED)
+  {
+    $this->XorgPage($tpl, $type);
+  }
+
+  function doAuth()
+  {
+    $_SESSION['session']->doAuth($this);
+  }
+}
+
+
+/** Une classe pour les pages nécessitant l'authentification permanente.
+ * (equivalent de controlpermanent.inc.php)
+ */
+class XorgCookie extends XorgPage
+{
+  function XorgCookie($tpl, $type=SKINNED)
+  {
+    $this->XorgPage($tpl, $type);
+  }
+
+  function doAuth()
+  {
+    $_SESSION['session']->doAuthCookie($this);
+  }
+}
+
+
+/** Une classe pour les pages réservées aux admins (authentifiés!).
+ */
+class XorgAdmin extends XorgAuth
+{
+  function XorgAdmin($tpl, $type=SKINNED)
+  {
+    $this->XorgAuth($tpl, $type);
+    check_perms();
+  }
+}
+
+
+/** ajoute le nb de ../ qvb
+ * Cette fonction recherche login.php dans les chemins donnés par INCLUDE_PATH
+ * et renvoie l'url avec le nombre de .. qvb
+ * @param $param URL relative (à la page web)
+ * @return URL absolue (au site web)
+ * @see getphoto.php
+ * @see ax/PasswordPromptScreen.inc
+ * @see include/footer.inc.php
+ * @see include/form_data_maj.inc.php
+ * @see include/header1.inc.php
+ * @see include/header2.inc.php
+ * @see include/header_all.inc.php
+ * @see include/header_logged.inc.php
+ * @see include/passwordpromptscreen.inc.php
+ * @see include/passwordpromptscreenlogged.inc.php
+ * @see listes/index.php
+ * @see mescontacts.php
+ */
+function xorg_func_url($params)
+{
+  extract($params);
+
+  if (empty($rel))
+    return;
+
+  $chemins = Array('.', '..', '/');
+  foreach ($chemins as $ch) {
+    if (file_exists("$ch/login.php") || file_exists("$ch/public/login.php"))
+      return "$ch/$rel";
+  }
+  return "";
+}
+?>
diff --git a/include/xorg.session.inc.php b/include/xorg.session.inc.php
new file mode 100644 (file)
index 0000000..075153e
--- /dev/null
@@ -0,0 +1,234 @@
+<?php
+require("diogenes.core.session.inc.php");
+require("diogenes.misc.inc.php");
+
+class XorgSession extends DiogenesCoreSession {
+  function XorgSession()
+  {
+    $this->DiogenesCoreSession();
+    $_SESSION['challenge']=rand_token();
+  }
+
+
+  /** Try to do an authentication.
+   *
+   * @param page the calling page (by reference)
+   */
+  function doAuth(&$page) {
+    if(identified()) { // ok, c'est bon, on n'a rien à faire
+      return;
+    }
+
+    if (isset($_REQUEST['username']) and isset($_REQUEST['response'])
+        and isset($_SESSION['challenge']))
+    {
+      // si on vient de recevoir une identification par passwordpromptscreen.tpl
+      // ou passwordpromptscreenlogged.tpl
+      $res = @mysql_query( "SELECT username,user_id,password FROM auth_user_md5 WHERE username='{$_REQUEST['username']}'");
+      if(@mysql_num_rows($res) != 0) {
+        list($username,$uid,$password)=mysql_fetch_row($res);
+        mysql_free_result($res);
+        $expected_response=md5("{$_REQUEST['username']}:$password:{$_SESSION['challenge']}");
+        if($_REQUEST['response'] == $expected_response) {
+          unset($_SESSION['challenge']);
+          // on logge la réussite pour les gens avec cookie
+          if(isset($_SESSION['log']))
+            $_SESSION['log']->log("auth_ok");
+          start_connexion($username, $uid, true);
+          return true;
+        } else {
+          // mot de passe incorrect pour le login existant
+          // on logge l'échec pour les gens avec cookie
+          if(isset($_SESSION['log']))
+            $_SESSION['log']->log("auth_fail","bad password");
+          $this->doLogin($page);
+        }
+      } else {
+        // login inexistant dans la base de donnees
+        // on logge l'échec pour les gens avec cookie
+        if(isset($_SESSION['log']))
+          $_SESSION['log']->log("auth_fail","bad login");
+        $this->doLogin($page);
+      }
+    } else {
+      // ni loggué ni tentative de login
+      $this->doLogin($page);
+    }
+  }
+
+
+  /** Try to do a cookie-based authentication.
+   *
+   * @param page the calling page (by reference)
+   */
+  function doAuthCookie(&$page) {
+    // si on est deja connecté, c'est bon, rien à faire
+    if(logged())
+      return;
+
+    // on vient de recevoir une demande d'auth, on passe la main a doAuth
+    if (isset($_REQUEST['username']) and isset($_REQUEST['response']))
+      return $this->doAuth($page);
+
+    // sinon, on vérifie que les bons cookies existent
+    if(!isset($_COOKIE['ORGaccess']) or $_COOKIE['ORGaccess'] == ''
+        or !isset($_COOKIE['ORGlogin']))
+      return $this->doAuth($page);
+
+
+    // les bons cookies existent, donc ça veut dire que la session a expirée
+    // il faut donc vérifier que les cookies sont bons et recréer la session
+    // et d'authoriser l'accès
+    $res = @mysql_query( "SELECT user_id,password FROM auth_user_md5 WHERE username='{$_COOKIE['ORGlogin']}'");
+    if(@mysql_num_rows($res) != 0) {
+      list($uid,$password)=mysql_fetch_row($res);
+      mysql_free_result($res);
+      $expected_value=md5($password);
+      if($expected_value == $_COOKIE['ORGaccess']) {
+        //session_start();
+        start_connexion($_COOKIE['ORGlogin'], $uid, false);
+        return true;
+      } else {
+        // ORGaccess n'est pas bon
+        // cette variable failed_ORGaccess permet à
+        // controlauthentication.inc.php de mettre
+        // passwordpromtscreen.inc.php plutôt que
+        // passwordpromtscreenlogged.inc.php dans le
+        // cas ou ORGaccess n'est pas bon, permettant à l'utilisateur
+        // de changer son login ci-nécessaire.
+        $failed_ORGaccess = true;
+        return $this->doAuth($page);
+      }
+    } else {
+      // ORGlogin n'est pas bon
+      return $this->doAuth($page);
+    }
+  }
+
+  /** Display login screen.
+   */
+  function doLogin(&$page) {
+    global $failed_ORGaccess,$site_dev;
+
+    if(isset($_COOKIE['ORGaccess']) and isset($_COOKIE['ORGlogin']) and !isset($failed_ORGaccess)) {
+      $page->display("passwordpromptscreenlogged.tpl");
+    } else {
+      if (isset($_COOKIE['ORGlogin'])) {
+        $pre = strtok($_COOKIE['ORGlogin'],".");
+        $pre1=strtok($pre,"-");
+        $pre2=strtok(" ");
+        $pre1=ucfirst($pre1);
+        $pre2=ucfirst($pre2);
+        if ($pre2) {
+          $prenom = $pre1."-".$pre2;
+        } else {
+          $prenom = $pre1;
+        }
+        $page->assign('prenom',$prenom);
+      }
+      $page->display("passwordpromptscreen.tpl");
+    }
+    //    $page->assign('challenge',$this->challenge);
+    exit;
+  }
+
+}
+
+
+/** verifie si un utilisateur a les droits pour voir une page
+ ** si ce n'est pas le cas, on affiche une erreur
+ * @return void
+ * TODO RECODER
+ */
+function check_perms($auth_array=array()) {
+  if (!has_perms($auth_array)) {
+    $_SESSION['log']->log("noperms",$_SERVER['PHP_SELF']);
+    echo "<div class=\"erreur\">";
+    echo "Tu n'as pas les permissions n&eacute;cessaires pour acc&eacute;der &agrave; cette page.";
+    echo "</div>";
+    include("footer.inc.php");
+    exit;
+  }
+}
+
+
+/** verifie si un utilisateur a les droits pour voir une page
+ ** soit parce qu'il est admin, soit il est dans une liste
+ ** supplementaire de personnes utilisées
+ * @return BOOL
+ */
+  function has_perms($auth_array=array()) {
+    return logged()
+      && ( (!empty($auth_array) && in_array($_SESSION['username'], $auth_array))
+          || ($_SESSION['perms']==PERMS_ADMIN) );
+  }
+
+
+/** renvoie true si la session existe et qu'on est loggué correctement
+ * false sinon
+ * @return bool vrai si loggué
+ * @see header2.inc.php
+ */
+function logged () {
+  return(isset($_SESSION['auth']) and $_SESSION['auth']>=AUTH_COOKIE);
+}
+
+
+
+/** renvoie true si la session existe et qu'on est loggué correctement
+ * et qu'on a été identifié par un mot de passe depuis le début de la session
+ * false sinon
+ * @return bool vrai si loggué
+ * @see header2.inc.php
+ */
+function identified () {
+  return(isset($_SESSION['auth']) and $_SESSION['auth']>=AUTH_MDP);
+}
+
+
+/** 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 ($username, $uid, $identified) {
+  $result=mysql_query("SELECT prenom, nom, perms, promo, UNIX_TIMESTAMP(lastnewslogin), UNIX_TIMESTAMP(lastlogin), host, matricule FROM auth_user_md5 WHERE user_id=$uid;");
+  list($prenom, $nom, $perms, $promo, $lastnewslogin, $lastlogin, $host, $matricule) = mysql_fetch_row($result);
+  mysql_free_result($result);
+  // on garde le logger si il existe (pour ne pas casser les sessions lors d'une
+  // authentification avec le cookie
+  // on vérifie que c'est bien un logger de l'utilisateur en question
+  if(isset($_SESSION['log']) && $_SESSION['log']->uid==$uid)
+    $logger = $_SESSION['log'];
+  // on vide la session pour effacer les valeurs précédentes (notamment de skin)
+  // qui peuvent être celles de quelqu'un d'autre ou celle par defaut
+  $_SESSION = array();
+  if (!isset($_SESSION['suid'])) {
+    // mise à jour de la date de dernière connexion
+    // sauf lorsque l'on est en SUID
+    $newhost=strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR']));
+    mysql_query("UPDATE auth_user_md5 SET host='$newhost',lastlogin=NULL WHERE user_id=$uid;");
+    $_SESSION['lastlogin'] = $lastlogin;
+    $_SESSION['host'] = $host;
+  }
+  // mise en place des variables de session
+  $_SESSION['auth'] = ($identified ? AUTH_MDP : AUTH_COOKIE);
+  $_SESSION['uid'] = $uid;
+  $_SESSION['username'] = $username;
+  $_SESSION['prenom'] = $prenom;
+  $_SESSION['nom'] = $nom;
+  $_SESSION['perms'] = $perms;
+  $_SESSION['promo'] = $promo;
+  $_SESSION['lastnewslogin'] = $lastnewslogin;
+  $res = mysql_query("SELECT flags FROM identification WHERE matricule = '$matricule' AND FIND_IN_SET(flags, 'femme')");
+  $_SESSION['femme'] = mysql_num_rows($res) > 0;
+  mysql_free_result($res);
+  // on récupère le logger si il existe, sinon, on logge la connexion
+  $_SESSION['log'] = (isset($logger) ? $logger : new DiogenesCoreLogger($uid));
+  if(empty($logger))
+    $_SESSION['log']->log("connexion",$_SERVER['PHP_SELF']);
+  // le login est stocké pour un an
+  setcookie('ORGlogin',$username,(time()+25920000),'/','',0);
+}
+
+?>
diff --git a/plugins/block.min_auth.php b/plugins/block.min_auth.php
new file mode 100644 (file)
index 0000000..f6b6691
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File:     block.min_auth.php
+ * Type:     block
+ * Name:     min_auth
+ * Purpose:  
+ * -------------------------------------------------------------
+ */
+function smarty_block_min_auth($params, $content, &$smarty)
+{
+    if( empty($content) || empty($params['level'] ))
+        return;
+    if( ($params['level'] == 'public') ||
+        ($params['level'] == 'cookie' && logged()) ||
+        ($params['level'] == 'auth' && identified()) )
+        return $content;
+}
+?>
diff --git a/plugins/block.min_perms.php b/plugins/block.min_perms.php
new file mode 100644 (file)
index 0000000..56244eb
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File:     block.min_perms.php
+ * Type:     block
+ * Name:     min_perms
+ * Purpose:  
+ * -------------------------------------------------------------
+ */
+function smarty_block_min_perms($params, $content, &$smarty)
+{
+    if( empty($content) || empty($params['level'] ))
+        return;
+    if( ($params['level'] == 'public') ||
+        ($params['level'] == 'marketing' && has_perms($marketing_admin)) ||
+        ($params['level'] == 'admin' && has_perms()) )
+        return $content;
+}
+?>
diff --git a/plugins/insert.getNbIns.php b/plugins/insert.getNbIns.php
new file mode 100644 (file)
index 0000000..92782de
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+/*
+ * Smarty plugin
+ * ------------------------------------------------------------- 
+ * File:     insert.getNbIns.php
+ * Type:     insert
+ * Name:     getNbIns
+ * Purpose:  
+ * -------------------------------------------------------------
+ */
+function smarty_insert_getNbIns($params, &$smarty)
+{
+    $result=mysql_query("SELECT COUNT(*) FROM auth_user_md5 AS a INNER JOIN identification AS i
+            ON a.matricule=i.matricule where i.deces = 0");
+    list($stats_count)=mysql_fetch_row($result);
+    mysql_free_result($result);
+    return "$stats_count";
+}
+?>
diff --git a/plugins/insert.mkStats.php b/plugins/insert.mkStats.php
new file mode 100644 (file)
index 0000000..1251127
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+function nb_trk($pri,$tr) {
+    $req = mysql_query("select count(rq_id) from trackers.requests left join trackers.states as st using(st_id)
+            where tr_id='$tr' and admin_id<=0 and pri='$pri' and st.texte!='fermé'");
+    list($res) = mysql_fetch_row($req);
+    mysql_free_result($req);
+    return ($res?$res:"-");
+}
+
+/*
+ * Smarty plugin
+ * ------------------------------------------------------------- 
+ * File:     insert.mkStats.php
+ * Type:     insert
+ * Name:     mkStats
+ * Purpose:  
+ * -------------------------------------------------------------
+ */
+function smarty_insert_mkStats($params, &$smarty)
+{
+    $req = mysql_query("select count(*) from requests");
+    list($stats_req) = mysql_fetch_row($req);
+    mysql_free_result($req);
+    $stats_req = ($stats_req ? $stats_req : "-");
+
+    $nbtrk = array(nb_trk(5,2), nb_trk(4,2), nb_trk(5,1), nb_trk(4,1));
+    return <<<EOF
+        <table class="bicol" width="100%"
+          style="font-weight:normal;text-align:center; border-left:0px; border-right:0px; margin-top:0.5em;">
+        <tr>
+          <th width="33%">Valid</th>
+          <th width="33%">Bugs</th>
+          <th width="33%">Todo</th>
+        </tr>
+        <tr class="impair">
+          <td><a href="####admin/valider.php###">$stats_req</a></td>
+          <td>
+            <a href="####trackers/tracker_show.php?tr_id=2###">
+            <strong>{$nbtrk[0]}</strong> / {$nbtrk[1]}
+            </a>
+          </td>
+          <td>
+            <a href="####trackers/tracker_show.php?tr_id=1">
+            <strong>{$nbtrk[2]}</strong> / {$nbtrk[3]}
+            </a>
+          </td>
+        </tr>
+        </table>
+EOF;
+}
+?>
diff --git a/templates/index.head.tpl b/templates/index.head.tpl
new file mode 100644 (file)
index 0000000..d615690
--- /dev/null
@@ -0,0 +1,17 @@
+{* index.head.tpl *}
+{literal}
+    <style type="text/css" media="screen,print">
+      <!--
+      li.spaced {
+        padding-bottom: 0.5em;
+        text-align: justify;
+      }
+      li {
+        padding-left: 4px;
+        padding-right: 4px;
+      }
+      -->
+    </style>
+{/literal}
+{* vim:set et sw=2 sts=2 sws=2: *}
+{* $Id: index.head.tpl,v 1.1 2004-01-25 17:19:21 x2000habouzit Exp $ *}
diff --git a/templates/index.tpl b/templates/index.tpl
new file mode 100644 (file)
index 0000000..aef1870
--- /dev/null
@@ -0,0 +1,32 @@
+{* index.tpl *}
+<div class="rubrique">
+  Bienvenue sur le portail des élèves et anciens élèves de l'X !
+</div>
+
+<p class="normal">
+  Polytechnique.org est le site qui connecte la communauté des polytechniciens.
+  Il comporte une partie publique, et une partie privée réservée aux
+  polytechniciens.
+</p>
+<br />
+<strong>Si vous êtes un recruteur ou une entreprise,</strong>
+  <ul>
+   <li class="spaced">vous avez la possibilité de <strong><a href="news/offreemploi.php">proposer une offre d'emploi</a></strong> accessible à tous les X directement en ligne, depuis la partie privée du site.</li>
+  </ul>
+  <strong>Si vous êtes polytechnicien,</strong>
+  <ul>
+   <li class="spaced">vous pouvez <strong><a href="inscrire.php">vous inscrire à Polytechnique.org</a></strong> si ce n'est pas encore fait,</li>
+   <li class="spaced">ou <strong><a href="login.php">vous connecter</a></strong> si vous êtes inscrit !</li>
+  </ul>
+  <strong>Dans tous les cas,</strong> vous pouvez :
+  <ul>
+   <li class="spaced"><strong><a href="recherche.php?annuaire_public=1">rechercher un ancien élève ou un élève</a></strong> dans l'annuaire en ligne,</li>
+   <li style="text-align: justify;" class="spaced"><strong><a href="http://asso.polytechnique.org/">accéder à la liste des sites en rapport avec l'École</a></strong> - les sites officiels de l'École sont <a href="http://www.polytechnique.fr">polytechnique.fr</a> et <a href="http://www.polytechnique.edu">polytechnique.edu</a>, le portail des X sur le web est <a href="http://www.polytechnique.org/">polytechnique.org</a>, et le site de l'amicale des Anciens est <a href="http://www.polytechniciens.com/">polytechniciens.com</a>.</li>
+  </ul>
+<p class="normal">
+  <strong>Bonne visite !</strong>
+  <br /><cite>L'équipe Polytechnique.org</cite>
+</p>
+{* vim:set et sw=2 sts=2 sws=2: *}
+{* $Id: index.tpl,v 1.1 2004-01-25 17:19:21 x2000habouzit Exp $ *}
diff --git a/templates/skin/common.bandeau.head.tpl b/templates/skin/common.bandeau.head.tpl
new file mode 100644 (file)
index 0000000..7dc4295
--- /dev/null
@@ -0,0 +1,22 @@
+{* Bandeau fédérateur : style *}
+{literal}
+    <!-- BANDEAU DEBUT -->
+    <style type="text/css">
+      body          { margin: 0 0 0 0; }
+      table.ligne   { background: #e7e7e7; }
+      td.ligne      { width: 100%; }
+      td.xdx {
+        padding: 0; background: #CCCCCC ; height: 14px; width: auto; font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif;
+      }
+      td.xdx img    {border: 0; padding: 0; margin: 0; }
+      a.xdx         { vertical-align: top; color: #505050; }
+      a.xdx:link    { text-decoration: none ; }
+      a.xdx:visited { text-decoration: none ; }
+      a.xdx:hover   { text-decoration: underline; }
+      a.xdx:active  { color: #CCCCCC ; background: #505050 ; }
+    </style>
+    <meta name="MSSmartTagsPreventParsing" content="true">
+    <!-- BANDEAU FIN -->
+{/literal}
+{* vim:set et sw=2 sts=2 sws=2: *}
+{* $Id: common.bandeau.head.tpl,v 1.1 2004-01-25 17:19:21 x2000habouzit Exp $ *}
diff --git a/templates/skin/common.bandeau.tpl b/templates/skin/common.bandeau.tpl
new file mode 100644 (file)
index 0000000..889bb02
--- /dev/null
@@ -0,0 +1,13 @@
+{* Bandeau : body *}
+    <!-- BANDEAU DEBUT -->
+
+    <!-- ligne grise de 1px -->
+    <table class="ligne" cellspacing="0" cellpadding="0" width="100%" border="0" summary=""><tr><td class="ligne"></td></tr></table>
+
+    <table cellspacing="0" cellpadding="1" width="100%" border="0" summary=""><tr><td class="xdx"><img alt="" src="/images/x.png" />&nbsp;&nbsp;<a class="xdx" href="http://www.polytechnique.fr/">L'&Eacute;cole</a>&nbsp;&middot;&nbsp;<a class="xdx" href="http://www.polytechnique.edu/">Institutional site</a>&nbsp;&nbsp;~~&nbsp;&nbsp;<a class="xdx" href="http://www.fondationx.org/">FX</a>&nbsp;&middot;&nbsp;<a class="xdx" href="http://www.polytechniciens.com/">AX</a>&nbsp;&nbsp;~~&nbsp;&nbsp;<a class="xdx" href="http://www.polytechnique.org/">Polytechnique.org</a>&nbsp;&middot;&nbsp;<a class="xdx" href="http://www.polytechnique.fr/eleves/">&Eacute;l&egrave;ves</a></td></tr></table>
+    <!-- ligne grise de 1px -->
+    <table class="ligne" cellspacing="0" cellpadding="0" width="100%" border="0" summary=""><tr><td class="ligne"></td></tr></table>
+
+    <!-- BANDEAU FIN -->
+{* vim:set et sw=2 sts=2 sws=2: *}
+{* $Id: common.bandeau.tpl,v 1.1 2004-01-25 17:19:21 x2000habouzit Exp $ *}
diff --git a/templates/skin/common.footer.tpl b/templates/skin/common.footer.tpl
new file mode 100644 (file)
index 0000000..0b00350
--- /dev/null
@@ -0,0 +1,17 @@
+{* foot par defaut *}
+<p>
+  Copyright © 1999-2003 Association <a href="http://x-org.polytechnique.org/">Polytechnique.org</a>
+  &nbsp;-&nbsp;
+  <a href="######apropos.php###">A propos de ce site</a>
+<br />
+    <a href="######secu.php#####">Sécurité et confidentialité</a>
+  | <a href="######ethique.php#####">Services et Ethique</a>
+  | <a href="######charte.php#####">Charte</a>
+{min_auth level=cookie}
+  | <a href="######coupure.php####">Disponibilité</a>
+  | <a href="######stats.php">Statistiques</a>
+{/min_auth}
+</p>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
+{* $Id: common.footer.tpl,v 1.1 2004-01-25 17:19:21 x2000habouzit Exp $ *}
diff --git a/templates/skin/common.header.tpl b/templates/skin/common.header.tpl
new file mode 100644 (file)
index 0000000..75f2615
--- /dev/null
@@ -0,0 +1,23 @@
+{* head par defaut *}
+    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+    <meta name="description" content="Le Portail des Polytechniciens" />
+    <meta name="keywords" content="Ecole polytechnique, anciens eleves, portail, alumni, AX, X, routage, reroutage, e-mail, email, mail" />
+    <link rel="icon" type="image/png" href="images/favicon.png" />
+    
+    <link rel="index" href="######">
+    <link rel="author" href="########">
+    <link rel="search" href="########">
+    <link rel="help" href="##########">
+    <link rel="bookmark" href="http://www.polytechnique.fr/"        title="| École polytechnique">
+    <link rel="bookmark" href="http://www.polytechnique.edu/"       title="| Institutionnal site">
+    <link rel="bookmark" href="http://www.fondationx.org/"          title="| FX">
+    <link rel="bookmark" href="http://www.polytechniciens.com/"     title="| AX">
+    <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">
+
+    <title>
+      Anciens eleves Polytechnique, annuaire email, Alumni
+    </title>
+    <script language="JavaScript" type="text/javascript" src="javascript/getnow.js"></script>
+{* vim:set et sw=2 sts=2 sws=2: *}
+{* $Id: common.header.tpl,v 1.1 2004-01-25 17:19:21 x2000habouzit Exp $ *}
diff --git a/templates/skin/default.tpl b/templates/skin/default.tpl
new file mode 100644 (file)
index 0000000..0b2643b
--- /dev/null
@@ -0,0 +1,71 @@
+{* Skin par défaut *}
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+{include file=skin/common.header.tpl}
+    <link rel="stylesheet" type="text/css" href="css/default.css" media="screen" />
+{if $xorg_head}{include file=$xorg_head}{/if}
+{include file=skin/common.bandeau.head.tpl}
+  </head>
+  <body>
+{include file=skin/common.bandeau.tpl}
+
+{if $smarty.session.suid}
+    <table id="suid" cellpadding="0" cellspacing="0">
+    <tr>
+      <td>{$smarty.session.suid}</strong></td>
+      <td><a href="#####exit.php######">exit</a></td>
+    </tr>
+    </table>
+{/if}
+
+    <table id="body" cellpadding="0" cellspacing="0">
+    <tr>
+      <td id="body-left" rowspan="2">
+        <img src="images/sk_default_headlogo.jpg" alt="[ LOGO ]" />
+        <div id="menu">
+{include_php file=menu.inc.php}
+{foreach key=menu_title item=menu_list from=$menu}
+{if $menu_title}
+        <div class="menu_title">{$menu_title}</div>
+{/if}
+{foreach key=menu_item item=menu_url from=$menu_list}
+        <div class="menu_item"><a href="{$menu_url}">{$menu_item}</a></div>
+{/foreach}
+{/foreach}
+{min_perms level=admin}{insert name="mkStats"}{/min_perms}
+      </td>
+      <td id="body-top">
+        <img src="images/sk_default_ban.jpg" alt="[ Polytechnique.org ]" />
+        <table>
+        <tr>
+          <td class="date-heure">
+          <script language="JavaScript" type="text/javascript">
+          <!--
+            document.write(getNow());
+          //-->
+          </script>
+          </td>
+          <td class="inscrits">{insert name="getNbIns"} polytechniciens sur le web</td>
+        </tr>
+        </table>
+        <img src="images/sk_default_lesX.gif" alt="[LES X SUR LE WEB]" />
+      </td>
+    </tr>
+    <tr>
+      <td id="content">
+{include file=$xorg_tpl}
+      </td>
+    </tr>
+    <tr>
+      <td id="body-bottom" colspan="2">
+{include file=skin/common.footer.tpl}
+      </td>
+    </tr>
+    </table>
+
+  </body>
+</html>
+{* vim:set et sw=2 sts=2 sws=2: *}
+{* $Id: default.tpl,v 1.1 2004-01-25 17:19:21 x2000habouzit Exp $ *}