mambax7 /
wflinks
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 | * File: viewcat.php |
||||||||
| 4 | * Module: WF-Links |
||||||||
| 5 | * Developer: John N |
||||||||
| 6 | * Team: WF-Projects |
||||||||
| 7 | * Licence: GNU |
||||||||
| 8 | */ |
||||||||
| 9 | |||||||||
| 10 | use XoopsModules\Wflinks; |
||||||||
| 11 | |||||||||
| 12 | require_once __DIR__ . '/header.php'; |
||||||||
| 13 | |||||||||
| 14 | /** @var Wflinks\Helper $helper */ |
||||||||
| 15 | $helper = Wflinks\Helper::getInstance(); |
||||||||
| 16 | |||||||||
| 17 | // Begin Main page Heading etc |
||||||||
| 18 | $cid = \Xmf\Request::getInt('cid', 0); |
||||||||
| 19 | $selectdate = \Xmf\Request::getString('selectdate', ''); |
||||||||
| 20 | $list = \Xmf\Request::getString('list', ''); |
||||||||
| 21 | $catsort = $helper->getConfig('sortcats'); |
||||||||
| 22 | |||||||||
| 23 | $mytree = new Wflinks\Tree($xoopsDB->prefix('wflinks_cat'), 'cid', 'pid'); |
||||||||
| 24 | $arr = $mytree->getFirstChild($cid, $catsort); |
||||||||
| 25 | |||||||||
| 26 | if (is_array($arr) > 0 && !$list && !$selectdate) { |
||||||||
| 27 | if (false === Wflinks\Utility::checkGroups($cid)) { |
||||||||
| 28 | redirect_header('index.php', 1, _MD_WFL_MUSTREGFIRST); |
||||||||
| 29 | } |
||||||||
| 30 | } |
||||||||
| 31 | $GLOBALS['xoopsOption']['template_main'] = 'wflinks_viewcat.tpl'; |
||||||||
| 32 | require XOOPS_ROOT_PATH . '/header.php'; |
||||||||
| 33 | |||||||||
| 34 | // Breadcrumb |
||||||||
| 35 | $pathstring = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php">' . _MD_WFL_MAIN . '</a> : '; |
||||||||
| 36 | $pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcat.php?op='); |
||||||||
| 37 | $xoopsTpl->assign('category_path', $pathstring); |
||||||||
| 38 | $xoopsTpl->assign('category_id', $cid); |
||||||||
| 39 | |||||||||
| 40 | $time = time(); |
||||||||
| 41 | |||||||||
| 42 | // Display Sub-categories for selected Category |
||||||||
| 43 | if (is_array($arr) > 0 && !$list && !$selectdate) { |
||||||||
| 44 | $scount = 1; |
||||||||
| 45 | foreach ($arr as $ele) { |
||||||||
| 46 | if (false === Wflinks\Utility::checkGroups($ele['cid'])) { |
||||||||
| 47 | continue; |
||||||||
| 48 | } |
||||||||
| 49 | $sub_arr = []; |
||||||||
| 50 | $sub_arr = $mytree->getFirstChild($ele['cid'], 'title'); |
||||||||
| 51 | $space = 1; |
||||||||
| 52 | $chcount = 1; |
||||||||
| 53 | $infercategories = ''; |
||||||||
| 54 | foreach ($sub_arr as $sub_ele) { |
||||||||
| 55 | // Subitem file count |
||||||||
| 56 | $hassubitems = Wflinks\Utility::getTotalItems($sub_ele['cid']); |
||||||||
| 57 | // Filter group permissions |
||||||||
| 58 | if (true === Wflinks\Utility::checkGroups($sub_ele['cid'])) { |
||||||||
| 59 | // If subcategory count > 5 then finish adding subcats to $infercategories and end |
||||||||
| 60 | if ($chcount > 5) { |
||||||||
| 61 | $infercategories .= '...'; |
||||||||
| 62 | break; |
||||||||
| 63 | } |
||||||||
| 64 | if ($space > 0) { |
||||||||
| 65 | $infercategories .= ', '; |
||||||||
| 66 | } |
||||||||
| 67 | $infercategories .= "<a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $sub_ele['cid'] . "'>" . htmlspecialchars($sub_ele['title'], ENT_QUOTES | ENT_HTML5) . '</a> (' . $hassubitems['count'] . ')'; |
||||||||
| 68 | ++$space; |
||||||||
| 69 | ++$chcount; |
||||||||
| 70 | } |
||||||||
| 71 | } |
||||||||
| 72 | $totallinks = Wflinks\Utility::getTotalItems($ele['cid']); |
||||||||
| 73 | $indicator = Wflinks\Utility::isNewImage($totallinks['published']); |
||||||||
| 74 | |||||||||
| 75 | // This code is copyright WF-Projects |
||||||||
| 76 | // Using this code without our permission or removing this code voids the license agreement |
||||||||
| 77 | $_image = $ele['imgurl'] ? urldecode($ele['imgurl']) : ''; |
||||||||
| 78 | if ('' !== $_image && $helper->getConfig('usethumbs')) { |
||||||||
| 79 | $_thumb_image = new Wflinks\ThumbsNails($_image, $helper->getConfig('catimage'), 'thumbs'); |
||||||||
| 80 | if ($_thumb_image) { |
||||||||
| 81 | $_thumb_image->setUseThumbs(1); |
||||||||
| 82 | $_thumb_image->setImageType('gd2'); |
||||||||
| 83 | $_image = $_thumb_image->createThumb($helper->getConfig('shotwidth'), $helper->getConfig('shotheight'), $helper->getConfig('imagequality'), $helper->getConfig('updatethumbs'), $helper->getConfig('keepaspect')); |
||||||||
| 84 | } |
||||||||
| 85 | } |
||||||||
| 86 | $imgurl = "{$helper->getConfig('catimage')}/$_image"; |
||||||||
| 87 | if (empty($_image) || '' === $_image) { |
||||||||
| 88 | $imgurl = $indicator['image']; |
||||||||
| 89 | } |
||||||||
| 90 | // End |
||||||||
| 91 | $xoopsTpl->append( |
||||||||
| 92 | 'subcategories', |
||||||||
| 93 | [ |
||||||||
| 94 | 'title' => htmlspecialchars($ele['title'], ENT_QUOTES | ENT_HTML5), |
||||||||
| 95 | 'id' => $ele['cid'], |
||||||||
| 96 | 'image' => XOOPS_URL . "/$imgurl", |
||||||||
| 97 | 'infercategories' => $infercategories, |
||||||||
| 98 | 'totallinks' => $totallinks['count'], |
||||||||
| 99 | 'count' => $scount, |
||||||||
| 100 | 'alttext' => $ele['description'], |
||||||||
| 101 | ] |
||||||||
| 102 | ); |
||||||||
| 103 | ++$scount; |
||||||||
| 104 | } |
||||||||
| 105 | } |
||||||||
| 106 | |||||||||
| 107 | // Show Description for Category listing |
||||||||
| 108 | $sql = 'SELECT title, description, nohtml, nosmiley, noxcodes, noimages, nobreak, imgurl, client_id, banner_id FROM ' . $xoopsDB->prefix('wflinks_cat') . ' WHERE cid =' . $cid; |
||||||||
| 109 | $head_arr = $xoopsDB->fetchArray($xoopsDB->query($sql)); |
||||||||
| 110 | $html = $head_arr['nohtml'] ? 0 : 1; |
||||||||
| 111 | $smiley = $head_arr['nosmiley'] ? 0 : 1; |
||||||||
| 112 | $xcodes = $head_arr['noxcodes'] ? 0 : 1; |
||||||||
| 113 | $images = $head_arr['noimages'] ? 0 : 1; |
||||||||
| 114 | $breaks = $head_arr['nobreak'] ? 1 : 0; |
||||||||
| 115 | |||||||||
| 116 | $description = $myts->displayTarea($head_arr['description'], $html, $smiley, $xcodes, $images, $breaks); |
||||||||
| 117 | $xoopsTpl->assign('description', $description); |
||||||||
| 118 | $xoopsTpl->assign('xoops_pagetitle', $head_arr['title']); |
||||||||
| 119 | //$xoopsTpl -> assign( 'client_banner', Wflinks\Utility::getBannerFromIdClient($head_arr['client_id']) ); |
||||||||
| 120 | |||||||||
| 121 | if ($head_arr['client_id'] > 0) { |
||||||||
| 122 | $catarray['imageheader'] = Wflinks\Utility::getBannerFromIdClient($head_arr['client_id']); |
||||||||
| 123 | } elseif ($head_arr['banner_id'] > 0) { |
||||||||
| 124 | $catarray['imageheader'] = Wflinks\Utility::getBannerFromIdBanner($head_arr['banner_id']); |
||||||||
| 125 | } else { |
||||||||
| 126 | $catarray['imageheader'] = Wflinks\Utility::getImageHeader(); |
||||||||
| 127 | } |
||||||||
| 128 | $catarray['letters'] = Wflinks\Utility::getLetters(); |
||||||||
| 129 | $catarray['toolbar'] = Wflinks\Utility::getToolbar(); |
||||||||
| 130 | $xoopsTpl->assign('catarray', $catarray); |
||||||||
| 131 | |||||||||
| 132 | // Extract linkload information from database |
||||||||
| 133 | $xoopsTpl->assign('show_categort_title', true); |
||||||||
| 134 | |||||||||
| 135 | $start = \Xmf\Request::getInt('start', 0); |
||||||||
| 136 | $orderby = (isset($_REQUEST['orderby']) |
||||||||
| 137 | && !empty($_REQUEST['orderby'])) ? Wflinks\Utility::convertOrderByIn(htmlspecialchars($_REQUEST['orderby'], ENT_QUOTES | ENT_HTML5)) : Wflinks\Utility::convertOrderByIn($helper->getConfig('linkxorder')); |
||||||||
| 138 | |||||||||
| 139 | if ($selectdate) { |
||||||||
| 140 | $d = date('j', $selectdate); |
||||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||||
| 141 | $m = date('m', $selectdate); |
||||||||
| 142 | $y = date('Y', $selectdate); |
||||||||
| 143 | |||||||||
| 144 | $stat_begin = mktime(0, 0, 0, $m, $d, $y); |
||||||||
|
0 ignored issues
–
show
$y of type string is incompatible with the type integer expected by parameter $year of mktime().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
$m of type string is incompatible with the type integer expected by parameter $month of mktime().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
$d of type string is incompatible with the type integer expected by parameter $day of mktime().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||||
| 145 | $stat_end = mktime(23, 59, 59, $m, $d, $y); |
||||||||
| 146 | |||||||||
| 147 | $query = ' WHERE published >= ' . $stat_begin . ' AND published <= ' . $stat_end . ' |
||||||||
| 148 | AND (expired = 0 OR expired > ' . $time . ') |
||||||||
| 149 | AND offline = 0 |
||||||||
| 150 | AND cid > 0'; |
||||||||
| 151 | |||||||||
| 152 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_links') . $query . ' ORDER BY ' . $orderby; |
||||||||
| 153 | $result = $xoopsDB->query($sql, $helper->getConfig('perpage'), $start); |
||||||||
| 154 | |||||||||
| 155 | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wflinks_links') . $query; |
||||||||
| 156 | list($count) = $xoopsDB->fetchRow($xoopsDB->query($sql)); |
||||||||
| 157 | |||||||||
| 158 | $list_by = 'selectdate=' . $selectdate; |
||||||||
| 159 | } elseif ($list) { |
||||||||
| 160 | $query = " WHERE title LIKE '$list%' AND (published > 0 AND published <= " . $time . ') AND (expired = 0 OR expired > ' . $time . ') AND offline = 0 AND cid > 0'; |
||||||||
| 161 | |||||||||
| 162 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_links') . $query . ' ORDER BY ' . $orderby; |
||||||||
| 163 | $result = $xoopsDB->query($sql, $helper->getConfig('perpage'), $start); |
||||||||
| 164 | |||||||||
| 165 | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wflinks_links') . $query; |
||||||||
| 166 | list($count) = $xoopsDB->fetchRow($xoopsDB->query($sql)); |
||||||||
| 167 | $list_by = 'list=' . $list; |
||||||||
| 168 | } else { |
||||||||
| 169 | $sql = 'SELECT DISTINCT a.* FROM ' |
||||||||
| 170 | . $xoopsDB->prefix('wflinks_links') |
||||||||
| 171 | . ' a LEFT JOIN ' |
||||||||
| 172 | . $xoopsDB->prefix('wflinks_altcat') |
||||||||
| 173 | . ' b ' |
||||||||
| 174 | . ' ON b.lid = a.lid' |
||||||||
| 175 | . ' WHERE a.published > 0 AND a.published <= ' |
||||||||
| 176 | . $time |
||||||||
| 177 | . ' AND (a.expired = 0 OR a.expired > ' |
||||||||
| 178 | . $time |
||||||||
| 179 | . ') AND a.offline = 0' |
||||||||
| 180 | . ' AND (b.cid=a.cid OR (a.cid=' |
||||||||
| 181 | . $cid |
||||||||
| 182 | . ' OR b.cid=' |
||||||||
| 183 | . $cid |
||||||||
| 184 | . '))' |
||||||||
| 185 | . ' ORDER BY ' |
||||||||
| 186 | . $orderby; |
||||||||
| 187 | $result = $xoopsDB->query($sql, $helper->getConfig('perpage'), $start); |
||||||||
| 188 | $xoopsTpl->assign('show_categort_title', false); |
||||||||
| 189 | |||||||||
| 190 | $sql2 = 'SELECT COUNT(*) FROM ' |
||||||||
| 191 | . $xoopsDB->prefix('wflinks_links') |
||||||||
| 192 | . ' a LEFT JOIN ' |
||||||||
| 193 | . $xoopsDB->prefix('wflinks_altcat') |
||||||||
| 194 | . ' b ' |
||||||||
| 195 | . ' ON b.lid = a.lid' |
||||||||
| 196 | . ' WHERE a.published > 0 AND a.published <= ' |
||||||||
| 197 | . $time |
||||||||
| 198 | . ' AND (a.expired = 0 OR a.expired > ' |
||||||||
| 199 | . $time |
||||||||
| 200 | . ') AND a.offline = 0' |
||||||||
| 201 | . ' AND (b.cid=a.cid OR (a.cid=' |
||||||||
| 202 | . $cid |
||||||||
| 203 | . ' OR b.cid=' |
||||||||
| 204 | . $cid |
||||||||
| 205 | . '))'; |
||||||||
| 206 | list($count) = $xoopsDB->fetchRow($xoopsDB->query($sql2)); |
||||||||
| 207 | $order = Wflinks\Utility::convertOrderByOut($orderby); |
||||||||
| 208 | $cid = $cid; |
||||||||
| 209 | $list_by = 'cid=' . $cid . '&orderby=' . $order; |
||||||||
| 210 | } |
||||||||
| 211 | $pagenav = new \XoopsPageNav($count, $helper->getConfig('perpage'), $start, 'start', $list_by); |
||||||||
| 212 | $page_nav = $pagenav->renderNav(); |
||||||||
| 213 | $istrue = (isset($page_nav) && !empty($page_nav)); |
||||||||
| 214 | $xoopsTpl->assign('page_nav', $istrue); |
||||||||
| 215 | $xoopsTpl->assign('pagenav', $page_nav); |
||||||||
| 216 | $xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname')); |
||||||||
| 217 | |||||||||
| 218 | // Show links |
||||||||
| 219 | if ($count > 0) { |
||||||||
| 220 | $moderate = 0; |
||||||||
| 221 | while (false !== ($link_arr = $xoopsDB->fetchArray($result))) { |
||||||||
| 222 | $res_type = 0; |
||||||||
| 223 | require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/linkloadinfo.php'; |
||||||||
| 224 | $xoopsTpl->append('wfllink', $link); |
||||||||
| 225 | } |
||||||||
| 226 | |||||||||
| 227 | // Show order box |
||||||||
| 228 | $xoopsTpl->assign('show_links', false); |
||||||||
| 229 | if ($count > 1 && 0 != $cid) { |
||||||||
| 230 | $xoopsTpl->assign('show_links', true); |
||||||||
| 231 | $orderbyTrans = Wflinks\Utility::convertOrderByTrans($orderby); |
||||||||
| 232 | $xoopsTpl->assign('lang_cursortedby', sprintf(_MD_WFL_CURSORTBY, Wflinks\Utility::convertOrderByTrans($orderby))); |
||||||||
| 233 | $orderby = Wflinks\Utility::convertOrderByOut($orderby); |
||||||||
| 234 | } |
||||||||
| 235 | |||||||||
| 236 | // Screenshots display |
||||||||
| 237 | $xoopsTpl->assign('show_screenshot', false); |
||||||||
| 238 | if (null !== $helper->getConfig('screenshot') && 1 == $helper->getConfig('screenshot')) { |
||||||||
| 239 | $xoopsTpl->assign('shots_dir', $helper->getConfig('screenshots')); |
||||||||
| 240 | $xoopsTpl->assign('shotwidth', $helper->getConfig('shotwidth')); |
||||||||
| 241 | $xoopsTpl->assign('shotheight', $helper->getConfig('shotheight')); |
||||||||
| 242 | $xoopsTpl->assign('show_screenshot', true); |
||||||||
| 243 | } |
||||||||
| 244 | } |
||||||||
| 245 | unset($link_arr); |
||||||||
| 246 | |||||||||
| 247 | require XOOPS_ROOT_PATH . '/footer.php'; |
||||||||
| 248 |