Issues (106)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

Classes/BeModules/Modfunc1.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace AOE\Languagevisibility\BeModules;
4
/***************************************************************
5
 * Copyright notice
6
 *
7
 * (c) 2008  <>
8
 * All rights reserved
9
 *
10
 * This script is part of the TYPO3 project. The TYPO3 project is
11
 * free software; you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation; either version 2 of the License, or
14
 * (at your option) any later version.
15
 *
16
 * The GNU General Public License can be found at
17
 * http://www.gnu.org/copyleft/gpl.html.
18
 *
19
 * This script is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * This copyright notice MUST APPEAR in all copies of the script!
25
 ***************************************************************/
26
27
use \TYPO3\CMS\Core\Utility\GeneralUtility;
28
use \TYPO3\CMS\Backend\Utility\BackendUtility;
29
use \TYPO3\CMS\Backend\Utility\IconUtility;
30
31
/**
32
 * Module extension (addition to function menu) 'Language Visibility Overview' for the 'testtt' extension.
33
 *
34
 * @author     <Daniel P�tzinger>
35
 * @package    TYPO3
36
 * @subpackage    tx_languagevisibility
37
 */
38
class Modfunc1 extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
39
40
	/**
41
	 * Returns the menu array
42
	 *
43
	 * @return	array
44
	 */
45
	public function modMenu() {
46
		$menuArray = array(
47
			'depth' => array(
48
				0 => $GLOBALS['LANG']->getLL('depth_0'),
49
				1 => $GLOBALS['LANG']->getLL('depth_1'),
50
				2 => $GLOBALS['LANG']->getLL('depth_2'),
51
				3 => $GLOBALS['LANG']->getLL('depth_3')
52
			)
53
		);
54
55
			// Languages:
56
		$languageRep = GeneralUtility::makeInstance('AOE\\Languagevisibility\\LanguageRepository');
57
		$languageList = $languageRep->getLanguages();
58
		$menuArray['lang'] = array(0 => '[All]' );
59
		foreach ( $languageList as $language ) {
60
			$menuArray['lang'][$language->getUid()] = $language->getTitle();
61
		}
62
63
		return $menuArray;
64
	}
65
66
	/**
67
	 * MAIN function for page information of localization
68
	 *
69
	 * @return	string		Output HTML for the module.
70
	 */
