forked from XoopsModules25x/suico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.php
126 lines (121 loc) · 4.73 KB
/
header.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
declare(strict_types=1);
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* @category Module
* @package suico
* @copyright {@link https://xoops.org/ XOOPS Project}
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org>
*/
use Xmf\Request;
use XoopsModules\Suico;
use XoopsModules\Suico\Helper;
require __DIR__ . '/preloads/autoloader.php';
require dirname(__DIR__, 2) . '/mainfile.php';
require XOOPS_ROOT_PATH . '/header.php';
$moduleDirName = basename(__DIR__);
$helper = Helper::getInstance();
$modulePath = XOOPS_ROOT_PATH . '/modules/' . $moduleDirName;
$myts = MyTextSanitizer::getInstance();
if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) {
require $GLOBALS['xoops']->path('class/theme.php');
$GLOBALS['xoTheme'] = new xos_opal_Theme();
}
//Handlers
//$XXXHandler = xoops_getModuleHandler('XXX', $moduleDirName);
/** @var \XoopsPersistableObjectHandler $imageHandler */
$imageHandler = $helper->getHandler('Image');
/** @var \XoopsPersistableObjectHandler $friendshipHandler */
$friendshipHandler = $helper->getHandler('Friendship');
/** @var \XoopsPersistableObjectHandler $visitorsHandler */
$visitorsHandler = $helper->getHandler('Visitors');
/** @var \XoopsPersistableObjectHandler $videoHandler */
$videoHandler = $helper->getHandler('Video');
/** @var \XoopsPersistableObjectHandler $friendrequestHandler */
$friendrequestHandler = $helper->getHandler('Friendrequest');
/** @var \XoopsPersistableObjectHandler $groupsHandler */
$groupsHandler = $helper->getHandler('Groups');
/** @var \XoopsPersistableObjectHandler $relgroupuserHandler */
$relgroupuserHandler = $helper->getHandler('Relgroupuser');
/** @var \XoopsPersistableObjectHandler $notesHandler */
$notesHandler = $helper->getHandler('Notes');
/** @var \XoopsPersistableObjectHandler $configsHandler */
$configsHandler = $helper->getHandler('Configs');
/** @var \XoopsPersistableObjectHandler $suspensionsHandler */
$suspensionsHandler = $helper->getHandler('Suspensions');
/** @var \XoopsPersistableObjectHandler $audioHandler */
$audioHandler = $helper->getHandler('Audio');
// Load language files
$helper->loadLanguage('blocks');
$helper->loadLanguage('common');
$helper->loadLanguage('main');
$helper->loadLanguage('modinfo');
$helper->loadLanguage('main');
//$helper->loadLanguage('user');
xoops_loadLanguage('user');
if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) {
require $GLOBALS['xoops']->path('class/template.php');
$xoopsTpl = new XoopsTpl();
}
$imageFactory = new Suico\ImageHandler($xoopsDB);
$visitorsFactory = new Suico\VisitorsHandler($xoopsDB);
$videosFactory = new Suico\VideoHandler($xoopsDB);
$friendrequestFactory = new Suico\FriendrequestHandler($xoopsDB);
$friendshipFactory = new Suico\FriendshipHandler($xoopsDB);
$isOwner = 0;
$isAnonym = 1;
$isFriend = 0;
if (1 === $helper->getConfig('enable_guestaccess')) {
/**
* Enable Guest Access
* If anonym and uid not set then redirect to admins profile
* Else redirects to own profile
*/
if (empty($xoopsUser)) {
$isAnonym = 1;
if (isset($_GET['uid'])) {
$uid_owner = Request::getInt('uid', 0, 'GET');
} else {
$uid_owner = 1;
$isOwner = 0;
}
} else {
$isAnonym = 0;
if (isset($_GET['uid'])) {
$uid_owner = Request::getInt('uid', 0, 'GET');
$isOwner = $xoopsUser->getVar('uid') === $uid_owner ? 1 : 0;
} else {
$uid_owner = (int)$xoopsUser->getVar('uid');
$isOwner = 1;
}
}
} else {
/**
* Disable Guest Access
* If anonym redirect to landing guest page
* Else redirects to own profile
*/
if (empty($xoopsUser)) {
$isAnonym = 1;
if (!mb_stripos($_SERVER['REQUEST_URI'], 'user.php')) {
$xoopsUser || redirect_header('user.php', 3, _NOPERM);
}
} else {
$isAnonym = 0;
if (isset($_GET['uid'])) {
$uid_owner = Request::getInt('uid', 0, 'GET');
$isOwner = $xoopsUser->getVar('uid') === $uid_owner ? 1 : 0;
} else {
$uid_owner = (int)$xoopsUser->getVar('uid');
$isOwner = 1;
}
}
}