update
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"web": "https://demo.winxg.com"
|
||||||
|
}
|
||||||
+51
-28
@@ -248,8 +248,7 @@ function api_test()
|
|||||||
|
|
||||||
function api_upload()
|
function api_upload()
|
||||||
{
|
{
|
||||||
$web = "https://demo.winxg.com";
|
$web = get_config('common', 'web');
|
||||||
|
|
||||||
$url = "https://telegra.ph/upload";
|
$url = "https://telegra.ph/upload";
|
||||||
$filePath = $_FILES["file"]["tmp_name"];
|
$filePath = $_FILES["file"]["tmp_name"];
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
@@ -298,32 +297,7 @@ function init()
|
|||||||
|
|
||||||
check_api();
|
check_api();
|
||||||
|
|
||||||
if (str_starts_with($_SERVER['REQUEST_URI'], "/file")) {
|
check_file();
|
||||||
$id = explode("/", $_SERVER['REQUEST_URI'])[2] ?? "";
|
|
||||||
|
|
||||||
$stmt = get_db()->prepare("SELECT * FROM files WHERE uuid=:uuid LIMIT 1");
|
|
||||||
$stmt->bindParam(':uuid', $id);
|
|
||||||
$stmt->execute();
|
|
||||||
|
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
if (empty($row['src'])) {
|
|
||||||
echo_json([
|
|
||||||
"code" => 1,
|
|
||||||
"msg" => "图片不存在",
|
|
||||||
"data" => []
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$imgUrl = "https://telegra.ph{$row['src']}";
|
|
||||||
|
|
||||||
$content = file_get_contents($imgUrl);
|
|
||||||
header('Content-Type: image/jpeg');
|
|
||||||
header('Content-Length: ' . strlen($content));
|
|
||||||
|
|
||||||
echo $content;
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_page_title()
|
function get_page_title()
|
||||||
@@ -377,5 +351,54 @@ function uniqidReal($lenght = 13)
|
|||||||
return substr(bin2hex($bytes), 0, $lenght);
|
return substr(bin2hex($bytes), 0, $lenght);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_file()
|
||||||
|
{
|
||||||
|
if (str_starts_with($_SERVER['REQUEST_URI'], "/file")) {
|
||||||
|
$id = explode("/", $_SERVER['REQUEST_URI'])[2] ?? "";
|
||||||
|
|
||||||
|
$stmt = get_db()->prepare("SELECT * FROM files WHERE uuid=:uuid LIMIT 1");
|
||||||
|
$stmt->bindParam(':uuid', $id);
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (empty($row['src'])) {
|
||||||
|
echo_json([
|
||||||
|
"code" => 1,
|
||||||
|
"msg" => "图片不存在",
|
||||||
|
"data" => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$imgUrl = "https://telegra.ph{$row['src']}";
|
||||||
|
|
||||||
|
$content = file_get_contents($imgUrl);
|
||||||
|
header('Content-Type: image/jpeg');
|
||||||
|
header('Content-Length: ' . strlen($content));
|
||||||
|
|
||||||
|
echo $content;
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_config($file, $path)
|
||||||
|
{
|
||||||
|
if (!file_exists(CONFIG_PATH . $file . ".json")) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
$conf = file_get_contents(CONFIG_PATH . $file . ".json");
|
||||||
|
|
||||||
|
$arr = json_decode($conf, true);
|
||||||
|
|
||||||
|
$value = $arr;
|
||||||
|
|
||||||
|
foreach(explode(".", $path) as $p){
|
||||||
|
$value = $value[$p] ?? "";
|
||||||
|
if (!$value) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
// common func end
|
// common func end
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user