-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelImg.php
More file actions
31 lines (31 loc) · 923 Bytes
/
delImg.php
File metadata and controls
31 lines (31 loc) · 923 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
<?php
header("content-type:text/html;charset=utf-8");
include_once "common.php";
$data = initPostData();
$link = $data['link'];
$token = $data['token'];
if($link == ''){
return;
}
//连接数据库
$con = pdo_database();
if($token){
[$openid,$identity,$nickName] = pdoCheckUserPrivilege($con,$token);
}
//echo $identity;
// 此处需要注意逻辑。
if($openid && $identity != 's'){
$identity = pdfCheckImageOwner($con,$openid,$link);
}
// 此处仅超级管理员和上传图片的用户本人可以删除,
if(($identity == 's' || $identity == 'o') && strlen($link) > 4 ){
$sql = "UPDATE `images` SET hide = 1 WHERE link = :link;";
}
else{
$con = null;
die('{"code":1006,"msg":"无权限,请登录后重试。"}');
}
$sth = $con->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$result = $sth->execute(array(':link' => $link));
echo '{"code":10,"msg":"已删除"}';
$con=null;