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 | include_once __DIR__ . '/header.php'; |
||
23 | require XOOPS_ROOT_PATH.'/modules/adslight/include/gtickets.php'; |
||
24 | include XOOPS_ROOT_PATH.'/modules/adslight/include/functions.php'; |
||
25 | |||
26 | /** |
||
27 | * @param $lid |
||
28 | */ |
||
29 | function SendFriend($lid) |
||
30 | { |
||
31 | global $xoopsConfig, $xoopsModuleConfig, $xoopsDB, $xoopsUser, $xoopsTheme, $xoopsLogger, $moduleDirName, $main_lang; |
||
32 | |||
33 | include XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
||
34 | include XOOPS_ROOT_PATH."/header.php"; |
||
35 | $xoTheme -> addMeta ( 'meta', 'robots', 'noindex, nofollow'); |
||
36 | |||
37 | $result = $xoopsDB->query("select lid, title, type FROM ".$xoopsDB->prefix("adslight_listing")." where lid=".mysql_real_escape_string($lid).""); |
||
38 | list($lid, $title, $type) = $xoopsDB->fetchRow($result); |
||
39 | |||
40 | echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'> |
||
41 | <strong>"._ADSLIGHT_SENDTO." $lid \"<strong>$type : $title</strong>\" "._ADSLIGHT_FRIEND."<br /><br /> |
||
42 | <form action=\"sendfriend.php\" method=post> |
||
43 | <input type=\"hidden\" name=\"lid\" value=\"$lid\" />"; |
||
44 | |||
45 | if ($xoopsUser) { |
||
46 | $idd = $xoopsUser->getVar("uname", "E"); |
||
47 | $idde = $xoopsUser->getVar("email", "E"); |
||
48 | } |
||
49 | |||
50 | echo " |
||
51 | <table width='99%' class='outer' cellspacing='1'> |
||
52 | <tr> |
||
53 | <td class='head' width='30%'>"._ADSLIGHT_NAME." </td> |
||
54 | <td class='even'><input class='textbox' type='text' name='yname' value='$idd' /></td> |
||
55 | </tr> |
||
56 | <tr> |
||
57 | <td class='head'>"._ADSLIGHT_MAIL." </td> |
||
58 | <td class='even'><input class='textbox' type='text' name='ymail' value='$idde' /></td> |
||
59 | </tr> |
||
60 | <tr> |
||
61 | <td class='head'>"._ADSLIGHT_NAMEFR." </td> |
||
62 | <td class='even'><input class='textbox' type='text' name='fname' /></td> |
||
63 | </tr> |
||
64 | <tr> |
||
65 | <td class='head'>"._ADSLIGHT_MAILFR." </td> |
||
66 | <td class='even'><input class='textbox' type='text' name='fmail' /></td> |
||
67 | </tr>"; |
||
68 | |||
69 | View Code Duplication | if ($xoopsModuleConfig["adslight_use_captcha"] == '1') { |
|
1 ignored issue
–
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. ![]() |
|||
70 | echo "<tr><td class='head'>"._ADSLIGHT_CAPTCHA." </td><td class='even'>"; |
||
71 | $jlm_captcha = ""; |
||
72 | $jlm_captcha = (new XoopsFormCaptcha(_ADSLIGHT_CAPTCHA, "xoopscaptcha", false)); |
||
73 | echo $jlm_captcha->render(); |
||
74 | echo '</td></tr>'; |
||
75 | } |
||
76 | |||
77 | echo "</table><br /> |
||
78 | <input type=hidden name=op value=MailAd> |
||
79 | <input type=submit value="._ADSLIGHT_SENDFR."> |
||
80 | </form></td></tr></table>"; |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @param $lid |
||
85 | * @param $yname |
||
86 | * @param $ymail |
||
87 | * @param $fname |
||
88 | * @param $fmail |
||
89 | */ |
||
90 | View Code Duplication | function MailAd($lid, $yname, $ymail, $fname, $fmail) |
|
0 ignored issues
–
show
The function
MailAd() has been defined more than once; this definition is ignored, only the first definition in report-abuse.php (L89-160) is considered.
This check looks for functions that have already been defined in other files. Some Codebases, like WordPress, make a practice of defining functions multiple times. This
may lead to problems with the detection of function parameters and types. If you really
need to do this, you can mark the duplicate definition with the /**
* @ignore
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. ![]() |
|||
91 | { |
||
92 | global $xoopsConfig, $xoopsUser, $xoopsTpl, $xoopsDB, $xoopsModule, $xoopsModuleConfig, $myts, $xoopsLogger, $moduleDirName, $main_lang; |
||
93 | |||
94 | if ($xoopsModuleConfig["adslight_use_captcha"] == '1') { |
||
95 | xoops_load("xoopscaptcha"); |
||
96 | $xoopsCaptcha = XoopsCaptcha::getInstance(); |
||
97 | if ( !$xoopsCaptcha->verify() ) { |
||
98 | redirect_header( XOOPS_URL . "/modules/adslight/index.php", 2, $xoopsCaptcha->getMessage() ); |
||
99 | } |
||
100 | } |
||
101 | |||
102 | $result = $xoopsDB->query("select lid, title, expire, type, desctext, tel, price, typeprice, date, email, submitter, town, country, photo FROM ".$xoopsDB->prefix("adslight_listing")." where lid=".mysql_real_escape_string($lid).""); |
||
103 | list($lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date, $email, $submitter, $town, $country, $photo) = $xoopsDB->fetchRow($result); |
||
104 | |||
105 | $title = $myts->addSlashes($title); |
||
106 | $expire = $myts->addSlashes($expire); |
||
107 | $type = $myts->addSlashes($type); |
||
108 | $desctext = $myts->displayTarea($desctext, 1, 1, 1, 1, 1); |
||
109 | $tel = $myts->addSlashes($tel); |
||
110 | $price = $myts->addSlashes($price); |
||
111 | $typeprice = $myts->addSlashes($typeprice); |
||
112 | $submitter = $myts->addSlashes($submitter); |
||
113 | $town = $myts->addSlashes($town); |
||
114 | $country = $myts->addSlashes($country); |
||
115 | |||
116 | $tags = array(); |
||
117 | $tags['YNAME'] = stripslashes($yname); |
||
118 | $tags['YMAIL'] = $ymail; |
||
119 | $tags['FNAME'] = stripslashes($fname); |
||
120 | $tags['FMAIL'] = $fmail; |
||
121 | $tags['HELLO'] = _ADSLIGHT_HELLO; |
||
122 | $tags['LID'] = $lid; |
||
123 | $tags['LISTING_NUMBER'] = _ADSLIGHT_LISTING_NUMBER; |
||
124 | $tags['TITLE'] = $title; |
||
125 | $tags['TYPE'] = adslight_NameType($type); |
||
126 | $tags['DESCTEXT'] = $desctext; |
||
127 | $tags['PRICE'] = $price; |
||
128 | $tags['TYPEPRICE'] = $typeprice; |
||
129 | $tags['TEL'] = $tel; |
||
130 | $tags['TOWN'] = $town; |
||
131 | $tags['COUNTRY'] = $country; |
||
132 | $tags['OTHER'] = ""._ADSLIGHT_INTERESS."". $xoopsConfig['sitename'].""; |
||
133 | $tags['LISTINGS'] = "".XOOPS_URL."/modules/adslight/"; |
||
134 | $tags['LINK_URL'] = "".XOOPS_URL."/modules/adslight/viewads.php?lid=".$lid.""; |
||
135 | $tags['THINKS_INTERESTING'] = ""._ADSLIGHT_MESSAGE.""; |
||
136 | $tags['NO_MAIL'] = ""._ADSLIGHT_NOMAIL.""; |
||
137 | $tags['YOU_CAN_VIEW_BELOW'] = ""._ADSLIGHT_YOU_CAN_VIEW_BELOW.""; |
||
138 | $tags['WEBMASTER'] = _ADSLIGHT_WEBMASTER; |
||
139 | $tags['NO_REPLY'] = _ADSLIGHT_NOREPLY; |
||
140 | $subject = ""._ADSLIGHT_SUBJET." ".$xoopsConfig['sitename'].""; |
||
141 | $xoopsMailer =& xoops_getMailer(); |
||
142 | $xoopsMailer->multimailer->isHTML(true); |
||
143 | $xoopsMailer->useMail(); |
||
144 | $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH."/modules/". $xoopsModule->getVar('dirname') ."/language/".$xoopsConfig['language']."/mail_template/"); |
||
145 | |||
146 | $xoopsMailer->setTemplate("listing_send_friend.tpl"); |
||
147 | $xoopsMailer->setFromEmail($ymail); |
||
148 | $xoopsMailer->setToEmails($fmail); |
||
149 | $xoopsMailer->setSubject($subject); |
||
150 | $xoopsMailer->assign($tags); |
||
151 | $xoopsMailer->send(); |
||
152 | echo $xoopsMailer->getErrors(); |
||
153 | |||
154 | redirect_header("index.php",3,_ADSLIGHT_ANNSEND); |
||
155 | exit(); |
||
0 ignored issues
–
show
The function MailAd() contains an exit expression.
An exit expression should only be used in rare cases. For example, if you write a short command line script. In most cases however, using an ![]() |
|||
156 | } |
||
157 | |||
158 | ############################################################## |
||
159 | $yname = !empty($_POST['yname']) ? $myts->addSlashes($_POST['yname']) : ""; |
||
160 | $ymail = !empty($_POST['ymail']) ? $myts->addSlashes($_POST['ymail']) : ""; |
||
161 | $fname = !empty($_POST['fname']) ? $myts->addSlashes($_POST['fname']) : ""; |
||
162 | $fmail = !empty($_POST['fmail']) ? $myts->addSlashes($_POST['fmail']) : ""; |
||
163 | |||
164 | View Code Duplication | if (!isset($_POST['lid']) && isset($_GET['lid']) ) { |
|
165 | $lid = intval($_GET['lid']) ; |
||
166 | } else { |
||
167 | $lid = intval($_POST['lid']) ; |
||
168 | } |
||
169 | |||
170 | $op= ''; |
||
171 | if (!empty($_GET['op'])) { |
||
172 | $op = $_GET['op']; |
||
173 | } elseif (!empty($_POST['op'])) { |
||
174 | $op = $_POST['op']; |
||
175 | } |
||
176 | |||
177 | View Code Duplication | switch ($op) { |
|
178 | |||
179 | case "SendFriend": |
||
180 | include(XOOPS_ROOT_PATH."/header.php"); |
||
181 | SendFriend($lid); |
||
182 | include(XOOPS_ROOT_PATH."/footer.php"); |
||
183 | break; |
||
184 | |||
185 | case "MailAd": |
||
186 | MailAd($lid, $yname, $ymail, $fname, $fmail); |
||
187 | break; |
||
188 | |||
189 | default: |
||
190 | redirect_header("index.php",1,""._RETURNGLO.""); |
||
191 | break; |
||
192 | |||
193 | } |
||
194 |
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.