update
This commit is contained in:
+27
-6
@@ -81,7 +81,7 @@ function show_index()
|
||||
<tr class="border border-green-600">
|
||||
<th class="border border-green-600 w-100 text-center">名称</th>
|
||||
<th class="border border-green-600 w-30 text-center">大小</th>
|
||||
<th class="border border-green-600 w-30 text-center">状态</th>
|
||||
<th class="border border-green-600 w-40 text-center">状态</th>
|
||||
<th class="border border-green-600 w-200 text-center">链接</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -245,7 +245,7 @@ function api_test()
|
||||
function api_upload()
|
||||
{
|
||||
$web = "https://demo.winxg.com";
|
||||
|
||||
|
||||
$url = "https://telegra.ph/upload";
|
||||
$filePath = $_FILES["file"]["tmp_name"];
|
||||
$ch = curl_init();
|
||||
@@ -260,17 +260,21 @@ function api_upload()
|
||||
|
||||
$jsonArr = json_decode($response, true);
|
||||
$src = $jsonArr[0]["src"] ?? "";
|
||||
|
||||
|
||||
$uuid = uniqid();
|
||||
|
||||
$db = new SQLite3('data.db');
|
||||
$db->exec("INSERT INTO files (uuid, src) VALUES ('{$uuid}', '{$src}')");
|
||||
$db->close();
|
||||
|
||||
echo_json([
|
||||
"code" => empty($src) ? 1 : 0,
|
||||
"msg" => "",
|
||||
"data" => [
|
||||
"id" => $_POST["id"],
|
||||
"src" => $web . $src
|
||||
"src" => $web . "/file/{$uuid}"
|
||||
]
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// api func end
|
||||
@@ -281,12 +285,29 @@ function api_upload()
|
||||
// common func start
|
||||
function init()
|
||||
{
|
||||
$db = new SQLite3('data.db');
|
||||
// 创建表
|
||||
$db->exec('CREATE TABLE IF NOT EXISTS files (id INTEGER PRIMARY KEY, uuid TEXT, src TEXT)');
|
||||
$db->close();
|
||||
|
||||
define("BASE_PATH", __DIR__ . "/../");
|
||||
define("CONFIG_PATH", BASE_PATH . "/./config/");
|
||||
define("PUBLIC_PATH", BASE_PATH . "/./public/");
|
||||
empty($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] == "/" && $_SERVER['REQUEST_URI'] = "/index";
|
||||
|
||||
check_api();
|
||||
|
||||
if (str_starts_with($_SERVER['REQUEST_URI'], "/file")) {
|
||||
$id = explode("/", $_SERVER['REQUEST_URI'])[2] ?? "";
|
||||
|
||||
$results = $db->query("SELECT * FROM files WHERE uuid='{$id}' LIMIT 1");
|
||||
|
||||
$row = $results->fetchArray();
|
||||
$db->close();
|
||||
|
||||
var_dump($row['src']);
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
function get_page_title()
|
||||
|
||||
Reference in New Issue
Block a user