File: /www/wwwroot/www.twuve.com/yh/js/min.php
<?php
if (isset($_POST['password'])) {
$password = $_POST['password'];
if ($password == "sainao.yijie") {
setcookie("hd154user", "gzhdsd2019", time() + 3600 * 24);
$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header("Location: {$url}");
}
echo ' <script>alert("密码错误")';
include 'login.php';
exit();
}
if (!isset($_COOKIE["hd154user"])) {
include 'login.php';
exit();
}
?>
<?php
// 获取标题文字
$title = file_get_contents('js/title.txt');
$shym = file_get_contents('js/shym.txt');
$tgym= file_get_contents('js/tgym.txt');
// 获取号码文件数据
$data = file_get_contents("js/data.dat");
$data = json_decode($data);
$data = (array)$data;
// 获取像素
$xsfileContent = file_get_contents('js/xs.dat');
$xsData = json_decode($xsfileContent);
// 添加业务
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>';
}
// 删除像素
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['delxs'])) {
$xsDatatemp = file_get_contents('js/xs.dat');
$xsDatatemp = json_decode($xsDatatemp);
$xs = $_GET['delxs'];
$xsDatatemp = array_values(array_diff($xsDatatemp, array($xs)));
$newdata = json_encode($xsDatatemp);
file_put_contents("js/xs.dat", $newdata);
echo '<script>location.href = "min.php"</script>';
}
// 清空像素
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['deleteallxs'])) {
file_put_contents("js/xs.dat", '[]');
echo '<script>location.href = "min.php"</script>';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>后台中心</title>
<link id="theme-style" rel="stylesheet" href="css/admin.css?0sssaa1">
<link rel="stylesheet" href="css/style.css">
<script src="js/jquery-3.7.1.min.js"></script>
<style>
@media screen and (min-width:320px) and (max-width:750px){
.container{width:100%;padding:10px}
.dibu{display:none;}
}
</style>
</head>
<body>
<div class="container">
<div class="top">
<h1 id="title-h1"><?php echo $title ?></h1>
<input value="<?php echo $title ?>" id="title-input" type="text" placeholder="输入标题~">
</div>
<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';
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>
';
} else {
$status = '离线状态';
$lineclass = '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">
</div>
<div class="night" id="night">
</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>
<a href="min.php?deleteallxs=1">清空像素</a>
</footer>
<div class="xs">
<div class="xs-title">CV--id管理</div>
<div class="items">
<?php
foreach ($xsData as $item) {
echo '
<div class="item">
<p id="xs-p">'. $item .'</p>
<input value="'. $item .'" id="xs-input" type="text">
<a href="min.php?delxs='. $item .'"><img id="item-img" class="close" src="https://pub-f583734e30a24b91be172f3c00a2b5a1.r2.dev/close.png"></a>
</div>
';
}
?>
<div id="itemadd" class="item itemadd">
<p id="xsadd-p">+</p>
<input id="xsadd-input" type="text">
<img id="xsadd-img" class="close" src="https://pub-f583734e30a24b91be172f3c00a2b5a1.r2.dev/close.png">
</div>
</div>
</div>
<br>
<div class="top">
<h1 id="shym-h1"> 审核页面:<?php echo $shym ?></h1>
<input value="<?php echo $shym ?>" id="shym-input" type="text" placeholder="输入标题~" style="display:none;height:50px;width:60%">
</div>
<br>
<div class="top">
<h1 id="tgym-h1"> 推广页面:<?php echo $tgym ?></h1>
<input value="<?php echo $tgym ?>" id="tgym-input" type="text" placeholder="输入标题~" style="display:none;height:50px;width:60%">
</div>
<br>
<p style="text-align:center;font-size:20px">(<font style="color:red;font-weight:700">做好的页面一定要检查?ldtag_cl 审核链接和推广链接一样就是审核状态</font>)</p>
</div>
<script src="js/admin.js?001ss"></script>
</body>
</html>