This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * |
||
5 | * Module: SmartPartner |
||
6 | * Author: The SmartFactory <www.smartfactory.ca> |
||
7 | * Licence: GNU |
||
8 | * @param $partnerObj |
||
9 | */ |
||
10 | function showfiles($partnerObj) |
||
11 | { |
||
12 | // UPLOAD FILES |
||
13 | //include_once XOOPS_ROOT_PATH . '/modules/smartpartner/include/functions.php'; |
||
14 | global $xoopsModule, $smartPartnerFileHandler; |
||
0 ignored issues
–
show
|
|||
15 | $pathIcon16 = '../' . $xoopsModule->getInfo('icons16'); |
||
16 | smartpartner_collapsableBar('filetable', 'filetableicon', _AM_SPARTNER_FILES_LINKED); |
||
17 | $filesObj = $smartPartnerFileHandler->getAllFiles($partnerObj->id()); |
||
18 | if (count($filesObj) > 0) { |
||
19 | echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>"; |
||
20 | echo '<tr>'; |
||
21 | echo "<td width='50' class='bg3' align='center'><b>ID</b></td>"; |
||
22 | echo "<td width='150' class='bg3' align='left'><b>" . _AM_SPARTNER_FILENAME . '</b></td>'; |
||
23 | echo "<td class='bg3' align='left'><b>" . _AM_SPARTNER_DESCRIPTION . '</b></td>'; |
||
24 | echo "<td width='60' class='bg3' align='center'><b>" . _AM_SPARTNER_HITS . '</b></td>'; |
||
25 | echo "<td width='100' class='bg3' align='center'><b>" . _AM_SPARTNER_UPLOADED_DATE . '</b></td>'; |
||
26 | echo "<td width='60' class='bg3' align='center'><b>" . _AM_SPARTNER_ACTION . '</b></td>'; |
||
27 | echo '</tr>'; |
||
28 | |||
29 | for ($i = 0, $iMax = count($filesObj); $i < $iMax; ++$i) { |
||
30 | $modify = "<a href='file.php?op=mod&fileid=" |
||
31 | . $filesObj[$i]->fileid() |
||
32 | . "'><img src='" |
||
33 | . $pathIcon16 |
||
34 | . '/edit.png' |
||
35 | . "' title='" |
||
36 | . _AM_SPARTNER_EDITFILE |
||
37 | . "' alt='" |
||
38 | . _AM_SPARTNER_EDITFILE |
||
39 | . "' /></a>"; |
||
40 | $delete = "<a href='file.php?op=del&fileid=" |
||
41 | . $filesObj[$i]->fileid() |
||
42 | . "'><img src='" |
||
43 | . $pathIcon16 |
||
44 | . '/delete.png' |
||
45 | . "' title='" |
||
46 | . _AM_SPARTNER_DELETEFILE |
||
47 | . "' alt='" |
||
48 | . _AM_SPARTNER_DELETEFILE |
||
49 | . "'/></a>"; |
||
50 | if ($filesObj[$i]->status() == 0) { |
||
51 | $not_visible = "<img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/no.gif'/>"; |
||
52 | } else { |
||
53 | $not_visible = ''; |
||
54 | } |
||
55 | echo '<tr>'; |
||
56 | echo "<td class='head' align='center'>" . $filesObj[$i]->getVar('fileid') . '</td>'; |
||
57 | echo "<td class='odd' align='left'>" . $not_visible . $filesObj[$i]->getFileLink() . '</td>'; |
||
58 | echo "<td class='even' align='left'>" . $filesObj[$i]->description() . '</td>'; |
||
59 | echo "<td class='even' align='center'>" . $filesObj[$i]->counter() . ''; |
||
60 | echo "<td class='even' align='center'>" . $filesObj[$i]->datesub() . '</td>'; |
||
61 | echo "<td class='even' align='center'> $modify $delete </td>"; |
||
62 | echo '</tr>'; |
||
63 | } |
||
64 | echo '</table>'; |
||
65 | echo '<br >'; |
||
66 | } else { |
||
67 | echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_SPARTNER_NOFILE . '</span>'; |
||
68 | } |
||
69 | |||
70 | echo "<form><div style=\"margin-bottom: 24px;\">"; |
||
71 | echo "<input type='button' name='button' onclick=\"location='file.php?op=mod&id=" . $partnerObj->id() . "'\" value='" . _AM_SPARTNER_UPLOAD_FILE_NEW . "'> "; |
||
72 | echo '</div></form>'; |
||
73 | |||
74 | smartpartner_close_collapsable('filetable', 'filetableicon'); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @param bool $showmenu |
||
79 | * @param int $id |
||
80 | */ |
||
81 | function editpartner($showmenu = false, $id = 0) |
||
82 | { |
||
83 | global $xoopsDB, $smartPartnerPartnerHandler, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
84 | if (!isset($smartPartnerPartnerHandler)) { |
||
85 | $smartPartnerPartnerHandler = smartpartner_gethandler('partner'); |
||
86 | } |
||
87 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
88 | // If there is a parameter, and the id exists, retrieve data: we're editing a partner |
||
89 | if ($id != 0) { |
||
90 | // Creating the partner object |
||
91 | $partnerObj = new SmartpartnerPartner($id); |
||
92 | |||
93 | if ($partnerObj->notLoaded()) { |
||
94 | redirect_header('partner.php', 1, _AM_SPARTNER_NOPARTNERSELECTED); |
||
95 | } |
||
96 | |||
97 | switch ($partnerObj->status()) { |
||
98 | |||
99 | case _SPARTNER_STATUS_SUBMITTED: |
||
100 | $breadcrumb_action1 = _AM_SPARTNER_SUBMITTED_PARTNERS; |
||
101 | $breadcrumb_action2 = _AM_SPARTNER_APPROVING; |
||
102 | $page_title = _AM_SPARTNER_SUBMITTED_TITLE; |
||
103 | $page_info = _AM_SPARTNER_SUBMITTED_INFO; |
||
104 | $button_caption = _AM_SPARTNER_APPROVE; |
||
105 | $new_status = _SPARTNER_STATUS_ACTIVE; |
||
106 | break; |
||
107 | |||
108 | case _SPARTNER_STATUS_ACTIVE: |
||
109 | $breadcrumb_action1 = _AM_SPARTNER_ACTIVE_PARTNERS; |
||
110 | $breadcrumb_action2 = _AM_SPARTNER_EDITING; |
||
111 | $page_title = _AM_SPARTNER_ACTIVE_EDITING; |
||
112 | $page_info = _AM_SPARTNER_ACTIVE_EDITING_INFO; |
||
113 | $button_caption = _AM_SPARTNER_MODIFY; |
||
114 | $new_status = _SPARTNER_STATUS_ACTIVE; |
||
115 | break; |
||
116 | |||
117 | case _SPARTNER_STATUS_INACTIVE: |
||
118 | $breadcrumb_action1 = _AM_SPARTNER_INACTIVE_PARTNERS; |
||
119 | $breadcrumb_action2 = _AM_SPARTNER_EDITING; |
||
120 | $page_title = _AM_SPARTNER_INACTIVE_EDITING; |
||
121 | $page_info = _AM_SPARTNER_INACTIVE_EDITING_INFO; |
||
122 | $button_caption = _AM_SPARTNER_MODIFY; |
||
123 | $new_status = _SPARTNER_STATUS_INACTIVE; |
||
124 | break; |
||
125 | |||
126 | case _SPARTNER_STATUS_REJECTED: |
||
127 | $breadcrumb_action1 = _AM_SPARTNER_REJECTED_PARTNERS; |
||
128 | $breadcrumb_action2 = _AM_SPARTNER_EDITING; |
||
129 | $page_title = _AM_SPARTNER_REJECTED_EDITING; |
||
130 | $page_info = _AM_SPARTNER_REJECTED_EDITING_INFO; |
||
131 | $button_caption = _AM_SPARTNER_MODIFY; |
||
132 | $new_status = _SPARTNER_STATUS_REJECTED; |
||
133 | break; |
||
134 | |||
135 | case 'default': |
||
136 | default: |
||
137 | break; |
||
138 | } |
||
139 | |||
140 | echo "<br>\n"; |
||
141 | smartpartner_collapsableBar('editpartner', 'editpartmericon', $page_title, $page_info); |
||
142 | } else { |
||
143 | // there's no parameter, so we're adding a partner |
||
144 | $partnerObj = $smartPartnerPartnerHandler->create(); |
||
145 | $breadcrumb_action1 = _AM_SPARTNER_PARTNERS; |
||
146 | $breadcrumb_action2 = _AM_SPARTNER_CREATE; |
||
147 | $button_caption = _AM_SPARTNER_CREATE; |
||
148 | $new_status = _SPARTNER_STATUS_ACTIVE; |
||
149 | smartpartner_collapsableBar('addpartner', 'addpartnericon', _AM_SPARTNER_PARTNER_CREATING, _AM_SPARTNER_PARTNER_CREATING_DSC); |
||
150 | } |
||
151 | |||
152 | // PARTNER FORM |
||
153 | $sform = new XoopsThemeForm(_AM_SPARTNER_PARTNERS, 'op', xoops_getenv('PHP_SELF')); |
||
154 | $sform->setExtra('enctype="multipart/form-data"'); |
||
155 | |||
156 | // TITLE |
||
157 | $title_text = new XoopsFormText(_AM_SPARTNER_TITLE, 'title', 50, 255, $partnerObj->title('e')); |
||
158 | $sform->addElement($title_text, true); |
||
159 | |||
160 | // Parent Category |
||
161 | $mytree = new SmartTree($xoopsDB->prefix('smartpartner_categories'), 'categoryid', 'parentid'); |
||
162 | ob_start(); |
||
163 | $mytree->makeMySelBox('name', 'weight', explode('|', $partnerObj->categoryid()), 0, 'categoryid', '', true); |
||
164 | //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="") |
||
165 | $parent_cat_select = new XoopsFormLabel(_AM_SPARTNER_CATEGORY_BELONG, ob_get_contents()); |
||
166 | $parent_cat_select->setDescription(_AM_SPARTNER_BELONG_CATEGORY_DSC); |
||
167 | $sform->addElement($parent_cat_select); |
||
168 | ob_end_clean(); |
||
169 | |||
170 | // LOGO |
||
171 | $logo_array = XoopsLists:: getImgListAsArray(smartpartner_getImageDir()); |
||
172 | $logo_select = new XoopsFormSelect('', 'image', $partnerObj->image()); |
||
173 | $logo_select->addOption('-1', '---------------'); |
||
174 | $logo_select->addOptionArray($logo_array); |
||
175 | $logo_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . SMARTPARTNER_DIRNAME . '/images' . "\", \"\", \"" . XOOPS_URL . "\")'"); |
||
176 | $logo_tray = new XoopsFormElementTray(_AM_SPARTNER_LOGO, ' '); |
||
177 | $logo_tray->addElement($logo_select); |
||
178 | $logo_tray->addElement(new XoopsFormLabel('', "<br><br><img src='" . smartpartner_getImageDir('', false) . $partnerObj->image() . "' name='image3' id='image3' alt='' />")); |
||
179 | $logo_tray->setDescription(_AM_SPARTNER_LOGO_DSC); |
||
180 | $sform->addElement($logo_tray); |
||
181 | |||
182 | // LOGO UPLOAD |
||
183 | $max_size = 5000000; |
||
184 | $file_box = new XoopsFormFile(_AM_SPARTNER_LOGO_UPLOAD, 'logo_file', $max_size); |
||
185 | $file_box->setExtra("size ='45'"); |
||
186 | $file_box->setDescription(sprintf(_AM_SPARTNER_LOGO_UPLOAD_DSC, $xoopsModuleConfig['img_max_width'], $xoopsModuleConfig['img_max_height'])); |
||
187 | $sform->addElement($file_box); |
||
188 | |||
189 | // IMAGE_URL |
||
190 | $image_url_text = new XoopsFormText(_CO_SPARTNER_IMAGE_URL, 'image_url', 50, 255, $partnerObj->image_url()); |
||
191 | $image_url_text->setDescription(_CO_SPARTNER_IMAGE_URL_DSC); |
||
192 | $sform->addElement($image_url_text, false); |
||
193 | |||
194 | // URL |
||
195 | $url_text = new XoopsFormText(_AM_SPARTNER_URL, 'url', 50, 255, $partnerObj->url()); |
||
196 | $url_text->setDescription(_AM_SPARTNER_URL_DSC); |
||
197 | $sform->addElement($url_text, false); |
||
198 | |||
199 | // SUMMARY |
||
200 | $summary_text = new XoopsFormTextArea(_AM_SPARTNER_SUMMARY, 'summary', $partnerObj->summary(0, 'e'), 7, 60); |
||
201 | $summary_text->setDescription(_AM_SPARTNER_SUMMARY_DSC); |
||
202 | $sform->addElement($summary_text, true); |
||
203 | |||
204 | // SHOW summary on partner page |
||
205 | $showsum_radio = new XoopsFormRadioYN(_AM_SPARTNER_SHOW_SUMMARY, 'showsummary', $partnerObj->getVar('showsummary')); |
||
206 | $showsum_radio->setDescription(_AM_SPARTNER_SHOW_SUMMARY_DSC); |
||
207 | $sform->addElement($showsum_radio); |
||
208 | |||
209 | // DESCRIPTION |
||
210 | $description_text = new XoopsFormDhtmlTextArea(_AM_SPARTNER_DESCRIPTION, 'description', $partnerObj->description(0, 'e'), 15, 60); |
||
211 | $description_text->setDescription(_AM_SPARTNER_DESCRIPTION_DSC); |
||
212 | $sform->addElement($description_text, false); |
||
213 | |||
214 | // CONTACT_NAME |
||
215 | $contact_name_text = new XoopsFormText(_CO_SPARTNER_CONTACT_NAME, 'contact_name', 50, 255, $partnerObj->contact_name('e')); |
||
216 | $contact_name_text->setDescription(_CO_SPARTNER_CONTACT_NAME_DSC); |
||
217 | $sform->addElement($contact_name_text, false); |
||
218 | |||
219 | // CONTACT_EMAIL |
||
220 | $contact_email_text = new XoopsFormText(_CO_SPARTNER_CONTACT_EMAIL, 'contact_email', 50, 255, $partnerObj->contact_email('e')); |
||
221 | $contact_email_text->setDescription(_CO_SPARTNER_CONTACT_EMAIL_DSC); |
||
222 | $sform->addElement($contact_email_text, false); |
||
223 | |||
224 | // EMAIL_PRIV |
||
225 | $email_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_EMAILPRIV, 'email_priv', $partnerObj->email_priv('e')); |
||
226 | $email_priv_radio->setDescription(_CO_SPARTNER_CONTACT_EMAILPRIV_DSC); |
||
227 | $sform->addElement($email_priv_radio); |
||
228 | |||
229 | // CONTACT_PHONE |
||
230 | $contact_phone_text = new XoopsFormText(_CO_SPARTNER_CONTACT_PHONE, 'contact_phone', 50, 255, $partnerObj->contact_phone('e')); |
||
231 | $contact_phone_text->setDescription(_CO_SPARTNER_CONTACT_PHONE_DSC); |
||
232 | $sform->addElement($contact_phone_text, false); |
||
233 | |||
234 | // PHONE_PRIV |
||
235 | $phone_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_PHONEPRIV, 'phone_priv', $partnerObj->phone_priv('e')); |
||
236 | $phone_priv_radio->setDescription(_CO_SPARTNER_CONTACT_PHONEPRIV_DSC); |
||
237 | $sform->addElement($phone_priv_radio); |
||
238 | |||
239 | // ADRESS |
||
240 | //$adress_text = new XoopsFormText(_CO_SPARTNER_ADRESS, 'adress', 50, 255, $partnerObj->adress('e')); |
||
241 | $adress_text = new XoopsFormTextArea(_CO_SPARTNER_ADRESS, 'adress', $partnerObj->adress('e')); |
||
242 | $adress_text->setDescription(_CO_SPARTNER_ADRESS_DSC); |
||
243 | $sform->addElement($adress_text, false); |
||
244 | |||
245 | // ADRESS_PRIV |
||
246 | $adress_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_ADRESSPRIV, 'adress_priv', $partnerObj->adress_priv('e')); |
||
247 | $adress_priv_radio->setDescription(_CO_SPARTNER_CONTACT_ADRESSPRIV_DSC); |
||
248 | $sform->addElement($adress_priv_radio); |
||
249 | |||
250 | // STATUS |
||
251 | $options = $partnerObj->getAvailableStatus(); |
||
252 | $status_select = new XoopsFormSelect(_AM_SPARTNER_STATUS, 'status', $new_status); |
||
253 | $status_select->addOptionArray($options); |
||
254 | $status_select->setDescription(_AM_SPARTNER_STATUS_DSC); |
||
255 | $sform->addElement($status_select); |
||
256 | |||
257 | // WEIGHT |
||
258 | $weight_text = new XoopsFormText(_AM_SPARTNER_WEIGHT, 'weight', 4, 4, $partnerObj->weight()); |
||
259 | $weight_text->setDescription(_AM_SPARTNER_WEIGHT_DSC); |
||
260 | $sform->addElement($weight_text); |
||
261 | |||
262 | //perms |
||
263 | global $smartPermissionsHandler; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
264 | include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectpermission.php'; |
||
265 | $smartPermissionsHandler = new SmartobjectPermissionHandler($smartPartnerPartnerHandler); |
||
266 | |||
267 | if ($partnerObj->id() != 0) { |
||
268 | $grantedGroups = $smartPermissionsHandler->getGrantedGroups('full_view', $partnerObj->id()); |
||
269 | } else { |
||
270 | $grantedGroups = $xoopsModuleConfig['default_full_view']; |
||
271 | } |
||
272 | $full_view_select = new XoopsFormSelectGroup(_CO_SPARTNER_FULL_PERM_READ, 'full_view', true, $grantedGroups, 5, true); |
||
273 | $full_view_select->setDescription(_CO_SPARTNER_FULL_PERM_READ_DSC); |
||
274 | $sform->addElement($full_view_select); |
||
275 | |||
276 | if ($partnerObj->id() != 0) { |
||
277 | $partGrantedGroups = $smartPermissionsHandler->getGrantedGroups('partial_view', $partnerObj->id()); |
||
278 | } else { |
||
279 | $partGrantedGroups = $xoopsModuleConfig['default_part_view']; |
||
280 | } |
||
281 | $part_view_select = new XoopsFormSelectGroup(_CO_SPARTNER_PART_PERM_READ, 'partial_view', true, $partGrantedGroups, 5, true); |
||
282 | $part_view_select->setDescription(_CO_SPARTNER_PART_PERM_READ_DSC); |
||
283 | $sform->addElement($part_view_select); |
||
284 | |||
285 | // Partner id |
||
286 | $sform->addElement(new XoopsFormHidden('id', $partnerObj->id())); |
||
287 | |||
288 | $button_tray = new XoopsFormElementTray('', ''); |
||
289 | $hidden = new XoopsFormHidden('op', 'addpartner'); |
||
290 | $button_tray->addElement($hidden); |
||
291 | |||
292 | $sform->addElement(new XoopsFormHidden('original_status', $partnerObj->status())); |
||
293 | |||
294 | if (!$id) { |
||
295 | // there's no id? Then it's a new partner |
||
296 | // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_CREATE, 'submit' ) ); |
||
297 | $butt_create = new XoopsFormButton('', '', _AM_SPARTNER_CREATE, 'submit'); |
||
298 | $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"'); |
||
299 | $button_tray->addElement($butt_create); |
||
300 | |||
301 | $butt_clear = new XoopsFormButton('', '', _AM_SPARTNER_CLEAR, 'reset'); |
||
302 | $button_tray->addElement($butt_clear); |
||
303 | |||
304 | $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); |
||
305 | $butt_cancel->setExtra('onclick="history.go(-1)"'); |
||
306 | $button_tray->addElement($butt_cancel); |
||
307 | } else { |
||
308 | // else, we're editing an existing partner |
||
309 | // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_MODIFY, 'submit' ) ); |
||
310 | $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); |
||
311 | $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"'); |
||
312 | $button_tray->addElement($butt_create); |
||
313 | |||
314 | $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); |
||
315 | $butt_cancel->setExtra('onclick="history.go(-1)"'); |
||
316 | $button_tray->addElement($butt_cancel); |
||
317 | } |
||
318 | |||
319 | $sform->addElement($button_tray); |
||
320 | $sform->display(); |
||
321 | unset($hidden); |
||
322 | if (!$id) { |
||
323 | smartpartner_close_collapsable('addpartner', 'addpartnericon'); |
||
324 | } else { |
||
325 | smartpartner_close_collapsable('editpartner', 'editpartnericon'); |
||
326 | } |
||
327 | if ($id != 0) { |
||
328 | showfiles($partnerObj); |
||
329 | } |
||
330 | } |
||
331 | |||
332 | include_once __DIR__ . '/admin_header.php'; |
||
333 | include(XOOPS_ROOT_PATH . '/class/xoopstree.php'); |
||
334 | |||
335 | $op = ''; |
||
336 | if (isset($_GET['op'])) { |
||
337 | $op = $_GET['op']; |
||
338 | } |
||
339 | if (isset($_POST['op'])) { |
||
340 | $op = $_POST['op']; |
||
341 | } |
||
342 | |||
343 | // Where shall we start ? |
||
344 | $startpartner = isset($_GET['startpartner']) ? (int)$_GET['startpartner'] : 0; |
||
345 | |||
346 | if (!isset($smartPartnerPartnerHandler)) { |
||
347 | $smartPartnerPartnerHandler = smartpartner_gethandler('partner'); |
||
348 | } |
||
349 | /* -- Available operations -- */ |
||
350 | switch ($op) { |
||
351 | case 'add': |
||
352 | xoops_cp_header(); |
||
353 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
354 | |||
355 | editpartner(true, 0); |
||
356 | break; |
||
357 | |||
358 | case 'mod': |
||
359 | global $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
360 | $id = isset($_GET['id']) ? $_GET['id'] : 0; |
||
361 | |||
362 | xoops_cp_header(); |
||
363 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
364 | |||
365 | editpartner(true, $id); |
||
366 | break; |
||
367 | |||
368 | case 'addpartner': |
||
369 | global $xoopsUser; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
370 | |||
371 | if (!$xoopsUser) { |
||
372 | if ($xoopsModuleConfig['anonpost'] == 1) { |
||
373 | $uid = 0; |
||
374 | } else { |
||
375 | redirect_header('index.php', 3, _NOPERM); |
||
376 | } |
||
377 | } else { |
||
378 | $uid = $xoopsUser->uid(); |
||
379 | } |
||
380 | |||
381 | $id = isset($_POST['id']) ? (int)$_POST['id'] : 0; |
||
382 | |||
383 | // Creating the partner object |
||
384 | if ($id != 0) { |
||
385 | $partnerObj = new SmartpartnerPartner($id); |
||
386 | } else { |
||
387 | $partnerObj = $smartPartnerPartnerHandler->create(); |
||
388 | } |
||
389 | |||
390 | // Uploading the logo, if any |
||
391 | // Retreive the filename to be uploaded |
||
392 | if ($_FILES['logo_file']['name'] != '') { |
||
393 | $filename = $_POST['xoops_upload_file'][0]; |
||
394 | View Code Duplication | if (!empty($filename) || $filename != '') { |
|
395 | global $xoopsModuleConfig; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
396 | |||
397 | $max_size = 10000000; |
||
398 | $max_imgwidth = $xoopsModuleConfig['img_max_width']; |
||
399 | $max_imgheight = $xoopsModuleConfig['img_max_height']; |
||
400 | $allowed_mimetypes = null; //smartpartner_getAllowedMimeTypes(); |
||
401 | |||
402 | include_once(XOOPS_ROOT_PATH . '/class/uploader.php'); |
||
403 | |||
404 | if ($_FILES[$filename]['tmp_name'] == '' || !is_readable($_FILES[$filename]['tmp_name'])) { |
||
405 | redirect_header('javascript:history.go(-1)', 2, _CO_SPARTNER_FILE_UPLOAD_ERROR); |
||
406 | exit; |
||
407 | } |
||
408 | |||
409 | $uploader = new XoopsMediaUploader(smartpartner_getImageDir(), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); |
||
410 | |||
411 | // TODO: prefix the image file with the partnerid, but for that we need to first save the partner to get partnerid... |
||
412 | // $uploader->setTargetFileName($partnerObj->partnerid() . "_" . $_FILES['logo_file']['name']); |
||
413 | |||
414 | if ($uploader->fetchMedia($filename) && $uploader->upload()) { |
||
415 | $partnerObj->setVar('image', $uploader->getSavedFileName()); |
||
416 | } else { |
||
417 | redirect_header('javascript:history.go(-1)', 2, _CO_SPARTNER_FILE_UPLOAD_ERROR . $uploader->getErrors()); |
||
418 | exit; |
||
419 | } |
||
420 | } |
||
421 | } else { |
||
422 | $partnerObj->setVar('image', $_POST['image']); |
||
423 | } |
||
424 | |||
425 | // Putting the values in the partner object |
||
426 | $partnerObj->setVar('id', isset($_POST['id']) ? (int)$_POST['id'] : 0); |
||
427 | $partnerObj->setVar('categoryid', isset($_POST['categoryid']) ? implode('|', $_POST['categoryid']) : array(0)); |
||
428 | $partnerObj->setVar('status', isset($_POST['status']) ? (int)$_POST['status'] : 0); |
||
429 | $partnerObj->setVar('title', $_POST['title']); |
||
430 | $partnerObj->setVar('summary', $_POST['summary']); |
||
431 | $partnerObj->setVar('image_url', $_POST['image_url']); |
||
432 | $partnerObj->setVar('description', $_POST['description']); |
||
433 | $partnerObj->setVar('contact_name', $_POST['contact_name']); |
||
434 | $partnerObj->setVar('contact_email', $_POST['contact_email']); |
||
435 | $partnerObj->setVar('contact_phone', $_POST['contact_phone']); |
||
436 | $partnerObj->setVar('adress', $_POST['adress']); |
||
437 | $partnerObj->setVar('url', $_POST['url']); |
||
438 | $partnerObj->setVar('weight', isset($_POST['weight']) ? (int)$_POST['weight'] : 0); |
||
439 | $partnerObj->setVar('email_priv', isset($_POST['email_priv']) ? (int)$_POST['email_priv'] : 0); |
||
440 | $partnerObj->setVar('phone_priv', isset($_POST['phone_priv']) ? (int)$_POST['phone_priv'] : 0); |
||
441 | $partnerObj->setVar('adress_priv', isset($_POST['adress_priv']) ? (int)$_POST['adress_priv'] : 0); |
||
442 | $partnerObj->setVar('showsummary', isset($_POST['showsummary']) ? (int)$_POST['showsummary'] : 0); |
||
443 | |||
444 | $redirect_msgs = $partnerObj->getRedirectMsg($_POST['original_status'], $_POST['status']); |
||
445 | |||
446 | // Storing the partner |
||
447 | if (!$partnerObj->store()) { |
||
448 | redirect_header('javascript:history.go(-1)', 3, $redirect_msgs['error'] . smartpartner_formatErrors($partnerObj->getErrors())); |
||
449 | } |
||
450 | |||
451 | if (($_POST['original_status'] == _SPARTNER_STATUS_SUBMITTED) || ($_POST['status'] == _SPARTNER_STATUS_ACTIVE)) { |
||
452 | $partnerObj->sendNotifications(array(_SPARTNER_NOT_PARTNER_APPROVED)); |
||
453 | } |
||
454 | if ($partnerObj->isNew()) { |
||
455 | $partnerObj->sendNotifications(array(_SPARTNER_NOT_PARTNER_NEW)); |
||
456 | } |
||
457 | redirect_header('partner.php', 2, $redirect_msgs['success']); |
||
458 | |||
459 | break; |
||
460 | |||
461 | View Code Duplication | case 'del': |
|
462 | global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $_GET; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
463 | |||
464 | $module_id = $xoopsModule->getVar('mid'); |
||
465 | $gpermHandler = xoops_getHandler('groupperm'); |
||
466 | |||
467 | $id = isset($_POST['id']) ? (int)$_POST['id'] : 0; |
||
468 | $id = isset($_GET['id']) ? (int)$_GET['id'] : $id; |
||
469 | |||
470 | $partnerObj = new SmartpartnerPartner($id); |
||
471 | |||
472 | $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0; |
||
473 | $title = isset($_POST['title']) ? $_POST['title'] : ''; |
||
474 | |||
475 | if ($confirm) { |
||
476 | if (!$smartPartnerPartnerHandler->delete($partnerObj)) { |
||
477 | redirect_header('partner.php', 2, _AM_SPARTNER_PARTNER_DELETE_ERROR); |
||
478 | exit; |
||
479 | } |
||
480 | |||
481 | redirect_header('partner.php', 2, sprintf(_AM_SPARTNER_PARTNER_DELETE_SUCCESS, $partnerObj->title())); |
||
482 | } else { |
||
483 | // no confirm: show deletion condition |
||
484 | $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
||
485 | xoops_cp_header(); |
||
486 | xoops_confirm(array('op' => 'del', 'id' => $partnerObj->id(), 'confirm' => 1, 'name' => $partnerObj->title()), 'partner.php', |
||
487 | _AM_SPARTNER_DELETETHISP . " <br>'" . $partnerObj->title() . "' <br> <br>", _AM_SPARTNER_DELETE); |
||
488 | xoops_cp_footer(); |
||
489 | } |
||
490 | |||
491 | exit(); |
||
492 | break; |
||
493 | |||
494 | case 'default': |
||
495 | default: |
||
496 | smartpartner_xoops_cp_header(); |
||
497 | $indexAdmin = new ModuleAdmin(); |
||
498 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
||
499 | |||
500 | $indexAdmin->addItemButton(_AM_SPARTNER_PARTNER_CREATE, 'partner.php?op=add', 'add', ''); |
||
501 | echo $indexAdmin->renderButton('left', ''); |
||
502 | |||
503 | // echo "<br>\n"; |
||
504 | // echo "<form><div style=\"margin-bottom: 12px;\">"; |
||
505 | // echo "<input type='button' name='button' onclick=\"location='partner.php?op=mod'\" value='" . _AM_SPARTNER_PARTNER_CREATE . "'> "; |
||
506 | // echo "</div></form>"; |
||
507 | |||
508 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
509 | include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
510 | |||
511 | global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig, $xoopsModule; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
512 | |||
513 | smartpartner_collapsableBar('partners', 'partnersicon', _AM_SPARTNER_ACTIVE_PARTNERS, _AM_SPARTNER_ACTIVE_PARTNERS_DSC); |
||
514 | |||
515 | // Get the total number of published PARTNER |
||
516 | $totalpartners = $smartPartnerPartnerHandler->getPartnerCount(_SPARTNER_STATUS_ACTIVE); |
||
517 | // creating the partner objects that are published |
||
518 | $partnersObj = $smartPartnerPartnerHandler->getPartners($xoopsModuleConfig['perpage_admin'], $startpartner); |
||
519 | $totalPartnersOnPage = count($partnersObj); |
||
520 | |||
521 | echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>"; |
||
522 | echo '<tr>'; |
||
523 | echo "<td class='bg3' width='200px' align='left'><b>" . _AM_SPARTNER_NAME . '</b></td>'; |
||
524 | echo "<td width='' class='bg3' align='left'><b>" . _AM_SPARTNER_INTRO . '</b></td>'; |
||
525 | echo "<td width='90' class='bg3' align='center'><b>" . _AM_SPARTNER_HITS . '</b></td>'; |
||
526 | echo "<td width='90' class='bg3' align='center'><b>" . _AM_SPARTNER_STATUS . '</b></td>'; |
||
527 | echo "<td width='90' class='bg3' align='center'><b>" . _AM_SPARTNER_ACTION . '</b></td>'; |
||
528 | echo '</tr>'; |
||
529 | if ($totalpartners > 0) { |
||
530 | for ($i = 0; $i < $totalPartnersOnPage; ++$i) { |
||
531 | $modify = "<a href='partner.php?op=mod&id=" |
||
532 | . $partnersObj[$i]->id() |
||
533 | . "'><img src='" |
||
534 | . $pathIcon16 |
||
535 | . '/edit.png' |
||
536 | . "' title='" |
||
537 | . _AM_SPARTNER_EDITPARTNER |
||
538 | . "' alt='" |
||
539 | . _AM_SPARTNER_EDITPARTNER |
||
540 | . "' /></a> "; |
||
541 | $delete = "<a href='partner.php?op=del&id=" |
||
542 | . $partnersObj[$i]->id() |
||
543 | . "'><img src='" |
||
544 | . $pathIcon16 |
||
545 | . '/delete.png' |
||
546 | . "' title='" |
||
547 | . _AM_SPARTNER_DELETEPARTNER |
||
548 | . "' alt='" |
||
549 | . _AM_SPARTNER_DELETEPARTNER |
||
550 | . "'/></a> "; |
||
551 | |||
552 | echo '<tr>'; |
||
553 | echo "<td class='head' align='left'><a href='" |
||
554 | . SMARTPARTNER_URL |
||
555 | . 'partner.php?id=' |
||
556 | . $partnersObj[$i]->id() |
||
557 | . "'><img src='" |
||
558 | . SMARTPARTNER_URL |
||
559 | . "assets/images/links/partner.gif' alt=''/> " |
||
560 | . $partnersObj[$i]->title() |
||
561 | . '</a></td>'; |
||
562 | echo "<td class='even' align='left'>" . $partnersObj[$i]->summary(100) . '</td>'; |
||
563 | echo "<td class='even' align='center'>" . $partnersObj[$i]->hits() . '</td>'; |
||
564 | echo "<td class='even' align='center'>" . $partnersObj[$i]->getStatusName() . '</td>'; |
||
565 | echo "<td class='even' align='center'> " . $modify . $delete . '</td>'; |
||
566 | echo '</tr>'; |
||
567 | } |
||
568 | } else { |
||
569 | $id = 0; |
||
570 | echo '<tr>'; |
||
571 | echo "<td class='head' align='center' colspan= '7'>" . _AM_SPARTNER_NOPARTNERS . '</td>'; |
||
572 | echo '</tr>'; |
||
573 | } |
||
574 | echo "</table>\n"; |
||
575 | echo "<br>\n"; |
||
576 | |||
577 | $pagenav = new XoopsPageNav($totalpartners, $xoopsModuleConfig['perpage_admin'], $startpartner, 'startpartner'); |
||
578 | echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>'; |
||
579 | |||
580 | smartpartner_close_collapsable('partners', 'partnersicon'); |
||
581 | |||
582 | break; |
||
583 | } |
||
584 | //smart_modFooter(); |
||
585 | //xoops_cp_footer(); |
||
586 | include_once __DIR__ . '/admin_footer.php'; |
||
587 |
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state