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; }
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; }
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; } }