aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Poster.php
blob: 10317ee61045d7d788b93ded4d4d5c3d799903e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

namespace Zotlabs\Module;

use Zotlabs\Web\Controller;

require_once('include/security.php');

class Poster extends Controller {

	function init() {

		$nick = argv(1);
		$hash = argv(2);

		if(! ($nick && $hash)) {
			return;
		}

		$u = channelx_by_nick($nick);

		$sql_extra = permissions_sql(intval($u['channel_id']));

		$r = q("select content from attach where hash = '%s' and uid = %d and os_storage = 1 $sql_extra limit 1",
			dbesc($hash),
			intval($u['channel_id'])
		);
		if($r) {
			$path = dbunescbin($r[0]['content']);
			if($path && @file_exists($path . '.thumb')) {
				header('Content-Type: image/jpeg');
				echo file_get_contents($path . '.thumb');
				killme();
			}
		}
	}
}