Passed
Push — master ( 3beb71...83935f )
by Michael
16:09
created
Severity
1
<?php declare(strict_types=1);
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    XOOPS Project (https://xoops.org)
15
 * @license      GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author       XOOPS Development Team
17
 * @author       Pascal Le Boustouller: original author ([email protected])
18
 * @author       Luc Bizet (www.frxoops.org)
19
 * @author       jlm69 (www.jlmzone.com)
20
 * @author       mamba (www.xoops.org)
21
 */
22
23
use Xmf\Request;
24
use XoopsModules\Adslight\{
25
    Helper,
26
    Utility
27
};
28
29
/** @var Helper $helper */
30
require_once __DIR__ . '/header.php';
31
//require_once XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
32
33
/**
34
 * @param $lid
35
 */
36
function printAd($lid): void
37
{
38
    global $xoopsConfig, $xoopsDB, $useroffset, $myts;
39
    $helper       = Helper::getInstance();
40
    $currenttheme = $xoopsConfig['theme_set'];
41
    $lid          = (int)$lid;
42
43
    $result = $xoopsDB->query(
44
        'SELECT l.lid, l.title, l.expire, l.type, l.desctext, l.tel, l.price, l.typeprice, l.date_created, l.email, l.submitter, l.town, l.country, l.photo, p.cod_img, p.lid, p.uid_owner, p.url FROM '
45
        . $xoopsDB->prefix('adslight_listing')
46
        . ' l LEFT JOIN '
47
        . $xoopsDB->prefix('adslight_pictures')
48
        . ' p ON l.lid=p.lid WHERE l.lid='
49
        . $xoopsDB->escape($lid)
50
    );
51
    [$lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date_created, $email, $submitter, $town, $country, $photo, $cod_img, $pic_lid, $uid_owner, $url] = $xoopsDB->fetchRow($result);
52
53
    $title     = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5);
54
    $expire    = \htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5);
55
    $type      = Utility::getNameType(htmlspecialchars($type, ENT_QUOTES | ENT_HTML5));
56
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1, 1, 1);
57
    $tel       = \htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5);
58
    $price     = \htmlspecialchars($price, ENT_QUOTES | ENT_HTML5);
59
    $typeprice = \htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5);
60
    $submitter = \htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5);
61
    $town      = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5);
62
    $country   = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5);
63
64
    echo '
65
    <html>
66
    <head><title>' . $xoopsConfig['sitename'] . "</title>
67
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" >
68
    <meta http-equiv=\”robots\” content=\"noindex, nofollow, noarchive\" >
69
    <link rel=\"StyleSheet\" href=\"../../themes/" . $currenttheme . '/style/style.css" type="text/css">
70
    </head>
71
    <body bgcolor="#FFFFFF" text="#000000">
72
    <table border=0><tr><td>
73
    <table border=0 width=100% cellpadding=0 cellspacing=1 bgcolor="#000000"><tr><td>
74
    <table border=0 width=100% cellpadding=15 cellspacing=1 bgcolor="#FFFFFF"><tr><td>';
75
76
    $useroffset = 0;
77
    if ($GLOBALS['xoopsUser'] instanceof \XoopsUser) {
78
        $timezone   = $GLOBALS['xoopsUser']->timezone();
79
        $useroffset = empty($timezone) ? $xoopsConfig['default_TZ'] : $GLOBALS['xoopsUser']->timezone();
80
    }
81
    $date_created = ($useroffset * 3600) + $date_created;
82
    $date2        = $date_created + ($expire * 86400);
83
    $date1        = formatTimestamp($date_created, 's');
0 ignored issues
show
The assignment to $date1 is dead and can be removed.
Loading history...
84
    $date2        = formatTimestamp($date2, 's');
85
86
    echo '<br><br><table width=99% border=0>
87
        <tr>
88
      <td>' . _ADSLIGHT_CLASSIFIED . " (No. {$lid} ) <br>" . _ADSLIGHT_FROM . " {$submitter} <br><br>";
89
90
    echo " <strong>{$type} :</strong> <i>{$title}</i><br>";
91
    if ($price > 0) {
92
        echo '<strong>' . _ADSLIGHT_PRICE2 . "</strong> {$price} " . $helper->getConfig('adslight_currency_symbol') . "  - {$typeprice}<br>";
93
    }
94
    if ($photo) {
95
        echo "<tr><td><div style='text-align:left'><img class=\"thumb\" src=\"" . XOOPS_URL . "/uploads/adslight/{$url}\" width=\"130px\" border=0 ></div>";
96
    }
97
    echo '</td>
98
          </tr>
99
    <tr>
100
      <td><strong>' . _ADSLIGHT_DESC . "</strong><br><br><div style=\"text-align:justify;\">{$desctext}</div><p>";
101
    if ('' !== $tel) {
102
        echo '<br><strong>' . _ADSLIGHT_TEL . "</strong> {$tel}";
103
    }
104
    if ('' !== $town) {
105
        echo '<br><strong>' . _ADSLIGHT_TOWN . "</strong> {$town}";
106
    }
107
    if ('' !== $country) {
108
        echo '<br><strong>' . _ADSLIGHT_COUNTRY . "</strong> {$country}";
109
    }
110
    echo '<hr>';
111
    echo '' . _ADSLIGHT_NOMAIL . ' <br>' . XOOPS_URL . '/modules/adslight/viewads.php?lid=' . $lid . '<br>';
112
    echo '<br><br>' . _ADSLIGHT_DATE2 . " {$date_created} " . _ADSLIGHT_AND . ' ' . _ADSLIGHT_DISPO . " {$date2}<br><br>";
113
    echo '</td>
114
    </tr>
115
    </table>';
116
    echo '<br><br></td></tr></table></td></tr></table>
117
    <br><br><div style="text-align:center">
118
    ' . _ADSLIGHT_EXTRANN . ' <strong>' . $xoopsConfig['sitename'] . '</strong></div><br>
119
    <a href="' . XOOPS_URL . '/modules/adslight/">' . XOOPS_URL . '/modules/adslight/</a>
120
    </td></tr></table>
121
    </body>
122
    </html>';
123
}
124
125
##############################################################
126
127
$lid = Request::getInt('lid', 0);
128
$op  = Request::getString('op', '');
129
130
switch ($op) {
131
    case 'PrintAd':
132
        printAd($lid);
133
        break;
134
    default:
135
        $helper->redirect('index.php', 3, ' ' . _RETURNANN . ' ');
136
        break;
137
}
138