streams/Code/Module/Poster.php

47 lines
976 B
PHP
Raw Normal View History

<?php
2022-02-16 04:08:28 +00:00
namespace Code\Module;
2022-02-16 04:08:28 +00:00
use Code\Web\Controller;
use Code\Lib\Channel;
require_once('include/security.php');
2021-12-02 23:02:31 +00:00
class Poster extends Controller
{
public function init()
{
$nick = argv(1);
$hash = argv(2);
if (!($nick && $hash)) {
return;
}
2022-01-25 01:26:12 +00:00
$u = Channel::from_username($nick);
2021-12-02 23:02:31 +00:00
if (!$u) {
return;
}
$sql_extra = permissions_sql(intval($u['channel_id']));
2021-12-03 03:01:39 +00:00
$r = q(
"select content from attach where hash = '%s' and uid = %d and os_storage = 1 $sql_extra limit 1",
2021-12-02 23:02:31 +00:00
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();
}
}
killme();
}
}