-
Notifications
You must be signed in to change notification settings - Fork 2
/
ajax_menu.php
58 lines (46 loc) · 1.62 KB
/
ajax_menu.php
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
53
54
55
56
57
58
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: *");
header("Access-Control-Allow-Headers: Origin, Methods, Content-Type");
use Xmf\Request;
use XoopsModules\Tadgallery\Tools;
use XoopsModules\Tadtools\Utility;
require_once __DIR__ . '/header.php';
header('HTTP/1.1 200 OK');
$xoopsLogger->activated = false;
$op = Request::getString('op');
$of_csn = Request::getInt('of_csn');
$def_csn = Request::getInt('def_csn');
$chk_view = Request::getInt('chk_view', 1);
$chk_up = Request::getInt('chk_up', 1);
echo get_option($of_csn, $def_csn, $chk_view, $chk_up);
function get_option($of_csn = '', $def_csn = '', $chk_view = 1, $chk_up = 1)
{
global $xoopsDB;
$ok_cat = $ok_up_cat = '';
if ($chk_view) {
$ok_cat = Tools::chk_cate_power();
}
if ($chk_up) {
$ok_up_cat = Tools::chk_cate_power('upload');
}
$option = '';
$sql = 'SELECT `csn`, `title` FROM `' . $xoopsDB->prefix('tad_gallery_cate') . '` WHERE `of_csn` = ? ORDER BY `sort`';
$result = Utility::query($sql, 'i', [$of_csn]) or Utility::web_error($sql, __FILE__, __LINE__);
while (list($csn, $title) = $xoopsDB->fetchRow($result)) {
$csn = (int) $csn;
if ($chk_view and is_array($ok_cat)) {
if (!in_array($csn, $ok_cat)) {
continue;
}
}
if ($chk_up and is_array($ok_up_cat)) {
if (!in_array($csn, $ok_up_cat)) {
continue;
}
}
$selected = $csn == $def_csn ? 'selected' : '';
$option .= "<option value='$csn' $selected>/$title</option>\n";
}
return $option;
}