lylme_spage/admin/ajax_apply.php

67 lines
2.3 KiB
PHP
Raw Normal View History

<?php
2023-12-25 22:26:12 +08:00
include_once("../include/common.php");
2024-05-06 00:34:06 +08:00
if (isset($islogin) == 1) {
2023-12-25 22:26:12 +08:00
} else {
exit("<script language='javascript'>window.location.href='./login.php';</script>");
}
header('Content-Type:application/json');
2023-12-25 22:26:12 +08:00
$set = isset($_GET['set']) ? $_GET['set'] : null;
2024-05-06 00:34:06 +08:00
switch ($set) {
//审核
2023-12-25 22:26:12 +08:00
case 'status':
2024-05-06 00:34:06 +08:00
$sw = $_POST['status'] == 1 ? 1 : 2;
$ids = $_POST['id'];
if (!is_array($ids)) {
//转为数组
$ids = array($ids);
}
$e = 0;
foreach ($ids as $id) {
if ($sw == 1) {
//将通过的链接插入到数据库
$applyres = $DB->get_row("SELECT * FROM `lylme_apply` WHERE `apply_status` = 0 ANd `apply_id` = $id");
if (!empty($applyres)) {
$name = strip_tags(daddslashes($applyres['apply_name']));
$url = strip_tags(daddslashes($applyres['apply_url']));
$icon = daddslashes($applyres['apply_icon']);
$group_id = strip_tags(daddslashes($applyres['apply_group']));
$link_order = $DB->count('select MAX(id) from `lylme_links`') + 1;
$DB->query("INSERT INTO `lylme_links` (`id`, `name`, `group_id`, `url`, `icon`, `link_desc`,`link_order`) VALUES (NULL, '$name', '$group_id', '$url', '$icon', '', '$link_order');");
2023-12-25 22:26:12 +08:00
}
}
2024-05-06 00:34:06 +08:00
$sql = "UPDATE `lylme_apply` SET `apply_status` = '$sw' WHERE `apply_status` = 0 ANd `apply_id` = $id;";
if (!$DB->query($sql)) {
$e++;
2023-12-25 22:26:12 +08:00
}
2024-05-06 00:34:06 +08:00
}
if ($e == 0) {
exit('{"code": 200,"msg":"操作成功!"}');
2023-12-25 22:26:12 +08:00
} else {
2024-05-06 00:34:06 +08:00
exit('{"code": 100,"msg":"错误,失败' . $e . '条"}');
2023-12-25 22:26:12 +08:00
}
break;
2024-05-06 00:34:06 +08:00
//删除
2023-12-25 22:26:12 +08:00
case 'delete':
2024-05-06 00:34:06 +08:00
$ids = $_POST['id'];
if (!is_array($ids)) {
$ids = array($ids);
}
$e = 0;
foreach ($ids as $id) {
if (!$DB->query("DELETE FROM `lylme_apply` WHERE apply_id = $id")) {
$e++;
}
}
if ($e == 0) {
exit('{"code": 200,"msg":"操作成功!"}');
2023-12-25 22:26:12 +08:00
} else {
2024-05-06 00:34:06 +08:00
exit('{"code": 100,"msg":"错误,失败' . $e . '条"}');
2023-12-25 22:26:12 +08:00
}
break;
default:
exit('error');
break;
}