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
|
|
|
ConfigsHandler |
22
|
|
|
}; |
23
|
|
|
|
24
|
|
|
require __DIR__ . '/header.php'; |
25
|
|
|
/** |
26
|
|
|
* Factories of groups |
27
|
|
|
*/ |
28
|
|
|
$configsFactory = new ConfigsHandler($xoopsDB); |
29
|
|
|
/** |
30
|
|
|
* Verify Token |
31
|
|
|
*/ |
32
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
33
|
|
|
redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 3, _MD_SUICO_TOKENEXPIRED); |
34
|
|
|
} |
35
|
|
|
// $this->initVar("config_id",XOBJ_DTYPE_INT,null,false,10); |
36
|
|
|
// $this->initVar("config_uid",XOBJ_DTYPE_INT,null,false,10); |
37
|
|
|
// $this->initVar("pictures",XOBJ_DTYPE_INT,null,false,10); |
38
|
|
|
// $this->initVar("videos",XOBJ_DTYPE_INT,null,false,10); |
39
|
|
|
// $this->initVar("groups",XOBJ_DTYPE_INT,null,false,10); |
40
|
|
|
// $this->initVar("Notes",XOBJ_DTYPE_INT,null,false,10); |
41
|
|
|
// $this->initVar("friends",XOBJ_DTYPE_INT,null,false,10); |
42
|
|
|
// $this->initVar("profile_contact",XOBJ_DTYPE_INT,null,false,10); |
43
|
|
|
// $this->initVar("profile_general",XOBJ_DTYPE_INT,null,false,10); |
44
|
|
|
// $this->initVar("profile_stats",XOBJ_DTYPE_INT,null,false,10); |
45
|
|
|
// $this->initVar("suspension",XOBJ_DTYPE_INT,null,false,10); |
46
|
|
|
// $this->initVar("backup_password",XOBJ_DTYPE_TXTBOX, null, false); |
47
|
|
|
// $this->initVar("backup_email",XOBJ_DTYPE_TXTBOX, null, false); |
48
|
|
|
// $this->initVar("end_suspension",XOBJ_DTYPE_TXTBOX, null, false); |
49
|
|
|
//$pic = $_POST['pic']; |
50
|
|
|
//$vid = $_POST['vid']; |
51
|
|
|
//$aud = $_POST['aud']; |
52
|
|
|
//$tri = $_POST['groups']; |
53
|
|
|
//$fri = $_POST['friends']; |
54
|
|
|
//$scr = $_POST['notes']; |
55
|
|
|
//$pcon = $_POST['profileContact']; |
56
|
|
|
//$pgen = $_POST['gen']; |
57
|
|
|
//$psta = $_POST['stat']; |
58
|
|
|
$criteria = new Criteria('config_uid', $xoopsUser->getVar('uid')); |
59
|
|
|
if ($configsFactory->getCount($criteria) > 0) { |
60
|
|
|
$configs = $configsFactory->getObjects($criteria); |
61
|
|
|
$config = $configs[0]; |
62
|
|
|
$config->unsetNew(); |
63
|
|
|
} else { |
64
|
|
|
$config = $configsFactory->create(); |
65
|
|
|
} |
66
|
|
|
$config->setVar('config_uid', $xoopsUser->getVar('uid')); |
67
|
|
|
if (isset($_POST['pic'])) { |
68
|
|
|
$config->setVar('pictures', Request::getInt('pic', 0, 'POST')); |
69
|
|
|
} |
70
|
|
|
if (isset($_POST['aud'])) { |
71
|
|
|
$config->setVar('audio', Request::getInt('aud', 0, 'POST')); |
72
|
|
|
} |
73
|
|
|
if (isset($_POST['vid'])) { |
74
|
|
|
$config->setVar('videos', Request::getInt('vid', 0, 'POST')); |
75
|
|
|
} |
76
|
|
|
if (isset($_POST['groups'])) { |
77
|
|
|
$config->setVar('groups', Request::getInt('groups', 0, 'POST')); |
78
|
|
|
} |
79
|
|
|
if (isset($_POST['notes'])) { |
80
|
|
|
$config->setVar('notes', Request::getInt('notes', 0, 'POST')); |
81
|
|
|
} |
82
|
|
|
if (isset($_POST['friends'])) { |
83
|
|
|
$config->setVar('friends', Request::getInt('friends', 0, 'POST')); |
84
|
|
|
} |
85
|
|
|
if (isset($_POST['profileContact'])) { |
86
|
|
|
$config->setVar('profile_contact', Request::getInt('profileContact', 0, 'POST')); |
87
|
|
|
} |
88
|
|
|
if (isset($_POST['gen'])) { |
89
|
|
|
$config->setVar('profile_general', Request::getInt('gen', 0, 'POST')); |
90
|
|
|
} |
91
|
|
|
if (isset($_POST['stat'])) { |
92
|
|
|
$config->setVar('profile_stats', Request::getInt('stat', 0, 'POST')); |
93
|
|
|
} |
94
|
|
|
if ($configsFactory->insert2($config)) { |
95
|
|
|
redirect_header('configs.php?uid=' . $xoopsUser->getVar('uid'), 3, _MD_SUICO_CONFIGS_SAVE); |
96
|
|
|
} else { |
97
|
|
|
redirect_header('configs.php?uid=' . $xoopsUser->getVar('uid'), 3, _MD_SUICO_CONFIGS_SAVE_FAILED); |
98
|
|
|
} |
99
|
|
|
/** |
100
|
|
|
* Close page |
101
|
|
|
*/ |
102
|
|
|
require \dirname(__DIR__, 2) . '/footer.php'; |
103
|
|
|
|
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: