function handler_photo($page, $x = null, $req = null) { if (!$x || !($profile = Profile::get($x))) { return PL_NOT_FOUND; } // Retrieve the photo and its mime type. if ($req && S::logged()) { $myphoto = PhotoReq::get_request($profile->id()); $photo = PlImage::fromData($myphoto->data, $myphoto->mimetype); } else { $photo = $profile->getPhoto(true, true); } // Display the photo, or a default one when not available. $photo->send(); }
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; } }
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; }
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; }