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 | require_once __DIR__ . '/admin_header.php'; |
||||
22 | |||||
23 | require_once __DIR__ . '/../include/functions.php'; |
||||
24 | require_once XOOPS_ROOT_PATH . '/class/xoopstree.php'; |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
25 | //require_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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. ![]() |
|||||
26 | require_once XOOPS_ROOT_PATH . '/include/xoopscodes.php'; |
||||
27 | require_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php'; |
||||
28 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||||
29 | global $xoopsModule; |
||||
30 | //$myts = MyTextSanitizer::getInstance(); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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. ![]() |
|||||
31 | $eh = new ErrorHandler; |
||||
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 ![]() |
|||||
32 | $mytree = new XoopsTree($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_cat'), 'cid', 'pid'); |
||||
0 ignored issues
–
show
The type
XoopsTree 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 ![]() |
|||||
33 | require_once __DIR__ . '/../class/class.datafieldmanager.php'; |
||||
34 | require_once __DIR__ . '/../class/class.subscription.php'; |
||||
35 | require_once __DIR__ . '/../class/class.efqtree.php'; |
||||
36 | require_once __DIR__ . '/../class/class.listing.php'; |
||||
37 | $efqtree = new EfqTree($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_cat'), 'cid', 'pid'); |
||||
38 | $datafieldmanager = new efqDataFieldManager(); |
||||
39 | |||||
40 | $listinghandler = new efqListingHandler; |
||||
41 | $subscription = new efqSubscription; |
||||
42 | $subscriptionhandler = new efqSubscriptionHandler; |
||||
43 | $moddir = $xoopsModule->getVar('dirname'); |
||||
44 | |||||
45 | if (isset($_GET['item'])) { |
||||
46 | $get_itemid = (int)$_GET['item']; |
||||
47 | } |
||||
48 | |||||
49 | function listings() |
||||
50 | { |
||||
51 | global $xoopsDB, $xoopsModule; |
||||
52 | xoops_cp_header(); |
||||
0 ignored issues
–
show
The function
xoops_cp_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
![]() |
|||||
53 | //adminmenu(0, _MD_A_MODADMIN_HOME); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
63% 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. ![]() |
|||||
54 | echo '<h4>' . _MD_LISTINGSCONF . '</h4>'; |
||||
55 | echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . '<tr class="odd"><td>'; |
||||
56 | //$result = $xoopsDB->query("select count(*) from ".$xoopsDB->prefix("efqdiralpha1_broken").""); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
65% 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. ![]() |
|||||
57 | //list($totalbrokenlinks) = $xoopsDB->fetchRow($result); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
72% 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. ![]() |
|||||
58 | $result3 = $xoopsDB->query('SELECT count(*) FROM ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items') . " WHERE status='1'"); |
||||
59 | list($totalnewlistings) = $xoopsDB->fetchRow($result3); |
||||
60 | if ($totalnewlistings > 0) { |
||||
61 | $totalnewlistings = "<span style='color: #ff0000; font-weight: bold'>$totalnewlistings</span>"; |
||||
0 ignored issues
–
show
|
|||||
62 | } |
||||
63 | // echo " - <a href='".XOOPS_URL."/modules/system/admin.php?fct=preferences&op=showmod&mod=".$xoopsModule->getVar('mid')."'>"._MD_GENERALSET."</a>"; |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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. ![]() |
|||||
64 | // echo "<br><br>"; |
||||
65 | // echo " - <a href=directories.php>"._MD_MANAGEDIRECTORIES."</a>"; |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
45% 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. ![]() |
|||||
66 | // echo "<br><br>"; |
||||
67 | // echo " - <a href=fieldtypes.php>"._MD_MANAGEFIELDTYPES."</a>"; |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
45% 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. ![]() |
|||||
68 | // echo "<br><br>"; |
||||
69 | // echo " - <a href=main.php?op=listNewListings>"._MD_LISTINGSWAITING." ($totalnewlistings)</a>"; |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
45% 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. ![]() |
|||||
70 | // echo "<br><br>"; |
||||
71 | // echo " - <a href=main.php?op=duplicateDataTypes>"._MD_DUPLICATE_DATATYPES."</a>"; |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
45% 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. ![]() |
|||||
72 | // echo "<br><br>"; |
||||
73 | $result = $xoopsDB->query('SELECT count(*) FROM ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items') . ' WHERE status>0'); |
||||
74 | list($numrows) = $xoopsDB->fetchRow($result); |
||||
75 | echo '<br /<div>'; |
||||
76 | printf(_MD_THEREARE, $numrows); |
||||
77 | echo '</div>'; |
||||
78 | echo '</td></tr></table>'; |
||||
79 | xoops_cp_footer(); |
||||
0 ignored issues
–
show
The function
xoops_cp_footer 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
![]() |
|||||
80 | } |
||||
81 | |||||
82 | function listNewListings() //completed |
||||
83 | { |
||||
84 | global $xoopsDB, $xoopsModule, $xoopsConfig, $myts, $eh, $mytree, $mytree2, $moddir; |
||||
85 | $sql = 'SELECT i.itemid, i.logourl, i.uid, i.status, i.created, i.title, i.typeid FROM ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items') . " i WHERE i.status='1'"; |
||||
86 | $result = $xoopsDB->query($sql, 10, 0); |
||||
87 | $numrows = $xoopsDB->getRowsNum($result); |
||||
88 | if ($numrows > 0) { |
||||
89 | xoops_cp_header(); |
||||
0 ignored issues
–
show
The function
xoops_cp_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
![]() |
|||||
90 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||||
0 ignored issues
–
show
The type
Xmf\Module\Admin 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 ![]() |
|||||
91 | $adminObject->displayNavigation('main.php?op=listNewListings'); |
||||
92 | |||||
93 | echo '<h4>' . _MD_LISTINGSCONF . '</h4>'; |
||||
94 | echo "<table width='100%' border='0' cellspacing='1' class='outer'>"; |
||||
95 | echo '<tr class="odd"><td>'; |
||||
96 | echo '<h4>' . _MD_LISTINGSWAITING . " ($numrows)</h4><br>"; |
||||
97 | echo '<table width="95%">'; |
||||
98 | echo '<tr><td align="left"nowrap><b>' . _MD_LISTINGTITLE . '</b></td>'; |
||||
99 | echo '<td align="left" nowrap><b>' . _MD_SUBMITTER . '</b></td><td align="left" nowrap><b>' . _MD_CREATED . '</b></td><td> </td></tr>'; |
||||
100 | while (list($itemid, $logourl, $submitterid, $status, $date, $title, $type) = $xoopsDB->fetchRow($result)) { |
||||
101 | $title = $myts->htmlSpecialChars($title); |
||||
102 | $submitter = XoopsUser::getUnameFromId($submitterid); |
||||
0 ignored issues
–
show
The type
XoopsUser 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 ![]() |
|||||
103 | $created = formatTimestamp($date); |
||||
0 ignored issues
–
show
The function
formatTimestamp 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
![]() |
|||||
104 | echo "<tr><td>$title</td><td><a href=\"" . XOOPS_URL . "/userinfo.php?uid=$submitterid\">$submitter</a></td><td>$created</td><td valign=\"bottom\">"; |
||||
0 ignored issues
–
show
|
|||||
105 | echo '<a href="' . XOOPS_URL . '/modules/' . $moddir . "/admin/main.php?op=edit&item=$itemid\">" . _MD_EDIT . '</a>'; |
||||
106 | echo "</td></tr>\n"; |
||||
107 | } |
||||
108 | echo '</table></td></tr></table>'; |
||||
109 | xoops_cp_footer(); |
||||
0 ignored issues
–
show
The function
xoops_cp_footer 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
![]() |
|||||
110 | } else { |
||||
111 | redirect_header('' . XOOPS_URL . '/modules/' . $moddir . '/admin/main.php?op=listings', 1, _MD_NONEW_LISTINGS); |
||||
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
![]() |
|||||
112 | exit(); |
||||
113 | } |
||||
114 | } |
||||
115 | |||||
116 | function delVote() |
||||
117 | { |
||||
118 | global $xoopsDB, $_GET, $eh; |
||||
119 | $rid = $_GET['rid']; |
||||
120 | $get_itemid = (int)$_GET['itemid']; |
||||
121 | $sql = sprintf('DELETE FROM %s WHERE ratingid = %u', $xoopsDB->prefix('listings_votedata'), $rid); |
||||
122 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
123 | updaterating($get_itemid); |
||||
124 | redirect_header('index.php', 1, _MD_VOTEDELETED); |
||||
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
![]() |
|||||
125 | exit(); |
||||
126 | } |
||||
127 | |||||
128 | View Code Duplication | function delListingConfirm() |
|||
0 ignored issues
–
show
This function seems to be duplicated in 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. ![]() |
|||||
129 | { |
||||
130 | global $xoopsDB, $eh, $xoopsModule, $get_itemid; |
||||
131 | xoops_cp_header(); |
||||
0 ignored issues
–
show
The function
xoops_cp_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
![]() |
|||||
132 | $form = new XoopsThemeForm(_MD_CONFIRM_DELETELISTING_FORM, 'confirmform', 'main.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 ![]() |
|||||
133 | $submit_tray = new XoopsFormElementTray(_MD_DELETEYN, '', '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 ![]() |
|||||
134 | $submit_tray->addElement(new XoopsFormButton('', 'submit', _MD_DELETE, '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 ![]() |
|||||
135 | $submit_tray->addElement(new XoopsFormLabel('', '<input type="button" class="formButton" value="' . _MD_CANCEL . "\" onclick=\"location='main.php?op=edit&item=$get_itemid'\"")); |
||||
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 ![]() |
|||||
136 | $form->addElement($submit_tray, true); |
||||
137 | //$form->addElement($form_submit); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
86% 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. ![]() |
|||||
138 | $form->addElement(new XoopsFormHidden('op', 'deleteListing')); |
||||
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 ![]() |
|||||
139 | $form->addElement(new XoopsFormHidden('itemid', $get_itemid)); |
||||
140 | $form->display(); |
||||
141 | xoops_cp_footer(); |
||||
0 ignored issues
–
show
The function
xoops_cp_footer 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
![]() |
|||||
142 | } |
||||
143 | |||||
144 | function delListing() |
||||
145 | { |
||||
146 | global $xoopsDB, $eh, $xoopsModule; |
||||
147 | $sql = sprintf('DELETE FROM %s WHERE itemid = %u', $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items'), (int)$_POST['itemid']);//EDIT-RC10 |
||||
148 | $xoopsDB->queryF($sql) or $eh->show('0013'); |
||||
149 | $sql = sprintf('DELETE FROM %s WHERE itemid = %u', $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_text'), (int)$_POST['itemid']);//EDIT-RC10 |
||||
150 | $xoopsDB->queryF($sql) or $eh->show('0013'); |
||||
151 | $sql = sprintf('DELETE FROM %s WHERE itemid = %u', $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_img'), (int)$_POST['itemid']);//EDIT-RC10 |
||||
152 | $xoopsDB->queryF($sql) or $eh->show('0013'); |
||||
153 | $sql = sprintf('DELETE FROM %s WHERE itemid = %u', $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat'), (int)$_POST['itemid']);//EDIT-RC10 |
||||
154 | $xoopsDB->queryF($sql) or $eh->show('0013'); |
||||
155 | $sql = sprintf('DELETE FROM %s WHERE itemid = %u', $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_loc'), (int)$_POST['itemid']);//EDIT-RC10 |
||||
156 | $xoopsDB->queryF($sql) or $eh->show('0013'); |
||||
157 | xoops_comment_delete($xoopsModule->getVar('mid'), (int)$_POST['itemid']); |
||||
0 ignored issues
–
show
The function
xoops_comment_delete 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
![]() |
|||||
158 | xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'listing', (int)$_POST['itemid']); |
||||
0 ignored issues
–
show
The function
xoops_notification_deletebyitem 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
![]() |
|||||
159 | redirect_header('index.php', 1, _MD_LISTINGDELETED); |
||||
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
![]() |
|||||
160 | exit(); |
||||
161 | } |
||||
162 | |||||
163 | function approve() |
||||
164 | { |
||||
165 | global $xoopsConfig, $xoopsDB, $get_itemid, $eh; |
||||
166 | $query = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items') . " set status='2' where itemid=" . $get_itemid . ''; |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
167 | $xoopsDB->queryF($query) or $eh->show('0013'); |
||||
168 | redirect_header('main.php?op=listNewListings', 1, _MD_LISTINGAPPROVED); |
||||
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
![]() |
|||||
169 | } |
||||
170 | |||||
171 | function updateItemType() |
||||
172 | { |
||||
173 | global $xoopsConfig, $xoopsDB, $eh; |
||||
174 | $post_itemid = (int)$_POST['itemid']; |
||||
175 | $post_typeid = (int)$_POST['typeid']; |
||||
176 | $query = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items') . " SET typeid='$post_typeid' WHERE itemid=" . $post_itemid . ''; |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
177 | $xoopsDB->query($query) or $eh->show('0013'); |
||||
178 | redirect_header("main.php?op=edit&item=$post_itemid", 2, _MD_ITEM_UPDATED); |
||||
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
![]() |
|||||
179 | } |
||||
180 | |||||
181 | function listDuplicateDataTypes() |
||||
182 | { |
||||
183 | global $xoopsConfig, $xoopsDB, $eh, $myts, $moddir, $xoopsModule; |
||||
184 | |||||
185 | xoops_cp_header(); |
||||
0 ignored issues
–
show
The function
xoops_cp_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
![]() |
|||||
186 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||||
187 | $adminObject->displayNavigation('main.php?op=duplicateDataTypes'); |
||||
188 | //adminmenu(-1, _MD_DUPLICATE_DATATYPES); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
56% 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. ![]() |
|||||
189 | echo '<br>'; |
||||
190 | $sql = 'SELECT dt1.dtypeid, dt1.title, dt1.fieldtypeid '; |
||||
191 | $sql .= 'FROM ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes') . ' dt1, ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes') . ' dt2 '; |
||||
192 | $sql .= 'WHERE dt1.title=dt2.title AND dt1.fieldtypeid=dt2.fieldtypeid ORDER BY dt1.title ASC, dt1.fieldtypeid ASC'; |
||||
193 | |||||
194 | $result = $xoopsDB->query($sql) or $eh->show('0013'); |
||||
195 | $numrows = $xoopsDB->getRowsNum($result); |
||||
196 | |||||
197 | if ($numrows > 0) { |
||||
198 | echo '<h4>' . _MD_DUPLICATE_DATATYPES . '</h4>'; |
||||
199 | echo "<table width='100%' border='0' cellspacing='1' class='outer'>"; |
||||
200 | echo '<tr><th>' . _MD_DTYPE . '</th><th>' . _MD_DTYPE_TITLE . '</th><th>' . _MD_FIELDTYPE . '</th></tr>'; |
||||
201 | while (list($dtypeid, $title, $fieldtypeid) = $xoopsDB->fetchRow($result)) { |
||||
202 | $dtypetitle = $myts->htmlSpecialChars($title); |
||||
203 | $result_arr[] = $dtypeid . $dtypetitle . $fieldtypeid; |
||||
204 | $result_array[] = array($dtypeid, $dtypetitle, $fieldtypeid); |
||||
205 | } |
||||
206 | $checkKeysUniqueComparison = create_function('$value', 'if ($value > 1) return true;'); |
||||
0 ignored issues
–
show
The use of
create_function is highly discouraged, better use a closure.
// Instead of
$function = create_function('$a, $b', 'return $a + $b');
// Better use
$function = function($a, $b) { return $a + $b; }
![]() |
|||||
207 | $duplicate_results = array_keys(array_filter(array_count_values($result_arr), $checkKeysUniqueComparison)); |
||||
208 | |||||
209 | if (count($duplicate_results) > 0) { |
||||
210 | $duplicates = '1'; |
||||
211 | } else { |
||||
212 | $duplicates = '0'; |
||||
213 | } |
||||
214 | |||||
215 | $last_title = ''; |
||||
216 | $last_fieldtypeid = '0'; |
||||
217 | $merge = ''; |
||||
218 | foreach ($result_array as $arr) { |
||||
219 | $id = $arr[0]; |
||||
220 | $match[$id] = $arr[0] . $arr[1] . $arr[2]; |
||||
221 | $test = array_pop($match); |
||||
222 | $key_to_be_deleted = array_search($test, $duplicate_results); |
||||
223 | |||||
224 | if (in_array($test, $duplicate_results)) { |
||||
225 | echo '<tr>'; |
||||
226 | echo "<td class=\"even\">$arr[0]</td>"; |
||||
227 | echo "<td class=\"odd\">$arr[1]</td>"; |
||||
228 | echo "<td class=\"even\">$arr[2]</td>"; |
||||
229 | echo '</tr>'; |
||||
230 | if ($last_title == '' && $last_fieldtypeid == '0') { |
||||
231 | $last_title = $arr[1]; |
||||
232 | $last_fieldtypeid = $arr[2]; |
||||
233 | $merge .= $arr[0]; |
||||
234 | } elseif ($arr[1] != $last_title && $arr[2] != $last_fieldtypeid) { |
||||
235 | $last_title = $arr[1]; |
||||
236 | $last_fieldtypeid = $arr[2]; |
||||
237 | $merge .= '|' . $arr[0]; |
||||
238 | echo "<tr><td colspan='3'>"; |
||||
239 | echo "<form action='main.php' method='post'>"; |
||||
240 | echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
||||
241 | echo "<input type='button' class='formButton' action='submit' name='submit' id='submit' value='" . _MD_MERGE . '\''; |
||||
242 | echo "<input type='hidden' name='merge' value='$merge'>"; |
||||
243 | echo "<input type='hidden' name='op' value='mergeDuplicates'>"; |
||||
244 | echo '</form>'; |
||||
245 | echo '</td></tr>'; |
||||
246 | $merge = ''; |
||||
247 | } else { |
||||
248 | $merge .= '|' . $arr[0]; |
||||
249 | } |
||||
250 | unset($duplicate_results[$key_to_be_deleted]); |
||||
251 | } |
||||
252 | unset($match); |
||||
253 | } |
||||
254 | if ($duplicates == '1') { |
||||
255 | echo "<tr><td colspan='3'>"; |
||||
256 | echo "<form action='main.php' method='post'>"; |
||||
257 | echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
||||
258 | echo "<input type='submit' class='formButton' action='submit' name='submit' id='submit' value='" . _MD_MERGE . '\''; |
||||
259 | echo "<input type='hidden' name='merge' value='$merge'>"; |
||||
260 | echo "<input type='hidden' name='op' value='mergeDuplicates'>"; |
||||
261 | echo '</form>'; |
||||
262 | echo '</td></tr>'; |
||||
263 | } else { |
||||
264 | echo "<tr><td colspan='3'>"; |
||||
265 | echo _MD_NORESULTS; |
||||
266 | echo '</td></tr>'; |
||||
267 | } |
||||
268 | echo '</table>'; |
||||
269 | } |
||||
270 | xoops_cp_footer(); |
||||
0 ignored issues
–
show
The function
xoops_cp_footer 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
![]() |
|||||
271 | } |
||||
272 | |||||
273 | function mergeDuplicates() |
||||
274 | { |
||||
275 | global $xoopsDB, $eh; |
||||
276 | if (isset($_POST['merge'])) { |
||||
277 | $merge = $_POST['merge']; |
||||
278 | $merge_arr = explode('[|]', $merge); |
||||
279 | $replacements_arr = array_slice($merge_arr, 1); |
||||
280 | $replacements = ''; |
||||
281 | foreach ($replacements_arr as $key => $value) { |
||||
282 | $replacements .= '\'' . $value . '\','; |
||||
283 | } |
||||
284 | $length = strlen($replacements); |
||||
285 | $replacements = substr($replacements, 0, $length - 1); |
||||
286 | $sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes_x_cat') . ' SET dtypeid=' . $merge_arr[0] . ' WHERE dtypeid IN (' . $replacements . ')'; |
||||
287 | $xoopsDB->queryF($sql) or $eh->show('0013'); |
||||
288 | $sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . ' SET dtypeid=' . $merge_arr[0] . ' WHERE dtypeid IN (' . $replacements . ')'; |
||||
289 | $xoopsDB->queryF($sql) or $eh->show('0013'); |
||||
290 | $sql = 'DELETE FROM ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes') . ' WHERE dtypeid IN (' . $replacements . ')'; |
||||
291 | $xoopsDB->queryF($sql) or $eh->show('0013'); |
||||
292 | } else { |
||||
293 | $merge = ''; |
||||
294 | } |
||||
295 | redirect_header('main.php?op=duplicateDataTypes', 2, _MD_SAVED); |
||||
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
![]() |
|||||
296 | } |
||||
297 | |||||
298 | View Code Duplication | if (!isset($_POST['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. ![]() |
|||||
299 | $op = isset($_GET['op']) ? $_GET['op'] : 'main'; |
||||
300 | } else { |
||||
301 | $op = $_POST['op']; |
||||
302 | } |
||||
303 | switch ($op) { |
||||
304 | case 'approve': |
||||
305 | approve(); |
||||
306 | break; |
||||
307 | case 'deleteListingConfirm': |
||||
308 | delListingConfirm(); |
||||
309 | break; |
||||
310 | case 'deleteListing': |
||||
311 | delListing(); |
||||
312 | break; |
||||
313 | case 'delVote': |
||||
314 | delVote(); |
||||
315 | break; |
||||
316 | case 'listNewListings': |
||||
317 | listNewListings(); |
||||
318 | break; |
||||
319 | case 'updateItemType': |
||||
320 | updateItemType(); |
||||
321 | break; |
||||
322 | case 'duplicateDataTypes': |
||||
323 | listDuplicateDataTypes(); |
||||
324 | break; |
||||
325 | case 'mergeDuplicates': |
||||
326 | mergeDuplicates(); |
||||
327 | break; |
||||
328 | case 'edit': |
||||
329 | global $xoopsDB, $xoopsConfig, $myts, $eh, $efqtree, $moddir, $xoopsUser, $datafieldmanager, $subscription, $subscriptionhandler; |
||||
330 | $sql = 'SELECT i.itemid, i.logourl, i.uid, i.status, i.created, i.title, i.typeid, t.description FROM ' |
||||
331 | . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items') |
||||
332 | . ' i LEFT JOIN ' |
||||
333 | . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_text') |
||||
334 | . ' t ON (i.itemid=t.itemid) WHERE i.itemid=' |
||||
335 | . $get_itemid |
||||
336 | . ''; |
||||
337 | $item_result = $xoopsDB->query($sql); |
||||
338 | $numrows = $xoopsDB->getRowsNum($item_result); |
||||
339 | xoops_cp_header(); |
||||
0 ignored issues
–
show
The function
xoops_cp_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
![]() |
|||||
340 | //adminmenu(-1, _MD_A_MODADMIN_HOME); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
56% 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. ![]() |
|||||
341 | echo "<hr size='1'><br>"; |
||||
342 | while (list($itemid, $logourl, $submitter, $status, $created, $itemtitle, $typeid, $description) = $xoopsDB->fetchRow($item_result)) { |
||||
343 | if ($status == '1') { |
||||
344 | echo '<input type="button" value="' . _MD_APPROVE . "\" onclick=\"location='main.php?op=approve&item=$get_itemid'\"> "; |
||||
345 | } |
||||
346 | echo ' <input type="button" value="' |
||||
347 | . _MD_DELETE |
||||
348 | . "\" onClick=\"location='main.php?op=deleteListingConfirm&item=$get_itemid'\"> <input type=\"button\" value=\"" |
||||
349 | . _MD_VIEWITEM |
||||
350 | . "\" onclick=\"location='" |
||||
351 | . XOOPS_URL |
||||
0 ignored issues
–
show
|
|||||
352 | . '/modules/' |
||||
353 | . $moddir |
||||
354 | . "/listing.php?item=$get_itemid'\"><br><br>"; |
||||
355 | |||||
356 | $sql = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, d.customtitle, t.custom '; |
||||
357 | $sql .= 'FROM ' |
||||
358 | . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat') |
||||
359 | . ' ic, ' |
||||
360 | . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes_x_cat') |
||||
361 | . ' xc, ' |
||||
362 | . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_fieldtypes') |
||||
363 | . ' f, ' |
||||
364 | . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes') |
||||
365 | . ' t '; |
||||
366 | $sql .= 'LEFT JOIN ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $get_itemid . ') '; |
||||
367 | $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $get_itemid . ''; |
||||
368 | $data_result = $xoopsDB->query($sql) or $eh->show('0013'); |
||||
369 | $numrows = $xoopsDB->getRowsNum($data_result); |
||||
370 | |||||
371 | $form = new XoopsThemeForm(_MD_EDITITEM_FORM, 'editform', 'main.php'); |
||||
372 | $form->addElement(new XoopsFormText(_MD_TITLE, 'itemtitle', 50, 250, $itemtitle), 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 ![]() |
|||||
373 | //$categories = getCategoriesPaths($get_itemid); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
56% 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. ![]() |
|||||
374 | $get_dirid = getDirIdFromItem($itemid); |
||||
375 | $categories = getCatSelectArea($itemid, $get_dirid); |
||||
376 | $form_cats = new XoopsFormLabel(_MD_ITEMCATEGORIES, "$categories"); |
||||
377 | $form->addElement($form_cats); |
||||
378 | $form->addElement(new XoopsFormDhtmlTextArea(_MD_DESCRIPTION, 'description', $description, 5, 50)); |
||||
0 ignored issues
–
show
The type
XoopsFormDhtmlTextArea 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 ![]() |
|||||
379 | View Code Duplication | while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $itemid, $value, $customtitle, $custom) = $xoopsDB->fetchRow($data_result)) { |
|||
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. ![]() |
|||||
380 | $field = $datafieldmanager->createField($title, $dtypeid, $fieldtype, $ext, $options, $value, $custom, $customtitle); |
||||
381 | } |
||||
382 | $form->addElement(new XoopsFormButton('', 'submit', _MD_SAVE, 'submit')); |
||||
383 | $form->addElement(new XoopsFormHidden('op', 'save')); |
||||
384 | $form->addElement(new XoopsFormHidden('itemid', $get_itemid)); |
||||
385 | $form->addElement(new XoopsFormHidden('dirid', $get_dirid)); |
||||
386 | $form->addElement(new XoopsFormHidden('ini_itemtitle', $itemtitle)); |
||||
387 | $form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid'))); |
||||
388 | View Code Duplication | if ($description === false) { |
|||
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. ![]() |
|||||
389 | $form->addElement(new XoopsFormHidden('description_set', '0')); |
||||
390 | } else { |
||||
391 | $form->addElement(new XoopsFormHidden('description_set', '1')); |
||||
392 | } |
||||
393 | $form->display(); |
||||
394 | echo '<br>'; |
||||
395 | $itemtypes = $subscriptionhandler->itemTypesArray(); |
||||
396 | $form = new XoopsThemeForm(_MD_EDITITEMTYPE_FORM, 'edititemtypeform', 'main.php'); |
||||
397 | $itemtypes_select = new XoopsFormSelect(_MD_SELECT_ITEMTYPE, 'typeid', $typeid); |
||||
0 ignored issues
–
show
The type
XoopsFormSelect 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 ![]() |
|||||
398 | $itemtypes_select->addOptionArray($itemtypes); |
||||
399 | $form->addElement($itemtypes_select); |
||||
400 | $form->addElement(new XoopsFormButton('', 'submit', _MD_SAVE, 'submit')); |
||||
401 | $form->addElement(new XoopsFormHidden('op', 'updateItemType')); |
||||
402 | $form->addElement(new XoopsFormHidden('itemid', $get_itemid)); |
||||
403 | $form->addElement(new XoopsFormHidden('dirid', $get_dirid)); |
||||
404 | $form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid'))); |
||||
405 | $form->display(); |
||||
406 | } |
||||
407 | xoops_cp_footer(); |
||||
0 ignored issues
–
show
The function
xoops_cp_footer 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
![]() |
|||||
408 | break; |
||||
409 | case 'save': |
||||
410 | if (!empty($_POST['submit'])) { |
||||
411 | $submitter = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
||||
412 | |||||
413 | View Code Duplication | if (!empty($_POST['itemid'])) { |
|||
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. ![]() |
|||||
414 | $post_itemid = (int)$_POST['itemid']; |
||||
415 | } else { |
||||
416 | redirect_header('index.php', 2, _MD_NOVALIDITEM); |
||||
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
![]() |
|||||
417 | exit(); |
||||
418 | } |
||||
419 | if (isset($_POST['itemtitle'])) { |
||||
420 | $p_title = $myts->makeTboxData4Save($_POST['itemtitle']); |
||||
421 | $p_ini_title = $_POST['ini_itemtitle']; |
||||
422 | if ($p_title != $p_ini_title) { |
||||
423 | //If the posted title is different from the initial title the record should be updated. |
||||
424 | $sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items') . " SET title = '$p_title' WHERE itemid = $post_itemid"; |
||||
425 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
426 | } |
||||
427 | } else { |
||||
428 | redirect_header('index.php', 2, _MD_NOVALIDITEM); |
||||
429 | exit(); |
||||
430 | } |
||||
431 | View Code Duplication | if (!empty($_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. ![]() |
|||||
432 | $post_dirid = (int)$_POST['dirid']; |
||||
433 | } else { |
||||
434 | $post_dirid = 0; |
||||
435 | } |
||||
436 | View Code Duplication | if (isset($_POST['ini_description'])) { |
|||
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. ![]() |
|||||
437 | $p_ini_description = $myts->makeTareaData4Save($_POST['ini_description']); |
||||
438 | } else { |
||||
439 | $p_ini_description = null; |
||||
440 | } |
||||
441 | View Code Duplication | if (isset($_POST['description'])) { |
|||
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. ![]() |
|||||
442 | $p_description = $myts->makeTareaData4Save($_POST['description']); |
||||
443 | } else { |
||||
444 | $p_description = null; |
||||
445 | } |
||||
446 | if (isset($_POST['description_set'])) { |
||||
447 | if ($_POST['description_set'] == '1') { |
||||
448 | if ($p_ini_description != $p_description) { |
||||
449 | $sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_text') . " SET description = '$p_description' WHERE itemid = $post_itemid"; |
||||
450 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
451 | } |
||||
452 | } elseif (isset($_POST['description']) && $_POST['description'] != '') { |
||||
453 | if ($p_description != null) { |
||||
454 | $sql = sprintf("INSERT INTO %s (itemid, description) VALUES (%u, '%s')", $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_text'), $post_itemid, $p_description); |
||||
455 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
456 | } |
||||
457 | } |
||||
458 | } |
||||
459 | $sql = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value '; |
||||
460 | $sql .= 'FROM ' |
||||
461 | . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat') |
||||
462 | . ' ic, ' |
||||
463 | . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes_x_cat') |
||||
464 | . ' xc, ' |
||||
465 | . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_fieldtypes') |
||||
466 | . ' f, ' |
||||
467 | . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes') |
||||
468 | . ' t '; |
||||
469 | $sql .= 'LEFT JOIN ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $post_itemid . ') '; |
||||
470 | $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND ic.itemid=" . $post_itemid . ''; |
||||
471 | $data_result = $xoopsDB->query($sql) or $eh->show('0013'); |
||||
472 | $numrows = $xoopsDB->getRowsNum($data_result); |
||||
473 | while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $itemid, $value) = $xoopsDB->fetchRow($data_result)) { |
||||
474 | if (isset($_POST["$dtypeid"])) { |
||||
475 | if ($fieldtype == 'textarea' || 'dhtml') { |
||||
476 | $post_value = $myts->makeTareaData4Save($_POST["$dtypeid"]); |
||||
477 | } else { |
||||
478 | $post_value = $myts->makeTboxData4Save($_POST["$dtypeid"]); |
||||
479 | } |
||||
480 | } else { |
||||
481 | $post_value = ''; |
||||
482 | } |
||||
483 | |||||
484 | View Code Duplication | if (isset($_POST['custom' . $dtypeid . ''])) { |
|||
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. ![]() |
|||||
485 | $post_customtitle = $myts->makeTboxData4Save($_POST['custom' . $dtypeid . '']); |
||||
486 | } else { |
||||
487 | $post_customtitle = ''; |
||||
488 | } |
||||
489 | if ($fieldtype == 'address') { |
||||
490 | $addressfields = array('address', 'address2', 'zip', 'postcode', 'phone', 'lat', 'lon', 'phone', 'fax', 'mobile', 'city', 'country', 'uselocyn', 'main', 'active'); |
||||
491 | foreach ($addressfields as $field) { |
||||
492 | if (isset($_POST["$dtypeid$field"])) { |
||||
493 | ${'post_' . $field} = $myts->makeTboxData4Save($_POST["$dtypeid$field"]); |
||||
494 | } else { |
||||
495 | ${'post_' . $field} = ''; |
||||
496 | } |
||||
497 | } |
||||
498 | //INSERT OF UPDATE address |
||||
499 | //If INSERT, then get $newid and save it as the value in efqdiralpha1_data table |
||||
500 | if (isset($_POST['submitaddress'])) { |
||||
501 | if ($itemid == null || $post_value == '') { |
||||
502 | //That means there was not any value, so a new record should be added to the data table. |
||||
503 | $newaddrid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_addresses') . '_addrid_seq'); |
||||
504 | $sql = sprintf("INSERT INTO %s (addrid, itemid, dtypeid, address, address2, zip, postcode, phone, lat, lon, main, active, fax, mobile, city, country) VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %u, %u, '%s', '%s', '%s', '%s')", |
||||
505 | $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_addresses'), $newaddrid, $post_itemid, $dtypeid, $post_address, $post_address2, $post_zip, $post_postcode, $post_phone, $post_lat, $post_lon, $post_main, $post_active, $post_fax, $post_mobile, |
||||
506 | $post_city, $post_country); |
||||
507 | //echo $sql."<br><br>"; |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% 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. ![]() |
|||||
508 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
509 | $post_value = $xoopsDB->getInsertId(); |
||||
510 | } else { |
||||
511 | $sql = 'UPDATE ' |
||||
512 | . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_addresses') |
||||
513 | . " SET address = '$post_address', address2 = '$post_address2', zip = '$post_zip', postcode = '$post_postcode', lat = '$post_lat', lon = '$post_lon', main = '$post_main', active = '$post_active', fax = '$post_fax', mobile = '$post_mobile', city = '$post_city', country = '$post_country' WHERE addrid = '$post_value' AND itemid = '$post_itemid'"; |
||||
514 | //echo $sql."<br><br>"; |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% 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. ![]() |
|||||
515 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
516 | } |
||||
517 | } |
||||
518 | } |
||||
519 | View Code Duplication | if ($itemid == null) { |
|||
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. ![]() |
|||||
520 | //That means there was not any value, so a new record should be added to the data table. |
||||
521 | $newid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . '_dataid_seq'); |
||||
522 | $sql = sprintf("INSERT INTO %s (dataid, itemid, dtypeid, VALUE, created) VALUES (%u, %u, %u, '%s', '%s')", $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data'), $newid, $post_itemid, $dtypeid, $post_value, time()); |
||||
523 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
524 | } else { |
||||
525 | if ($value != $post_value) { |
||||
526 | $sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . " SET value = '$post_value' WHERE dtypeid = $dtypeid AND itemid = $itemid"; |
||||
527 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
528 | } |
||||
529 | } |
||||
530 | } |
||||
531 | |||||
532 | $efqlisting = new efqListing(); |
||||
533 | $efqlistinghandler = new efqListingHandler(); |
||||
534 | $linkedcats = $efqlistinghandler->getLinkedCatsArray($post_itemid, $post_dirid); |
||||
535 | $sql = 'SELECT cid FROM ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_cat') . " WHERE dirid='" . $post_dirid . '\' AND active=\'1\''; |
||||
536 | $allcatsresult = $xoopsDB->query($sql); |
||||
537 | |||||
538 | $numrows = $xoopsDB->getRowsNum($allcatsresult); |
||||
539 | $count = 0; |
||||
540 | View Code Duplication | if ($numrows > 0) { |
|||
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. ![]() |
|||||
541 | while (list($cid) = $xoopsDB->fetchRow($allcatsresult)) { |
||||
542 | if (isset($_POST['selected' . $cid . ''])) { |
||||
543 | if (!in_array($cid, $linkedcats)) { |
||||
544 | $newid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat') . '_xid_seq'); |
||||
545 | $sql = sprintf("INSERT INTO %s (xid, cid, itemid, active, created) VALUES (%u, %u, %u, '%s', '%s')", $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat'), $newid, $cid, $post_itemid, 1, time()); |
||||
546 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
547 | } |
||||
548 | |||||
549 | ++$count; |
||||
550 | } else { |
||||
551 | if (in_array($cid, $linkedcats)) { |
||||
552 | $sql = sprintf('DELETE FROM %s WHERE cid=%u AND itemid=%u', $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat'), $cid, $post_itemid); |
||||
553 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
554 | } |
||||
555 | } |
||||
556 | } |
||||
557 | if ($count == 0) { |
||||
558 | redirect_header(XOOPS_URL . "/modules/$moddir/admin/main.php?op=edit&item=" . $post_itemid . '', 2, _MD_NOCATEGORYMATCH); |
||||
559 | exit(); |
||||
560 | } |
||||
561 | } else { |
||||
562 | redirect_header(XOOPS_URL . "/modules/$moddir/admin/main.php?op=edit&item=" . $post_itemid . '', 2, _MD_NOCATEGORIESAVAILABLE); |
||||
0 ignored issues
–
show
|
|||||
563 | exit(); |
||||
564 | } |
||||
565 | |||||
566 | redirect_header("main.php?op=edit&item=$post_itemid", 2, _MD_ITEM_UPDATED); |
||||
567 | exit(); |
||||
568 | } |
||||
569 | break; |
||||
570 | default: |
||||
571 | listings(); |
||||
572 | break; |
||||
573 | } |
||||
574 | |||||
575 | function unique_events($array) |
||||
576 | { |
||||
577 | //checks $array for duplicate values and returns an |
||||
578 | //array containing the keys of duplicates |
||||
579 | $count = array_intersect_assoc($array, array_flip(array_count_values($array))); |
||||
580 | $return = array(); |
||||
581 | foreach ($array as $key => $value) { |
||||
582 | if (in_array($value, $count)) { |
||||
583 | $return[$value][] = $key; |
||||
584 | } |
||||
585 | } |
||||
586 | |||||
587 | return $return; |
||||
588 | } |
||||
589 |