71
	public function main() {
72
		$theOutput = '';
73
		if ($this->pObj->id) {
74
75
				// Depth selector:
76
			$h_func = BackendUtility::getFuncMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth'], 'index.php');
77
			$h_func .= BackendUtility::getFuncMenu($this->pObj->id, 'SET[lang]', $this->pObj->MOD_SETTINGS['lang'], $this->pObj->MOD_MENU['lang'], 'index.php');
78
			$theOutput .= $h_func;
79
80
				// Add CSH:
81
			$theOutput .= BackendUtility::cshItem('_MOD_web_info', 'lang', $GLOBALS['BACK_PATH'], '|<br/>');
82
83
				// Showing the tree:
84
				// Initialize starting point of page tree:
85
			$treeStartingPoint = intval($this->pObj->id);
86
			$treeStartingRecord = BackendUtility::getRecordWSOL('pages', $treeStartingPoint);
87
			$depth = $this->pObj->MOD_SETTINGS['depth'];
88
89
				// Initialize tree object:
90
			$tree = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
91
			$tree->init('AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
92
			$tree->addField('l18n_cfg');
93
94
				// Creating top icon; the current page
95
			$HTML = IconUtility::getIconImage('pages', $treeStartingRecord, $GLOBALS['BACK_PATH'], 'align="top"');
96
			$tree->tree[] = array('row' => $treeStartingRecord, 'HTML' => $HTML );
97
98
				// Create the tree from starting point:
99
			if ($depth) {
100
				$tree->getTree($treeStartingPoint, $depth, '');
101
			}
102
103
				// Add CSS needed:
104
			$css_content = '
105
				TABLE#langTable {
106
					margin-top: 10px;
107
				}
108
				TABLE#langTable TR TD {
109
					padding-left : 2px;
110
					padding-right : 2px;
111
					white-space: nowrap;
112
				}
113
				TD.c-notvisible { background-color: red; }
114
				TD.c-visible { background-color: #669966; }
115
				TD.c-translated { background-color: #A8E95C; }
116
				TD.c-nottranslated { background-color: #E9CD5C; }
117
				TD.c-leftLine {border-left: 2px solid black; }
118
				.bgColor5 { font-weight: bold; }
119
			';
120
			$marker = '/*###POSTCSSMARKER###*/';
121
			$this->pObj->content = str_replace($marker, $css_content . chr(10) . $marker, $this->pObj->content);
122
123
				// Render information table:
124
			$theOutput .= $this->renderL10nTable($tree);
125
		}
126
127
		return $theOutput;
128
	}
129
130
	/**
131
	 * Rendering the localization information table.
132
	 *
133
	 * @param	array		The Page tree data
134
	 * @return	string		HTML for the localization information table.
135
	 */
136
	public function renderL10nTable(&$tree) {
137
			// Title length:
138
		$titleLen = $GLOBALS['BE_USER']->uc['titleLen'];
139
140
			// Put together the tree:
141
		$output = '';
142
		$newOL_js = array();
143
		$langRecUids = array();
144
145
			// Init DAO
146
		$dao = GeneralUtility::makeInstance('AOE\\Languagevisibility\\Dao\DaoCommon');
147
		$elementfactory = GeneralUtility::makeInstance('AOE\\Languagevisibility\\ElementFactory', $dao);
148
		$languageRep = GeneralUtility::makeInstance('AOE\\Languagevisibility\\LanguageRepository');
149
		$languageList = $languageRep->getLanguages();
150
		$visibility = GeneralUtility::makeInstance('AOE\\Languagevisibility\\Services\\VisibilityService');
151
152
			//traverse tree:
153
		foreach ( $tree->tree as $data ) {
154
			$tCells = array();
155
156
			$element = $elementfactory->getElementForTable('pages', $data['row']['uid']);
157
158
				// first cell (tree):
159
				// Page icons / titles etc.
160
			$tCells[] = '<td' . ($data['row']['_CSSCLASS'] ? ' class="' . $data['row']['_CSSCLASS'] . '"' : '') . '>' . $data['HTML'] . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($data['row']['title'], $titleLen)) . (strcmp($data['row']['nav_title'], '') ? ' [Nav: <em>' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($data['row']['nav_title'], $titleLen)) . '</em>]' : '') . '</td>';
161
				// language cells:
162
			foreach ( $languageList as $language ) {
163
				$info = '';
164
				$editUid = $data['row']['uid'];
165
				$params = '&edit[pages][' . $editUid . ']=edit';
166
				$langId = $language->getUid();
167
				if ($visibility->isVisible($language, $element)) {
168
					$isVisible = TRUE;
169
					$statusVis = 'c-visible';
170
				} else {
171
					$isVisible = FALSE;
172
					$statusVis = 'c-notvisible';
173
				}
174
				if ($element->hasTranslation($langId)) {
175
					$statusTrans = 'c-translated';
176
				} else {
177
					$statusTrans = 'c-nottranslated';
178
				}
179
180
				if ($language->getUid() == 0) {
181
						// Default
182
						// "View page" link is created:
183
					$viewPageLink = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($data['row']['uid'], $GLOBALS['BACK_PATH'], '', '', '', '&L=###LANG_UID###')) . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_viewPage', '1') . '" border="0" alt="" />' . '</a>';
0 ignored issues
show
'' is of type string, but the function expects a array|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
184
					$info .= '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif', 'width="11" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_editDefaultLanguagePage', '1') . '" border="0" alt="" />' . '</a>';
185
					$info .= '<a href="#" onclick="' . htmlspecialchars('top.loadEditId(' . intval($data['row']['uid']) . ',"&SET[language]=0"); return FALSE;') . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit_page.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_editPage', '1') . '" border="0" alt="" />' . '</a>';
186
					$info .= str_replace('###LANG_UID###', '0', $viewPageLink);
187
					$info .= $data['row']['l18n_cfg'] & 1 ? '<span title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/locallang_tca.php:pages.l18n_cfg.I.1', '1') . '">D</span>' : '&nbsp;';
188
						// Put into cell:
189
					$tCells[] = '<td class="' . $statusTrans . ' c-leftLine">' . $info . '</td>';
190
					$tCells[] = '<td class="' . $statusTrans . '" title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_CEcount', '1') . '" align="center">' . $this->getContentElementCount($data['row']['uid'], 0) . '</td>';
