From adbdf493197146e64f93e085bb039e8bfdcc22bb Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Tue, 11 Jul 2006 19:48:52 +0000 Subject: [PATCH] exit getphoto.php => photo git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@440 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs/fiche.php | 2 +- htdocs/getphoto.php | 53 --------------------------------- modules/profile.php | 36 ++++++++++++++++++++++ templates/admin/admin_trombino.tpl | 2 +- templates/include/form.valid.photos.tpl | 4 +-- templates/include/trombi.tpl | 2 +- templates/listes/trombi.tpl | 2 +- templates/profil/general.tpl | 2 +- templates/trombino.tpl | 4 +-- 9 files changed, 45 insertions(+), 62 deletions(-) delete mode 100644 htdocs/getphoto.php diff --git a/htdocs/fiche.php b/htdocs/fiche.php index 4ff1587..2453df2 100644 --- a/htdocs/fiche.php +++ b/htdocs/fiche.php @@ -60,7 +60,7 @@ $page->assign('xorg_title', $title); // photo -$photo = 'getphoto.php?x='.$user['forlife'].($new ? '&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 index 5533dec..0000000 --- a/htdocs/getphoto.php +++ /dev/null @@ -1,53 +0,0 @@ -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: -?> diff --git a/modules/profile.php b/modules/profile.php index 4c3703e..2d12210 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -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'; diff --git a/templates/admin/admin_trombino.tpl b/templates/admin/admin_trombino.tpl index 828a55c..627ed65 100644 --- a/templates/admin/admin_trombino.tpl +++ b/templates/admin/admin_trombino.tpl @@ -29,7 +29,7 @@ Photo actuelle de {$forlife}

-[ PHOTO ] +[ PHOTO ]

diff --git a/templates/include/form.valid.photos.tpl b/templates/include/form.valid.photos.tpl index 5c85d62..847d28a 100644 --- a/templates/include/form.valid.photos.tpl +++ b/templates/include/form.valid.photos.tpl @@ -23,9 +23,9 @@ Photos -  [ PHOTO ] +  [ PHOTO ]      -  [ PHOTO ] +  [ PHOTO ] diff --git a/templates/include/trombi.tpl b/templates/include/trombi.tpl index 1a45528..5d54562 100644 --- a/templates/include/trombi.tpl +++ b/templates/include/trombi.tpl @@ -29,7 +29,7 @@ {/if} -  [ PHOTO ] +  [ PHOTO ] {if $trombi_admin && $smarty.session.perms eq 'admin'} diff --git a/templates/listes/trombi.tpl b/templates/listes/trombi.tpl index 5dbabc7..357a1a3 100644 --- a/templates/listes/trombi.tpl +++ b/templates/listes/trombi.tpl @@ -77,7 +77,7 @@ {cycle values="1,2,3" assign="loop"} {if $loop eq "1"}{/if} -  [ PHOTO ] +  [ PHOTO ]
{$x.n} ({$promo}) diff --git a/templates/profil/general.tpl b/templates/profil/general.tpl index 1144e68..dd3decb 100644 --- a/templates/profil/general.tpl +++ b/templates/profil/general.tpl @@ -221,7 +221,7 @@ {/if}. -  [ PHOTO ] +  [ PHOTO ] diff --git a/templates/trombino.tpl b/templates/trombino.tpl index 158b266..7bbb9c7 100644 --- a/templates/trombino.tpl +++ b/templates/trombino.tpl @@ -50,11 +50,11 @@ -  [ PHOTO ] +  [ PHOTO ] {if $submited} -  [ PHOTO ] +  [ PHOTO ] {else} Pas d'image soumise {/if} -- 2.1.4