Completed
Push — master ( 67bb37...e20777 )
by Michael
02:35
created

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
require_once XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
25
26
$myts      = MyTextSanitizer::getInstance();
27
$module_id = $xoopsModule->getVar('mid');
28
29 View Code Duplication
if (is_object($GLOBALS['xoopsUser'])) {
30
    $groups = $GLOBALS['xoopsUser']->getGroups();
31
} else {
32
    $groups = XOOPS_GROUP_ANONYMOUS;
33
}
34
$gpermHandler = xoops_getHandler('groupperm');
35
$perm_itemid = XoopsRequest::getInt('item_id', 0, 'POST');
36
//If no access
37 View Code Duplication
if (!$gpermHandler->checkRight('adslight_view', $perm_itemid, $groups, $module_id)) {
38
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
39
}
40
if (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) {
41
    $prem_perm = '0';
42
} else {
43
    $prem_perm = '1';
44
}
45
46
#  function adslightMaps
47
#####################################################
48
function adslightMaps()
1 ignored issue
show
adslightMaps uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
49
{
50
    global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsTpl, $myts, $mytree, $meta, $mid, $moduleDirName, $main_lang, $prem_perm;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
51
52
    $GLOBALS['xoopsOption']['template_main'] = 'adslight_maps.tpl';
53
54
    include XOOPS_ROOT_PATH . '/header.php';
55
56
    $xoopsTpl->assign('xmid', $xoopsModule->getVar('mid'));
57
    $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
58
    $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM);
59
    $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']);
60
    $xoopsTpl->assign('search_listings', _ADSLIGHT_SEARCH_LISTINGS);
61
    $xoopsTpl->assign('all_words', _ADSLIGHT_ALL_WORDS);
62
    $xoopsTpl->assign('any_words', _ADSLIGHT_ANY_WORDS);
63
    $xoopsTpl->assign('exact_match', _ADSLIGHT_EXACT_MATCH);
64
    $xoopsTpl->assign('only_pix', _ADSLIGHT_ONLYPIX);
65
    $xoopsTpl->assign('search', _ADSLIGHT_SEARCH);
66
    $xoopsTpl->assign('permit', $prem_perm);
67
    $xoopsTpl->assign('imgscss', XOOPS_URL . '/modules/adslight/assets/css/adslight.css');
68
    $xoopsTpl->assign('adslight_logolink', _ADSLIGHT_LOGOLINK);
69
70
    $xoTheme->addMeta('meta', 'robots', 'noindex, nofollow');
0 ignored issues
show
The variable $xoTheme does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
71
72
    $header_cssadslight = '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" />';
73
74
    $xoopsTpl->assign('xoops_module_header', $header_cssadslight);
75
76
    $maps_name   = $GLOBALS['xoopsModuleConfig']['adslight_maps_set'];
77
    $maps_width  = $GLOBALS['xoopsModuleConfig']['adslight_maps_width'];
78
    $maps_height = $GLOBALS['xoopsModuleConfig']['adslight_maps_height'];
79
80
    $xoopsTpl->assign('maps_name', $maps_name);
81
    $xoopsTpl->assign('maps_width', $maps_width);
82
    $xoopsTpl->assign('maps_height', $maps_height);
83
84
    $xoopsTpl->assign('adlight_maps_title', _ADSLIGHT_MAPS_TITLE);
85
    $xoopsTpl->assign('bullinfotext', _ADSLIGHT_MAPS_TEXT);
86
87
    // adslight 2
88
    $xoopsTpl->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']);
89
    $xoopsTpl->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']);
90
91 View Code Duplication
    if ($GLOBALS['xoopsUser']) {
92
        $member_usid = $GLOBALS['xoopsUser']->getVar('uid');
93
        if ($usid = $member_usid) {
94
            $xoopsTpl->assign('istheirs', true);
95
96
            list($show_user) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE usid=$member_usid"));
97
98
            $xoopsTpl->assign('show_user', $show_user);
99
            $xoopsTpl->assign('show_user_link', "members.php?usid=$member_usid");
100
        }
101
    }
102
}
103
104
######################################################
105
106
$pa      = XoopsRequest::getInt('pa', null, 'GET');
107
108
switch ($pa) {
109
    default:
110
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_maps.tpl';
111
        adslightMaps();
112
        break;
113
}
114
include XOOPS_ROOT_PATH . '/footer.php';
115