191
192
				} else {
193
						// Normal Language:
194
					if ($element->hasTranslation($langId)) {
195
						$viewPageLink = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($data['row']['uid'], $GLOBALS['BACK_PATH'], '', '', '', '&L=###LANG_UID###')) . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_viewPage', '1') . '" border="0" alt="" />' . '</a>';
0 ignored issues
show
'' is of type string, but the function expects a array|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
196
197
						$overLayRow = $element->getOverLayRecordForCertainLanguage($langId);
198
							// add uid of overlay to list of editable records:
199
						$langRecUids[$langId][] = $overLayRow['uid'];
200
						$icon = IconUtility::getIconImage('pages_language_overlay', $overLayRow, $GLOBALS['BACK_PATH'], 'align="top" class="c-recIcon"');
201
202
						$info = $icon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($overLayRow['title'], $titleLen)) . (strcmp($overLayRow['nav_title'], '') ? ' [Nav: <em>' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($overLayRow['nav_title'], $titleLen)) . '</em>]' : '') . ($overLayRow['_COUNT'] > 1 ? '<div>' . $GLOBALS['LANG']->getLL('lang_renderl10n_badThingThereAre', '1') . '</div>' : '');
203
						$tCells[] = '<td class="' . $statusTrans . ' c-leftLine">' . $info . '</td>';
204
205
							// Edit whole record:
206
						$info = '';
207
						$editUid = $overLayRow['uid'];
208
						$params = '&edit[pages_language_overlay][' . $editUid . ']=edit';
209
						$info .= '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif', 'width="11" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_editLanguageOverlayRecord', '1') . '" border="0" alt="" />' . '</a>';
210
211
						$info .= '<a href="#" onclick="' . htmlspecialchars('top.loadEditId(' . intval($data['row']['uid']) . ',"&SET[language]=' . $langId . '"); return FALSE;') . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit_page.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_editPageLang', '1') . '" border="0" alt="" />' . '</a>';
212
						$info .= str_replace('###LANG_UID###', $langId, $viewPageLink);
213
214
						$tCells[] = '<td class="' . $statusTrans . '">' . $info . '</td>';
215
						$tCells[] = '<td class="' . $statusTrans . '" title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_CEcount', '1') . '" align="center">' . $this->getContentElementCount($data['row']['uid'], $langId) . '</td>';
216
					} else {
217
						$tCells[] = '<td class="' . $statusTrans . ' c-leftLine">&nbsp;</td>';
218
						$tCells[] = '<td class="' . $statusTrans . '">&nbsp;</td>';
219
						//add to JS
220
						$infoCell = '<input type="checkbox" name="newOL[' . $langId . '][' . $data['row']['uid'] . ']" value="1" />';
221
						$newOL_js[$langId] .= '
222
								+(document.webinfoForm[\'newOL[' . $langId . '][' . $data['row']['uid'] . ']\'].checked ? \'&edit[pages_language_overlay][' . $data['row']['uid'] . ']=new\' : \'\')
223
							';
224
						$tCells[] = '<td class="' . $statusTrans . '">' . $infoCell . '</td>';
225
226
					}
227
				}
228
				//last cell show status
229
				$tCells[] = '<td class="' . $statusVis . '">' . $this->_getStatusImage($isVisible) . '</td>';
230
			}
