-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhandleGrab.php
More file actions
58 lines (45 loc) · 2.36 KB
/
Copy pathhandleGrab.php
File metadata and controls
58 lines (45 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* Created by PhpStorm.
* User: TreeNewBeee
* Date: 2017-04-13
* Time: 02:18
*/
if (isset($_GET['title'])){
// echo $_GET['title'];
// echo $_GET['branch'];
require_once './db_login.php';
$conn = new mysqli($db_hostname, $db_username, $db_password, $db_database);
if ($conn->connect_error) die($conn->connect_error);
mysqli_set_charset($conn, 'utf8');
$today = date("Y-m-d");
$branch = $_GET['branch'];
$query = "select * from `missionlog` WHERE `title` = '".$_GET['title']."' and `branch` = '".$_GET['branch']."' and `type` = '抢接任务'";
$result = $conn->query($query);
if (!$result) die($conn->connect_error);
$num = $result->num_rows;
if ($num != 0){
// 已经抢接过了
echo "<script>alert('您所在的支部已经抢接该任务,请及时完成并上传相关文件');location.href='missionList.php?type=抢接任务&branch={$branch}';</script>";
// echo "<script>alert('您所在的支部已经抢接该任务,请及时完成并上传相关文件')</script>";
}else{
$query = "SELECT * FROM `rushmission` WHERE `title` = '".$_GET['title']."'";
$result = $conn->query($query);
if (!$result) die($conn->connect_error);
$rows = $result->fetch_array();
$query = "INSERT INTO `missionlog` (`id`, `title`, `publisher`, `annix`,
`details`,`publishTime`, `timeLimit`, `finishTime`, `type`, `status`, `score`, `annixSubmit`,
`branch`, `submitter`) VALUES (NULL, '" . $rows['title'] . "', '" . $rows['publisher'] . "',
'" . $rows['annix'] . "', '" . $rows['details'] . "','".$today."',
'" . $rows['timeLimit'] . "', NULL, '抢接任务', '已发布', '0', NULL, '".$_GET['branch']."', NULL);";
$conn->query($query);
$leftnum = $rows['leftnum'] - 1;
$query = "UPDATE `rushmission` SET `leftnum` = '".$leftnum."' WHERE
`rushmission`.`title` = '" . $rows['title'] . "'";
$conn->query($query);
echo "<script>alert('抢接成功!');</script>";
}
$result->close();
$conn->close();
echo "<script> window.location.href='./missionList.php?type=抢接任务&branch={$branch}';</script>";
}