Completed
Push — master ( fd0c8a...c024a6 )
by
unknown
03:33 queued 01:53
created

admin/main.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
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * SmallWorld
14
 *
15
 * @package      \XoopsModules\SmallWorld
16
 * @license      GNU GPL (https://www.gnu.org/licenses/gpl-2.0.html/)
17
 * @copyright    The XOOPS Project (https://xoops.org)
18
 * @copyright    2011 Culex
19
 * @author       Michael Albertsen (http://culex.dk) <[email protected]>
20
 * @link         https://github.com/XoopsModules25x/smallworld
21
 * @since        1.0
22
 */
23
24
use Xmf\Request;
25
use XoopsModules\Smallworld;
26
use XoopsModules\Smallworld\Constants;
27
28
require_once __DIR__ . '/admin_header.php';
29
/**
30
 * Vars defined by inclusion of ./admin_header.php
31
 *
32
 * @var \XoopsModules\Smallworld\Admin $admin
33
 * @var \XoopsModules\Smallworld\SwUserHandler $swUserHandler
34
 * @var \XoopsModules\Smallworld\DoSync $d
35
 * @var \XoopsModules\Smallworld\User $check
36
 * @var \XoopsModules\Smallworld\SwDatabase $swDB
37
 * @var \XoopsModules\Smallworld\WallUpdates $wall
38
 * @var \Xmf\Module\Admin $adminObject
39
 * @var \XoopsModules\Smallworld\Helper $helper
40
 * @var string $moduleDirName
41
 * @var string $moduleDirNameUpper
42
 */
43
require_once $helper->path('include/functions.php');
44
require_once XOOPS_ROOT_PATH . '/class/template.php';
45
$GLOBALS['xoopsTpl']->caching = 0;
46
47
xoops_cp_header();
48
49
if (Request::hasVar('xim_admin_message', 'POST')) {
50
    $_POST['xim_admin_message'] = '';
51
}
52
53
$admin = new Smallworld\Admin();
54
55
$ai  = [];
56
$ani = [];
57
58
// --------------- First tab in admin ---------------
59
// Find oldest message and apply to template
60
61
//$dateoffirstmessage = date('d-m-Y H:i:s', $admin->oldestMsg());
62
$dfm = $admin->oldestMsg();
63
$dateoffirstmessage = (Constants::NO_DATE == $dfm) ? _AM_SMALLWORLD_NONEYET : date(_SHORTDATESTRING, $dfm);
64
65
// Get days number
66
$totaldays = $admin->countDays();
67
// get average messages per day
68
$avgperday = $admin->AvgMsgDay($totaldays);
69
// Smallworld version number
70
$installversion = $admin->ModuleInstallVersion();
71
// Smallworld install date
72
$installdate = $admin->ModuleInstallDate();
73
74
//check current version of XIM, return desc,link,version if new available
75
$installCheck = $admin->doCheckUpdate();
76
77
// Count members using XIM
78
$sumallusers = $swUserHandler->getCount();
79
//$sumallusers = $admin->TotalUsers();
80
81
// Find list of most active users (total)
82
$GLOBALS['xoopsTpl']->assign('topuser', $admin->mostactiveusers_allround());
83
84
// Find list of most active users (24 hours)
85
$GLOBALS['xoopsTpl']->assign('topusertoday', $admin->mostactiveusers_today());
86
87
// Find list of best rated users overall
88
$GLOBALS['xoopsTpl']->assign('topratedusers', $admin->topratedusers('up'));
89
90
// Find list of worst rated users overall
91
$GLOBALS['xoopsTpl']->assign('bottomratedusers', $admin->topratedusers('down'));
92
93
$allusers_inspect = $admin->getAllUsers('yes');
94
if (!empty($allusers_inspect)) {
95 View Code Duplication
    foreach ($allusers_inspect as $data) {
96
        $ai['id']                    = $data['id'];
97
        $ai['userid']                = $data['userid'];
98
        $ai['username']              = $data['username'];
99
        $ai['realname']              = $data['realname'];
100
        $ai['userimage']             = $swUserHandler->getAvatarLink($data['userid'], $data['userimage']);
101
        $ai['avatar_size']           = smallworld_getImageSize(80, 100, $ai['userimage']);
102
        $ai['avatar_highwide']       = smallworld_imageResize($ai['avatar_size'][0], $ai['avatar_size'][1], 50);
103
        $ai['ip']                    = $data['ip'];
104
        $ai['complaint']             = $data['complaint'];
105
        $ai['inspect_start']         = $data['inspect_start'];
106
        $ai['inspect_stop']          = $data['inspect_stop'];
107
        $ai['userinspect_timetotal'] = ($data['inspect_start'] + $data['inspect_stop']) - time();
108
        $GLOBALS['xoopsTpl']->append('allusersinspect', $ai);
109
    }
110
}
111
$GLOBALS['xoopsTpl']->assign('allusersinspectcounter', count($ai));
112
113
$allusers_noinspect = $admin->getAllUsers('no');
114
if (!empty($allusers_noinspect)) {
115 View Code Duplication
    foreach ($allusers_noinspect as $data) {
116
        $ani['id']                    = $data['id'];
117
        $ani['userid']                = $data['userid'];
118
        $ani['username']              = $data['username'];
119
        $ani['realname']              = $data['realname'];
120
        $ani['userimage']             = $swUserHandler->getAvatarLink($data['userid'], $data['userimage']);
121
        $ani['avatar_size']           = smallworld_getImageSize(80, 100, $ani['userimage']);
122
        $ani['avatar_highwide']       = smallworld_imageResize($ani['avatar_size'][0], $ani['avatar_size'][1], 50);
123
        $ani['ip']                    = $data['ip'];
124
        $ani['complaint']             = $data['complaint'];
125
        $ani['inspect_start']         = '';
126
        $ani['inspect_stop']          = '';
127
        $ani['userinspect_timetotal'] = '';
128
        $GLOBALS['xoopsTpl']->append('allusersnoinspect', $ani);
129
    }
130
}
131
$GLOBALS['xoopsTpl']->assign('allusersnoinspectcounter', count($ani));
132
// ---------------- end of tabs ---------------- //
133
134
// template assignments
135
// tab titles
136
$GLOBALS['xoopsTpl']->assign([
137
    'lang_statistics'            => _AM_SMALLWORLD_STATISTICS_TITLE,
138
    'lang_moduleinfo'            => _AM_SMALLWORLD_MODULEINFO,
139
    'lang_userstats'             => _AM_SMALLWORLD_USERSTATS,
140
    'lang_installversion'        => _AM_SMALLWORLD_MODULEINSTALL,
141
    'lang_installversion_status' => _AM_SMALLWORLD_UPDATE_STATUS,
142
    'lang_installdate'           => _AM_SMALLWORLD_INSTALLDATE,
143
    'lang_dateoffirstmessage'    => _AM_SMALLWORLD_DATEOFFIRSTMESSAGE,
144
    'lang_totalusers'            => _AM_SMALLWORLD_TOTALUSERS,
145
    'lang_averagemsgperday'      => _AM_SMALLWORLD_AVERAGEMSGPERDAY,
146
    'lang_topchatters'           => _AM_SMALLWORLD_TOPCHATTERS,
147
    'lang_topchatterstoday'      => _AM_SMALLWORLD_TOPCHATTERS_TODAY,
148
    'lang_toprated'              => _AM_SMALLWORLD_TOPRATEDUSERS,
149
    'lang_bottomrated'           => _AM_SMALLWORLD_BOTTOMRATEDUSERS,
150
    'lang_useradmin'             => _AM_SMALLWORLD_USERADMIN_TITLE,
151
    'lang_help'                  => _AM_SMALLWORLD_HELP,
152
    'lang_prefs'                 => _MI_SYSTEM_ADMENU6,
153
    'lang_prefslink'             => "<a href='../../system/admin.php?fct=preferences&amp;op=showmod&amp;mod=" . $helper->getModule()->mid() . "'>" . _MI_SYSTEM_ADMENU6 . '</a>'
154
]);
155
156
// help file from admin
157
$GLOBALS['xoopsTpl']->assign([
158
    'lang_hlp_about'            => _AM_SMALLWORLD_HELP_ABOUT,
159
    'lang_hlp_preface'          => _AM_SMALLWORLD_HELP_PREFACE,
160
    'lang_hlp_requirements_t'   => _AM_SMALLWORLD_HELP_HEADER_REQUIREMENTS,
161
    'lang_hlp_requirements'     => _AM_SMALLWORLD_HELP_REQUIREMENTS,
162
    'lang_hlp_recommended_t'    => _AM_SMALLWORLD_HELP_HEADER_RECOMMENDED,
163
    'lang_hlp_recommended'      => _AM_SMALLWORLD_HELP_RECOMMENDED,
164
    'lang_hlp_installation_t'   => _AM_SMALLWORLD_HELP_HEADER_INSTALLATION,
165
    'lang_hlp_firsttime'        => _AM_SMALLWORLD_HELP_FIRSTTIMEINSTALL,
166
    'lang_hlp_hostedplatform_t' => _AM_SMALLWORLD_HELP_HEADER_HOSTED_PLATFORM,
167
    'lang_hlp_hostedplatform'   => _AM_SMALLWORLD_HELP_HOSTED_PLATFORM,
168
    'lang_hlp_upgrading_t'      => _AM_SMALLWORLD_HELP_HEADER_UPGRADING,
169
    'lang_hlp_upgrading'        => _AM_SMALLWORLD_HELP_UPGRADING,
170
    'lang_hlp_faq_t'            => _AM_SMALLWORLD_HELP_HEADER_FAQ,
171
    'lang_hlp_commen1_t'        => _AM_SMALLWORLD_HELP_HEADER_COMMENPROBLEMS1,
172
    'lang_hlp_commen1'          => _AM_SMALLWORLD_HELP_COMMENPROBLEMS1,
173
    'lang_hlp_contacts_t'       => _AM_SMALLWORLD_HELP_HEADER_CONTACTS,
174
    'lang_hlp_otherhelp'        => _AM_SMALLWORLD_HELP_OTHERHELP,
175
    'installversion'            => $installversion,
176
    'installdate'               => $installdate,
177
    'installversion_status'     => $installCheck,
178
    'dateoffirstmessage'        => $dateoffirstmessage,
179
    'totalusers'                => $sumallusers,
180
    'averagemsgperday'          => $avgperday
181
]);
182
$GLOBALS['xoopsTpl']->display('db:smallworld_admin.tpl');
183
184
//Check Language
185
$lang = $GLOBALS['xoopsConfig']['language'];
186
// GET various variables from language folder
187 View Code Duplication
if (file_exists($helper->path('language/' . $lang . '/js/variables.js'))) {
0 ignored issues
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...
188
    $GLOBALS['xoTheme']->addScript($helper->url('language/' . $lang . '/js/variables.js'));
189
} else {
190
    $GLOBALS['xoTheme']->addScript($helper->url('language/english/js/variables.js'));
191
}
192
193
$adminscript = <<<SCRIPT
194
        var smallworld_url="XOOPS_URL/modules/smallworld/";
195
        //var $ = jQuery();
196
SCRIPT;
197
$GLOBALS['xoTheme']->addStylesheet($helper->url('assets/css/SmallworldAdmin.css'));
198
$GLOBALS['xoTheme']->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js');
199
$GLOBALS['xoTheme']->addScript($helper->url('assets/js/jquery-ui-1.8.11.custom.js'));
200
$GLOBALS['xoTheme']->addScript($helper->url('assets/js/smallworld_tabs.js'));
201
$GLOBALS['xoTheme']->addScript('', '', $adminscript);
202
$GLOBALS['xoTheme']->addScript($helper->url('assets/js/jquery.form.js'));
203
$GLOBALS['xoTheme']->addScript($helper->url('assets/js/jquery.countdown.js'));
204 View Code Duplication
if (file_exists($helper->path('language/' . $lang . '/js/jquery.ui.datepicker-language.js'))) {
0 ignored issues
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...
205
    $GLOBALS['xoTheme']->addScript($helper->url('language/' . $lang . '/js/jquery.ui.datepicker-language.js'));
206
    $GLOBALS['xoTheme']->addScript($helper->url('language/' . $lang . '/js/jquery.countdown.js'));
207
} else {
208
    $GLOBALS['xoTheme']->addScript($helper->url('language/english/js/jquery.ui.datepicker-language.js'));
209
    $GLOBALS['xoTheme']->addScript($helper->url('language/english/js/jquery.countdown.js'));
210
}
211
$GLOBALS['xoTheme']->addScript($helper->url('assets/js/adminsmallworld.js'));
212
213
xoops_cp_footer();
214