Completed
Branch master (f83415)
by Michael
02:57 queued 18s
created

replies.php (1 issue)

Labels
Severity

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
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
include XOOPS_ROOT_PATH . '/modules/adslight/include/functions.php';
25
26
$myts          = MyTextSanitizer::getInstance(); // MyTextSanitizer object
27
$module_id     = $xoopsModule->getVar('mid');
28
$groups        = ($xoopsUser instanceof XoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
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 dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
29
$gperm_handler = xoops_getHandler('groupperm');
30
$perm_itemid   = XoopsRequest::getInt('item_id', 0, 'POST');
31
32
//If no access
33 View Code Duplication
if (!$gperm_handler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) {
34
    redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM);
35
}
36
include_once XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php';
37
$mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
38
39
$lid                                     = XoopsRequest::getInt('lid', 0, 'GET');
40
$GLOBALS['xoopsOption']['template_main'] = 'adslight_replies.tpl';
41
include XOOPS_ROOT_PATH . '/header.php';
42
43
$xoopsTpl->assign('nav_main', "<a href=\"index.php\">" . _ADSLIGHT_MAIN . '</a>');
44
$show = 1;
45
$min  = XoopsRequest::getInt('min', 0, 'GET');
46
if (!isset($max)) {
47
    $max = $min + $show;
48
}
49
$orderby = 'date Desc';
50
51
$xoopsTpl->assign('lid', $lid);
52
$countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_replies') . ' WHERE lid=' . $xoopsDB->escape($lid) . '');
53
list($trow) = $xoopsDB->fetchRow($countresult);
54
$trows   = $trow;
55
$pagenav = '';
56
57
if ($trows < '1') {
58
    $xoopsTpl->assign('has_replies', false);
59
    $xoopsTpl->assign('no_more_replies', _ADSLIGHT_NO_REPLIES);
60
}
61
62
if ($trows > '0') {
63
    $xoopsTpl->assign('has_replies', true);
64
    $xoopsTpl->assign('last_head', _ADSLIGHT_THE . ' ' . $xoopsModuleConfig['adslight_newcount'] . ' ' . _ADSLIGHT_LASTADD);
65
    $xoopsTpl->assign('last_head_title', _ADSLIGHT_TITLE);
66
    $xoopsTpl->assign('last_head_price', _ADSLIGHT_PRICE);
67
    $xoopsTpl->assign('last_head_date', _ADSLIGHT_DATE);
68
    $xoopsTpl->assign('last_head_local', _ADSLIGHT_LOCAL2);
69
    $xoopsTpl->assign('last_head_views', _ADSLIGHT_VIEW);
70
    $xoopsTpl->assign('last_head_photo', _ADSLIGHT_PHOTO);
71
    $xoopsTpl->assign('min', $min);
72
73
    $sql    = 'SELECT r_lid, lid, title, date, submitter, message, tele, email, r_usid FROM ' . $xoopsDB->prefix('adslight_replies') . ' WHERE lid=' . $xoopsDB->escape($lid) . " ORDER BY $orderby";
74
    $result = $xoopsDB->query($sql, $show, $min);
75
76
    if ($trows > '1') {
77
        $xoopsTpl->assign('has_replies', true);
78
        $xoopsTpl->assign('show_nav', true);
79
        $xoopsTpl->assign('lang_sortby', _ADSLIGHT_SORTBY);
80
        $xoopsTpl->assign('lang_title', _ADSLIGHT_TITLE);
81
        $xoopsTpl->assign('lang_titleatoz', _ADSLIGHT_TITLEATOZ);
82
        $xoopsTpl->assign('lang_titleztoa', _ADSLIGHT_TITLEZTOA);
83
        $xoopsTpl->assign('lang_date', _ADSLIGHT_DATE);
84
        $xoopsTpl->assign('lang_dateold', _ADSLIGHT_DATEOLD);
85
        $xoopsTpl->assign('lang_datenew', _ADSLIGHT_DATENEW);
86
        $xoopsTpl->assign('lang_popularity', _ADSLIGHT_POPULARITY);
87
        $xoopsTpl->assign('lang_popularityleast', _ADSLIGHT_POPULARITYLTOM);
88
        $xoopsTpl->assign('lang_popularitymost', _ADSLIGHT_POPULARITYMTOL);
89
        $xoopsTpl->assign('lang_cursortedby', _ADSLIGHT_CURSORTEDBY . '' . $orderby);
90
    }
91
92
    while (list($r_lid, $lid, $title, $date, $submitter, $message, $tele, $email, $r_usid) = $xoopsDB->fetchRow($result)) {
93
        $useroffset = '';
94 View Code Duplication
        if ($xoopsUser) {
95
            $timezone = $xoopsUser->timezone();
96
            if (isset($timezone)) {
97
                $useroffset = $xoopsUser->timezone();
98
            } else {
99
                $useroffset = $xoopsConfig['default_TZ'];
100
            }
101
        }
102
        $r_usid = $r_usid;
103
        $xoopsTpl->assign('submitter', " <a href='" . XOOPS_URL . "/userinfo.php?uid=$r_usid'>$submitter</a>");
104
        $date = ($useroffset * 3600) + $date;
105
        $date = formatTimestamp($date, 's');
106
        $xoopsTpl->assign('title', "<a href='viewads.php?lid=$lid'>$title</a>");
107
        $xoopsTpl->assign('title_head', _ADSLIGHT_REPLY_TITLE);
108
        $xoopsTpl->assign('date_head', _ADSLIGHT_REPLIED_ON);
109
        $xoopsTpl->assign('submitter_head', _ADSLIGHT_REPLIED_BY);
110
        $xoopsTpl->assign('message_head', _ADSLIGHT_REPLY_MESSAGE);
111
        $xoopsTpl->assign('email_head', _ADSLIGHT_EMAIL);
112
        $xoopsTpl->assign('tele_head', _ADSLIGHT_TEL);
113
        $xoopsTpl->assign('email', "<a href ='mailto:$email'>$email</a>");
114
        $xoopsTpl->assign('delete_reply', "<a href='modify.php?op=DelReply&amp;r_lid=$r_lid'>" . _ADSLIGHT_DELETE_REPLY . '</a>');
115
        $xoopsTpl->append('items', array(
116
            'id'      => $lid,
117
            'title'   => $myts->htmlSpecialChars($title),
118
            'date'    => $date,
119
            'message' => $myts->displayTarea($message),
120
            'tele'    => $myts->htmlSpecialChars($tele)
121
        ));
122
    }
123
    $lid = XoopsRequest::getInt('lid', 0, 'GET');
124
    //Calculates how many pages exist.  Which page one should be on, etc...
125
    $linkpages = ceil($trows / $show);
126
    //Page Numbering
127 View Code Duplication
    if ($linkpages != 1 && $linkpages != 0) {
128
        $prev = $min - $show;
129
        if ($prev >= 0) {
130
            $pagenav .= "<a href='replies.php?lid=$lid&min=$prev&show=$show'><strong><u>&laquo;</u></strong></a> ";
131
        }
132
        $counter     = 1;
133
        $currentpage = ($max / $show);
134
        while ($counter <= $linkpages) {
135
            $mintemp = ($show * $counter) - $show;
136
            if ($counter == $currentpage) {
137
                $pagenav .= "<strong>($counter)</strong> ";
138
            } else {
139
                $pagenav .= "<a href='replies.php?lid=$lid&min=$mintemp&show=$show'>$counter</a> ";
140
            }
141
            ++$counter;
142
        }
143
        if ($trows > $max) {
144
            $pagenav .= "<a href='replies.php?lid=$lid&min=$max&show=$show'>";
145
            $pagenav .= '<strong><u>&raquo;</u></strong></a>';
146
        }
147
        $xoopsTpl->assign('nav_page', '<strong>' . _ADSLIGHT_REPLY . "</strong>&nbsp;&nbsp; $pagenav");
148
    }
149
}
150
151
include XOOPS_ROOT_PATH . '/footer.php';
152