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

blocks/ads_2.php (2 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
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
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
24
25
/**
26
 * @param $options
27
 *
28
 * @return array
29
 */
30
function adslight_b2_show($options)
31
{
32
    global $xoopsDB, $xoopsModuleConfig, $blockdirname, $block_lang;
33
34
    $block = array();
35
    $myts  = MyTextSanitizer::getInstance();
36
37
    $blockdirname = basename(dirname(__DIR__));
38
    $block_lang   = '_MB_' . strtoupper($blockdirname);
39
40
    include_once(XOOPS_ROOT_PATH . "/modules/$blockdirname/include/functions.php");
41
42
    $block['title'] = '' . constant($block_lang . '_TITLE') . '';
43
44
    $updir      = $xoopsModuleConfig['' . $blockdirname . '_link_upload'];
45
    $cat_perms  = '';
46
    $categories = adslight_MygetItemIds('adslight_view');
47
    if (is_array($categories) && count($categories) > 0) {
48
        $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
49
    }
50
51
    $result = $xoopsDB->query('SELECT lid, cid, title, status, type, price, typeprice, date, town, country, contactby, usid, premium, valid, photo, hits FROM ' .
52
                              $xoopsDB->prefix('' . $blockdirname . '_listing') .
53
                              " WHERE valid='Yes' and status!='1' $cat_perms ORDER BY " .
54
                              $options[0] .
55
                              ' DESC', $options[1], 0);
56
57
    while ($myrow = $xoopsDB->fetchArray($result)) {
58
        $a_item    = array();
59
        $title     = $myts->htmlSpecialChars($myrow['title']);
60
        $status    = $myts->htmlSpecialChars($myrow['status']);
61
        $type      = $myts->htmlSpecialChars($myrow['type']);
62
        $price     = $myts->htmlSpecialChars($myrow['price']);
63
        $typeprice = $myts->htmlSpecialChars($myrow['typeprice']);
64
        $town      = $myts->htmlSpecialChars($myrow['town']);
65
        $country   = $myts->htmlSpecialChars($myrow['country']);
66
        $usid      = $myts->htmlSpecialChars($myrow['usid']);
67
        $hits      = $myts->htmlSpecialChars($myrow['hits']);
68
69 View Code Duplication
        if (!XOOPS_USE_MULTIBYTES) {
70
            if (strlen($myrow['title']) >= $options[2]) {
71
                $title = $myts->htmlSpecialChars(substr($myrow['title'], 0, $options[2] - 1)) . '...';
72
            }
73
        }
74
75
        $ad_title               = $myrow['title'];
76
        $a_item['status']       = $status;
77
        $a_item['type']         = adslight_NameType($type);
78
        $a_item['price']        = $price;
79
        $a_item['typeprice']    = $typeprice;
80
        $a_item['town']         = $town;
81
        $a_item['country']      = $country;
82
        $a_item['id']           = $myrow['lid'];
83
        $a_item['cid']          = $myrow['cid'];
84
        $a_item['price_symbol'] = $xoopsModuleConfig['' . $blockdirname . '_money'];
85
86
        if ($status == 2) {
87
            $a_item['sold'] = "<img src=\"assets/images/sold.gif\" align=\"left\" alt=\"\">";
88
        }
89
90
        $a_item['no_photo'] = "<a href=\"" .
91
                              XOOPS_URL .
92
                              "/modules/$blockdirname/viewads.php?lid=" .
93
                              addslashes($myrow['lid']) .
94
                              "\"><img class=\"thumb\" src=\"" .
95
                              XOOPS_URL .
96
                              "/modules/$blockdirname/assets/images/nophoto.jpg\" align=\"left\" width=\"100px\" alt=\"$ad_title\"></a>";
97
98
        if ($myrow['photo'] != '') {
99
            //  $updir = $xoopsModuleConfig["".$blockdirname."_link_upload"];
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
100
            $sql     = 'select cod_img, lid, uid_owner, url from ' .
101
                       $xoopsDB->prefix('' . $blockdirname . '_pictures') .
102
                       ' where  uid_owner=' .
103
                       $xoopsDB->escape($usid) .
104
                       ' and lid=' .
105
                       $xoopsDB->escape($myrow['lid']) .
106
                       ' order by date_added ASC limit 1';
107
            $resultp = $xoopsDB->query($sql);
108
            while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) {
109
                $a_item['photo'] = "<a href=\"" .
110
                                   XOOPS_URL .
111
                                   "/modules/$blockdirname/viewads.php?lid=" .
112
                                   addslashes($myrow['lid']) .
113
                                   "\"><img class=\"thumb\" src=\"" .
114
                                   XOOPS_URL .
115
                                   "/uploads/AdsLight/thumbs/thumb_$url\" align=\"left\" width=\"100px\" alt=\"$title\"></a>";
116
            }
117
        } else {
118
            $a_item['photo'] = '';
119
        }
120
        $a_item['link'] = "<a href=\"" . XOOPS_URL . "/modules/$blockdirname/viewads.php?lid=" . addslashes($myrow['lid']) . "\"><b>$title</b></a>";
121
        $a_item['date'] = formatTimestamp($myrow['date'], 's');
122
        $a_item['hits'] = $myrow['hits'];
123
124
        $block['items'][] = $a_item;
125
    }
126
    $block['lang_title']     = constant($block_lang . '_ITEM');
127
    $block['lang_price']     = constant($block_lang . '_PRICE');
128
    $block['lang_typeprice'] = constant($block_lang . '_TYPEPRICE');
129
    $block['lang_date']      = constant($block_lang . '_DATE');
130
    $block['lang_local']     = constant($block_lang . '_LOCAL2');
131
    $block['lang_hits']      = constant($block_lang . '_HITS');
132
    $block['link']           = "<a href=\"" . XOOPS_URL . "/modules/$blockdirname/\"><b>" . constant($block_lang . '_ALL_LISTINGS') . '</b></a><br>';
133
    $block['add']            = "<a href=\"" . XOOPS_URL . "/modules/$blockdirname/\"><b>" . constant($block_lang . '_ADDNOW') . '</b></a><br>';
134
135
    return $block;
136
}
137
138
/**
139
 * @param $options
140
 *
141
 * @return string
142
 */
143 View Code Duplication
function adslight_b2_edit($options)
144
{
145
    global $xoopsDB;
146
    $blockdirname = basename(dirname(__DIR__));
147
    $block_lang   = '_MB_' . strtoupper($blockdirname);
148
149
    $form = constant($block_lang . '_ORDER') . "&nbsp;<select name='options[]'>";
150
    $form .= "<option value='date'";
151
    if ($options[0] === 'date') {
152
        $form .= " selected='selected'";
153
    }
154
    $form .= '>' . constant($block_lang . '_DATE') . "</option>\n";
155
    $form .= "<option value='hits'";
156
    if ($options[0] === 'hits') {
157
        $form .= " selected='selected'";
158
    }
159
    $form .= '>' . constant($block_lang . '_HITS') . '</option>';
160
    $form .= "</select>\n";
161
    $form .= '&nbsp;' . constant($block_lang . '_DISP') . "&nbsp;<input type='text' name='options[]' value='" . $options[1] . "'/>&nbsp;" . constant($block_lang . '_LISTINGS');
162
    $form .= '&nbsp;<br><br>' . constant($block_lang . '_CHARS') . "&nbsp;<input type='text' name='options[]' value='" . $options[2] . "'/>&nbsp;" . constant($block_lang . '_LENGTH') . '<br><br>';
163
164
    return $form;
165
}
166