These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /* |
||
3 | ------------------------------------------------------------------------- |
||
4 | ADSLIGHT 2 : Module for Xoops |
||
5 | |||
6 | Redesigned and ameliorate By Luc Bizet user at www.frxoops.org |
||
7 | Started with the Classifieds module and made MANY changes |
||
8 | Website : http://www.luc-bizet.fr |
||
9 | Contact : [email protected] |
||
10 | ------------------------------------------------------------------------- |
||
11 | Original credits below Version History |
||
12 | ########################################################################## |
||
13 | # Classified Module for Xoops # |
||
14 | # By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com # |
||
15 | # Started with the MyAds module and made MANY changes # |
||
16 | ########################################################################## |
||
17 | Original Author: Pascal Le Boustouller |
||
18 | Author Website : [email protected] |
||
19 | Licence Type : GPL |
||
20 | ------------------------------------------------------------------------- |
||
21 | */ |
||
22 | |||
23 | include_once __DIR__ . '/header.php'; |
||
24 | require_once XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php'; |
||
25 | //include XOOPS_ROOT_PATH . '/modules/adslight/class/utilities.php'; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
38% 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 | |||
27 | /** |
||
28 | * @param $lid |
||
29 | */ |
||
30 | function PrintAd($lid) |
||
31 | { |
||
32 | global $xoopsConfig, $xoopsUser, $xoopsDB, $xoopsModuleConfig, $useroffset, $myts, $xoopsLogger, $moduleDirName, $main_lang; |
||
1 ignored issue
–
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
}
}
![]() |
|||
33 | |||
34 | $currenttheme = $xoopsConfig['theme_set']; |
||
35 | $lid = (int)$lid; |
||
36 | |||
37 | $result = $xoopsDB->query('SELECT l.lid, l.title, l.expire, l.type, l.desctext, l.tel, l.price, l.typeprice, l.date, l.email, l.submitter, l.town, l.country, l.photo, p.cod_img, p.lid, p.uid_owner, p.url FROM ' |
||
38 | . $xoopsDB->prefix('adslight_listing') |
||
39 | . ' l LEFT JOIN ' |
||
40 | . $xoopsDB->prefix('adslight_pictures') |
||
41 | . ' p ON l.lid=p.lid WHERE l.lid=' |
||
42 | . $xoopsDB->escape($lid) |
||
43 | . ''); |
||
44 | list($lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date, $email, $submitter, $town, $country, $photo, $cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($result); |
||
0 ignored issues
–
show
The assignment to
$email is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() The assignment to
$cod_img is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() The assignment to
$pic_lid is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() The assignment to
$uid_owner is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() |
|||
45 | |||
46 | $title = $myts->htmlSpecialChars($title); |
||
47 | $expire = $myts->htmlSpecialChars($expire); |
||
48 | $type = AdslightUtilities::getNameType($myts->htmlSpecialChars($type)); |
||
49 | $desctext = $myts->displayTarea($desctext, 1, 1, 1, 1, 1); |
||
50 | $tel = $myts->htmlSpecialChars($tel); |
||
51 | $price = $myts->htmlSpecialChars($price); |
||
52 | $typeprice = $myts->htmlSpecialChars($typeprice); |
||
53 | $submitter = $myts->htmlSpecialChars($submitter); |
||
54 | $town = $myts->htmlSpecialChars($town); |
||
55 | $country = $myts->htmlSpecialChars($country); |
||
56 | |||
57 | echo ' |
||
58 | <html> |
||
59 | <head><title>' . $xoopsConfig['sitename'] . "</title> |
||
60 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> |
||
61 | <meta http-equiv=\”robots\” content=\"noindex, nofollow, noarchive\" /> |
||
62 | <link rel=\"StyleSheet\" href=\"../../themes/" . $currenttheme . "/style/style.css\" type=\"text/css\"> |
||
63 | </head> |
||
64 | <body bgcolor=\"#FFFFFF\" text=\"#000000\"> |
||
65 | <table border=0><tr><td> |
||
66 | <table border=0 width=100% cellpadding=0 cellspacing=1 bgcolor=\"#000000\"><tr><td> |
||
67 | <table border=0 width=100% cellpadding=15 cellspacing=1 bgcolor=\"#FFFFFF\"><tr><td>"; |
||
68 | |||
69 | $useroffset = 0; |
||
70 | if ($xoopsUser instanceof XoopsUser) { |
||
0 ignored issues
–
show
The class
XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
71 | $timezone = $xoopsUser->timezone(); |
||
72 | $useroffset = (!empty($timezone)) ? $xoopsUser->timezone() : $xoopsConfig['default_TZ']; |
||
73 | } |
||
74 | $date = ($useroffset * 3600) + $date; |
||
75 | $date2 = $date + ($expire * 86400); |
||
76 | $date = formatTimestamp($date, 's'); |
||
77 | $date2 = formatTimestamp($date2, 's'); |
||
78 | |||
79 | echo '<br><br><table width=99% border=0> |
||
80 | <tr> |
||
81 | <td>' . _ADSLIGHT_CLASSIFIED . " (No. $lid ) <br>" . _ADSLIGHT_FROM . " $submitter <br><br>"; |
||
82 | |||
83 | echo " <strong>$type :</strong> <i>$title</i><br>"; |
||
84 | if ($price > 0) { |
||
85 | echo '<strong>' . _ADSLIGHT_PRICE2 . "</strong> $price " . $xoopsModuleConfig['adslight_money'] . " - $typeprice<br>"; |
||
86 | } |
||
87 | if ($photo) { |
||
88 | echo "<tr><td><div style='text-align:left'><img class=\"thumb\" src=\"" . XOOPS_URL . "/uploads/AdsLight/$url\" width=\"130px\" border=0 /></div>"; |
||
89 | } |
||
90 | echo '</td> |
||
91 | </tr> |
||
92 | <tr> |
||
93 | <td><strong>' . _ADSLIGHT_DESC . "</strong><br><br><div style=\"text-align:justify;\">$desctext</div><p>"; |
||
94 | if ($tel) { |
||
95 | echo '<br><strong>' . _ADSLIGHT_TEL . "</strong> $tel"; |
||
96 | } |
||
97 | if ($town) { |
||
98 | echo '<br><strong>' . _ADSLIGHT_TOWN . "</strong> $town"; |
||
99 | } |
||
100 | if ($country) { |
||
101 | echo '<br><strong>' . _ADSLIGHT_COUNTRY . "</strong> $country"; |
||
102 | } |
||
103 | echo '<hr />'; |
||
104 | echo '' . _ADSLIGHT_NOMAIL . ' <br>' . XOOPS_URL . '/modules/adslight/viewads.php?lid=' . $lid . '<br>'; |
||
105 | echo '<br><br>' . _ADSLIGHT_DATE2 . " $date " . _ADSLIGHT_AND . ' ' . _ADSLIGHT_DISPO . " $date2<br><br>"; |
||
106 | echo '</td> |
||
107 | </tr> |
||
108 | </table>'; |
||
109 | echo '<br><br></td></tr></table></td></tr></table> |
||
110 | <br><br><div style="text-align:center"> |
||
111 | ' . _ADSLIGHT_EXTRANN . ' <strong>' . $xoopsConfig['sitename'] . "</strong></div><br> |
||
112 | <a href=\"" . XOOPS_URL . "/modules/adslight/\">" . XOOPS_URL . '/modules/adslight/</a> |
||
113 | </td></tr></table> |
||
114 | </body> |
||
115 | </html>'; |
||
116 | } |
||
117 | |||
118 | ############################################################## |
||
119 | |||
120 | $lid = XoopsRequest::getInt('lid', 0); |
||
121 | $op = XoopsRequest::getCmd('op', ''); |
||
122 | |||
123 | switch ($op) { |
||
124 | |||
125 | case 'PrintAd': |
||
126 | PrintAd($lid); |
||
127 | break; |
||
128 | |||
129 | default: |
||
130 | redirect_header('index.php', 3, '' . _RETURNGLO . ''); |
||
131 | break; |
||
132 | |||
133 | } |
||
134 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.