mirror of
https://github.com/ZSCGR/genshin-impart.git
synced 2026-08-13 05:33:43 +08:00
+45
@@ -0,0 +1,45 @@
|
|||||||
|
# Dependencies
|
||||||
|
node_modules/
|
||||||
|
package-lock.json
|
||||||
|
# (Keep package-lock.json if you want to lock versions, but some prefer to ignore. Standard is to KEEP it, but I'll list node_modules which is the big one)
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Database
|
||||||
|
*.db
|
||||||
|
*.sqlite
|
||||||
|
webs/genshin.db
|
||||||
|
|
||||||
|
# OS generated files
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store?
|
||||||
|
._*
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# IDEs and Editors
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
.env.production
|
||||||
|
|
||||||
|
# Optional: Verce output
|
||||||
|
.vercel
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
$file= __DIR__ . '/..'.$_SERVER["PHP_SELF"];
|
|
||||||
|
|
||||||
if(file_exists($file))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
require_once __DIR__ . '/../index.php';
|
|
||||||
}
|
|
||||||
#echo $_SERVER["PHP_SELF"];
|
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="canonical" href="https://ys.chgr.cc/" />
|
||||||
<title>原神主题网站 | Genshin Theme</title>
|
<title>原神主题网站 | Genshin Theme</title>
|
||||||
|
|
||||||
<!-- 样式文件 | CSS file -->
|
<!-- 样式文件 | CSS file -->
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "genshin-impart",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "本网站所参考的源码:[Herta Kuru~](https://github.com/duiqt/herta_kuru) |",
|
||||||
|
"main": "indexscript.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node server.js",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"body-parser": "^2.2.1",
|
||||||
|
"cors": "^2.8.5",
|
||||||
|
"express": "^5.1.0",
|
||||||
|
"sqlite3": "^5.1.7"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const sqlite3 = require('sqlite3').verbose();
|
||||||
|
const bodyParser = require('body-parser');
|
||||||
|
const cors = require('cors');
|
||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
const PORT = process.env.PORT || 3000;
|
||||||
|
|
||||||
|
// Middleware
|
||||||
|
app.use(cors());
|
||||||
|
app.use(bodyParser.json());
|
||||||
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
|
// Database setup
|
||||||
|
const dbFile = path.join(__dirname, 'webs', 'genshin.db');
|
||||||
|
const db = new sqlite3.Database(dbFile, (err) => {
|
||||||
|
if (err) {
|
||||||
|
console.error('Error opening database:', err.message);
|
||||||
|
} else {
|
||||||
|
console.log('Connected to the SQLite database.');
|
||||||
|
initializeDatabase();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function initializeDatabase() {
|
||||||
|
db.serialize(() => {
|
||||||
|
db.run(`CREATE TABLE IF NOT EXISTS ys (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
name TEXT NOT NULL UNIQUE,
|
||||||
|
globalcount INTEGER DEFAULT 0
|
||||||
|
)`);
|
||||||
|
|
||||||
|
const characters = ['klee', 'nahida', 'kirara', 'dori', 'babara'];
|
||||||
|
const stmt = db.prepare("INSERT OR IGNORE INTO ys (name, globalcount) VALUES (?, 0)");
|
||||||
|
characters.forEach(char => {
|
||||||
|
stmt.run(char);
|
||||||
|
});
|
||||||
|
stmt.finalize();
|
||||||
|
console.log('Database initialized.');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serve static files
|
||||||
|
// Serve root files (index.html, img, etc.)
|
||||||
|
app.use(express.static(path.join(__dirname)));
|
||||||
|
|
||||||
|
// API Routes
|
||||||
|
|
||||||
|
// Get count
|
||||||
|
app.get('/api/count/:name', (req, res) => {
|
||||||
|
const name = req.params.name;
|
||||||
|
db.get("SELECT globalcount FROM ys WHERE name = ?", [name], (err, row) => {
|
||||||
|
if (err) {
|
||||||
|
res.status(500).json({ error: err.message });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (row) {
|
||||||
|
// Format matches the previous PHP array structure: [{globalcount: 123}]
|
||||||
|
res.json([{ globalcount: row.globalcount }]);
|
||||||
|
} else {
|
||||||
|
res.status(404).json({ error: "Character not found" });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update count
|
||||||
|
app.post('/api/count/:name', (req, res) => {
|
||||||
|
const name = req.params.name;
|
||||||
|
const localCount = parseInt(req.body.localcount) || 0;
|
||||||
|
|
||||||
|
// First get current count to add to it (though atomic update is better)
|
||||||
|
// Using atomic update directly:
|
||||||
|
db.run("UPDATE ys SET globalcount = globalcount + ? WHERE name = ?", [localCount, name], function(err) {
|
||||||
|
if (err) {
|
||||||
|
res.status(500).send("Update failed: " + err.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.changes > 0) {
|
||||||
|
res.send("更新成功");
|
||||||
|
} else {
|
||||||
|
res.send("没有找到全局计数值"); // Or create if not exists
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fallback for specific PHP routes to redirect/handle gracefully if needed,
|
||||||
|
// but we will update frontend to use /api/count/:name.
|
||||||
|
|
||||||
|
app.listen(PORT, () => {
|
||||||
|
console.log(`Server running on http://localhost:${PORT}`);
|
||||||
|
});
|
||||||
+10
-5
@@ -1,10 +1,15 @@
|
|||||||
{
|
{
|
||||||
"functions": {
|
"version": 2,
|
||||||
"api/index.php": {
|
"builds": [
|
||||||
"runtime": "[email protected]"
|
{
|
||||||
|
"src": "server.js",
|
||||||
|
"use": "@vercel/node"
|
||||||
}
|
}
|
||||||
},
|
],
|
||||||
"routes": [
|
"routes": [
|
||||||
{ "src": "/(.*)", "dest": "/api/index.php" }
|
{
|
||||||
|
"src": "/(.*)",
|
||||||
|
"dest": "/server.js"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title id="doc-title">Babara~</title><!--change-->
|
<title id="doc-title">Kirakira~</title>
|
||||||
|
<link rel="canonical" href="https://ys.chgr.cc/webs/BabaraWeb/babara.html" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
||||||
<link rel="stylesheet" href="./babarastyle.css" type="text/css" /><!--change-->
|
<link rel="stylesheet" href="./babarastyle.css" type="text/css" /><!--change-->
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
<?php
|
|
||||||
//加载数据库信息
|
|
||||||
require_once('../config.php');
|
|
||||||
// 创建连接
|
|
||||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
|
||||||
// 连接成功,可以进行数据库操作
|
|
||||||
$sql = "SELECT globalcount FROM ys WHERE name = 'babara'";
|
|
||||||
// 执行查询
|
|
||||||
$result = $conn->query($sql);
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
||||||
// 处理 POST 请求
|
|
||||||
//接收前端数据
|
|
||||||
$localcount = $_POST["localcount"];
|
|
||||||
//检查查询结果
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
$row = $result->fetch_assoc();
|
|
||||||
$globalCount = $row['globalcount'];
|
|
||||||
|
|
||||||
// 将本地计数值加给全局计数
|
|
||||||
$globalCount += $localcount;
|
|
||||||
|
|
||||||
// 更新数据库中的全局计数值
|
|
||||||
$updateSql = "UPDATE ys SET globalcount = $globalCount WHERE name = 'babara';";
|
|
||||||
|
|
||||||
if ($conn->query($updateSql) === TRUE) {
|
|
||||||
// 更新成功
|
|
||||||
echo "更新成功";
|
|
||||||
} else {
|
|
||||||
// 更新失败
|
|
||||||
echo "更新失败: " . $conn->error;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 没有找到全局计数值
|
|
||||||
echo "没有找到全局计数值";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回响应
|
|
||||||
//echo "这是 POST 请求的响应";
|
|
||||||
} elseif ($_SERVER["REQUEST_METHOD"] === "GET") {
|
|
||||||
// 处理 GET 请求
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
// 有数据返回
|
|
||||||
$rows = array();
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
$rows[] = $row;
|
|
||||||
}
|
|
||||||
// 将查询结果转换为 JSON 格式发送回前端
|
|
||||||
echo json_encode($rows);
|
|
||||||
} else {
|
|
||||||
// 无数据返回
|
|
||||||
echo "没有数据";
|
|
||||||
}
|
|
||||||
// 返回响应
|
|
||||||
//echo "这是 GET 请求的响应";
|
|
||||||
} else {
|
|
||||||
// 不支持其他请求方法
|
|
||||||
http_response_code(405); // 返回“Method Not Allowed”状态码
|
|
||||||
echo "不支持的请求方法";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -537,7 +537,7 @@ $(document).ready(function () {
|
|||||||
//上传数据
|
//上传数据
|
||||||
function updateGlobalCount() {
|
function updateGlobalCount() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './babara.php',
|
url: '/api/count/babara',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
async: false,
|
async: false,
|
||||||
data: { localcount: thisTimeCounts },
|
data: { localcount: thisTimeCounts },
|
||||||
@@ -560,7 +560,7 @@ function updateGlobalCount() {
|
|||||||
//首次访问网站的时候,立即获取 globalCounts并刷新 (页面加载完成后立即执行)
|
//首次访问网站的时候,立即获取 globalCounts并刷新 (页面加载完成后立即执行)
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './babara.php',
|
url: '/api/count/babara',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -586,7 +586,7 @@ function updateGlobalCount() {
|
|||||||
// 定时轮询后端获取 globalCounts
|
// 定时轮询后端获取 globalCounts
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './babara.php',
|
url: '/api/count/babara',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title id="doc-title">❤Duang~</title><!--change-->
|
<title id="doc-title">Duang~</title>
|
||||||
|
<link rel="canonical" href="https://ys.chgr.cc/webs/DoriWeb/dori.html" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
||||||
<link rel="stylesheet" href="./doristyle.css" type="text/css" /><!--change-->
|
<link rel="stylesheet" href="./doristyle.css" type="text/css" /><!--change-->
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
<?php
|
|
||||||
//加载数据库信息
|
|
||||||
require_once('../config.php');
|
|
||||||
// 创建连接
|
|
||||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
|
||||||
// 连接成功,可以进行数据库操作
|
|
||||||
$sql = "SELECT globalcount FROM ys WHERE name = 'dori'";
|
|
||||||
// 执行查询
|
|
||||||
$result = $conn->query($sql);
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
||||||
// 处理 POST 请求
|
|
||||||
//接收前端数据
|
|
||||||
$localcount = $_POST["localcount"];
|
|
||||||
//检查查询结果
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
$row = $result->fetch_assoc();
|
|
||||||
$globalCount = $row['globalcount'];
|
|
||||||
|
|
||||||
// 将本地计数值加给全局计数
|
|
||||||
$globalCount += $localcount;
|
|
||||||
|
|
||||||
// 更新数据库中的全局计数值
|
|
||||||
$updateSql = "UPDATE ys SET globalcount = $globalCount WHERE name = 'dori';";
|
|
||||||
|
|
||||||
if ($conn->query($updateSql) === TRUE) {
|
|
||||||
// 更新成功
|
|
||||||
echo "更新成功";
|
|
||||||
} else {
|
|
||||||
// 更新失败
|
|
||||||
echo "更新失败: " . $conn->error;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 没有找到全局计数值
|
|
||||||
echo "没有找到全局计数值";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回响应
|
|
||||||
//echo "这是 POST 请求的响应";
|
|
||||||
} elseif ($_SERVER["REQUEST_METHOD"] === "GET") {
|
|
||||||
// 处理 GET 请求
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
// 有数据返回
|
|
||||||
$rows = array();
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
$rows[] = $row;
|
|
||||||
}
|
|
||||||
// 将查询结果转换为 JSON 格式发送回前端
|
|
||||||
echo json_encode($rows);
|
|
||||||
} else {
|
|
||||||
// 无数据返回
|
|
||||||
echo "没有数据";
|
|
||||||
}
|
|
||||||
// 返回响应
|
|
||||||
//echo "这是 GET 请求的响应";
|
|
||||||
} else {
|
|
||||||
// 不支持其他请求方法
|
|
||||||
http_response_code(405); // 返回“Method Not Allowed”状态码
|
|
||||||
echo "不支持的请求方法";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -549,7 +549,7 @@ $(document).ready(function () {
|
|||||||
//上传数据
|
//上传数据
|
||||||
function updateGlobalCount() {
|
function updateGlobalCount() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './dori.php',
|
url: '/api/count/dori',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
async: false,
|
async: false,
|
||||||
data: { localcount: thisTimeCounts },
|
data: { localcount: thisTimeCounts },
|
||||||
@@ -572,7 +572,7 @@ function updateGlobalCount() {
|
|||||||
//首次访问网站的时候,立即获取 globalCounts并刷新 (页面加载完成后立即执行)
|
//首次访问网站的时候,立即获取 globalCounts并刷新 (页面加载完成后立即执行)
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './dori.php',
|
url: '/api/count/dori',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -598,7 +598,7 @@ function updateGlobalCount() {
|
|||||||
// 定时轮询后端获取 globalCounts
|
// 定时轮询后端获取 globalCounts
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './dori.php',
|
url: '/api/count/dori',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title id="doc-title">Miaouuuu~</title><!--change-->
|
<title id="doc-title">Meow~</title>
|
||||||
|
<link rel="canonical" href="https://ys.chgr.cc/webs/KiraraWeb/kirara.html" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
||||||
<link rel="stylesheet" href="kirarastyle.css" type="text/css" /><!--change-->
|
<link rel="stylesheet" href="kirarastyle.css" type="text/css" /><!--change-->
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
<?php
|
|
||||||
//加载数据库信息
|
|
||||||
require_once('../config.php');
|
|
||||||
// 创建连接
|
|
||||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
|
||||||
// 连接成功,可以进行数据库操作
|
|
||||||
$sql = "SELECT globalcount FROM ys WHERE name = 'kirara'";
|
|
||||||
// 执行查询
|
|
||||||
$result = $conn->query($sql);
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
||||||
// 处理 POST 请求
|
|
||||||
//接收前端数据
|
|
||||||
$localcount = $_POST["localcount"];
|
|
||||||
//检查查询结果
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
$row = $result->fetch_assoc();
|
|
||||||
$globalCount = $row['globalcount'];
|
|
||||||
|
|
||||||
// 将本地计数值加给全局计数
|
|
||||||
$globalCount += $localcount;
|
|
||||||
|
|
||||||
// 更新数据库中的全局计数值
|
|
||||||
$updateSql = "UPDATE ys SET globalcount = $globalCount WHERE name = 'kirara';";
|
|
||||||
|
|
||||||
if ($conn->query($updateSql) === TRUE) {
|
|
||||||
// 更新成功
|
|
||||||
echo "更新成功";
|
|
||||||
} else {
|
|
||||||
// 更新失败
|
|
||||||
echo "更新失败: " . $conn->error;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 没有找到全局计数值
|
|
||||||
echo "没有找到全局计数值";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回响应
|
|
||||||
//echo "这是 POST 请求的响应";
|
|
||||||
} elseif ($_SERVER["REQUEST_METHOD"] === "GET") {
|
|
||||||
// 处理 GET 请求
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
// 有数据返回
|
|
||||||
$rows = array();
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
$rows[] = $row;
|
|
||||||
}
|
|
||||||
// 将查询结果转换为 JSON 格式发送回前端
|
|
||||||
echo json_encode($rows);
|
|
||||||
} else {
|
|
||||||
// 无数据返回
|
|
||||||
echo "没有数据";
|
|
||||||
}
|
|
||||||
// 返回响应
|
|
||||||
//echo "这是 GET 请求的响应";
|
|
||||||
} else {
|
|
||||||
// 不支持其他请求方法
|
|
||||||
http_response_code(405); // 返回“Method Not Allowed”状态码
|
|
||||||
echo "不支持的请求方法";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -543,7 +543,7 @@ $(document).ready(function () {
|
|||||||
//上传数据
|
//上传数据
|
||||||
function updateGlobalCount() {
|
function updateGlobalCount() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './kirara.php',
|
url: '/api/count/kirara',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
async: false,
|
async: false,
|
||||||
data: { localcount: thisTimeCounts },
|
data: { localcount: thisTimeCounts },
|
||||||
@@ -566,7 +566,7 @@ function updateGlobalCount() {
|
|||||||
//首次访问网站的时候,立即获取 globalCounts并刷新 (页面加载完成后立即执行)
|
//首次访问网站的时候,立即获取 globalCounts并刷新 (页面加载完成后立即执行)
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './kirara.php',
|
url: '/api/count/kirara',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -592,7 +592,7 @@ function updateGlobalCount() {
|
|||||||
// 定时轮询后端获取 globalCounts
|
// 定时轮询后端获取 globalCounts
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './kirara.php',
|
url: '/api/count/kirara',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title id="doc-title">DaDaDa~</title>
|
<title id="doc-title">DaDaDa~</title>
|
||||||
|
<link rel="canonical" href="https://ys.chgr.cc/webs/KleeWeb/klee.html" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
||||||
|
|
||||||
<!-- 样式文件 | CSS file -->
|
<!-- 样式文件 | CSS file -->
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
<?php
|
|
||||||
//加载数据库信息
|
|
||||||
require_once('../config.php');
|
|
||||||
// 创建连接
|
|
||||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
|
||||||
// 连接成功,可以进行数据库操作
|
|
||||||
$sql = "SELECT globalcount FROM ys WHERE name = 'klee'";
|
|
||||||
// 执行查询
|
|
||||||
$result = $conn->query($sql);
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
||||||
// 处理 POST 请求
|
|
||||||
//接收前端数据
|
|
||||||
$localcount = $_POST["localcount"];
|
|
||||||
//检查查询结果
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
$row = $result->fetch_assoc();
|
|
||||||
$globalCount = $row['globalcount'];
|
|
||||||
|
|
||||||
// 将本地计数值加给全局计数
|
|
||||||
$globalCount += $localcount;
|
|
||||||
|
|
||||||
// 更新数据库中的全局计数值
|
|
||||||
$updateSql = "UPDATE ys SET globalcount = $globalCount WHERE name = 'klee';";
|
|
||||||
|
|
||||||
if ($conn->query($updateSql) === TRUE) {
|
|
||||||
// 更新成功
|
|
||||||
echo "更新成功";
|
|
||||||
} else {
|
|
||||||
// 更新失败
|
|
||||||
echo "更新失败: " . $conn->error;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 没有找到全局计数值
|
|
||||||
echo "没有找到全局计数值";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回响应
|
|
||||||
//echo "这是 POST 请求的响应";
|
|
||||||
} elseif ($_SERVER["REQUEST_METHOD"] === "GET") {
|
|
||||||
// 处理 GET 请求
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
// 有数据返回
|
|
||||||
$rows = array();
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
$rows[] = $row;
|
|
||||||
}
|
|
||||||
// 将查询结果转换为 JSON 格式发送回前端
|
|
||||||
echo json_encode($rows);
|
|
||||||
} else {
|
|
||||||
// 无数据返回
|
|
||||||
echo "没有数据";
|
|
||||||
}
|
|
||||||
// 返回响应
|
|
||||||
//echo "这是 GET 请求的响应";
|
|
||||||
} else {
|
|
||||||
// 不支持其他请求方法
|
|
||||||
http_response_code(405); // 返回“Method Not Allowed”状态码
|
|
||||||
echo "不支持的请求方法";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -584,7 +584,7 @@ $(document).ready(function () {
|
|||||||
//上传数据
|
//上传数据
|
||||||
function updateGlobalCount() {
|
function updateGlobalCount() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './klee.php',
|
url: '/api/count/klee',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
async: false,
|
async: false,
|
||||||
data: { localcount: thisTimeCounts },
|
data: { localcount: thisTimeCounts },
|
||||||
@@ -607,7 +607,7 @@ function updateGlobalCount() {
|
|||||||
//首次访问网站的时候,立即获取 globalCounts并刷新 (页面加载完成后立即执行)
|
//首次访问网站的时候,立即获取 globalCounts并刷新 (页面加载完成后立即执行)
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './klee.php',
|
url: '/api/count/klee',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -633,7 +633,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
// 定时轮询后端获取 globalCounts
|
// 定时轮询后端获取 globalCounts
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './klee.php',
|
url: '/api/count/klee',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title id="doc-title">Nahida~</title>
|
<title id="doc-title">Nahida~</title>
|
||||||
|
<link rel="canonical" href="https://ys.chgr.cc/webs/NahidaWeb/nahida.html" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
||||||
|
|
||||||
<!-- 样式文件 | CSS file -->
|
<!-- 样式文件 | CSS file -->
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
<?php
|
|
||||||
//加载数据库信息
|
|
||||||
require_once('../config.php');
|
|
||||||
// 创建连接
|
|
||||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
|
||||||
// 连接成功,可以进行数据库操作
|
|
||||||
$sql = "SELECT globalcount FROM ys WHERE name = 'nahida'";
|
|
||||||
// 执行查询
|
|
||||||
$result = $conn->query($sql);
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
||||||
// 处理 POST 请求
|
|
||||||
//接收前端数据
|
|
||||||
$localcount = $_POST["localcount"];
|
|
||||||
//检查查询结果
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
$row = $result->fetch_assoc();
|
|
||||||
$globalCount = $row['globalcount'];
|
|
||||||
|
|
||||||
// 将本地计数值加给全局计数
|
|
||||||
$globalCount += $localcount;
|
|
||||||
|
|
||||||
// 更新数据库中的全局计数值
|
|
||||||
$updateSql = "UPDATE ys SET globalcount = $globalCount WHERE name = 'nahida';";
|
|
||||||
|
|
||||||
if ($conn->query($updateSql) === TRUE) {
|
|
||||||
// 更新成功
|
|
||||||
echo "更新成功";
|
|
||||||
} else {
|
|
||||||
// 更新失败
|
|
||||||
echo "更新失败: " . $conn->error;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 没有找到全局计数值
|
|
||||||
echo "没有找到全局计数值";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回响应
|
|
||||||
//echo "这是 POST 请求的响应";
|
|
||||||
} elseif ($_SERVER["REQUEST_METHOD"] === "GET") {
|
|
||||||
// 处理 GET 请求
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
// 有数据返回
|
|
||||||
$rows = array();
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
$rows[] = $row;
|
|
||||||
}
|
|
||||||
// 将查询结果转换为 JSON 格式发送回前端
|
|
||||||
echo json_encode($rows);
|
|
||||||
} else {
|
|
||||||
// 无数据返回
|
|
||||||
echo "没有数据";
|
|
||||||
}
|
|
||||||
// 返回响应
|
|
||||||
//echo "这是 GET 请求的响应";
|
|
||||||
} else {
|
|
||||||
// 不支持其他请求方法
|
|
||||||
http_response_code(405); // 返回“Method Not Allowed”状态码
|
|
||||||
echo "不支持的请求方法";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -565,7 +565,7 @@ $(document).ready(function () {
|
|||||||
//上传数据
|
//上传数据
|
||||||
function updateGlobalCount() {
|
function updateGlobalCount() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './nahida.php',
|
url: '/api/count/nahida',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
async: false,
|
async: false,
|
||||||
data: { localcount: thisTimeCounts },
|
data: { localcount: thisTimeCounts },
|
||||||
@@ -588,7 +588,7 @@ function updateGlobalCount() {
|
|||||||
//首次访问网站的时候,立即获取 globalCounts并刷新 (页面加载完成后立即执行)
|
//首次访问网站的时候,立即获取 globalCounts并刷新 (页面加载完成后立即执行)
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './nahida.php',
|
url: '/api/count/nahida',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -614,7 +614,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
// 定时轮询后端获取 globalCounts
|
// 定时轮询后端获取 globalCounts
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: './nahida.php',
|
url: '/api/count/nahida',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
// 数据库连接信息
|
|
||||||
$servername = "mysql-38e967b6-mysql-mariadb.a.aivencloud.com:10755";
|
|
||||||
$username = "ys_zscgr_top";
|
|
||||||
$password = "AVNS_2xlZt0F7x2gaY4mKyFL";
|
|
||||||
$dbname = "ys_zscgr_top";
|
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user