XoopsModules25x /
lexikon
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Module: Lexikon - glossary module |
||
| 4 | * Version: v 1.00 |
||
| 5 | * Release Date: 18 Dec 2011 |
||
| 6 | * Author: Yerres |
||
| 7 | * adapted from news |
||
| 8 | * Licence: GNU |
||
| 9 | */ |
||
| 10 | |||
| 11 | use Xmf\Module\Admin; |
||
| 12 | use Xmf\Request; |
||
| 13 | use XoopsModules\Lexikon\{ |
||
| 14 | Helper, |
||
| 15 | Utility |
||
| 16 | }; |
||
| 17 | /** @var Helper $helper */ |
||
| 18 | |||
| 19 | require_once __DIR__ . '/admin_header.php'; |
||
| 20 | |||
| 21 | $helper = Helper::getInstance(); |
||
| 22 | |||
| 23 | $myts = \MyTextSanitizer::getInstance(); |
||
| 24 | if (!isset($op)) { |
||
| 25 | $op = ''; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Statistics about the Glossary: Definitions, Categories, views and authors |
||
| 30 | * |
||
| 31 | * You can reach the statistics from the admin part of the news module by clicking on the "Statistics" tabs |
||
| 32 | * The number of visible elements in each table is equal to the module's option called "perpage" |
||
| 33 | * There are three kind of different statistics : |
||
| 34 | * - Categories statistics |
||
| 35 | * For each Category you can see its number of definitions, the number of time each Definition was viewed, |
||
| 36 | * the number of unused i.e. offline or submitted Definitions and the number of unique authors. |
||
| 37 | * - Definitions statistics |
||
| 38 | * This part consists of 2 tables : |
||
| 39 | * a) Most read definitions |
||
| 40 | * This table resumes, for all the terms in your database, the most read Definitions. |
||
| 41 | * The table contains, for each term, its Category, name, author and the number of views. |
||
| 42 | * b) Less read Definitions |
||
| 43 | * That's the opposite action of the previous table and its content is the same |
||
| 44 | * - Authors statistics |
||
| 45 | * This part also consists of 2 tables |
||
| 46 | * a) Most read authors |
||
| 47 | * To create this table, the program computes the total number of reads per author and displays the most read author and the number of views |
||
| 48 | * b) Biggest contributors |
||
| 49 | * The goal of this table is to know who is creating the biggest number of terms. |
||
| 50 | **/ |
||
| 51 | function lx_Statistics() |
||
| 52 | { |
||
| 53 | global $xoopsModule, $xoopsConfig; |
||
| 54 | $helper = Helper::getInstance(); |
||
| 55 | xoops_load('XoopsUserUtility'); |
||
| 56 | xoops_cp_header(); |
||
| 57 | $myts = \MyTextSanitizer::getInstance(); |
||
| 58 | xoops_load('XoopsUserUtility'); // LionHell |
||
| 59 | |||
| 60 | $stats = []; |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 61 | $stats = lx_GetStatistics($helper->getConfig('perpage')); |
||
| 62 | $totals = [0, 0, 0, 0]; |
||
| 63 | |||
| 64 | $adminObject = Admin::getInstance(); |
||
| 65 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 66 | // First part of the stats, everything about categories |
||
| 67 | $termspercategory = $stats['termspercategory']; |
||
| 68 | $readspercategory = $stats['readspercategory']; |
||
| 69 | $offlinepercategory = $stats['offlinepercategory']; |
||
| 70 | $authorspercategory = $stats['authorspercategory']; |
||
| 71 | $class = ''; |
||
| 72 | |||
| 73 | echo "<div class='center;'><strong>" . _AM_LEXIKON_STATS0 . '</strong><br>'; |
||
| 74 | echo "<table class='outer' style='margin-top:6px; clear:both; width:99%;'>"; |
||
| 75 | echo "<tr class='bg3'><th style='text-align:center;'>" . _AM_LEXIKON_ENTRYCATNAME . "</th><th style='text-align:center;'>" . _AM_LEXIKON_TOTALENTRIES . '</th><th>' . _READS . '</th><th>' . _AM_LEXIKON_STATS6 . '</th><th>' . _AM_LEXIKON_STATS1 . '</th></tr>'; |
||
| 76 | |||
| 77 | foreach ($termspercategory as $categoryID => $data) { |
||
| 78 | $url = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/category.php?categoryID=' . $categoryID; |
||
| 79 | $views = 0; |
||
| 80 | if (array_key_exists($categoryID, $readspercategory)) { |
||
| 81 | $views = $readspercategory[$categoryID]; |
||
| 82 | } |
||
| 83 | $offline = 0; |
||
| 84 | if (array_key_exists($categoryID, $offlinepercategory)) { |
||
| 85 | $offline = $offlinepercategory[$categoryID]; |
||
| 86 | } |
||
| 87 | $authors = 0; |
||
| 88 | if (array_key_exists($categoryID, $authorspercategory)) { |
||
| 89 | $authors = $authorspercategory[$categoryID]; |
||
| 90 | } |
||
| 91 | $terms = $data['cpt']; |
||
| 92 | |||
| 93 | $totals[0] += $terms; |
||
| 94 | $totals[1] += $views; |
||
| 95 | $totals[2] += $offline; |
||
| 96 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
| 97 | printf( |
||
| 98 | "<tr class='" . $class . "'><td style='text-align:left;'><a href='%s' target ='_blank'>%s</a></td><td style='text-align:center;'>%u</td><td style='text-align:center;'>%u</td><td style='text-align:center;'>%u</td><td style='text-align:center;'>%u</td></tr>\n", |
||
| 99 | $url, |
||
| 100 | $myts->displayTarea($data['name']), |
||
| 101 | $terms, |
||
| 102 | $views, |
||
| 103 | $offline, |
||
| 104 | $authors |
||
| 105 | ); |
||
| 106 | } |
||
| 107 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
| 108 | printf("<tr class='" . $class . "'><td style='text-align:right;'><b>%s:</b></td><td style='text-align:center;'><b>%u</b></td><td style='text-align:center;'><b>%u</b></td><td style='text-align:center;'><b>%u</b></td><td> </td>\n", _AM_LEXIKON_STATS2, $totals[0], $totals[1], $totals[2]); |
||
| 109 | echo '</table></div><br><br>'; |
||
| 110 | |||
| 111 | // Second part of the stats, everything about reads |
||
| 112 | // a) Most read definitions |
||
| 113 | $mostreadterms = $stats['mostreadterms']; |
||
| 114 | |||
| 115 | echo "<div class='center;'><strong>" . _AM_LEXIKON_STATS3 . '</strong><br>' . _AM_LEXIKON_STATS4 . '<br>'; |
||
| 116 | echo "<table class='outer' style='margin-top:6px; clear:both; width:99%;'>"; |
||
| 117 | echo "<tr class='bg3'><th style='text-align:center;'>" . _AM_LEXIKON_ENTRYCATNAME . "</th><th style='text-align:center;'>" . _AM_LEXIKON_ENTRYTERM . '</th><th>' . _AM_LEXIKON_AUTHOR . '</th><th>' . _READS . '</th></tr>'; |
||
| 118 | foreach ($mostreadterms as $entryID => $data) { |
||
| 119 | $url1 = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/category.php?categoryID=' . $data['categoryID']; |
||
| 120 | $url2 = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/entry.php?entryID=' . $entryID; |
||
| 121 | $sentby = \XoopsUserUtility::getUnameFromId($data['uid']); |
||
| 122 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
| 123 | printf( |
||
| 124 | "<tr class='" . $class . "'><td style='text-align:left;'><a href='%s' target ='_blank'>%s</a></td><td style='text-align:left;'><a href='%s' target='_blank'>%s</a></td><td style='text-align:center;'>%s</td><td style='text-align:right;'>%u</td></tr>\n", |
||
| 125 | $url1, |
||
| 126 | $myts->displayTarea($data['name']), |
||
| 127 | $url2, |
||
| 128 | $myts->displayTarea($data['term']), |
||
| 129 | $sentby, |
||
| 130 | $data['counter'] |
||
| 131 | ); |
||
| 132 | } |
||
| 133 | echo '</table></div><br><br>'; |
||
| 134 | |||
| 135 | // b) Less read definitions |
||
| 136 | $lessreadnews = $stats['lessreadterms']; |
||
| 137 | echo "<div class='center;'><strong>" . _AM_LEXIKON_STATS5 . '</strong><br>'; |
||
| 138 | echo "<table class='outer' style='margin-top:6px; clear:both; width:99%;'>"; |
||
| 139 | echo "<tr class='bg3'><th style='text-align:center;'>" . _AM_LEXIKON_ENTRYCATNAME . "</th><th style='text-align:center;'>" . _AM_LEXIKON_ENTRYTERM . "</th><th style='text-align:center;'>" . _AM_LEXIKON_AUTHOR . "</th><th style='text-align:center;'>" . _READS . '</th></tr>'; |
||
| 140 | foreach ($lessreadnews as $entryID => $data) { |
||
| 141 | $url1 = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/category.php?categoryID=' . $data['categoryID']; |
||
| 142 | $url2 = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/entry.php?entryID=' . $entryID; |
||
| 143 | $sentby = \XoopsUserUtility::getUnameFromId($data['uid']); |
||
| 144 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
| 145 | printf( |
||
| 146 | "<tr class='" . $class . "'><td style='text-align:left;'><a href='%s' target ='_blank'>%s</a></td><td style='text-align:left;'><a href='%s' target='_blank'>%s</a></td><td style='text-align:center;'>%s</td><td style='text-align:right;'>%u</td></tr>\n", |
||
| 147 | $url1, |
||
| 148 | $myts->displayTarea($data['name']), |
||
| 149 | $url2, |
||
| 150 | $myts->displayTarea($data['term']), |
||
| 151 | $sentby, |
||
| 152 | $data['counter'] |
||
| 153 | ); |
||
| 154 | } |
||
| 155 | echo '</table></div><br><br>'; |
||
| 156 | |||
| 157 | // Last part of the stats, everything about authors |
||
| 158 | // a) Most read authors |
||
| 159 | $mostreadauthors = $stats['mostreadauthors']; |
||
| 160 | echo "<div class='center;'><strong>" . _AM_LEXIKON_STATS10 . '</strong><br>' . _AM_LEXIKON_STATS7 . '<br>'; |
||
| 161 | echo "<table class='outer' style='margin-top:6px; clear:both; width:99%;'>"; |
||
| 162 | echo "<tr class='bg3'><th style='text-align:center;'>" . _AM_LEXIKON_AUTHOR . "</th><th style='text-align:center;'>" . _READS . '</th></tr>'; |
||
| 163 | foreach ($mostreadauthors as $uid => $reads) { |
||
| 164 | $sentby = \XoopsUserUtility::getUnameFromId($uid); |
||
| 165 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
| 166 | printf("<tr class='" . $class . "'><td style='text-align:center;'>%s</td><td style='text-align:center;'>%u</td></tr>\n", $sentby, $reads); |
||
| 167 | } |
||
| 168 | echo '</table></div><br><br>'; |
||
| 169 | |||
| 170 | // c) Biggest contributors |
||
| 171 | $biggestcontributors = $stats['biggestcontributors']; |
||
| 172 | echo "<div class='center;'><strong>" . _AM_LEXIKON_STATS9 . '</strong><br>'; |
||
| 173 | echo "<table class='outer' style='margin-top:6px; clear:both; width:99%;'>"; |
||
| 174 | echo "<tr class='bg3'><th style='text-align:center;'>" . _AM_LEXIKON_AUTHOR . "</th><th style='text-align:center;'>" . _AM_LEXIKON_STATS11 . '</th></tr>'; |
||
| 175 | foreach ($biggestcontributors as $uid => $count) { |
||
| 176 | $url = XOOPS_URL . '/userinfo.php?uid=' . $uid; |
||
|
0 ignored issues
–
show
|
|||
| 177 | $sentby = \XoopsUserUtility::getUnameFromId($uid); |
||
| 178 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
| 179 | printf("<tr class='" . $class . "'><td style='text-align:center;'>%s</td><td style='text-align:center;'>%u</td></tr>\n", $sentby, $count); |
||
| 180 | } |
||
| 181 | echo '</table></div><br>'; |
||
| 182 | } |
||
| 183 | |||
| 184 | /* -- Available operations -- */ |
||
| 185 | $op = Request::getCmd('op', ''); |
||
| 186 | switch ($op) { |
||
| 187 | default: |
||
| 188 | lx_Statistics(); |
||
| 189 | break; |
||
| 190 | } |
||
| 191 | |||
| 192 | require_once __DIR__ . '/admin_footer.php'; |
||
| 193 |