Redesign prototype merge #18

Merged
MrPetovan merged 50 commits from feature/redesign-prototype into master 2017-05-06 08:10:18 +02:00
Showing only changes of commit e82a1e3816 - Show all commits

View file

@ -1,12 +1,9 @@
<?php <?php
use \DateTime; require_once 'datetime.php';
require_once('datetime.php'); function photo_init(App $a) {
function photo_init(&$a) { switch ($a->argc) {
switch($a->argc) {
case 2: case 2:
$photo = $a->argv[1]; $photo = $a->argv[1];
break; break;
@ -17,36 +14,35 @@ function photo_init(&$a) {
$profile_id = str_replace('.jpg', '', $photo); $profile_id = str_replace('.jpg', '', $photo);
$r = q("SELECT * FROM `photo` WHERE `profile-id` = %d LIMIT 1", $r = q('SELECT * FROM `photo` WHERE `profile-id` = %d LIMIT 1',
intval($profile_id) intval($profile_id)
); );
if(count($r)) { if (count($r)) {
$data = $r[0]['data']; $data = $r[0]['data'];
} }
if(x($data) === false || (! strlen($data))) { if (x($data) === false || (! strlen($data))) {
$data = file_get_contents('images/default-profile-sm.jpg'); $data = file_get_contents('images/default-profile-sm.jpg');
} }
//Enable async process from here. //Enable async process from here.
session_write_close(); session_write_close();
//Try and cache our result. //Try and cache our result.
$etag = md5($data); $etag = md5($data);
header('Etag: '.$etag); header('Etag: '.$etag);
header('Expires: ' . datetime_convert('UTC','UTC', 'now + 1 week', 'D, d M Y H:i:s' . ' GMT')); header('Expires: ' . datetime_convert('UTC', 'UTC', 'now + 1 week', 'D, d M Y H:i:s' . ' GMT'));
header("Cache-Control: max-age=".intval(7*24*3600)); header('Cache-Control: max-age=' . intval(7*24*3600));
if(function_exists('header_remove')) { if (function_exists('header_remove')) {
header_remove('Pragma'); header_remove('Pragma');
header_remove('pragma'); header_remove('pragma');
} }
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) {
header('HTTP/1.1 304 Not Modified'); header('HTTP/1.1 304 Not Modified');
exit; exit;
} }
header("Content-type: image/jpeg"); header('Content-type: image/jpeg');
echo $data; echo $data;
exit; exit;
}
}