mambax7 /
pedigree
| 1 | <?php |
||
| 2 | // ------------------------------------------------------------------------- |
||
| 3 | |||
| 4 | use Xmf\Request; |
||
| 5 | use XoopsModules\Pedigree; |
||
|
0 ignored issues
–
show
|
|||
| 6 | |||
| 7 | |||
| 8 | //require_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
||
| 9 | require_once __DIR__ . '/header.php'; |
||
| 10 | $moduleDirName = basename(__DIR__); |
||
| 11 | xoops_loadLanguage('main', $moduleDirName); |
||
| 12 | // Include any common code for this module. |
||
| 13 | require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php'; |
||
| 14 | |||
| 15 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_delete.tpl'; |
||
| 16 | |||
| 17 | include XOOPS_ROOT_PATH . '/header.php'; |
||
| 18 | |||
| 19 | //check for access |
||
| 20 | $xoopsModule = XoopsModule::getByDirname($moduleDirName); |
||
| 21 | if (empty($GLOBALS['xoopsUser']) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
||
| 22 | redirect_header('javascript:history.go(-1)', 3, _NOPERM . '<br>' . _MA_PEDIGREE_REGIST); |
||
| 23 | } |
||
| 24 | |||
| 25 | global $xoopsTpl, $xoopsDB, $xoopsUser; |
||
| 26 | |||
| 27 | $ownid = Request::getInt('dogid', 0, 'post'); |
||
| 28 | $ownername = Request::getString('curname', '', 'post'); |
||
| 29 | |||
| 30 | if (!empty($ownername)) { |
||
| 31 | $queryString = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_owner') . ' WHERE id=' . $ownid; |
||
| 32 | $result = $GLOBALS['xoopsDB']->query($queryString); |
||
| 33 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
| 34 | //check for edit rights |
||
| 35 | $access = 0; |
||
| 36 | $xoopsModule = XoopsModule::getByDirname($moduleDirName); |
||
| 37 | if (!empty($xoopsUser)) { |
||
| 38 | if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
||
| 39 | $access = 1; |
||
| 40 | } |
||
| 41 | if ($row['user'] == $xoopsUser->getVar('uid')) { |
||
| 42 | $access = 1; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | if ('1' == $access) { |
||
| 46 | $delsql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_owner') . ' WHERE id =' . $row['id']; |
||
| 47 | $GLOBALS['xoopsDB']->query($delsql); |
||
| 48 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " SET id_owner = '0' where id_owner = " . $row['id']; |
||
| 49 | $GLOBALS['xoopsDB']->query($sql); |
||
| 50 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " SET id_breeder = '0' where id_breeder = " . $row['id']; |
||
| 51 | $GLOBALS['xoopsDB']->query($sql); |
||
| 52 | $ch = 1; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | if ($ch) { |
||
| 58 | redirect_header('index.php', 1, _MD_DATACHANGED); |
||
| 59 | } else { |
||
| 60 | redirect_header('owner.php?ownid=' . $ownid, 1, 'ERROR!!'); |
||
| 61 | } |
||
| 62 | //footer |
||
| 63 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
| 64 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes 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: