update
This commit is contained in:
+17
-16
@@ -297,8 +297,10 @@ function init()
|
|||||||
if (str_starts_with($_SERVER['REQUEST_URI'], "/file")) {
|
if (str_starts_with($_SERVER['REQUEST_URI'], "/file")) {
|
||||||
$id = explode("/", $_SERVER['REQUEST_URI'])[2] ?? "";
|
$id = explode("/", $_SERVER['REQUEST_URI'])[2] ?? "";
|
||||||
|
|
||||||
$results = query_db("SELECT * FROM files WHERE uuid='{$id}' LIMIT 1");
|
$stmt = get_db()->prepare("SELECT * FROM files WHERE uuid=:uuid LIMIT 1");
|
||||||
$row = $results->fetchArray();
|
$stmt->bindParam(':uuid', $id);
|
||||||
|
|
||||||
|
$row = $stmt->fetch();
|
||||||
|
|
||||||
if (empty($row['stc'])) {
|
if (empty($row['stc'])) {
|
||||||
echo_json([
|
echo_json([
|
||||||
@@ -333,23 +335,22 @@ function show_page()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function exec_db($sql){
|
function get_db()
|
||||||
$db = new SQLite3(DATA_PATH . 'data.db');
|
{
|
||||||
// 创建表
|
$db = new PDO('sqlite:' . DATA_PATH . 'data.db');
|
||||||
|
|
||||||
|
return $db;
|
||||||
|
}
|
||||||
|
|
||||||
|
function exec_db($sql)
|
||||||
|
{
|
||||||
|
$db = get_db();
|
||||||
|
|
||||||
$db->exec($sql);
|
$db->exec($sql);
|
||||||
$db->close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function query_db($sql){
|
function inti_db()
|
||||||
$db = new SQLite3(DATA_PATH . 'data.db');
|
{
|
||||||
// 创建表
|
|
||||||
$results = $db->query($sql);
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user