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
|
|
|
use XoopsModules\Pedigree; |
24
|
|
|
|
25
|
|
|
require_once __DIR__ . '/header.php'; |
26
|
|
|
/** @var XoopsModules\Pedigree\Helper $helper */ |
27
|
|
|
$helper->loadLanguage('main'); |
28
|
|
|
|
29
|
|
|
require XOOPS_ROOT_PATH . '/header.php'; |
30
|
|
|
|
31
|
|
|
// Include any common code for this module. |
32
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php'; |
33
|
|
|
|
34
|
|
|
$naar = Request::getCmd('naar', '', 'POST'); |
35
|
|
|
$van = Request::getString('van', '', 'POST'); |
36
|
|
|
|
37
|
|
|
echo "<form method=\"post\" action=\"convert.php\" method=\"post\">\n" . "convert:<input type=\"text\" name=\"van\">\n" . "to:<input type=\"text\" name=\"naar\">\n" . "<input type=\"submit\"></form>\n"; |
38
|
|
|
|
39
|
|
|
//@todo refactor code to use Tree object access methods |
40
|
|
|
if ('' != $_POST['naar']) { |
41
|
|
|
$query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " SET user4 = '" . $naar . "' WHERE user4 = '" . $van . "'"; |
42
|
|
|
echo $query . '<br>'; |
43
|
|
|
$GLOBALS['xoopsDB']->query($query); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
$result = $GLOBALS['xoopsDB']->query("SELECT user4, COUNT('user4') AS X FROM " . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " GROUP BY 'user4'"); |
47
|
|
|
$count = 0; |
48
|
|
|
$total = 0; |
49
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
50
|
|
|
++$count; |
51
|
|
|
echo $row['user4'] . ' - ' . $row['X'] . '<br>'; |
52
|
|
|
$total += $row['X']; |
53
|
|
|
} |
54
|
|
|
echo '<hr>' . $count . '-' . $total; |
55
|
|
|
|
56
|
|
|
//comments and footer |
57
|
|
|
require XOOPS_ROOT_PATH . '/footer.php'; |
58
|
|
|
|
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: