mambax7 /
adslight
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 | * @copyright XOOPS Project (https://xoops.org) |
||
| 15 | * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 16 | * @author XOOPS Development Team |
||
| 17 | * @author Pascal Le Boustouller: original author ([email protected]) |
||
| 18 | * @author Luc Bizet (www.frxoops.org) |
||
| 19 | * @author jlm69 (www.jlmzone.com) |
||
| 20 | * @author mamba (www.xoops.org) |
||
| 21 | */ |
||
| 22 | $rssContent = []; |
||
| 23 | /** |
||
| 24 | * @param DOMDocument $item |
||
| 25 | * @param string $type |
||
| 26 | * @return array |
||
| 27 | */ |
||
| 28 | function rssTags($item, $type): array |
||
| 29 | { |
||
| 30 | $y = []; |
||
| 31 | $tnl = $item->getElementsByTagName('title'); |
||
| 32 | $tnl = $tnl->item(0); |
||
| 33 | $title = $tnl->firstChild->textContent; |
||
| 34 | $tnl = $item->getElementsByTagName('link'); |
||
| 35 | $tnl = $tnl->item(0); |
||
| 36 | $link = $tnl->firstChild->textContent; |
||
| 37 | $tnl = $item->getElementsByTagName('pubDate'); |
||
| 38 | $tnl = $tnl->item(0); |
||
| 39 | $date = $tnl->firstChild->textContent; |
||
| 40 | $tnl = $item->getElementsByTagName('description'); |
||
| 41 | $tnl = $tnl->item(0); |
||
| 42 | $description = $tnl->firstChild->textContent; |
||
| 43 | $y['title'] = $title; |
||
| 44 | $y['link'] = $link; |
||
| 45 | $y['date_created'] = $date; |
||
| 46 | $y['description'] = $description; |
||
| 47 | $y['type'] = $type; |
||
| 48 | |||
| 49 | return $y; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @param DOMDocument $channel |
||
| 54 | */ |
||
| 55 | function rssChannel($channel): void |
||
| 56 | { |
||
| 57 | global $rssContent; |
||
| 58 | $items = $channel->getElementsByTagName('item'); |
||
| 59 | // Processing channel |
||
| 60 | $y = rssTags($channel, 0); // get description of channel, type 0 |
||
| 61 | $rssContent[] = $y; |
||
| 62 | // Processing articles |
||
| 63 | foreach ($items as $item) { |
||
| 64 | $y = rssTags($item, 1); // get description of article, type 1 |
||
| 65 | $rssContent[] = $y; |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @param string $url |
||
| 71 | */ |
||
| 72 | function rssRetrieve($url): void |
||
| 73 | { |
||
| 74 | global $rssContent; |
||
| 75 | $doc = new DOMDocument(); |
||
| 76 | $doc->load($url); |
||
| 77 | $channels = $doc->getElementsByTagName('channel'); |
||
| 78 | $rssContent = []; |
||
| 79 | foreach ($channels as $channel) { |
||
| 80 | rssChannel($channel); |
||
| 81 | } |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @param string $url |
||
| 86 | */ |
||
| 87 | function rssRetrieveLinks($url): void |
||
| 88 | { |
||
| 89 | global $rssContent; |
||
| 90 | $doc = new DOMDocument(); |
||
| 91 | $doc->load($url); |
||
| 92 | $channels = $doc->getElementsByTagName('channel'); |
||
| 93 | $rssContent = []; |
||
| 94 | foreach ($channels as $channel) { |
||
| 95 | $items = $channel->getElementsByTagName('item'); |
||
| 96 | foreach ($items as $item) { |
||
| 97 | $y = rssTags($item, 1); // get description of article, type 1 |
||
| 98 | $rssContent[] = $y; |
||
| 99 | } |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @param string $url |
||
| 105 | * @param int $size |
||
| 106 | * @return string |
||
| 107 | */ |
||
| 108 | function rssLinks($url, $size = 15): string |
||
| 109 | { |
||
| 110 | global $rssContent; |
||
| 111 | $recents = []; |
||
| 112 | $page = '<ul>'; |
||
| 113 | rssRetrieveLinks($url); |
||
| 114 | if ($size > 0) { |
||
| 115 | $recents = array_slice($rssContent, 0, $size + 1); |
||
| 116 | } |
||
| 117 | foreach ($recents as $article) { |
||
| 118 | $type = $article['type']; |
||
| 119 | if (0 === $type) { |
||
| 120 | continue; |
||
| 121 | } |
||
| 122 | $title = $article['title']; |
||
| 123 | $link = $article['link']; |
||
| 124 | $page .= "<li><a href=\"{$link}\">{$title}</a></li>\n"; |
||
| 125 | } |
||
| 126 | |||
| 127 | return $page . "</ul>\n"; |
||
| 128 | } |
||
| 129 | |||
| 130 | /** |
||
| 131 | * @param string $url |
||
| 132 | * @param int $size |
||
| 133 | * @param int $site |
||
| 134 | * @return string |
||
| 135 | */ |
||
| 136 | function rssDisplay( |
||
| 137 | $url, |
||
| 138 | $size = 15, |
||
| 139 | $site = 0 |
||
| 140 | ): string { |
||
| 141 | global $rssContent; |
||
| 142 | $recents = []; |
||
| 143 | $opened = false; |
||
| 144 | $page = ''; |
||
| 145 | $site = 0 === (int)$site ? 1 : 0; |
||
| 146 | rssRetrieve($url); |
||
| 147 | if ($size > 0) { |
||
| 148 | $recents = array_slice($rssContent, $site, $size + 1 - $site); |
||
| 149 | } |
||
| 150 | foreach ($recents as $article) { |
||
| 151 | $type = $article['type']; |
||
| 152 | if (0 === $type) { |
||
| 153 | if ($opened) { |
||
| 154 | $page .= '</ul>'; |
||
| 155 | $opened = false; |
||
| 156 | } |
||
| 157 | $page .= '<b>'; |
||
| 158 | } elseif (!$opened) { |
||
| 159 | $page .= '<ul>'; |
||
| 160 | $opened = true; |
||
| 161 | } |
||
| 162 | |||
| 163 | $title = $article['title']; |
||
| 164 | $link = $article['link']; |
||
| 165 | $page .= "<tr class=\"even\"><td width=\"300\"><img src=\"/assets/images/admin/info_button.png\" border=\"0\"> <a href=\"{$link}\">{$title}</a><br>"; |
||
| 166 | $description = $article['description']; |
||
| 167 | if (false !== $description) { |
||
| 168 | $page .= "{$description}<br><br></td></tr>"; |
||
| 169 | } |
||
| 170 | $page .= ''; |
||
| 171 | if (0 === $type) { |
||
| 172 | $page .= '</b>'; |
||
| 173 | } |
||
| 174 | } |
||
| 175 | if ($opened) { |
||
| 176 | $page .= '</ul>'; |
||
| 177 | } |
||
| 178 | |||
| 179 | return $page; |
||
| 180 | } |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @param string $url |
||
| 184 | * @param int $size |
||
| 185 | * @param int $site |
||
| 186 | * @param int $withdate |
||
| 187 | * @return string |
||
| 188 | */ |
||
| 189 | function rssDisplayForum( |
||
| 190 | $url, |
||
| 191 | $size = 15, |
||
| 192 | $site = 0, |
||
| 193 | $withdate = 0 |
||
|
0 ignored issues
–
show
|
|||
| 194 | ): string { |
||
| 195 | global $rssContent; |
||
| 196 | $recents = []; |
||
| 197 | $opened = false; |
||
| 198 | $page = ''; |
||
| 199 | $site = 0 === (int)$site ? 1 : 0; |
||
| 200 | rssRetrieve($url); |
||
| 201 | if ($size > 0) { |
||
| 202 | $recents = array_slice($rssContent, $site, $size + 1 - $site); |
||
| 203 | } |
||
| 204 | foreach ($recents as $article) { |
||
| 205 | $type = $article['type']; |
||
| 206 | if (0 === $type) { |
||
| 207 | if ($opened) { |
||
| 208 | $page .= '</ul>'; |
||
| 209 | $opened = false; |
||
| 210 | } |
||
| 211 | $page .= '<b>'; |
||
| 212 | } elseif (!$opened) { |
||
| 213 | $page .= '<ul>'; |
||
| 214 | $opened = true; |
||
| 215 | } |
||
| 216 | |||
| 217 | $title = $article['title']; |
||
| 218 | $link = $article['link']; |
||
| 219 | |||
| 220 | $page .= "<img src=\"../assets/images/admin/comment.png\" border=0 > <a href=\"{$link}\">{$title}</a><br><br>"; |
||
| 221 | |||
| 222 | if (0 === $type) { |
||
| 223 | $page .= '</b>'; |
||
| 224 | } |
||
| 225 | } |
||
| 226 | if ($opened) { |
||
| 227 | $page .= '</ul>'; |
||
| 228 | } |
||
| 229 | |||
| 230 | return $page; |
||
| 231 | } |
||
| 232 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.