-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclientConnect.php
More file actions
executable file
·52 lines (32 loc) · 941 Bytes
/
Copy pathclientConnect.php
File metadata and controls
executable file
·52 lines (32 loc) · 941 Bytes
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
<?php
include('head.php');
$cjson = $_GET["cid"];
$time = time();
$sql = "";
if(strlen(trim(rtrim(ltrim($cjson)))) == 0){
$sql = "INSERT INTO clients (chash, last_active, status) VALUES ('demo', '$time', '0')";
if(!($conn->query($sql))){
echo $conn->error;
}
$cid = $conn->insert_id;
$chash = md5($cid);
$sql = "UPDATE clients SET chash = '$chash' WHERE cid = '$cid'";
if(!mysqli_query($conn, $sql)){
echo mysqli_error($conn);
}
$res = Array("chash"=>$chash, "cid"=>$cid);
$response = json_encode($res);
echo $response;
}
else{
$cj = substr($cjson, 0, strlen($cjson)-1);
$cid = $cj;
$sql = "UPDATE clients SET status = '0', last_active = '$time' WHERE cid = '$cid'";
$conn->query($sql);
$chash = md5($cid);
$res = Array("chash"=>$chash, "cid"=>$cid);
$response = json_encode($res);
echo $response;
}
//echo $sql;
// {"chash":"c4ca4238a0b923820dcc509a6f75849b","cid":1}