示例#1
0
 function handler_picture_token(PlPage $page, $size, $token)
 {
     XDB::rawExecute('DELETE FROM  profile_photo_tokens
                            WHERE  expires <= NOW()');
     $pid = XDB::fetchOneCell('SELECT  pid
                                 FROM  profile_photo_tokens
                                WHERE  token = {?}', $token);
     if ($pid != null) {
         $res = XDB::fetchOneAssoc('SELECT  attach, attachmime, x, y, last_update
                                      FROM  profile_photos
                                     WHERE  pid = {?}', $pid);
         $photo = PlImage::fromData($res['attach'], 'image/' . $res['attachmime'], $res['x'], $res['y'], $res['last_update']);
         $photo->send();
     } else {
         return PL_NOT_FOUND;
     }
 }
示例#2
0
文件: group.php 项目: Ekleog/platal
 public function getLogo($fallback = true)
 {
     if (!empty($this->logo)) {
         return PlImage::fromData($this->logo, $this->logo_mime);
     } else {
         if ($fallback) {
             return PlImage::fromFile(dirname(__FILE__) . '/../htdocs/images/dflt_carre.jpg', 'image/jpeg');
         }
     }
     return null;
 }
示例#3
0
文件: profile.php 项目: Ekleog/platal
 public function getPhoto($fallback = true, $data = false)
 {
     if ($this->has_photo) {
         if ($data && ($this->photo == null || $this->photo->mimeType == null)) {
             $res = XDB::fetchOneAssoc('SELECT  attach, attachmime, x, y, last_update
                                          FROM  profile_photos
                                         WHERE  pid = {?}', $this->pid);
             $this->photo = PlImage::fromData($res['attach'], 'image/' . $res['attachmime'], $res['x'], $res['y'], $res['last_update']);
         } else {
             if ($this->photo == null) {
                 $this->photo = PlImage::fromData(null, null, $this->photo_width, $this->photo_height);
             }
         }
         return $this->photo;
     } else {
         if ($fallback) {
             if ($this->mainEducation() == 'X') {
                 return PlImage::fromFile(dirname(__FILE__) . '/../htdocs/images/none_x.png', 'image/png');
             }
             return PlImage::fromFile(dirname(__FILE__) . '/../htdocs/images/none_md.png', 'image/png');
         }
     }
     return null;
 }
示例#4
0
文件: profile.php 项目: Ekleog/platal
 function handler_admin_trombino($page, $login = null, $action = null)
 {
     $page->changeTpl('profile/admin_trombino.tpl');
     $page->setTitle('Administration - Trombino');
     if (!$login || !($user = User::get($login))) {
         return PL_NOT_FOUND;
     } else {
         $page->assign_by_ref('user', $user);
     }
     switch ($action) {
         case "original":
             PlImage::fromFile("/home/web/trombino/photos" . $user->promo() . "/" . $user->login() . ".jpg", "image/jpeg")->send();
             exit;
         case "new":
             S::assert_xsrf_token();
             $data = file_get_contents($_FILES['userfile']['tmp_name']);
             list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
             $mimetype = substr($_FILES['userfile']['type'], 6);
             unlink($_FILES['userfile']['tmp_name']);
             XDB::execute('INSERT INTO  profile_photos (pid, attachmime, attach, x, y)
                                VALUES  ({?}, {?}, {?}, {?}, {?})
               ON DUPLICATE KEY UPDATE  attachmime = VALUES(attachmime), attach = VALUES(attach), x = VALUES(x), y = VALUES(y)', $user->profile()->id(), $mimetype, $data, $x, $y);
             break;
         case "delete":
             S::assert_xsrf_token();
             XDB::execute('DELETE FROM profile_photos WHERE pid = {?}', $user->profile()->id());
             break;
     }
 }