|
1
|
|
|
<?php |
|
|
|
|
|
|
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
|
|
|
use Xmf\Request; |
|
24
|
|
|
|
|
25
|
|
|
require_once __DIR__ . '/header.php'; |
|
26
|
|
|
//require XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php'; |
|
|
|
|
|
|
27
|
|
|
//include XOOPS_ROOT_PATH . '/modules/adslight/class/utility.php'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param $lid |
|
31
|
|
|
*/ |
|
32
|
|
|
function SendFriend($lid) |
|
33
|
|
|
{ |
|
34
|
|
|
global $xoopsConfig, $xoopsDB, $xoopsTheme, $xoopsLogger, $moduleDirName, $main_lang; |
|
35
|
|
|
$idd = $idde = $iddee = ''; |
|
36
|
|
|
include XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
37
|
|
|
include XOOPS_ROOT_PATH . '/header.php'; |
|
38
|
|
|
$GLOBALS['xoTheme']->addMeta('meta', 'robots', 'noindex, nofollow'); |
|
39
|
|
|
|
|
40
|
|
|
$result = $xoopsDB->query('SELECT lid, title, type FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}"); |
|
41
|
|
|
list($lid, $title, $type) = $xoopsDB->fetchRow($result); |
|
42
|
|
|
|
|
43
|
|
|
echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'> |
|
44
|
|
|
<strong>" . _ADSLIGHT_SENDTO . " $lid \"<strong>$type : $title</strong>\" " . _ADSLIGHT_FRIEND . "<br><br> |
|
45
|
|
|
<form action=\"sendfriend.php\" method=post> |
|
46
|
|
|
<input type=\"hidden\" name=\"lid\" value=\"$lid\" >"; |
|
47
|
|
|
|
|
48
|
|
|
if ($GLOBALS['xoopsUser'] instanceof XoopsUser) { |
|
|
|
|
|
|
49
|
|
|
$idd = $GLOBALS['xoopsUser']->getVar('uname', 'E'); |
|
50
|
|
|
$idde = $GLOBALS['xoopsUser']->getVar('email', 'E'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
echo " |
|
54
|
|
|
<table width='99%' class='outer' cellspacing='1'> |
|
55
|
|
|
<tr> |
|
56
|
|
|
<td class='head' width='30%'>" . _ADSLIGHT_NAME . " </td> |
|
57
|
|
|
<td class='even'><input class='textbox' type='text' name='yname' value='$idd' ></td> |
|
58
|
|
|
</tr> |
|
59
|
|
|
<tr> |
|
60
|
|
|
<td class='head'>" . _ADSLIGHT_MAIL . " </td> |
|
61
|
|
|
<td class='even'><input class='textbox' type='text' name='ymail' value='$idde' ></td> |
|
62
|
|
|
</tr> |
|
63
|
|
|
<tr> |
|
64
|
|
|
<td class='head'>" . _ADSLIGHT_NAMEFR . " </td> |
|
65
|
|
|
<td class='even'><input class='textbox' type='text' name='fname' ></td> |
|
66
|
|
|
</tr> |
|
67
|
|
|
<tr> |
|
68
|
|
|
<td class='head'>" . _ADSLIGHT_MAILFR . " </td> |
|
69
|
|
|
<td class='even'><input class='textbox' type='text' name='fmail' ></td> |
|
70
|
|
|
</tr>"; |
|
71
|
|
|
|
|
72
|
|
View Code Duplication |
if ($GLOBALS['xoopsModuleConfig']['adslight_use_captcha'] == '1') { |
|
73
|
|
|
echo "<tr><td class='head'>" . _ADSLIGHT_CAPTCHA . " </td><td class='even'>"; |
|
74
|
|
|
$jlm_captcha = ''; |
|
|
|
|
|
|
75
|
|
|
$jlm_captcha = new XoopsFormCaptcha(_ADSLIGHT_CAPTCHA, 'xoopscaptcha', false); |
|
76
|
|
|
echo $jlm_captcha->render(); |
|
77
|
|
|
echo '</td></tr>'; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
echo '</table><br> |
|
81
|
|
|
<input type=hidden name=op value=MailAd> |
|
82
|
|
|
<input type=submit value=' . _ADSLIGHT_SENDFR . '> |
|
83
|
|
|
</form></td></tr></table>'; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @param $lid |
|
88
|
|
|
* @param $yname |
|
89
|
|
|
* @param $ymail |
|
90
|
|
|
* @param $fname |
|
91
|
|
|
* @param $fmail |
|
92
|
|
|
*/ |
|
93
|
|
|
function MailAd($lid, $yname, $ymail, $fname, $fmail) |
|
|
|
|
|
|
94
|
|
|
{ |
|
95
|
|
|
global $xoopsConfig, $xoopsTpl, $xoopsDB, $xoopsModule, $myts, $xoopsLogger, $moduleDirName, $main_lang; |
|
96
|
|
|
|
|
97
|
|
View Code Duplication |
if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_use_captcha']) { |
|
98
|
|
|
xoops_load('xoopscaptcha'); |
|
99
|
|
|
$xoopsCaptcha = XoopsCaptcha::getInstance(); |
|
100
|
|
|
if (!$xoopsCaptcha->verify()) { |
|
101
|
|
|
redirect_header(XOOPS_URL . '/modules/adslight/index.php', 2, $xoopsCaptcha->getMessage()); |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
$result = $xoopsDB->query('SELECT lid, title, expire, type, desctext, tel, price, typeprice, date, email, submitter, town, country, photo FROM ' |
|
106
|
|
|
. $xoopsDB->prefix('adslight_listing') |
|
107
|
|
|
. ' WHERE lid=' |
|
108
|
|
|
. $xoopsDB->escape($lid)); |
|
109
|
|
|
list($lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date, $email, $submitter, $town, $country, $photo) = $xoopsDB->fetchRow($result); |
|
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
$title = $myts->addSlashes($title); |
|
112
|
|
|
$expire = $myts->addSlashes($expire); |
|
|
|
|
|
|
113
|
|
|
$type = $myts->addSlashes($type); |
|
114
|
|
|
$desctext = $myts->displayTarea($desctext, 1, 1, 1, 1, 1); |
|
115
|
|
|
$tel = $myts->addSlashes($tel); |
|
116
|
|
|
$price = $myts->addSlashes($price); |
|
117
|
|
|
$typeprice = $myts->addSlashes($typeprice); |
|
118
|
|
|
$submitter = $myts->addSlashes($submitter); |
|
|
|
|
|
|
119
|
|
|
$town = $myts->addSlashes($town); |
|
120
|
|
|
$country = $myts->addSlashes($country); |
|
121
|
|
|
|
|
122
|
|
|
$tags = array(); |
|
123
|
|
|
$tags['YNAME'] = stripslashes($yname); |
|
124
|
|
|
$tags['YMAIL'] = $ymail; |
|
125
|
|
|
$tags['FNAME'] = stripslashes($fname); |
|
126
|
|
|
$tags['FMAIL'] = $fmail; |
|
127
|
|
|
$tags['HELLO'] = _ADSLIGHT_HELLO; |
|
128
|
|
|
$tags['LID'] = $lid; |
|
129
|
|
|
$tags['LISTING_NUMBER'] = _ADSLIGHT_LISTING_NUMBER; |
|
130
|
|
|
$tags['TITLE'] = $title; |
|
131
|
|
|
$tags['TYPE'] = AdslightUtility::getNameType($type); |
|
132
|
|
|
$tags['DESCTEXT'] = $desctext; |
|
133
|
|
|
$tags['PRICE'] = $price; |
|
134
|
|
|
$tags['TYPEPRICE'] = $typeprice; |
|
135
|
|
|
$tags['TEL'] = $tel; |
|
136
|
|
|
$tags['TOWN'] = $town; |
|
137
|
|
|
$tags['COUNTRY'] = $country; |
|
138
|
|
|
$tags['OTHER'] = '' . _ADSLIGHT_INTERESS . '' . $xoopsConfig['sitename'] . ''; |
|
139
|
|
|
$tags['LISTINGS'] = XOOPS_URL . '/modules/adslight/'; |
|
140
|
|
|
$tags['LINK_URL'] = XOOPS_URL . '/modules/adslight/viewads.php?lid=' . $lid; |
|
141
|
|
|
$tags['THINKS_INTERESTING'] = _ADSLIGHT_MESSAGE; |
|
142
|
|
|
$tags['NO_MAIL'] = _ADSLIGHT_NOMAIL; |
|
143
|
|
|
$tags['YOU_CAN_VIEW_BELOW'] = _ADSLIGHT_YOU_CAN_VIEW_BELOW; |
|
144
|
|
|
$tags['WEBMASTER'] = _ADSLIGHT_WEBMASTER; |
|
145
|
|
|
$tags['NO_REPLY'] = _ADSLIGHT_NOREPLY; |
|
146
|
|
|
$subject = '' . _ADSLIGHT_SUBJET . ' ' . $xoopsConfig['sitename'] . ''; |
|
147
|
|
|
$xoopsMailer = xoops_getMailer(); |
|
148
|
|
|
$xoopsMailer->multimailer->isHTML(true); |
|
149
|
|
|
$xoopsMailer->useMail(); |
|
150
|
|
|
$xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template/'); |
|
151
|
|
|
$xoopsMailer->setTemplate('listing_send_friend.tpl'); |
|
152
|
|
|
$xoopsMailer->setFromEmail($ymail); |
|
153
|
|
|
$xoopsMailer->setToEmails($fmail); |
|
154
|
|
|
$xoopsMailer->setSubject($subject); |
|
155
|
|
|
$xoopsMailer->assign($tags); |
|
156
|
|
|
$xoopsMailer->send(); |
|
157
|
|
|
echo $xoopsMailer->getErrors(); |
|
158
|
|
|
|
|
159
|
|
|
redirect_header('index.php', 3, _ADSLIGHT_ANNSEND); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
############################################################## |
|
163
|
|
|
$yname = Request::getString('yname', '', 'POST'); |
|
164
|
|
|
$ymail = Request::getString('ymail', '', 'POST'); |
|
165
|
|
|
$fname = Request::getString('fname', '', 'POST'); |
|
166
|
|
|
$fmail = Request::getString('fmail', '', 'POST'); |
|
167
|
|
|
|
|
168
|
|
|
$lid = Request::getInt('lid', 0); |
|
169
|
|
|
$op = Request::getString('op', ''); |
|
170
|
|
|
|
|
171
|
|
View Code Duplication |
switch ($op) { |
|
172
|
|
|
|
|
173
|
|
|
case 'SendFriend': |
|
174
|
|
|
include XOOPS_ROOT_PATH . '/header.php'; |
|
175
|
|
|
SendFriend($lid); |
|
176
|
|
|
include XOOPS_ROOT_PATH . '/footer.php'; |
|
177
|
|
|
break; |
|
178
|
|
|
|
|
179
|
|
|
case 'MailAd': |
|
180
|
|
|
MailAd($lid, $yname, $ymail, $fname, $fmail); |
|
181
|
|
|
break; |
|
182
|
|
|
|
|
183
|
|
|
default: |
|
184
|
|
|
redirect_header('index.php', 1, ' ' . _RETURNANN . ' '); |
|
185
|
|
|
break; |
|
186
|
|
|
|
|
187
|
|
|
} |
|
188
|
|
|
|
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.