Completed
Push — master ( 0424ea...923121 )
by Michael
03:57
created

sendfriend.php (3 issues)

Upgrade to new PHP Analysis Engine

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
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 29 and the first side effect is on line 22.

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.

Loading history...
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=' . $xoopsDB->escape($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.

Loading history...
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 (L91-165) 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 annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
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 ' .
103
                              $xoopsDB->prefix('adslight_listing') .
104
                              ' where lid=' .
105
                              $xoopsDB->escape($lid) .
106
                              '');
107
    list($lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date, $email, $submitter, $town, $country, $photo) = $xoopsDB->fetchRow($result);
108
109
    $title     = $myts->addSlashes($title);
110
    $expire    = $myts->addSlashes($expire);
111
    $type      = $myts->addSlashes($type);
112
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1, 1, 1);
113
    $tel       = $myts->addSlashes($tel);
114
    $price     = $myts->addSlashes($price);
115
    $typeprice = $myts->addSlashes($typeprice);
116
    $submitter = $myts->addSlashes($submitter);
117
    $town      = $myts->addSlashes($town);
118
    $country   = $myts->addSlashes($country);
119
120
    $tags                       = array();
121
    $tags['YNAME']              = stripslashes($yname);
122
    $tags['YMAIL']              = $ymail;
123
    $tags['FNAME']              = stripslashes($fname);
124
    $tags['FMAIL']              = $fmail;
125
    $tags['HELLO']              = _ADSLIGHT_HELLO;
126
    $tags['LID']                = $lid;
127
    $tags['LISTING_NUMBER']     = _ADSLIGHT_LISTING_NUMBER;
128
    $tags['TITLE']              = $title;
129
    $tags['TYPE']               = adslight_NameType($type);
130
    $tags['DESCTEXT']           = $desctext;
131
    $tags['PRICE']              = $price;
132
    $tags['TYPEPRICE']          = $typeprice;
133
    $tags['TEL']                = $tel;
134
    $tags['TOWN']               = $town;
135
    $tags['COUNTRY']            = $country;
136
    $tags['OTHER']              = '' . _ADSLIGHT_INTERESS . '' . $xoopsConfig['sitename'] . '';
137
    $tags['LISTINGS']           = '' . XOOPS_URL . '/modules/adslight/';
138
    $tags['LINK_URL']           = '' . XOOPS_URL . '/modules/adslight/viewads.php?lid=' . $lid . '';
139
    $tags['THINKS_INTERESTING'] = '' . _ADSLIGHT_MESSAGE . '';
140
    $tags['NO_MAIL']            = '' . _ADSLIGHT_NOMAIL . '';
141
    $tags['YOU_CAN_VIEW_BELOW'] = '' . _ADSLIGHT_YOU_CAN_VIEW_BELOW . '';
142
    $tags['WEBMASTER']          = _ADSLIGHT_WEBMASTER;
143
    $tags['NO_REPLY']           = _ADSLIGHT_NOREPLY;
144
    $subject                    = '' . _ADSLIGHT_SUBJET . ' ' . $xoopsConfig['sitename'] . '';
145
    $xoopsMailer                = xoops_getMailer();
146
    $xoopsMailer->multimailer->isHTML(true);
147
    $xoopsMailer->useMail();
148
    $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template/');
149
150
    $xoopsMailer->setTemplate('listing_send_friend.tpl');
151
    $xoopsMailer->setFromEmail($ymail);
152
    $xoopsMailer->setToEmails($fmail);
153
    $xoopsMailer->setSubject($subject);
154
    $xoopsMailer->assign($tags);
155
    $xoopsMailer->send();
156
    echo $xoopsMailer->getErrors();
157
158
    redirect_header('index.php', 3, _ADSLIGHT_ANNSEND);
159
}
160
161
##############################################################
162
$yname = !empty($_POST['yname']) ? $myts->addSlashes($_POST['yname']) : '';
163
$ymail = !empty($_POST['ymail']) ? $myts->addSlashes($_POST['ymail']) : '';
164
$fname = !empty($_POST['fname']) ? $myts->addSlashes($_POST['fname']) : '';
165
$fmail = !empty($_POST['fmail']) ? $myts->addSlashes($_POST['fmail']) : '';
166
167 View Code Duplication
if (!isset($_POST['lid']) && isset($_GET['lid'])) {
168
    $lid = (int)$_GET['lid'];
169
} else {
170
    $lid = (int)$_POST['lid'];
171
}
172
173
$op = '';
174
if (!empty($_GET['op'])) {
175
    $op = $_GET['op'];
176
} elseif (!empty($_POST['op'])) {
177
    $op = $_POST['op'];
178
}
179
180 View Code Duplication
switch ($op) {
181
182
    case 'SendFriend':
183
        include(XOOPS_ROOT_PATH . '/header.php');
184
        SendFriend($lid);
185
        include(XOOPS_ROOT_PATH . '/footer.php');
186
        break;
187
188
    case 'MailAd':
189
        MailAd($lid, $yname, $ymail, $fname, $fmail);
190
        break;
191
192
    default:
193
        redirect_header('index.php', 1, '' . _RETURNGLO . '');
194
        break;
195
196
}
197