NW_love/plugins/picture_delete.php
2023-02-03 18:43:19 +08:00

44 lines
1.1 KiB
PHP

<?php
/**
* @var array $config
*/
include $_SERVER['DOCUMENT_ROOT'].'/config.inc.php';
if (!empty($_COOKIE['user'])) {
// 函数处理
$PostUrl = 'https://www.na-wen.love/api/album/delete_picture.php';
$data = [
'session'=> $config['SESSION'],
'album'=> (int)urldecode(htmlspecialchars($_GET['album'])),
'data'=>$_POST['cbox'],
];
$JsonStr = json_encode($data); //转换为json格式
$PostData = http_post_json($PostUrl, $JsonStr);
$PostData = json_decode($PostData,true);
echo $PostData['output'];
}
// 发送POST
/**
* @param $url
* @param $jsonStr
* @return bool|string
*/
function http_post_json($url, $jsonStr) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($jsonStr)
)
);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}