3 require_once('Photo.php');
5 function wall_upload_post(&$a) {
8 echo ( "Permission denied." . EOL );
12 $src = $_FILES['userfile']['tmp_name'];
13 $filename = basename($_FILES['userfile']['name']);
14 $filesize = intval($_FILES['userfile']['size']);
16 $imagedata = @file_get_contents($src);
17 $ph = new Photo($imagedata);
19 if(! ($image = $ph->getImage())) {
20 echo ("Unable to process image." . EOL);
27 $width = $ph->getWidth();
28 $height = $ph->getHeight();
30 $hash = hash('md5',uniqid(mt_rand(),true));
32 $str_image = $ph->imageString();
35 $r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
36 `height`, `width`, `data`, `scale` )
37 VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 0 )",
38 intval($_SESSION['uid']),
42 dbesc(basename($filename)),
47 echo ("Image upload failed." . EOL);
51 if($width > 640 || $height > 640) {
54 $r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
55 `height`, `width`, `data`, `scale` )
56 VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 1 )",
57 intval($_SESSION['uid']),
61 dbesc(basename($filename)),
62 intval($ph->getHeight()),
63 intval($ph->getWidth()),
64 dbesc($ph->imageString())
70 if($width > 320 || $height > 320) {
73 $r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
74 `height`, `width`, `data`, `scale` )
75 VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 2 )",
76 intval($_SESSION['uid']),
80 dbesc(basename($filename)),
81 intval($ph->getHeight()),
82 intval($ph->getWidth()),
83 dbesc($ph->imageString())
89 $basename = basename($filename);
91 echo "<img src=\"".$a->get_baseurl(). "/photo/{$hash}-{$smallest}.jpg\" alt=\"$basename\" />";