1 | <?php |
||||
2 | /* |
||||
3 | * You may not change or alter any portion of this comment or credits |
||||
4 | * of supporting developers from this source code or any supporting source code |
||||
5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||
6 | * |
||||
7 | * This program is distributed in the hope that it will be useful, |
||||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
10 | */ |
||||
11 | |||||
12 | /** |
||||
13 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||
14 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||||
15 | * @package efqdirectory |
||||
16 | * @since |
||||
17 | * @author Martijn Hertog (aka wtravel) |
||||
18 | * @author XOOPS Development Team, |
||||
19 | */ |
||||
20 | |||||
21 | include __DIR__ . '/header.php'; |
||||
22 | $myts = MyTextSanitizer::getInstance();// MyTextSanitizer object |
||||
0 ignored issues
–
show
|
|||||
23 | require_once XOOPS_ROOT_PATH . '/class/xoopstree.php'; |
||||
0 ignored issues
–
show
|
|||||
24 | require_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php'; |
||||
25 | require_once XOOPS_ROOT_PATH . '/include/xoopscodes.php'; |
||||
26 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||||
27 | |||||
28 | $moddir = $xoopsModule->getVar('dirname'); |
||||
29 | View Code Duplication | if (isset($_POST['dirid'])) { |
|||
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||||
30 | $dirid = (int)$_POST['dirid']; |
||||
31 | } elseif (isset($_GET['dirid'])) { |
||||
32 | $dirid = (int)$_GET['dirid']; |
||||
33 | } |
||||
34 | |||||
35 | $eh = new ErrorHandler; //ErrorHandler object |
||||
0 ignored issues
–
show
The type
ErrorHandler was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
36 | |||||
37 | View Code Duplication | if (isset($_GET['op'])) { |
|||
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||||
38 | $op = $_GET['op']; |
||||
39 | } elseif (isset($_POST['op'])) { |
||||
40 | $op = $_POST['op']; |
||||
41 | } |
||||
42 | |||||
43 | View Code Duplication | if (empty($xoopsUser) and !$xoopsModuleConfig['anonpost']) { |
|||
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||||
44 | redirect_header(XOOPS_URL . '/user.php', 2, _MD_MUSTREGFIRST); |
||||
0 ignored issues
–
show
The function
redirect_header was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
45 | exit(); |
||||
46 | } |
||||
47 | |||||
48 | if (!empty($_POST['submit'])) { |
||||
49 | //Get all selectable categories and put the prefix 'selectcat' in front of the catid. |
||||
50 | //With all results check if the result has a corresponding $_POST value. |
||||
51 | if ($_POST['title'] === '') { |
||||
52 | $eh->show('1001'); |
||||
53 | } |
||||
54 | $title = $myts->makeTboxData4Save($_POST['title']); |
||||
55 | $date = time(); |
||||
56 | $newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . '_itemid_seq'); |
||||
57 | if ($xoopsModuleConfig['autoapprove'] == 1) { |
||||
58 | $status = 1; |
||||
59 | } else { |
||||
60 | $status = 0; |
||||
61 | } |
||||
62 | //itemtype = bronze, silver, gold etc., start with 0 as default. |
||||
63 | $submitter = $xoopsUser->getVar('uid'); |
||||
64 | $newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . '_itemid_seq'); |
||||
65 | $sql = sprintf("INSERT INTO %s (itemid, uid, STATUS, created, title, hits, rating, votes, typeid, dirid) VALUES (%u, %u, %u, '%s', '%s', %u, %u, %u, '%s', %u)", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items'), $newid, $submitter, $status, time(), $title, 0, 0, 0, 0, $dirid); |
||||
66 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
67 | if ($newid == 0) { |
||||
68 | $itemid = $xoopsDB->getInsertId(); |
||||
69 | } |
||||
70 | $allcatsresult = $xoopsDB->query('SELECT cid FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_cat') . " WHERE dirid='" . $dirid . '\' AND active=\'1\''); |
||||
71 | $numrows = $xoopsDB->getRowsNum($allcatsresult); |
||||
72 | $count = 0; |
||||
73 | if ($numrows > 0) { |
||||
74 | while (list($cid) = $xoopsDB->fetchRow($allcatsresult)) { |
||||
75 | if (isset($_POST['selected' . $cid . ''])) { |
||||
76 | $sql = sprintf("INSERT INTO %s (xid, cid, itemid, active, created) VALUES (%u, %u, %u, '%s', '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat'), $newid, $cid, $itemid, 1, time()); |
||||
77 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
78 | ++$count; |
||||
79 | } |
||||
80 | } |
||||
81 | if ($count == 0) { |
||||
82 | redirect_header(XOOPS_URL . "/modules/$moddir/submit.php?dirid=" . $post_dirid . '', 2, _MD_NOCATEGORYMATCH); |
||||
83 | exit(); |
||||
84 | } |
||||
85 | } else { |
||||
86 | redirect_header(XOOPS_URL . "/modules/$moddir/submit.php?dirid=" . $post_dirid . '', 2, _MD_NOCATEGORIESAVAILABLE); |
||||
0 ignored issues
–
show
|
|||||
87 | exit(); |
||||
88 | } |
||||
89 | |||||
90 | /* // RMV-NEW |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
52% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||||
91 | // Notify of new listing (anywhere). To be completed. |
||||
92 | $notificationHandler = xoops_getHandler('notification'); |
||||
93 | $tags = array(); |
||||
94 | $tags['ITEM_NAME'] = $title; |
||||
95 | $tags['ITEM_URL'] = XOOPS_URL . '/modules/'. $xoopsModule->getVar('dirname') . '/listing.php?item=' . $itemid; |
||||
96 | if ($xoopsModuleConfig['autoapprove'] == 1) { |
||||
97 | $notificationHandler->triggerEvent('global', $itemid, 'new_listing', $tags); |
||||
98 | redirect_header(XOOPS_URL."/modules/$moddir/edit.php?item=".$itemid."",2,_MD_APPROVED); |
||||
99 | } else { |
||||
100 | $tags['WAITINGLINKS_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=listNewListings'; |
||||
101 | $notificationHandler->triggerEvent('global', $itemid, 'new_listing', $tags); |
||||
102 | if ($notify) { |
||||
103 | require_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
||||
104 | $notificationHandler->subscribe('link', $newid, 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); |
||||
105 | } |
||||
106 | redirect_header(XOOPS_URL."/modules/$moddir/edit.php?item=".$itemid."",2,_MD_SAVED); |
||||
107 | }*/ |
||||
108 | |||||
109 | redirect_header(XOOPS_URL . "/modules/$moddir/edit.php?item=" . $itemid . '', 2, _MD_SAVED); |
||||
110 | exit(); |
||||
111 | } else { |
||||
112 | View Code Duplication | if (isset($_GET['dirid'])) { |
|||
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||||
113 | $get_dirid = (int)$_GET['dirid']; |
||||
114 | } else { |
||||
115 | redirect_header(XOOPS_URL . "/modules/$moddir/index.php", 2, _MD_NODIRECTORYSELECTED); |
||||
116 | } |
||||
117 | $GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_submit.tpl'; |
||||
118 | include XOOPS_ROOT_PATH . '/header.php'; |
||||
119 | $xoopsTpl->assign('xoops_module_header', $xoops_module_header); |
||||
120 | //Query datatypes that match the categories selected. If not category selected. |
||||
121 | ob_start(); |
||||
122 | $form = new XoopsThemeForm(_MD_SUBMITLISTING_FORM, 'submitform', 'submit.php'); |
||||
0 ignored issues
–
show
The type
XoopsThemeForm was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
123 | $form->setExtra('enctype="multipart/form-data"'); |
||||
124 | $editor = !empty($_REQUEST['editor']) ? $_REQUEST['editor'] : ''; |
||||
125 | if (!empty($editor)) { |
||||
126 | setcookie('editor', $editor); // save to cookie |
||||
127 | } else { |
||||
128 | // Or use user pre-selected editor through profile |
||||
129 | if (is_object($xoopsUser)) { |
||||
130 | $editor = @ $xoopsUser->getVar('editor'); // Need set through user profile |
||||
131 | } |
||||
132 | } |
||||
133 | $editor = 'koivi'; |
||||
134 | $options['name'] = 'link_description'; |
||||
135 | $options['value'] = empty($_REQUEST['message']) ? '' : $_REQUEST['message']; |
||||
136 | $options['value'] = ''; |
||||
137 | //optional configs |
||||
138 | $options['rows'] = 25; // default value = 5 |
||||
139 | $options['cols'] = 60; // default value = 50 |
||||
140 | $options['width'] = '100%'; // default value = 100% |
||||
141 | $options['height'] = '400px'; // default value = 400px |
||||
142 | $options['small'] = true; |
||||
143 | $options['smiles'] = false; |
||||
144 | |||||
145 | // "textarea": if the selected editor with name of $editor can not be created, the editor "textarea" will be used |
||||
146 | // if no $onFailure is set, then the first available editor will be used |
||||
147 | // If dohtml is disabled, set $noHtml to true |
||||
148 | $form->addElement(new XoopsFormText(_MD_TITLE, 'title', 50, 250, ''), true); |
||||
0 ignored issues
–
show
The type
XoopsFormText was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
149 | $category_tray = new XoopsFormElementTray(_MD_CATEGORIES, '', 'cid'); |
||||
0 ignored issues
–
show
The type
XoopsFormElementTray was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
150 | $catselarea = getCatSelectArea2(); |
||||
151 | $category_tray->addElement(new XoopsFormLabel('', $catselarea)); |
||||
0 ignored issues
–
show
The type
XoopsFormLabel was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
152 | $form->addElement($category_tray, true); |
||||
153 | $form->addElement(new XoopsFormButton('', 'submit', _MD_CONTINUE, 'submit')); |
||||
0 ignored issues
–
show
The type
XoopsFormButton was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
154 | $form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid'))); |
||||
0 ignored issues
–
show
The type
XoopsFormHidden was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
155 | $form->addElement(new XoopsFormHidden('op', 'selectcat')); |
||||
156 | $form->addElement(new XoopsFormHidden('dirid', $get_dirid)); |
||||
157 | $form->display(); |
||||
158 | $xoopsTpl->assign('submit_form', ob_get_contents()); |
||||
159 | ob_end_clean(); |
||||
160 | |||||
161 | $xoopsTpl->assign('notify_show', !empty($xoopsUser) && !$xoopsModuleConfig['autoapprove'] ? 1 : 0); |
||||
162 | $xoopsTpl->assign('lang_sitetitle', _MD_SITETITLE); |
||||
163 | $xoopsTpl->assign('lang_siteurl', _MD_SITEURL); |
||||
164 | $xoopsTpl->assign('lang_category', _MD_CATEGORYC); |
||||
165 | $xoopsTpl->assign('lang_options', _MD_OPTIONS); |
||||
166 | $xoopsTpl->assign('lang_notify', _MD_NOTIFYAPPROVE); |
||||
167 | $xoopsTpl->assign('lang_description', _MD_DESCRIPTIONC); |
||||
168 | $xoopsTpl->assign('lang_cancel', _CANCEL); |
||||
0 ignored issues
–
show
|
|||||
169 | include XOOPS_ROOT_PATH . '/footer.php'; |
||||
170 | } |
||||
171 |
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