1
|
|
|
<?php declare(strict_types=1); |
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
|
|
|
* @category Module |
14
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
15
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use Xmf\Request; |
|
|
|
|
20
|
|
|
use XoopsModules\Suico\{ |
21
|
|
|
FriendrequestHandler, |
22
|
|
|
FriendshipHandler, |
23
|
|
|
Helper, |
24
|
|
|
ImageHandler, |
25
|
|
|
VisitorsHandler, |
26
|
|
|
VideoHandler |
27
|
|
|
}; |
28
|
|
|
|
29
|
|
|
/** @var Helper $helper */ |
30
|
|
|
require __DIR__ . '/preloads/autoloader.php'; |
31
|
|
|
require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
32
|
|
|
require XOOPS_ROOT_PATH . '/header.php'; |
33
|
|
|
$moduleDirName = basename(__DIR__); |
34
|
|
|
$helper = Helper::getInstance(); |
35
|
|
|
$modulePath = XOOPS_ROOT_PATH . '/modules/' . $moduleDirName; |
36
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
37
|
|
|
if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
38
|
|
|
require $GLOBALS['xoops']->path('class/theme.php'); |
39
|
|
|
$GLOBALS['xoTheme'] = new xos_opal_Theme(); |
40
|
|
|
} |
41
|
|
|
//Handlers |
42
|
|
|
//$XXXHandler = xoops_getModuleHandler('XXX', $moduleDirName); |
43
|
|
|
/** @var \XoopsPersistableObjectHandler $imageHandler */ |
44
|
|
|
$imageHandler = $helper->getHandler('Image'); |
45
|
|
|
/** @var \XoopsPersistableObjectHandler $friendshipHandler */ |
46
|
|
|
$friendshipHandler = $helper->getHandler('Friendship'); |
47
|
|
|
/** @var \XoopsPersistableObjectHandler $visitorsHandler */ |
48
|
|
|
$visitorsHandler = $helper->getHandler('Visitors'); |
49
|
|
|
/** @var \XoopsPersistableObjectHandler $videoHandler */ |
50
|
|
|
$videoHandler = $helper->getHandler('Video'); |
51
|
|
|
/** @var \XoopsPersistableObjectHandler $friendrequestHandler */ |
52
|
|
|
$friendrequestHandler = $helper->getHandler('Friendrequest'); |
53
|
|
|
/** @var \XoopsPersistableObjectHandler $groupsHandler */ |
54
|
|
|
$groupsHandler = $helper->getHandler('Groups'); |
55
|
|
|
/** @var \XoopsPersistableObjectHandler $relgroupuserHandler */ |
56
|
|
|
$relgroupuserHandler = $helper->getHandler('Relgroupuser'); |
57
|
|
|
/** @var \XoopsPersistableObjectHandler $notesHandler */ |
58
|
|
|
$notesHandler = $helper->getHandler('Notes'); |
59
|
|
|
/** @var \XoopsPersistableObjectHandler $configsHandler */ |
60
|
|
|
$configsHandler = $helper->getHandler('Configs'); |
61
|
|
|
/** @var \XoopsPersistableObjectHandler $suspensionsHandler */ |
62
|
|
|
$suspensionsHandler = $helper->getHandler('Suspensions'); |
63
|
|
|
/** @var \XoopsPersistableObjectHandler $audioHandler */ |
64
|
|
|
$audioHandler = $helper->getHandler('Audio'); |
65
|
|
|
// Load language files |
66
|
|
|
$helper->loadLanguage('blocks'); |
67
|
|
|
$helper->loadLanguage('common'); |
68
|
|
|
$helper->loadLanguage('main'); |
69
|
|
|
$helper->loadLanguage('modinfo'); |
70
|
|
|
$helper->loadLanguage('main'); |
71
|
|
|
//$helper->loadLanguage('user'); |
72
|
|
|
xoops_loadLanguage('user'); |
73
|
|
|
if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { |
74
|
|
|
require $GLOBALS['xoops']->path('class/template.php'); |
75
|
|
|
$xoopsTpl = new \XoopsTpl(); |
76
|
|
|
} |
77
|
|
|
$imageFactory = new ImageHandler($xoopsDB); |
78
|
|
|
$visitorsFactory = new VisitorsHandler($xoopsDB); |
79
|
|
|
$videosFactory = new VideoHandler($xoopsDB); |
80
|
|
|
$friendrequestFactory = new FriendrequestHandler($xoopsDB); |
81
|
|
|
$friendshipFactory = new FriendshipHandler($xoopsDB); |
82
|
|
|
$isOwner = 0; |
83
|
|
|
$isAnonym = 1; |
84
|
|
|
$isFriend = 0; |
85
|
|
|
if (1 === $helper->getConfig('enable_guestaccess')) { |
86
|
|
|
/** |
87
|
|
|
* Enable Guest Access |
88
|
|
|
* If anonym and uid not set then redirect to admins profile |
89
|
|
|
* Else redirects to own profile |
90
|
|
|
*/ |
91
|
|
|
if (empty($xoopsUser)) { |
92
|
|
|
$isAnonym = 1; |
93
|
|
|
if (isset($_GET['uid'])) { |
94
|
|
|
$uid_owner = Request::getInt('uid', 0, 'GET'); |
95
|
|
|
} else { |
96
|
|
|
$uid_owner = 1; |
97
|
|
|
$isOwner = 0; |
98
|
|
|
} |
99
|
|
|
} else { |
100
|
|
|
$isAnonym = 0; |
101
|
|
|
if (isset($_GET['uid'])) { |
102
|
|
|
$uid_owner = Request::getInt('uid', 0, 'GET'); |
103
|
|
|
$isOwner = $xoopsUser->getVar('uid') === $uid_owner ? 1 : 0; |
104
|
|
|
} else { |
105
|
|
|
$uid_owner = (int)$xoopsUser->getVar('uid'); |
106
|
|
|
$isOwner = 1; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
} else { |
110
|
|
|
/** |
111
|
|
|
* Disable Guest Access |
112
|
|
|
* If anonym redirect to landing guest page |
113
|
|
|
* Else redirects to own profile |
114
|
|
|
*/ |
115
|
|
|
if (empty($xoopsUser)) { |
116
|
|
|
$isAnonym = 1; |
117
|
|
|
if (!mb_stripos($_SERVER['REQUEST_URI'], 'user.php')) { |
118
|
|
|
$xoopsUser || redirect_header('user.php', 3, _NOPERM); |
119
|
|
|
} |
120
|
|
|
} else { |
121
|
|
|
$isAnonym = 0; |
122
|
|
|
if (isset($_GET['uid'])) { |
123
|
|
|
$uid_owner = Request::getInt('uid', 0, 'GET'); |
124
|
|
|
$isOwner = $xoopsUser->getVar('uid') === $uid_owner ? 1 : 0; |
125
|
|
|
} else { |
126
|
|
|
$uid_owner = (int)$xoopsUser->getVar('uid'); |
127
|
|
|
$isOwner = 1; |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: