trombino
authorx2000habouzit <x2000habouzit>
Sat, 24 Jul 2004 18:22:41 +0000 (18:22 +0000)
committerx2000habouzit <x2000habouzit>
Sat, 24 Jul 2004 18:22:41 +0000 (18:22 +0000)
etat_migration
htdocs/css/default.css
htdocs/getphoto.php
htdocs/images/none.png [new file with mode: 0644]
htdocs/trombino.php [new file with mode: 0644]
include/validations.inc.php
templates/profil.tpl
templates/trombino.tpl [new file with mode: 0644]

index 97d9a42..d5ac957 100644 (file)
@@ -17,7 +17,6 @@
 Etat  | Ancien nom                                                               | Nouveau nom
 ------+-[ marketing ]-----------------------------+----------------
 ;        | admin/utilisateurs_identification.php         | marketing/
-------+-[ docs ]----------------------------------+----------------
 ------+-[ emails ... ]----------------------------+----------------
 ;        | routage-mail.php                                              | 
 ------+-[ inscription + mdp ]---------------------+----------------
@@ -26,7 +25,6 @@ Etat  | Ancien nom                                                              | Nouveau nom
 ------+-[ bordel ]--------------------------------+----------------
 ;        | fiche_referent.php                                            | 
 ;        | recherche.php                                                         | 
-;        | trombino.php                                                          | 
 ;        | x.php                                                                         | 
 ------+-[ listes ]--------------------------------+----------------
  ;       | listes/creation.php                                           | \
@@ -179,6 +177,7 @@ xx    | services.php                                                          | docs/services.php
 xx       | skins.php                                                             | -
 xx       | trezo/gere_operations.php                             | -
 xx       | trezo/index.php                                                       | -
+xx       | trombino.php                                                          | 
 xx       | trombipromo.php                                                       | 
 xx       | vcard.php                                                             | -
 ------+-------------------------------------------+----------------
index 348a840..914d7d4 100644 (file)
@@ -235,6 +235,29 @@ div.long td.lt { width: 35%; }
 div.long td.rt { width: 65%; }
 
 /**: VI. :**/
