banana
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Wed, 15 Dec 2004 19:58:57 +0000 (19:58 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:26:43 +0000 (23:26 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-105

htdocs/banana/include/password.inc.php
htdocs/banana/include/profile.inc.php
htdocs/banana/include/session.inc.php
htdocs/banana/include/subscribe.inc.php
htdocs/banana/xface.php

index a95132d..464480f 100644 (file)
@@ -8,8 +8,8 @@ unset($array);
 if ($sname == "spoolgen.php") {
     $news["user"] = $globals->banana->web_user;
     $news["pass"] = $globals->banana->web_pass;
-} elseif (isset($_SESSION['forlife'])) {
-    $news["user"]= "web_".$_SESSION['forlife'];
+} elseif (Session::has('forlife')) {
+    $news["user"]= "web_".Session::get('forlife');
     $news["pass"]= $globals->banana->password;
 }
 $news['server']="$news_server:$news_port";
index ff02c9d..034d870 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 function checkcancel($_headers) {
-    return ($_headers->xorgid == $_SESSION['forlife'] or has_perms());
+    return ($_headers->xorgid == Session::get('forlife') or has_perms());
 }
 
 /** getprofile : sets profile variables
@@ -25,33 +25,35 @@ function checkcancel($_headers) {
 function getprofile() {
     if (logged()) {
         global $globals;
+        
+        $uid = Session::getInt('uid');
        $req = mysql_query("SELECT  nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
                                    IF(FIND_IN_SET('automaj',flags),'1','0') 
                              FROM  {$globals->banana->table_prefix}profils
-                            WHERE  uid='{$_SESSION['uid']}'");
+                            WHERE  uid=$uid");
        if (!(list($nom,$mail,$sig,$disp,$maj)=mysql_fetch_row($req))) {
-           $nom = $_SESSION['prenom']." ".$_SESSION['nom'];
-           $mail = $_SESSION['forlife']."@polytechnique.org";
-           $sig = $nom." (".$_SESSION['promo'].")";
+           $nom  = Session::get('prenom')." ".Session::get('nom');
+           $mail = Session::get('forlife')."@polytechnique.org";
+           $sig  = $nom." (".Session::getInt('promo').")";
            $disp = 0;
-           $maj = 1;
+           $maj  = 1;
        }
-       $array['name'] = "$nom <$mail>";
-       $array['sig'] = $sig;
-       $array['org']  = "Utilisateur de Polytechnique.org";
+       $array['name']      = "$nom <$mail>";
+       $array['sig']       = $sig;
+       $array['org']       = "Utilisateur de Polytechnique.org";
        $array['customhdr'] = "";
-       $array['display'] = $disp;
-       $array['autoup'] = $maj;
-       $array['lastnews'] = $_SESSION['banana_last'];
-       $array['dropsig'] = true;
+       $array['display']   = $disp;
+       $array['autoup']    = $maj;
+       $array['lastnews']  = Session::get('banana_last');
+       $array['dropsig']   = true;
        if ($maj) {
            mysql_query("UPDATE auth_user_quick SET banana_last='"
-               .gmdate("YmdHis")."' WHERE user_id='{$_SESSION['uid']}'");
+               .gmdate("YmdHis")."' WHERE user_id=$uid");
        }
        $req=mysql_query("SELECT  nom
                            FROM  {$globals->banana->table_prefix}abos
                       LEFT JOIN  {$globals->banana->table_prefix}list ON list.fid=abos.fid
-                          WHERE  uid={$_SESSION['uid']};");
+                          WHERE  uid=$uid");
        $array['subscribe']=array();
        while (list($fnom)=mysql_fetch_array($req)) {
            array_push($array['subscribe'],$fnom);
index b4c9d4c..492d10e 100644 (file)
@@ -12,18 +12,20 @@ $array = explode('/',$sname);
 $sname = array_pop($array);
 unset($array);
 switch ($sname) {
-  case "thread.php":
-    if (!isset($_SESSION['bananapostok'])) 
-      $_SESSION['bananapostok']=true;
+    case "thread.php":
+        if (!Session::has('bananapostok')) {
+            $_SESSION['bananapostok']=true;
+        }
     break;
-  case "index.php":
-    if (isset($_GET["banana"]) && ($_GET["banana"]=="updateall")) {
-      mysql_query("UPDATE auth_user_quick SET banana_last='"
-              .gmdate("YmdHis")."' WHERE user_id='{$_SESSION['uid']}'");
-      $_SESSION["banana_last"]=time();
-    }
-  default:
+    
+    case "index.php":
+        if (Get::get('banana') == 'updateall') {
+            mysql_query("UPDATE auth_user_quick SET banana_last='"
+                    .gmdate("YmdHis")."' WHERE user_id=".Session::getInt('uid'));
+            $_SESSION["banana_last"]=time();
+        }
+
+    default:
     $_SESSION['bananapostok']=true;
-    break;
 }
 ?>
index 74138cd..1a66fc9 100644 (file)
@@ -5,33 +5,35 @@
    */
 
 function update_subscriptions($_subscriptions) {
-  mysql_query("DELETE FROM {$globals->banana->table_prefix}abos WHERE uid='{$_SESSION['uid']}'");
-  if (!count($_subscriptions)) {
-    return true;
-  }
-  // Récupération des fid
-  $req = mysql_query("SELECT fid,nom FROM {$globals->banana->table_prefix}list");
-  $fids=array();
-  while (list($fid,$fnom)=mysql_fetch_row($req)) {
-    $fids[$fnom]=$fid;
-  }
-  // MAJ table de forums
-  if (count(array_keys($fids))) {
-    $diff = array_diff($_subscriptions,array_keys($fids));
-  } else {
-    $diff = $_subscriptions;
-  }
-  if (count($diff)) {
-    foreach ($diff as $g) {
-      mysql_query("INSERT INTO {$globals->banana->table_prefix}list (nom) VALUES ('$g')");
-      $fids[$g]=mysql_insert_id();
+    global $globals;
+    $uid = Session::getInt('uid');
+
+    mysql_query("DELETE FROM {$globals->banana->table_prefix}abos WHERE uid='$uid'");
+    if (!count($_subscriptions)) {
+        return true;
+    }
+    // Récupération des fid
+    $req = mysql_query("SELECT fid,nom FROM {$globals->banana->table_prefix}list");
+    $fids=array();
+    while (list($fid,$fnom)=mysql_fetch_row($req)) {
+        $fids[$fnom]=$fid;
+    }
+    // MAJ table de forums
+    if (count(array_keys($fids))) {
+        $diff = array_diff($_subscriptions,array_keys($fids));
+    } else {
+        $diff = $_subscriptions;
+    }
+    if (count($diff)) {
+        foreach ($diff as $g) {
+            mysql_query("INSERT INTO {$globals->banana->table_prefix}list (nom) VALUES ('$g')");
+            $fids[$g]=mysql_insert_id();
+        }
+    }
+    // MAJ Abonnements
+    foreach ($_subscriptions as $g) {
+        mysql_query("REPLACE INTO {$globals->banana->table_prefix}abos (fid,uid) VALUES ('{$fids[$g]}','$uid')");
     }
-  }
-  // MAJ Abonnements
-  foreach ($_subscriptions as $g) {
-    mysql_query("REPLACE INTO {$globals->banana->table_prefix}abos (fid,uid) VALUES "
-        ."('{$fids[$g]}','{$_SESSION['uid']}')");
-  }
 }
 
 ?>
index 4edd725..e83e9b2 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-$face = base64_decode($_REQUEST['face']);
+$face = base64_decode(Env::get('face'));
 $face = ereg_replace("'", "'\\''", $face);
 
 header("Content-Type: image/png");