update
This commit is contained in:
+19
-2
@@ -261,7 +261,7 @@ function api_upload()
|
|||||||
$jsonArr = json_decode($response, true);
|
$jsonArr = json_decode($response, true);
|
||||||
$src = $jsonArr[0]["src"] ?? "";
|
$src = $jsonArr[0]["src"] ?? "";
|
||||||
|
|
||||||
$uuid = uniqid();
|
$uuid = uniqidReal();
|
||||||
|
|
||||||
exec_db("INSERT INTO files (uuid, src) VALUES ('{$uuid}', '{$src}')");
|
exec_db("INSERT INTO files (uuid, src) VALUES ('{$uuid}', '{$src}')");
|
||||||
|
|
||||||
@@ -312,7 +312,12 @@ function init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
$imgUrl = "https://telegra.ph{$row['src']}";
|
$imgUrl = "https://telegra.ph{$row['src']}";
|
||||||
var_dump($imgUrl);
|
|
||||||
|
$content = file_get_contents($imgUrl);
|
||||||
|
header('Content-Type: image/jpeg');
|
||||||
|
header('Content-Length: ' . strlen($content));
|
||||||
|
|
||||||
|
echo $content;
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -355,5 +360,17 @@ function inti_db()
|
|||||||
exec_db('CREATE TABLE IF NOT EXISTS files (id INTEGER PRIMARY KEY, uuid TEXT, src TEXT)');
|
exec_db('CREATE TABLE IF NOT EXISTS files (id INTEGER PRIMARY KEY, uuid TEXT, src TEXT)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function uniqidReal($lenght = 13) {
|
||||||
|
// uniqid gives 13 chars, but you could adjust it to your needs.
|
||||||
|
if (function_exists("random_bytes")) {
|
||||||
|
$bytes = random_bytes(ceil($lenght / 2));
|
||||||
|
} elseif (function_exists("openssl_random_pseudo_bytes")) {
|
||||||
|
$bytes = openssl_random_pseudo_bytes(ceil($lenght / 2));
|
||||||
|
} else {
|
||||||
|
throw new Exception("no cryptographically secure random function available");
|
||||||
|
}
|
||||||
|
return substr(bin2hex($bytes), 0, $lenght);
|
||||||
|
}
|
||||||
|
|
||||||
// common func end
|
// common func end
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user