mambax7 /
pedigree
| 1 | <?php |
||
| 2 | // ------------------------------------------------------------------------- |
||
| 3 | |||
| 4 | use XoopsModules\Pedigree; |
||
|
0 ignored issues
–
show
|
|||
| 5 | |||
| 6 | |||
| 7 | //require_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
||
| 8 | require_once __DIR__ . '/header.php'; |
||
| 9 | |||
| 10 | $moduleDirName = basename(__DIR__); |
||
| 11 | xoops_loadLanguage('main', $moduleDirName); |
||
| 12 | |||
| 13 | // Include any common code for this module. |
||
| 14 | /* |
||
| 15 | // Get all HTTP post or get parameters into global variables that are prefixed with "param_" |
||
| 16 | //import_request_variables("gp", "param_"); |
||
| 17 | extract($_GET, EXTR_PREFIX_ALL, "param"); |
||
| 18 | extract($_POST, EXTR_PREFIX_ALL, "param"); |
||
| 19 | */ |
||
| 20 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_members.tpl'; |
||
| 21 | |||
| 22 | include $GLOBALS['xoops']->path('/header.php'); |
||
| 23 | |||
| 24 | $queryString = 'SELECT COUNT(d.user) AS X, d.user AS d_user, u.uname AS u_uname FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' d LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('users') . ' u ON d.user = u.uid GROUP BY user ORDER BY X DESC LIMIT 50'; |
||
| 25 | $result = $GLOBALS['xoopsDB']->query($queryString); |
||
| 26 | $numpos = 1; |
||
| 27 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
| 28 | $content = ''; |
||
| 29 | $star = $row['X']; |
||
| 30 | if ($star > 10000) { |
||
| 31 | $sterretje = floor($star / 10000); |
||
| 32 | for ($c = 0; $c < $sterretje; ++$c) { |
||
| 33 | $content .= '<img src="assets/images/star.png" border="0">'; |
||
| 34 | $star -= 10000; |
||
| 35 | } |
||
| 36 | } |
||
| 37 | if ($star > 1000) { |
||
| 38 | $sterretje = floor($star / 1000); |
||
| 39 | for ($c = 0; $c < $sterretje; ++$c) { |
||
| 40 | $content .= '<img src="assets/images/star3.gif" border="0">'; |
||
| 41 | $star -= 1000; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | if ($star > 100) { |
||
| 45 | $sterretje = floor($star / 100); |
||
| 46 | for ($c = 0; $c < $sterretje; ++$c) { |
||
| 47 | $content .= '<img src="assets/images/star2.gif" border="0">'; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | $members[] = [ |
||
| 52 | 'position' => $numpos, |
||
| 53 | 'user' => '<a href="../../userinfo.php?uid=' . $row['d_user'] . '">' . $row['u_uname'] . '</a>', |
||
| 54 | 'stars' => $content, |
||
| 55 | 'nument' => '<a href="result.php?f=user&l=0&w=' . $row['d_user'] . '&o=naam">' . $row['X'] . '</a>' |
||
| 56 | ]; |
||
| 57 | ++$numpos; |
||
| 58 | } |
||
| 59 | $GLOBALS['xoopsTpl']->assign('members', $members); |
||
| 60 | $GLOBALS['xoopsTpl']->assign('title', _MA_PEDIGREE_M50_TIT); |
||
| 61 | $GLOBALS['xoopsTpl']->assign('position', _MA_PEDIGREE_M50_POS); |
||
| 62 | $GLOBALS['xoopsTpl']->assign('numdogs', _MA_PEDIGREE_M50_NUMD); |
||
| 63 | //comments and footer |
||
| 64 | include $GLOBALS['xoops']->path('footer.php'); |
||
| 65 |
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: