16 include_once (
"WHAT/Lib.Prefix.php");
17 include_once (
"WHAT/Lib.Http.php");
18 include_once (
"WHAT/Lib.Common.php");
20 define(
"MAX_RESIZE_IMG_SIZE", 512);
26 if (
$size[0] ==
'H') {
35 $cmd = sprintf(
"convert -strip -thumbnail $h%d %s %s",
$size, escapeshellarg($source) , escapeshellarg(
$dest));
47 $result = pg_query(sprintf(
"select id_dir,name from vaultdiskstorage where id_file = %s", pg_escape_literal($vid)));
49 $row = pg_fetch_assoc($result);
51 $iddir = $row[
"id_dir"];
55 if (preg_match(
'/\.([^\.]*)$/', $name, $reg)) {
59 $result = pg_query(sprintf(
"SELECT l_path,id_fs from vaultdiskdirstorage where id_dir = %d", $iddir));
60 $row = pg_fetch_assoc($result);
61 $lpath = $row[
"l_path"];
62 $idfs = $row[
"id_fs"];
63 $result = pg_query(sprintf(
"SELECT r_path from vaultdiskfsstorage where id_fs = %d", $idfs));
64 $row = pg_fetch_assoc($result);
65 $rpath = $row[
"r_path"];
67 $localimg =
"$rpath/$lpath/$vid.$ext";
68 if (file_exists($localimg))
return $localimg;
84 $result = pg_query(sprintf(
"select id_dir,name,public_access, id_tmp from vaultdiskstorage where id_file = %s", pg_escape_literal($vid)));
86 $row = pg_fetch_assoc($result);
88 $free = $row[
"public_access"];
89 $tmpSessId = $row[
"id_tmp"];
93 } elseif ($tmpSessId) {
95 include_once (
"WHAT/Class.Session.php");
96 if (isset($_COOKIE[
Session::PARAMNAME]) && $tmpSessId === $_COOKIE[Session::PARAMNAME])
return true;
106 $basedest = sprintf(
"/var/cache/image/%s-vid%s.png",
$size, $vid);
112 if (isset(
$_GET[
"width"])) {
117 $heigth = isset(
$_GET[
"height"]) ?
$_GET[
"height"] : null;
119 $size =
"H" . $heigth;
123 if (!preg_match(
'/^H?[0-9]+(px)?$/',
$size)) {
124 header(
'HTTP/1.0 400 Bad request');
125 print "Wrong image size";
128 if (
$size[0] ==
'H') {
138 $img = isset(
$_GET[
"img"]) ?
$_GET[
"img"] : null;
140 $vid = isset(
$_GET[
"vid"]) ?
$_GET[
"vid"] : null;
141 if (ctype_digit($vid)) $img =
"vaultid=$vid";
146 if (preg_match(
"/vaultid=([0-9]+)/", $img, $vids)) {
151 header(
'HTTP/1.0 404 Not found');
157 if (file_exists(
$dest)) {
163 if ($newimg)
$location =
"$ldir/$newimg";
165 header(
'HTTP/1.0 404 Not found');
171 $turl = (parse_url($img));
173 if (
$path[0] ==
'/') {
179 $turl = parse_url(
$_SERVER[
"REQUEST_URI"]);
180 $directory = dirname($turl[
"path"]);
182 if (strlen($directory) > 1) {
183 if (
'/' . substr(
$path, 0, strlen($directory) - 1) === $directory) {
184 $img = substr(
$path, strlen($directory));
188 header(
'HTTP/1.0 404 Not found');
192 header(
'HTTP/1.0 404 Not found');
200 if (!is_link(
$path)) {
201 header(
'HTTP/1.0 403 Forbidden');
207 header(
'HTTP/1.0 403 Forbidden');
215 header(
'HTTP/1.0 403 Forbidden');
219 if (preg_match(
'%[0-9]+/[0-9]+\.[a-z]+$%',
$realfile)) {
220 header(
'HTTP/1.0 403 Forbidden');
225 $localimage = substr(
$path, strlen(
$dir));
230 $basedest = sprintf(
"/var/cache/image/%s-%s.png",
$size, basename(str_replace(
"/",
"_", $localimage)));
237 if ($newimg)
$location =
"$ldir/$newimg";
245 header(
'HTTP/1.0 404 Not found');
if(!$realfile) $itselfName
getVaultCacheImage($vid, $size)
verifyAccessByVaultId($vid)
if($path[0]== '/') $realfile
if(substr(dirname($realfile), 0, strlen($itselfdir))!=$itselfdir) if(strtok(substr($realfile, strlen($itselfdir)), '/')=="var") $cmd
Http_DownloadFile($filename, $name, $mime_type= '', $inline=false, $cache=true, $deleteafter=false)
rezizelocalimage($img, $size, $basedest)
const MAX_RESIZE_IMG_SIZE