]> git.mxchange.org Git - friendica.git/blob - mod/photo.php
Initial checkin
[friendica.git] / mod / photo.php
1 <?php
2
3 function photo_init(&$a) {
4
5         if($a->argc != 2) {
6                 killme();
7         }
8         $resolution = 0;
9         $photo = $a->argv[1];
10         $photo = str_replace('.jpg','',$photo);
11         if(substr($photo,-2,1) == '-') {
12                 $resolution = intval(substr($photo,-1,1));
13                 $photo = substr($photo,0,-2);
14         }
15         $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s'
16                 AND `scale` = %d LIMIT 1",
17                 dbesc($photo),
18                 intval($resolution));
19         if($r === NULL || (! count($r))) {
20                 killme();
21         }
22         header("Content-type: image/jpeg");
23         echo $r[0]['data'];
24
25 }