231
			$output .= '
232
			<tr class="bgColor5">
233
				' . implode('
234
				', $tCells) . '
235
			</tr>';
236
		}
237
238
			// first ROW:
239
		$firstRowCells = array();
240
		$firstRowCells[] = '<td>' . $GLOBALS['LANG']->getLL('lang_renderl10n_page', '1') . ':</td>';
241
		foreach ( $languageList as $language ) {
242
			$langId = $language->getUid();
243
			if ($this->pObj->MOD_SETTINGS['lang'] == 0 || ( int ) $this->pObj->MOD_SETTINGS['lang'] === ( int ) $langId) {
244
				$firstRowCells[] = '<td class="c-leftLine">' . $language->getTitle() . $language->getFlagImg() . '</td>';
245
				if ($langId == 0) {
246
					$firstRowCells[] = '<td></td>';
247
					$firstRowCells[] = '<td></td>';
248
				} else {
249
					// Title:
250
251
252
					// Edit language overlay records:
253
					if (is_array($langRecUids[$langId])) {
254
						$params = '&edit[pages_language_overlay][' . implode(',', $langRecUids[$langId]) . ']=edit&columnsOnly=title,nav_title,hidden';
255
						$firstRowCells[] = '<td><a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '">
256
							<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif', 'width="11" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_renderl10n_editLangOverlays', '1') . '" border="0" alt="" />
257
							</a></td>';
258
					} else {
259
						$firstRowCells[] = '<td>&nbsp;</td>';
260
					}
261
262
					// Create new overlay records:
263
					$params = "'" . $newOL_js[$langId] . "+'&columnsOnly=title,hidden,sys_language_uid&defVals[pages_language_overlay][sys_language_uid]=" . $langId;
264
					$firstRowCells[] = '<td><a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '">
265
						<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/new_el.gif', 'width="11" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('lang_getlangsta_createNewTranslationHeaders', '1') . '" border="0" alt="" />
266
						</a></td>';
267
					$firstRowCells[] = '<td></td>';
268
				}
269
			}
270
		}
271
272
		$output = '
273
			<tr class="bgColor4">
274
				' . implode('
275
				', $firstRowCells) . '
276
			</tr>' . $output;
277
278
		$output = '
279
280
		<table border="0" cellspacing="0" cellpadding="0" id="langTable">' . $output . '
281
		</table>';
282
283
		return $output;
284
	}
285
286
	protected function _getStatusImage($stat) {
287
		if ($stat) {
288
			return '<img src="' . $GLOBALS['BACK_PATH'] . '../typo3conf/ext/languagevisibility/Resources/Public/Icons/ok.gif">';
289
		} else {
290
			return '<img src="' . $GLOBALS['BACK_PATH'] . '../typo3conf/ext/languagevisibility/Resources/Public/Icons/nok.gif">';
291
		}
292
	}
293
294
	/**
295
	 * Counting content elements for a single language on a page.
296
	 *
297
	 * @param	integer		Page id to select for.
298
	 * @param	integer		Sys language uid
299
	 * @return	integer		Number of content elements from the PID where the language is set to a certain value.
300
	 */
301
	public function getContentElementCount($pageId, $sysLang) {
302
		if ($sysLang == 0) {
303
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'tt_content', 'pid=' . intval($pageId) . ' AND sys_language_uid=' . intval($sysLang) . BackendUtility::deleteClause('tt_content') . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('tt_content'));
304
			list ( $count ) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
305
		}
306
307
		return $count ? $count : '-';
0 ignored issues
show
The variable $count does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
308
	}
309
}
310
311
if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/languagevisibility/modfunc1/class.tx_languagevisibility_modfunc1.php']) {
312
	include_once ($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/languagevisibility/modfunc1/class.tx_languagevisibility_modfunc1.php']);
313
}
314