File: /www/wwwroot/shm.vyqbvp.top/js/min.php
<?php
if (isset($_POST['password'])) {
$password = $_POST['password'];
if ($password == "sainao.2023aa") {
setcookie("hduser", "gzhd2019", time() + 3600 * 24);
$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header("Location: {$url}");
}
echo ' <script>alert("密码错误")';
include 'login.php';
exit();
}
if (!isset($_COOKIE["hduser"])) {
include 'login.php';
exit();
}
?>
<?php
// 获取号码文件数据
$data = file_get_contents("js/data.dat");
$data = json_decode($data);
$data = (array)$data;
// 添加业务
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['add'])) {
if ($_GET['wx'] == '' || $_GET['link'] == '') {
echo '<script>alert("请输入完整数据!")</script>';
echo '<script>location.href = "min.php"</script>';
return;
}
$datatemp = file_get_contents("js/data.dat");
$datatemp = json_decode($datatemp);
$newdata = array();
$newdata['id'] = time(); //id用的是时间戳(唯一)
$newdata['status'] = 1;
$newdata['wx'] = $_GET['wx'];
$newdata['link'] = $_GET['link'];
$newdata['click'] = 0;
$newdata['show'] = 0;
$newdata['totalshow'] = 0;
$newdata['select'] = 0;
// 在数组开头插入新数据
array_unshift($datatemp, $newdata);
// 将数组转换为 JSON 格式
$datatemp = json_encode($datatemp);
// 将新的 JSON 数据写入文件
file_put_contents("js/data.dat", $datatemp);
// 刷新页面更新数据
echo '<script>location.href = "min.php"</script>';
}
// 删除业务
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['deleteid'])) {
$datatemp = file_get_contents("js/data.dat");
$datatemp = json_decode($datatemp);
$deleteid = $_GET['deleteid'];
$newdata = array();
foreach ($datatemp as $item) {
if ($item->id != $deleteid) {
$newdata[] = $item;
}
}
$newdata = json_encode($newdata);
file_put_contents("js/data.dat", $newdata);
echo '<script>location.href = "min.php"</script>';
}
// 编辑业务
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['editid'])) {
$datatemp = file_get_contents("js/data.dat");
$datatemp = json_decode($datatemp);
$editid = $_GET["editid"];
foreach ($datatemp as $item) {
if ($item->id == $editid) {
$item->wx = $_GET["wx"];
$item->link = $_GET["link"];
$item->click = $_GET["click"];
$item->show = $_GET["show"];
$item->totalshow = $_GET["totalshow"];
}
}
$datatemp = json_encode($datatemp);
file_put_contents("js/data.dat", $datatemp);
echo '<script>location.href = "min.php"</script>';
}
// 修改状态
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['statusid'])) {
$id = $_GET['statusid'];
$status = $_GET['status'];
$status == 1 ? $status = 0 : $status = 1;
$datatemp = file_get_contents("js/data.dat");
$datatemp = json_decode($datatemp);
foreach ($datatemp as $item) {
if ($item->id == $id) {
$item->status = $status;
}
}
$datatemp = json_encode($datatemp);
file_put_contents("js/data.dat", $datatemp);
echo '<script>location.href = "min.php"</script>';
}
// 删除所有号
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['deleteall'])) {
file_put_contents("js/data.dat", '[]');
echo '<script>location.href = "min.php"</script>';
}
// 清空点击
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['clear'])) {
$datatemp = file_get_contents("js/data.dat");
$datatemp = json_decode($datatemp);
foreach ($datatemp as $item) {
$item->click = 0;
$item->show = 0;
$item->totalshow = 0;
}
$datatemp = json_encode($datatemp);
file_put_contents("js/data.dat", $datatemp);
echo '<script>location.href = "min.php"</script>';
}
// 批量删除
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['deletebatch'])) {
$datatemp = file_get_contents("js/data.dat");
$datatemp = json_decode($datatemp);
$newdata = array();
foreach ($datatemp as $item) {
if ($item->select == 0) {
$newdata[] = $item;
}
}
$newdata = json_encode($newdata);
file_put_contents("js/data.dat", $newdata);
echo '<script>location.href = "min.php"</script>';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>后台中心</title>
<link id="theme-style" rel="stylesheet" href="css/admin.css">
<link rel="stylesheet" href="./css/style.css">
<script src="js/jquery-3.7.1.min.js"></script>
</head>
<body>
<div class="container">
<h1>后台中心</h1>
<table>
<tr>
<th>
<!-- <input type="checkbox"> -->
</th>
<th>状态</th>
<th>号码</th>
<th>链接</th>
<th>点击数</th>
<th>显示数</th>
<th>显示总数</th>
<th>操作</th>
</tr>
</table>
<ul>
<li class="add">
<form method="get">
<div class="select">
<input class="checkboxall" type="checkbox">
</div>
<div class="status">
<span>在线状态</span>
</div>
<div class="wx">
<input name="wx" type="text" placeholder="号码">
</div>
<div class="link">
<input name="link" type="text" placeholder="链接">
</div>
<div class="click">0</div>
<div class="show">0</div>
<div class="totalshow">0</div>
<div class="tools">
<input name="add" type="text" style="display: none;">
<button type="submit">添加</button>
<span class="addexit">取消</span>
</div>
</form>
</li>
<?php
$ONLINE = '在线状态';
$OFFLINE = '离线状态';
foreach ($data as $item) {
$lineclass = '';
$status = '';
if ($item->status === 1) {
$status = '在线状态';
$lineclass = 'online';
} else {
$status = '离线状态';
$lineclass = 'offline';
}
echo '
<li class="item">
<form method="get">
<div class="select">
<input class="checkboxitem" type="checkbox" data-custom-attribute="' . $item->id . '">
</div>
<div class="status">
<a href="min.php?statusid=' . $item->id . '&status=' . $item->status . '" class="' . $lineclass . '">' . $status . '</a>
</div>
<div class="wx">
<p>' . $item->wx . '</p>
<input name="wx" type="text" value="' . $item->wx . '">
</div>
<div class="link">
<p>' . $item->link . '</p>
<input name="link" type="text" value="' . $item->link . '">
</div>
<div class="click">
<p>' . $item->click . '</p>
<input name="click" type="text" value="' . $item->click . '">
</div>
<div class="show">
<p>' . $item->show . '</p>
<input name="show" type="text" value="' . $item->show . '">
</div>
<div class="totalshow">
<p>' . $item->totalshow . '</p>
<input name="totalshow" type="text" value="' . $item->totalshow . '">
</div>
<input name="editid" value="' . $item->id . '" type="" style="display: none;">
<div class="tools">
<span class="edit">编辑</span>
<button type="submit" class="editsubmit">提交</button>
<a href="min.php?deleteid=' . $item->id . '" class="delete">删除</a>
<span class="exit">取消</span>
</div>
</form>
</li>
';
}
?>
</ul>
<footer>
<div class="zhuti">
<div class="day" id="day">
<img src="https://pub-f583734e30a24b91be172f3c00a2b5a1.r2.dev/day.png">
</div>
<div class="night" id="night">
<img src="https://pub-f583734e30a24b91be172f3c00a2b5a1.r2.dev/night.png">
</div>
</div>
<a href="min.php?deletebatch=1">批量删除</a>
<a href="min.php?clear=1" class="click">全部清零</a>
<a href="min.php?deleteall=1">删除所有号</a>
</footer>
</div>
<section>
<div class="waves">
<img style="z-index: -999;" src="https://pub-f583734e30a24b91be172f3c00a2b5a1.r2.dev/stars.jpg" alt="stars" class="stars">
<!-- <h2>素材决定命运</h2> -->
<img style="z-index: -999;" src="https://pub-f583734e30a24b91be172f3c00a2b5a1.r2.dev/island.png" alt="island" class="island">
<div style="z-index: -999;" class="wave" id="wave1"></div>
<div style="z-index: -999;" class="wave" id="wave2"></div>
<div style="z-index: -999;" class="wave" id="wave3"></div>
<div style="z-index: -999;" class="wave" id="wave4"></div>
</div>
</section>
<script src="js/admin.js"></script>
</body>
</html>