exit getphoto.php => photo
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 19:48:52 +0000 (19:48 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 19:48:52 +0000 (19:48 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@440 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs/fiche.php
htdocs/getphoto.php [deleted file]
modules/profile.php
templates/admin/admin_trombino.tpl
templates/include/form.valid.photos.tpl
templates/include/trombi.tpl
templates/listes/trombi.tpl
templates/profil/general.tpl
templates/trombino.tpl

index 4ff1587..2453df2 100644 (file)
@@ -60,7 +60,7 @@ $page->assign('xorg_title', $title);
 
 // photo
 
-$photo = 'getphoto.php?x='.$user['forlife'].($new ? '&amp;req=true' : '');
+$photo = 'photo/'.$user['forlife'].($new ? '/req' : '');
 
 if(!isset($user['y']) and !isset($user['x'])) {
     list($user['x'], $user['y']) = getimagesize("images/none.png");
diff --git a/htdocs/getphoto.php b/htdocs/getphoto.php
deleted file mode 100644 (file)
index 5533dec..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-
-require_once('xorg.inc.php');
-new_skinned_page('login.tpl', AUTH_PUBLIC);
-
-if (Env::has('x')) {
-
-    $res = $globals->xdb->query("SELECT id, pub FROM aliases LEFT JOIN photo ON(id=uid) WHERE alias = {?}", Env::get('x'));
-    list($uid, $photo_pub) = $res->fetchOneRow();
-    
-    if (Env::get('req') == "true" && logged()) {
-        include 'validations.inc.php';
-       $myphoto = PhotoReq::get_request($uid);
-        Header('Content-type: image/'.$myphoto->mimetype);
-       echo $myphoto->data;
-    } else {
-        $res = $globals->xdb->query(
-                "SELECT  attachmime, attach
-                   FROM  photo
-                  WHERE  uid={?}", $uid);
-
-       if( (list($type,$data) = $res->fetchOneRow()) && ($photo_pub == 'public' || logged()) ) {
-           Header(  "Content-type: image/$type");
-           echo $data;
-       } else {
-           Header(  'Content-type: image/png');
-           echo file_get_contents(dirname(__FILE__).'/images/none.png');
-       }
-    }
-}
-
-// vim:set et sws=4 sw=4 sts=4:
-?>
index 4c3703e..2d12210 100644 (file)
@@ -24,6 +24,7 @@ class ProfileModule extends PLModule
     function handlers()
     {
         return array(
+            'photo'  => $this->make_hook('photo',  AUTH_PUBLIC),
             'trombi' => $this->make_hook('trombi', AUTH_COOKIE),
         );
     }
@@ -52,6 +53,41 @@ class ProfileModule extends PLModule
         return array($pnb, $res->fetchAllAssoc());
     }
 
+    function handler_photo(&$page, $x = null, $req = null)
+    {
+        if (is_null($x)) {
+            return PL_NOT_FOUND;
+        }
+
+        global $globals;
+
+        $res = $globals->xdb->query("SELECT id, pub FROM aliases
+                                  LEFT JOIN photo ON(id = uid)
+                                      WHERE alias = {?}", $x);
+        list($uid, $photo_pub) = $res->fetchOneRow();
+
+        if ($req && logged()) {
+            include 'validations.inc.php';
+            $myphoto = PhotoReq::get_request($uid);
+            Header('Content-type: image/'.$myphoto->mimetype);
+            echo $myphoto->data;
+        } else {
+            $res = $globals->xdb->query(
+                    "SELECT  attachmime, attach
+                       FROM  photo
+                      WHERE  uid={?}", $uid);
+
+            if ((list($type,$data) = $res->fetchOneRow()) && ($photo_pub == 'public' || logged())) {
+                Header("Content-type: image/$type");
+                echo $data;
+            } else {
+                Header('Content-type: image/png');
+                echo file_get_contents(dirname(__FILE__).'../htdocs/images/none.png');
+            }
+        }
+        exit;
+    }
+
     function handler_trombi(&$page, $promo = null)
     {
         require_once 'trombi.inc.php';
index 828a55c..627ed65 100644 (file)
@@ -29,7 +29,7 @@
 Photo actuelle de {$forlife}
 </p>
 
-<img src="../getphoto.php?x={$forlife}" alt="[ PHOTO ]" />
+<img src="{rel}/photo/{$forlife}" alt="[ PHOTO ]" />
 <br />
 
 <p>
index 5c85d62..847d28a 100644 (file)
@@ -23,9 +23,9 @@
 <tr class="pair">
   <td class="titre">Photos</td>
   <td>
-    <img src="{rel}/getphoto.php?x={$valid->forlife}" style="width:110px;" alt=" [ PHOTO ] " />
+    <img src="{rel}/photo/{$valid->forlife}" style="width:110px;" alt=" [ PHOTO ] " />
     &nbsp;&nbsp;&nbsp;&nbsp;
-    <img src="{rel}/getphoto.php?x={$valid->forlife}&amp;req=true" style="width:110px;" alt=" [ PHOTO ] " />
+    <img src="{rel}/photo/{$valid->forlife}/req" style="width:110px;" alt=" [ PHOTO ] " />
   </td>
 </tr>
 
index 1a45528..5d54562 100644 (file)
@@ -29,7 +29,7 @@
   {/if}
     <td class="center">
       <a href="{"fiche.php"|url}?user={$p.forlife}" class="popup2">
-        <img src="{"getphoto.php"|url}?x={$p.forlife}" width="110" alt=" [ PHOTO ] " />
+        <img src="{rel}/photo/{$p.forlife}" width="110" alt=" [ PHOTO ] " />
       </a>
       {if $trombi_admin && $smarty.session.perms eq 'admin'}
       <a href="{"admin/admin_trombino.php"|url}?uid={$p.user_id}">
index 5dbabc7..357a1a3 100644 (file)
@@ -77,7 +77,7 @@
       {cycle values="1,2,3" assign="loop"}
       {if $loop eq "1"}<tr>{/if}
         <td class='center'>
-          <img src="{"getphoto.php"|url}?x={$x.l}" width="110" alt=" [ PHOTO ] " />
+          <img src="{rel}/photo/{$x.l}" width="110" alt=" [ PHOTO ] " />
           <br />
           <a href="{"fiche.php"|url}?user={$x.l}" class="popup2">
             {$x.n} ({$promo})
index 1144e68..dd3decb 100644 (file)
               {/if}.
             </td>
             <td class="dcolg">
-              <img src="getphoto.php?x={$smarty.session.forlife}" alt=" [ PHOTO ] " />
+              <img src="{rel}/photo/{$smarty.session.forlife}" alt=" [ PHOTO ] " />
             </td>
           </tr>
         </table>
index 158b266..7bbb9c7 100644 (file)
     </tr>
     <tr>
       <td class="center">
-        <img src="{rel}/getphoto.php?x={$smarty.session.forlife}" width="200" alt=" [ PHOTO ] " />
+        <img src="{rel}/photo/{$smarty.session.forlife}" width="200" alt=" [ PHOTO ] " />
       </td>
       <td class="center half">
         {if $submited}
-        <img src="{rel}/getphoto.php?x={$smarty.session.forlife}&amp;req=true" width="200" alt=" [ PHOTO ] " />
+        <img src="{rel}/photo/{$smarty.session.forlife}/req" width="200" alt=" [ PHOTO ] " />
         {else}
         Pas d'image soumise
         {/if}