+  
+table.flags td.texte {
+    font-size: smaller;
+    font-weight: bold;
+    padding-left: 0.5em;
+}
+table.flags td.vert {
+    background-color: green;
+    width: 1.5em; height: 1.5em;
+    text-align: center;
+}
+table.flags td.orange {
+    background-color: #ff9900;
+    width: 1.5em;
+    height: 1.5em;
+    text-align: center;
+}
+table.flags td.rouge {
+    background-color: red;
+    width: 1.5em;
+    height: 1.5em;
+    text-align: center;
+}
 
 table.cadre_a_onglet{
     border-width: 0;
@@ -418,4 +441,4 @@ div.conteneur_tab {
     font-size: 95%
 }
 /* vim: set et ts=4 sts=4 sw=4: */
-/* $Id: default.css,v 1.28 2004-07-24 16:06:57 x2000habouzit Exp $ */
+/* $Id: default.css,v 1.29 2004-07-24 18:22:42 x2000habouzit Exp $ */
index d6eb5df..30e10f8 100644 (file)
@@ -16,28 +16,29 @@ new_skinned_page('login.tpl', AUTH_COOKIE);
 function url($url) {
     $chemins = Array('.', '..', '/');
     foreach ($chemins as $ch)
-      if (file_exists("$ch/login.php") || file_exists("$ch/public/login.php"))
-        return "$ch/$url";
+       if (file_exists("$ch/login.php") || file_exists("$ch/public/login.php"))
+           return "$ch/$url";
     return "";
 }
 
 if(isset($_REQUEST['x'])) {
-       if(isset($_REQUEST['req']) && $_REQUEST['req']="true") {
-               $myphoto = PhotoReq::get_unique_request($_REQUEST['x']);
-               Header("Content-type: image/".$myphoto->mimetype);
-               echo $myphoto->data;
-       } else {
-               $result = $globals->db->query("SELECT attachmime, attach FROM photo WHERE uid = '{$_REQUEST['x']}'");
+    if(isset($_REQUEST['req']) && $_REQUEST['req']="true") {
+    include 'validations.inc.php';
+       $myphoto = PhotoReq::get_unique_request($_REQUEST['x']);
+       Header("Content-type: image/".$myphoto->mimetype);
+       echo $myphoto->data;
+    } else {
+       $result = $globals->db->query("SELECT attachmime, attach FROM photo WHERE uid = '{$_REQUEST['x']}'");
 
-               if(  list($type,$data) = @mysql_fetch_row($result) ) {
-                       Header(  "Content-type: image/$type");
-                       echo $data;
-               } else {
-                       Header(  "Content-type: image/png");
-                       $f=fopen(url("none.png"),"r");
-                       echo fread($f,30000);
-                       fclose($f);
-               }
+       if(  list($type,$data) = @mysql_fetch_row($result) ) {
+           Header(  "Content-type: image/$type");
+           echo $data;
+       } else {
+           Header(  "Content-type: image/png");
+           $f=fopen(url("images/none.png"),"r");
+           echo fread($f,30000);
+           fclose($f);
        }
+    }
 }
 ?>
diff --git a/htdocs/images/none.png b/htdocs/images/none.png
new file mode 100644 (file)
index 0000000..06f2061
Binary files /dev/null and b/htdocs/images/none.png differ
diff --git a/htdocs/trombino.php b/htdocs/trombino.php
new file mode 100644 (file)
index 0000000..81ebf47
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+require("auto.prepend.inc.php");
+new_skinned_page('trombino.tpl', AUTH_MDP);
+
+require("validations.inc.php");
+
+if (isset($_REQUEST["ordi"]) and
+    isset($_FILES["userfile"]) and isset($_FILES["userfile"]["tmp_name"])) {
+    //Fichier en local
+    $myphoto = new PhotoReq($_SESSION['uid'], $_FILES["userfile"]["tmp_name"]);
+    if(!isset($erreur))
+        $myphoto->submit();
+} elseif (isset($_REQUEST["web"]) and isset($_REQUEST["photo"])) {
+    // net
+    $fp = fopen($_REQUEST["photo"], 'r');
+    if (!$fp) {
+        $erreur = "Fichier inexistant";
+    } else {
+        $attach = fread($fp, 35000);
+        fclose($fp);
+        $file = tempnam('/tmp','photo_');
+        $fp = fopen($file,'w');
+        fwrite($fp, $attach);
+        fclose($fp);
+
+       $myphoto = new PhotoReq($_SESSION['uid'], $file);
+    if(!isset($erreur))
+        $myphoto->submit();
+    }
+} elseif (isset($_REQUEST["trombi"])) {
+    // Fichier à récupérer dans les archives trombi + commit immédiat
+    $file = "/home/web/trombino/photos".$_SESSION["promo"]."/".$_SESSION["username"].".jpg";
+    $myphoto = new PhotoReq($_SESSION['uid'], $file);
+    $myphoto->commit();
+    $myphoto->clean();
+} elseif (isset($_REQUEST["suppr"])) {
+    // effacement de la photo
+    $globals->db->query("DELETE FROM photo WHERE uid = ".$_SESSION["uid"]);
+    $globals->db->query("DELETE FROM requests WHERE user_id = ".$_SESSION["uid"]." AND type='photo'");
+}
+
+// Si une requête a été faite et qu'une erreur est signalée, on affiche l'erreur
+if(isset($erreur)) $page->assign('erreur', $erreur);
+
+$sql = $globals->db->query("SELECT * FROM requests WHERE user_id='{$_SESSION['uid']}' AND type='photo'");
+$page->assign('submited', mysql_num_rows($sql) > 0);
+
+$page->run();
+
+// Affichage de la page principale
+?>
index dfd7512..1feaa6b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100:
- * $Id: validations.inc.php,v 1.8 2004-02-20 10:14:58 x2000habouzit Exp $
+ * $Id: validations.inc.php,v 1.9 2004-07-24 18:22:43 x2000habouzit Exp $
  *
  */
 
@@ -113,8 +113,6 @@ class Validate {
     function submit () {
         global $no_update_bd, $globals;
         if($no_update_bd) return false;
-        $globals->db->query("LOCK requests"); // le lock est obligatoire pour récupérer le dernier stamp !
-        
         if($this->unique)
             $globals->db->query("DELETE FROM requests WHERE user_id='".$this->uid
                     .   "' AND type='".$this->type."'");
@@ -127,8 +125,6 @@ class Validate {
                 .   "WHERE user_id='".$this->uid."' AND type='".$this->type."'");
         list($this->stamp) = mysql_fetch_row($sql);
         mysql_free_result($sql);
-
-        $globals->db->query("UNLOCK requests");
         return true;
     }
     
index 826a468..062aff7 100644 (file)
@@ -1,4 +1,4 @@
-{* $Id: profil.tpl,v 1.2 2004-07-17 11:23:09 x2000habouzit Exp $ *}
+{* $Id: profil.tpl,v 1.3 2004-07-24 18:22:43 x2000habouzit Exp $ *}
 
 {config_load file="profil.conf"}
 {literal}
   table.bicol span.nom {}
   table.bicol span.valeur {font-weight: bold;}
   table.bicol span.lien {font-size: smaller;}
-  table.flags td.texte {font-size: smaller; font-weight: bold; padding-left: 0.5em;}
-  table.flags td.vert {background-color: green; width: 1.5em; height: 1.5em; text-align: center;}
-  table.flags td.orange {background-color: #ff9900; width: 1.5em; height: 1.5em; text-align: center;}
-  table.flags td.rouge {background-color: red; width: 1.5em; height: 1.5em; text-align: center;}
   -->
 </style>
 {/literal}
diff --git a/templates/trombino.tpl b/templates/trombino.tpl
new file mode 100644 (file)
index 0000000..03f187b
--- /dev/null
@@ -0,0 +1,137 @@
+{* $Id: trombino.tpl,v 1.1 2004-07-24 18:22:43 x2000habouzit Exp $ *}
+
+{dynamic}
+
+{if $erreur}
+<p class="erreur">
+{$erreur}
+</p>
+<p class="normal">
+La photo soumise n'a pu être correctement téléchargée pour la raison précédente.
+La photo par défaut est donc gardée.
+</p>
+{/if}
+
+
+<div class="rubrique">
+  Trombinoscope
+</div>
+
+<form enctype="multipart/form-data" action="{$smarty.server.REQUEST_URI}" method="post">
+  <table class="flags" cellspacing="0" summary="Flags">
+    <tr>
+      <td class="rouge"><input type="radio" checked>
+      </td>
+      <td class="texte">privé
+      </td>
+    </tr>
+  </table>
+
+  {if ($session.promo ge 1995) or ($session.promo le 2002)}
+  <p class="normal">
+  Si tu n'as pas encore fourni de photo, c'est celle du trombinoscope de l'X qui est
+  affichée par défaut dans le profil. Si elle ne te plaît pas, ou si tu n'es quand même
+  plus un tos, tu peux la remplacer par ta photo en suivant les instructions suivantes.
+  </p>
+  {/if}
+
+  <table class="bicol" cellspacing="0" cellpadding="2">
+    <tr>
+      <th>
+        Photo actuelle
+      </th>
+      <th>
+        Photo en cours de validation<sup>(*)</sup>
+      </th>
+    </tr>
+    <tr>
+      <td class="center">
+        <img src="{"getphoto.php"|url}?x={$smarty.session.uid}" width=110 alt=" [ PHOTO ] " />
+      </td>
+      <td class="center" style="width: 50%">
+        {if $submited}
+        <img src="{"getphoto.php"|url}?x={$smarty.session.uid}&amp;req=true" width=110 alt=" [ PHOTO ] " />
+        {else}
+        Pas d'image soumise
+        {/if}
+        
+      </td>
+    </tr>
+    <tr>
+      <td colspan="2" class="center">
+        Si tu ne souhaites plus montrer cette photo tu peux aussi l'effacer en la remplaçant par : <br />
+        {if ($session.promo ge 1995) or ($session.promo le 2002)}
+        <input type="submit" value="Trombino de l'X" name="trombi" /><br />
+        {/if}
+        <input type="submit" value="Image par défaut" name="suppr" />
+      </td>
+    </tr>
+    <tr>
+      <td colspan="2" class="smaller">
+        * Les photos sont soumises à une validation manuelle en raison des législations relatives
+        aux droits d'auteur et à la protection des mineurs. Il faut donc attendre l'intervention
+        d'un administrateur pour que la photo soit prise en compte. Tu recevras un mail lorsque ta
+        photo aura été contrôlée.
+      </td>
+    </tr>
+  </table>
+
+  <br />
+
+  <table class="bicol" cellspacing="0" cellpadding="2">
+    <tr>
+      <th>
+        Changement de ta photo
+      </th>
+    </tr>
+    <tr>
+      <td>
+        <p class="normal">
+        Nous te proposons deux possibilités pour mettre à jour ta photo (30 Ko maximum). Tout dépend
+        de savoir où se trouve ta photo. Si elle est sur ton poste de travail local, c'est la première
+        solution qu'il faut choisir.
+        </p>
+        <p class="normal">
+        Si elle est sur Internet, choisis la seconde solution et nos robots iront la télécharger
+        directement où il faut :-)
+        </p>
+      </td>
+    </tr>
+    <tr>
+      <td class="titre">
+        Sur ton ordinateur
+      </td>
+    </tr>
+    <tr>
+      <td>
+        <input name="userfile" type="file" size="20" maxlength="150" />
+      </td>
+    </tr>
+    <tr>
+      <td class="bouton">
+        <input type="submit" value="  OK  " name="ordi">
+      </td>
+    </tr>
+    <tr>
+      <td class="titre">
+        Sur Internet
+      </td>
+    </tr>
+    <tr>
+      <td>
+        <input type="text" size="45" maxlength="140" name="photo"
+        value="{$smarty.request.photo|default:"http://www.multimania.com/joe/maphoto.jpg"}" />
+      </td>
+    </tr>
+    <tr>
+      <td class="center">
+        <input type="submit" value="  OK  " name="web">
+      </td>
+    </tr>
+  </table>
+
+</form>
+
+{/dynamic}
+
+{* vim:set et sw=2 sts=2 sws=2: *}