1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits of |
4
|
|
|
supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit |
6
|
|
|
authors. |
7
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, but |
9
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Module: Pedigree |
15
|
|
|
* |
16
|
|
|
* @package XoopsModules\Pedigree |
17
|
|
|
* @author XOOPS Module Development Team |
18
|
|
|
* @copyright Copyright (c) 2001-2019 {@link https://xoops.org XOOPS Project} |
19
|
|
|
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
use Xmf\Request; |
|
|
|
|
23
|
|
|
|
24
|
|
|
//require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
25
|
|
|
require_once __DIR__ . '/header.php'; |
26
|
|
|
$moduleDirName = basename(__DIR__); |
27
|
|
|
xoops_loadLanguage('main', $moduleDirName); |
28
|
|
|
// Include any common code for this module. |
29
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php'; |
30
|
|
|
|
31
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'pedigree_delete.tpl'; |
32
|
|
|
|
33
|
|
|
require XOOPS_ROOT_PATH . '/header.php'; |
34
|
|
|
|
35
|
|
|
//check for access |
36
|
|
|
$xoopsModule = XoopsModule::getByDirname($moduleDirName); |
37
|
|
|
if (empty($GLOBALS['xoopsUser']) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
38
|
|
|
redirect_header('javascript:history.go(-1)', 3, _NOPERM . '<br>' . _MA_PEDIGREE_REGIST); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
global $xoopsTpl, $xoopsDB, $xoopsUser; |
42
|
|
|
|
43
|
|
|
$ownid = Request::getInt('dogid', 0, 'post'); |
44
|
|
|
$ownername = Request::getString('curname', '', 'post'); |
45
|
|
|
|
46
|
|
|
if (!empty($ownername)) { |
47
|
|
|
$sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_owner') . ' WHERE id=' . $ownid; |
48
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
49
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
50
|
|
|
//check for edit rights |
51
|
|
|
$access = 0; |
52
|
|
|
$xoopsModule = XoopsModule::getByDirname($moduleDirName); |
53
|
|
|
if (!empty($xoopsUser)) { |
54
|
|
|
if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
55
|
|
|
$access = 1; |
56
|
|
|
} |
57
|
|
|
if ($row['user'] == $xoopsUser->getVar('uid')) { |
58
|
|
|
$access = 1; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
if ('1' == $access) { |
62
|
|
|
$delsql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_owner') . ' WHERE id =' . $row['id']; |
63
|
|
|
$GLOBALS['xoopsDB']->query($delsql); |
64
|
|
|
$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " SET id_owner = '0' where id_owner = " . $row['id']; |
65
|
|
|
$GLOBALS['xoopsDB']->query($sql); |
66
|
|
|
$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " SET id_breeder = '0' where id_breeder = " . $row['id']; |
67
|
|
|
$GLOBALS['xoopsDB']->query($sql); |
68
|
|
|
$ch = 1; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
if ($ch) { |
74
|
|
|
redirect_header('index.php', 1, _MD_DATACHANGED); |
75
|
|
|
} else { |
76
|
|
|
redirect_header('owner.php?ownid=' . $ownid, 1, 'ERROR!!'); |
77
|
|
|
} |
78
|
|
|
//footer |
79
|
|
|
require XOOPS_ROOT_PATH . '/footer.php'; |
80
|
|
|
|
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: