Skip to content

Commit

Permalink
正式版
Browse files Browse the repository at this point in the history
  • Loading branch information
youranreus committed Nov 19, 2020
1 parent e25e4f1 commit 6dbeac4
Show file tree
Hide file tree
Showing 6 changed files with 666 additions and 45 deletions.
19 changes: 19 additions & 0 deletions X/cron.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
require 'main.class.php';
$X = new main();
echo "\n";
echo "开始".date("Y-m-d")."任务\n";
$Machine = $X->Cron();
$title = "小鸡管理推送";

$endangerMachine = implode(',', $Machine["endanger"]);
$deadMachine = implode(',', $Machine["dead"]);
$autoMachine = implode(',', $Machine["auto"]);

$msg = "
一共有".count($Machine["endanger"])."台小鸡即将到期。[".$endangerMachine."]
".count($Machine["dead"])."台小鸡已经过期。[".$deadMachine."]
".count($Machine["auto"])."台小鸡自动续费。[".$autoMachine."]
请前往小鸡管理查看
";
file_get_contents('http://sc.ftqq.com/SCU108711Te987fd883e60a263488101a8d91f1a965f2e0fe2eee7f.send?text='.urlencode($title).'&desp='.urlencode($msg));
Binary file modified X/database.db
Binary file not shown.
100 changes: 96 additions & 4 deletions X/main.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class main
{
private $database;
private $key = 'jojo';

public function __construct()
{
Expand All @@ -31,8 +32,7 @@ public function yo()

public function login()
{
$key = $this->database->select('user','*');
if($_GET['key'] == $key[0]['key']){
if($_GET['key'] == $this->key){
exit(json_encode(['msg'=>'true']));
}else{
exit(json_encode(['msg'=>'false']));
Expand All @@ -52,6 +52,8 @@ public function getMachineList()
exit(json_encode($machines));
}



public function getInfo()
{
$info = array(
Expand All @@ -69,10 +71,13 @@ public function getInfo()
if ($machines[$i]['auto'] == 1){
$info["autoMachine"] += 1;
}else{
$days = $this->dateDistance($machines[$i]['deadline'],date("Y-m-d"));
if($days <= 15 and $days > 0){
$days = $this->dateDistance(date("Y-m-d"),$machines[$i]['deadline']);
if($days <= 15 and $days >= 0){
$info["endangerMachine"] += 1;
}
if($days < 0){
$info["deadMachine"] += 1;
}
}
if ($machines[$i]['liked'] == 1){
$info["feeLeast"] += $machines[$i]['fee'];
Expand Down Expand Up @@ -104,4 +109,91 @@ public function getMachineDetail(){
}
}

public function updateMachineDetail(){
if(isset($_GET['id'])){
$result = $this->database->update("machines", [
"name" => $_GET["name"],
"liked" => $_GET["liked"],
"deadline" => $_GET["deadline"],
"location" => $_GET["location"],
"fee" => $_GET["fee"],
"cycle" => $_GET["cycle"],
"auto" => $_GET["auto"],
"panel" => $_GET["panel"],
"info" => $_GET["info"],
"HOST" => $_GET["HOST"],
"ip" => $_GET["ip"]
], [
"rowid" => $_GET["id"]
]);
exit(json_encode($result->rowCount()));
}
}

public function AddMachine(){
if(isset($_GET['id'])){
$result = $this->database->insert("machines", [
"name" => $_GET["name"],
"liked" => $_GET["liked"],
"deadline" => $_GET["deadline"],
"location" => $_GET["location"],
"fee" => $_GET["fee"],
"cycle" => $_GET["cycle"],
"auto" => $_GET["auto"],
"panel" => $_GET["panel"],
"info" => $_GET["info"],
"HOST" => $_GET["HOST"],
"ip" => $_GET["ip"]
]);
exit(json_encode($result->rowCount()));
}
}

public function DeleteMachine(){
if(isset($_GET['id'])) {
$result = $this->database->delete("machines", [
"rowid" => $_GET["id"]
]);
exit(json_encode($result->rowCount()));
}
}

public function Cron(){

$machines = $this->database->select('machines',['rowid','name','liked','deadline','auto','cycle']);

$machinesNum = count($machines);
$Machine = [];
$Machine["endanger"] = [];
$Machine["dead"] = [];
$Machine["auto"] = [];

for($i=0;$i<$machinesNum;$i++){
echo "------\n";
echo '名称:'.$machines[$i]["name"]."\n";
$days = $this->dateDistance(date("Y-m-d"),$machines[$i]['deadline']);
echo '距离过期'.$days."\n";
if($days <=7 and $days>=0 and $machines[$i]['auto'] == 0){
$Machine["endanger"][] = $machines[$i]['name'];
}
if($days < 0 and $machines[$i]['auto'] == 0){
$Machine["dead"][] = $machines[$i]['name'];
}

if($days == 0 and $machines[$i]['auto'] == '1'){

$this->database->update("machines", [
"deadline" => date('Y-m-d',strtotime("+".$machines[$i]['cycle']." day"))
], [
"rowid" => $machines[$i]['rowid']
]);
$Machine["auto"][] = $machines[$i]['name'];
}

}

return $Machine;

}

}
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<title>小鸡管理</title>
<link href="https://cdn.bootcdn.net/ajax/libs/normalize/8.0.1/normalize.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@alphardex/[email protected]/dist/aqua.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/youranreus/R/G/CSS/yue.css" rel="stylesheet" />
<link rel="stylesheet" href="main.css?v=1.3">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
Expand All @@ -17,5 +18,6 @@
<script src="https://cdn.bootcdn.net/ajax/libs/vue-router/2.7.0/vue-router.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/js-cookie/latest/js.cookie.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0/axios.js"></script>
<script src="main.js?v=2.2" type="module"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/marked/1.2.2/marked.min.js"></script>
<script src="main.js?v=2.4" type="module"></script>
</html>
24 changes: 24 additions & 0 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,28 @@ a,a:link,a:visited{
}
.endanger > *{
color:#ee827c!important;
}

#machine-detail,#machine-edit,#machine-add,#machine-delete{
padding: 25px;
background: RGB(250,250,250);
border-radius: 15px;
margin-bottom: 20px;
}
#machine-detail h2 span,#machine-edit h2 span,#machine-add h2 span,#machine-delete h2 span{
font-size:18px;
color:#999999;
float:right;
cursor: pointer;
margin-left: 10px;
}
textarea{
display: inline-block;
/*padding: .438rem .525rem;*/
border-radius: 0.3125rem;
overflow-y: visible;
width: 100%;
vertical-align: top;
color: #333;
border-color: #ececec;
}
Loading

0 comments on commit 6dbeac4

Please sign in to comment.