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

replies.php (1 issue)

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