ggoffy /
wgevents
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 declare(strict_types=1); |
||
| 2 | |||
| 3 | /* |
||
| 4 | You may not change or alter any portion of this comment or credits |
||
| 5 | of supporting developers from this source code or any supporting source code |
||
| 6 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 7 | |||
| 8 | This program is distributed in the hope that it will be useful, |
||
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 11 | */ |
||
| 12 | |||
| 13 | /** |
||
| 14 | * wgEvents module for xoops |
||
| 15 | * |
||
| 16 | * @copyright 2021 XOOPS Project (https://xoops.org) |
||
| 17 | * @license GPL 2.0 or later |
||
| 18 | * @package wgevents |
||
| 19 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||
| 20 | */ |
||
| 21 | |||
| 22 | use Xmf\Request; |
||
|
0 ignored issues
–
show
|
|||
| 23 | use XoopsModules\Wgevents\ { |
||
| 24 | Export\Simplexlsxgen, |
||
| 25 | Export\Ics |
||
| 26 | }; |
||
| 27 | |||
| 28 | require __DIR__ . '/header.php'; |
||
| 29 | $GLOBALS['xoopsOption']['template_main'] = 'wgevents_export.tpl'; |
||
| 30 | require_once \XOOPS_ROOT_PATH . '/header.php'; |
||
| 31 | |||
| 32 | // Permission |
||
| 33 | if (!$permissionsHandler->getPermEventsView()) { |
||
| 34 | \redirect_header('index.php', 0); |
||
| 35 | } |
||
| 36 | |||
| 37 | $op = Request::getCmd('op', 'list'); |
||
| 38 | $start = Request::getInt('start'); |
||
| 39 | $limit = Request::getInt('limit', $helper->getConfig('userpager')); |
||
| 40 | $filterCats = Request::getArray('filter_cats'); |
||
| 41 | $chkEvents = Request::getArray('chk_event'); |
||
| 42 | |||
| 43 | if (Request::hasVar('datefrom')) { |
||
| 44 | // data from filter form: |
||
| 45 | $eventDatefromArr = Request::getArray('datefrom'); |
||
| 46 | $eventDatefromObj = \DateTime::createFromFormat(\_SHORTDATESTRING, $eventDatefromArr['date']); |
||
| 47 | $eventDatefromObj->setTime(0, 0); |
||
| 48 | $dateFrom = $eventDatefromObj->getTimestamp() + (int)$eventDatefromArr['time']; |
||
| 49 | $eventDatetoArr = Request::getArray('dateto'); |
||
| 50 | $eventDatetoObj = \DateTime::createFromFormat(\_SHORTDATESTRING, $eventDatetoArr['date']); |
||
| 51 | $eventDatetoObj->setTime(0, 0); |
||
| 52 | $dateTo = $eventDatetoObj->getTimestamp() + (int)$eventDatetoArr['time']; |
||
| 53 | } elseif (Request::hasVar('export_datefrom')) { |
||
| 54 | // data from other sources |
||
| 55 | $dateFrom = Request::getInt('export_datefrom'); |
||
| 56 | $dateTo = Request::getInt('export_dateto'); |
||
| 57 | } else { |
||
| 58 | // new load |
||
| 59 | $dateFrom = \time(); |
||
| 60 | $dateTo = \time() + 365*24*60*60; |
||
| 61 | } |
||
| 62 | $GLOBALS['xoopsTpl']->assign('dateFrom', $dateFrom); |
||
| 63 | $GLOBALS['xoopsTpl']->assign('dateTo', $dateTo); |
||
| 64 | if (Request::hasVar('export_limit')) { |
||
| 65 | // data from filter form: |
||
| 66 | $limit = Request::getInt('export_limit'); |
||
| 67 | } |
||
| 68 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||
| 69 | |||
| 70 | // get type of output |
||
| 71 | $outType = 'none'; |
||
| 72 | if (Request::hasVar('export_excel')) { |
||
| 73 | $outType = 'xlsx'; |
||
| 74 | } |
||
| 75 | if (Request::hasVar('export_ics')) { |
||
| 76 | $outType = 'ics'; |
||
| 77 | } |
||
| 78 | $new = Request::hasVar('new'); |
||
| 79 | |||
| 80 | $data = []; |
||
| 81 | if ('xlsx' === $outType) { |
||
| 82 | //add field names |
||
| 83 | $data[0] = [\_MA_WGEVENTS_EVENT_CATID, \_MA_WGEVENTS_EVENT_NAME, \_MA_WGEVENTS_EVENT_DESC, \_MA_WGEVENTS_EVENT_DATEFROM, \_MA_WGEVENTS_EVENT_DATETO, \_MA_WGEVENTS_EVENT_LOCATION]; |
||
| 84 | } |
||
| 85 | $filename = ''; |
||
| 86 | if ('xlsx' === $outType || 'ics' === $outType) { |
||
| 87 | $filename = \date('Ymd_H_i_s_') . \_MA_WGEVENTS_EVENTS . '.' . $outType; |
||
| 88 | } |
||
| 89 | |||
| 90 | // Define Stylesheet |
||
| 91 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||
| 92 | // Paths |
||
| 93 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_eventlogos_url', \WGEVENTS_UPLOAD_EVENTLOGOS_URL); |
||
| 94 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
||
| 95 | // JS |
||
| 96 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms.js'); |
||
| 97 | // Keywords |
||
| 98 | $keywords = []; |
||
| 99 | $keywords[] = \_MA_WGEVENTS_EVENTS_EXPORT; |
||
| 100 | $keywords[] = \_MA_WGEVENTS_OUTPUT_EXCEL; |
||
| 101 | $keywords[] = \_MA_WGEVENTS_OUTPUT_ICS; |
||
| 102 | // Breadcrumbs |
||
| 103 | $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_INDEX, 'link' => 'index.php']; |
||
| 104 | |||
| 105 | //preferences |
||
| 106 | $eventDisplayCats = (string)$helper->getConfig('event_displaycats'); |
||
| 107 | $GLOBALS['xoopsTpl']->assign('event_displaycats', $eventDisplayCats); |
||
| 108 | |||
| 109 | // get form for filtering events |
||
| 110 | $formFilter = $eventHandler->getFormFilterExport($limit, $dateFrom, $dateTo, $eventDisplayCats, $filterCats); |
||
| 111 | $GLOBALS['xoopsTpl']->assign('formFilter', $formFilter->render()); |
||
| 112 | |||
| 113 | // get events |
||
| 114 | $eventsArr = $eventHandler->getEvents($start, $limit, $dateFrom, $dateTo, '', '', $op, 0, '', $filterCats); |
||
| 115 | |||
| 116 | $eventsCount = $eventsArr['count']; |
||
| 117 | $GLOBALS['xoopsTpl']->assign('eventsCount', $eventsCount); |
||
| 118 | if ($eventsCount > 0) { |
||
| 119 | $eventsAll = $eventsArr['eventsAll']; |
||
| 120 | $events = []; |
||
| 121 | // Get All Event |
||
| 122 | foreach (\array_keys($eventsAll) as $i) { |
||
| 123 | $events[$i] = $eventsAll[$i]->getValuesEvents(); |
||
| 124 | if ($new) { |
||
| 125 | // preselect all events after new filter result |
||
| 126 | $events[$i]['checked'] = true; |
||
| 127 | } |
||
| 128 | if (\in_array($i, $chkEvents)) { |
||
| 129 | $events[$i]['checked'] = true; |
||
| 130 | if ('xlsx' === $outType) { |
||
| 131 | // prepare data for ouput as excel |
||
| 132 | $data[$i] = [ |
||
| 133 | $events[$i]['catname'], |
||
| 134 | $events[$i]['name'], |
||
| 135 | $events[$i]['desc_text'], |
||
| 136 | $events[$i]['datefrom_text'], |
||
| 137 | $events[$i]['dateto_text'], |
||
| 138 | $events[$i]['location_text'] |
||
| 139 | ]; |
||
| 140 | } |
||
| 141 | if ('ics' === $outType) { |
||
| 142 | // prepare data for ouput as ics |
||
| 143 | $data[$i] = $eventsAll[$i]; |
||
| 144 | } |
||
| 145 | } |
||
| 146 | } |
||
| 147 | // add data for displaying filtered events |
||
| 148 | $GLOBALS['xoopsTpl']->assign('events_list', $events); |
||
| 149 | |||
| 150 | // output of data |
||
| 151 | if ('xlsx' === $outType) { |
||
| 152 | $xlsx = Simplexlsxgen\SimpleXLSXGen::fromArray($data); |
||
| 153 | $xlsx->downloadAs($filename); |
||
| 154 | } |
||
| 155 | if ('ics' === $outType) { |
||
| 156 | $icsText = ''; |
||
| 157 | $exportICS = new Ics\ExportICS(); |
||
| 158 | $exportICS->setEvents($data); |
||
| 159 | $icsText .= $exportICS->createIcsHeader(); |
||
| 160 | $icsText .= $exportICS->createIcsEvent(); |
||
| 161 | $icsText .= $exportICS->createIcsFooter(); |
||
| 162 | $exportICS->downloadAsIcs($filename, $icsText); |
||
| 163 | } |
||
| 164 | |||
| 165 | unset($events); |
||
| 166 | // Display Navigation |
||
| 167 | if ($eventsCount > $limit) { |
||
| 168 | $urlCats = \implode(',', $filterCats); |
||
| 169 | require_once \XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
| 170 | $params = '&datefrom_val=' . $dateFrom . '&dateto_val=' . $dateTo . '&new=1&cats=' . $urlCats; |
||
| 171 | $pagenav = new \XoopsPageNav($eventsCount, $limit, $start, 'start', 'op=list&limit=' . $limit . $params); |
||
| 172 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
||
| 173 | } |
||
| 174 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||
| 175 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||
| 176 | |||
| 177 | $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', \_MA_WGEVENTS_EVENTS_EXPORT . ' - ' . $GLOBALS['xoopsModule']->getVar('name')); |
||
| 178 | |||
| 179 | } elseif (\count($filterCats) > 0) { |
||
| 180 | $GLOBALS['xoopsTpl']->assign('noEventsReason', \_MA_WGEVENTS_INDEX_THEREARENT_EVENTS_FILTER); |
||
| 181 | } else { |
||
| 182 | $GLOBALS['xoopsTpl']->assign('noEventsReason', \_MA_WGEVENTS_INDEX_THEREARENT_EVENTS); |
||
| 183 | } |
||
| 184 | |||
| 185 | // Keywords |
||
| 186 | wgeventsMetaKeywords($helper->getConfig('keywords') . ', ' . \implode(',', $keywords)); |
||
| 187 | unset($keywords); |
||
| 188 | |||
| 189 | // Description |
||
| 190 | wgeventsMetaDescription(\_MA_WGEVENTS_EVENTS_DESC); |
||
| 191 | $GLOBALS['xoopsTpl']->assign('xoops_mpageurl', \WGEVENTS_URL.'/event.php'); |
||
| 192 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
||
| 193 | |||
| 194 | require __DIR__ . '/footer.php'; |
||
| 195 |
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: