|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Xooghost module |
|
4
|
|
|
* |
|
5
|
|
|
* You may not change or alter any portion of this comment or credits |
|
6
|
|
|
* of supporting developers from this source code or any supporting source code |
|
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
8
|
|
|
* This program is distributed in the hope that it will be useful, |
|
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
13
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
14
|
|
|
* @package Xooghost |
|
15
|
|
|
* @since 2.6.0 |
|
16
|
|
|
* @author Laurent JEN (Aka DuGris) |
|
17
|
|
|
*/ |
|
18
|
|
|
use Xoops\Core\Request; |
|
19
|
|
|
use XoopsModules\Xooghost\Form; |
|
20
|
|
|
|
|
21
|
|
|
include __DIR__ . '/header.php'; |
|
22
|
|
|
|
|
23
|
|
|
switch ($op) { |
|
24
|
|
|
case 'save': |
|
25
|
|
|
if (!$xoops->security()->check()) { |
|
26
|
|
|
$xoops->redirect('pages.php', 5, implode(',', $xoops->security()->getErrors())); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
$xooghost_id = Request::getInt('xooghost_id', 0); //$system->cleanVars($_POST, 'xooghost_id', 0, 'int'); |
|
30
|
|
|
|
|
31
|
|
|
if (isset($xooghost_id) && $xooghost_id > 0) { |
|
32
|
|
|
$page = $pageHandler->get($xooghost_id); |
|
33
|
|
|
$isnew = false; |
|
34
|
|
|
} else { |
|
35
|
|
|
$page = $pageHandler->create(); |
|
36
|
|
|
$isnew = true; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
$page->cleanVarsForDB(); |
|
40
|
|
|
|
|
41
|
|
|
// uploads images |
|
42
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
43
|
|
|
$upload_images = $pageHandler->uploadImages($page->getVar('xooghost_title')); |
|
44
|
|
|
|
|
45
|
|
|
if (is_array($upload_images) && 0 != count($upload_images)) { |
|
46
|
|
|
foreach ($upload_images as $k => $reponse) { |
|
47
|
|
|
if (true === $reponse['error']) { |
|
48
|
|
|
$errors[] = $reponse['message']; |
|
49
|
|
|
} else { |
|
50
|
|
|
$page->setVar($k, $reponse['filename']); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
} else { |
|
54
|
|
|
$page->setVar('xooghost_image', $myts->htmlSpecialChars(Request::getString('image_list', '', 'POST'))); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
if ($xooghost_id = $pageHandler->insert($page)) { |
|
58
|
|
|
$msg = _AM_XOO_GHOST_SAVED; |
|
59
|
|
|
if (isset($errors) && 0 != count($errors)) { |
|
60
|
|
|
$msg .= '<br>' . implode('<br>', $errors); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
// tags |
|
64
|
|
|
if ($xoops->registry()->offsetExists('XOOTAGS') && $xoops->registry()->get('XOOTAGS')) { |
|
65
|
|
|
$xootagsHandler = \XoopsModules\Xootags\Helper::getInstance()->getHandler('Tags'); //$xoops->getModuleHandler('tags', 'xootags'); |
|
|
|
|
|
|
66
|
|
|
$msg .= '<br>' . $xootagsHandler->updateByItem('tags', $xooghost_id); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
if ($isnew) { |
|
70
|
|
|
$page->setPost(true); |
|
71
|
|
|
|
|
72
|
|
|
//notifications |
|
73
|
|
|
$page->sendNotifications(); |
|
74
|
|
|
} |
|
75
|
|
|
$xoops->redirect('pages.php', 5, $msg); |
|
76
|
|
|
} |
|
77
|
|
|
break; |
|
78
|
|
|
case 'add': |
|
79
|
|
|
/** @var \XoopsModules\Xooghost\PageHandler $pageHandler */ |
|
80
|
|
|
$page = $pageHandler->create(); |
|
81
|
|
|
// $form = $helper->getForm($page, 'pages'); |
|
82
|
|
|
$form = new Form\PagesForm($page); |
|
83
|
|
|
$form->display(); |
|
84
|
|
|
break; |
|
85
|
|
|
case 'edit': |
|
86
|
|
|
$xooghost_id = Request::getInt('xooghost_id', 0); //$system->cleanVars($_REQUEST, 'xooghost_id', 0, 'int'); |
|
87
|
|
|
$page = $pageHandler->get($xooghost_id); |
|
88
|
|
|
$form = $helper->getForm($page, 'pages'); |
|
89
|
|
|
$form->display(); |
|
90
|
|
|
break; |
|
91
|
|
|
case 'del': |
|
92
|
|
|
$xooghost_id = Request::getInt('xooghost_id', 0); //$system->cleanVars($_REQUEST, 'xooghost_id', 0, 'int'); |
|
93
|
|
|
if (isset($xooghost_id) && $xooghost_id > 0) { |
|
94
|
|
|
if ($page = $pageHandler->get($xooghost_id)) { |
|
95
|
|
|
$delete = Request::getInt('ok', 0); //$system->cleanVars($_POST, 'ok', 0, 'int'); |
|
96
|
|
|
if (1 == $delete) { |
|
97
|
|
|
if (!$xoops->security()->check()) { |
|
98
|
|
|
$xoops->redirect('pages.php', 5, implode(',', $xoops->security()->getErrors())); |
|
99
|
|
|
} |
|
100
|
|
|
// tags |
|
101
|
|
|
if ($xoops->registry()->offsetExists('XOOTAGS') && $xoops->registry()->get('XOOTAGS')) { |
|
102
|
|
|
$xootagsHandler = \XoopsModules\Xootags\Helper::getInstance()->getHandler('Tags'); //$xoops->getModuleHandler('tags', 'xootags'); |
|
103
|
|
|
$xootagsHandler->deleteByItem($page->getVar('xooghost_id')); |
|
104
|
|
|
} |
|
105
|
|
|
$page->setPost(false); |
|
106
|
|
|
$pageHandler->delete($page); |
|
107
|
|
|
$xoops->redirect('pages.php', 5, _AM_XOO_GHOST_DELETED); |
|
108
|
|
|
} else { |
|
109
|
|
|
$xoops->confirm(['ok' => 1, 'xooghost_id' => $xooghost_id, 'op' => 'del'], Request::getString('REQUEST_URI', '', 'SERVER'), sprintf(_AM_XOO_GHOST_DELETE_CFM . "<br><b><span style='color : #ff0000'> %s </span></b><br><br>", $page->getVar('xooghost_title'))); |
|
110
|
|
|
} |
|
111
|
|
|
} else { |
|
112
|
|
|
$xoops->redirect('pages.php', 5); |
|
113
|
|
|
} |
|
114
|
|
|
} else { |
|
115
|
|
|
$xoops->redirect('pages.php', 5); |
|
116
|
|
|
} |
|
117
|
|
|
break; |
|
118
|
|
|
case 'view': |
|
119
|
|
|
case 'hide': |
|
120
|
|
|
$xooghost_id = Request::getInt('xooghost_id', 0); //$system->cleanVars($_REQUEST, 'xooghost_id', 0, 'int'); |
|
121
|
|
|
$pageHandler->setOnline($xooghost_id); |
|
122
|
|
|
$xoops->redirect('pages.php', 5, _AM_XOO_GHOST_SAVED); |
|
123
|
|
|
break; |
|
124
|
|
|
default: |
|
125
|
|
|
$online = Request::getInt('online', -1); //$system->cleanVars($_REQUEST, 'online', -1, 'int'); |
|
126
|
|
|
$admin_page->addItemButton(_AM_XOO_GHOST_ADD, 'pages.php?op=add', 'add'); |
|
127
|
|
|
$admin_page->displayButton(); |
|
128
|
|
|
|
|
129
|
|
|
$xoops->tpl()->assign('pages', $pageHandler->renderAdminList($online)); |
|
130
|
|
|
break; |
|
131
|
|
|
} |
|
132
|
|
|
include __DIR__ . '/footer.php'; |
|
133
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths