forked from jxj666/2code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
46 lines (43 loc) · 1.04 KB
/
search.php
File metadata and controls
46 lines (43 loc) · 1.04 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
<?php
header("Access-Control-Allow-Origin: *");
$u = isset($_GET["u"]) ? $_GET["u"] : '';
$n = isset($_GET["n"]) ? $_GET["n"] : '';
$c = isset($_GET["c"]) ? $_GET["c"] : '';
$a = isset($_GET["a"]) ? $_GET["a"] : '';
// 连主库
session_start();
if ($_SESSION['code']!=$u) {
exit('{"code":0,"msg":"非法操作!"}');
}
//$conn = mysqli_connect('路径'.':'.'端口','账号','密码','库名');
include 'conn_sql.php';
// Check connection
if ($conn->connect_error) {
die("连接失败: " . $conn->connect_error);
}
class Content {
public $code = '00';
public $content = '00';
}
$content =new Content();
$sql = "SELECT *
FROM `2code_code`
WHERE address LIKE '%".$a."%'
AND name LIKE '%".$n."%'
AND content LIKE '%".$c."%'
AND user = '".$u."'
ORDER BY `id` DESC ";
$result = $conn->query($sql);
$data = array();
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$data[] = $row;
}
$content->code='1';
$content->content=$data;
} else {
$content->code='0';
}
echo json_encode($content);
$conn->close();
?>