Commit 6f895ba4 authored by Markus Sommer's avatar Markus Sommer Committed by Thomas Löffler

[TASK] CGL Fix

parent 99917543
......@@ -68,7 +68,7 @@ class tx_ter_api
*/
public function __construct($parentObj)
{
$this->helperObj = new tx_ter_helper ($parentObj);
$this->helperObj = new tx_ter_helper($parentObj);
$this->parentObj = $parentObj;
$this->cObj = $parentObj->cObj;
}
......@@ -128,15 +128,17 @@ class tx_ter_api
// All following code will then fail, because it is tested if it was an array.
// To make it work, we wrap the object into an array, so that the following code works as expected
if (!empty($extensionInfoData->technicalData->dependencies) && is_object(
$extensionInfoData->technicalData->dependencies
)
$extensionInfoData->technicalData->dependencies
)
) {
$extensionInfoData->technicalData->dependencies = [$extensionInfoData->technicalData->dependencies];
}
$extensionKey = strtolower($extensionInfoData->extensionKey);
if (TYPO3_DLOG) {
GeneralUtility::devLog(
'tx_ter_api->uploadExtension()', 'ter', 0,
'tx_ter_api->uploadExtension()',
'ter',
0,
'Upload of extension ' . $extensionKey . ' (' . $extensionInfoData->version . ') by user ' . $accountData->username
);
}
......@@ -147,8 +149,8 @@ class tx_ter_api
throw new tx_ter_exception_notFound('Extension "' . $extensionKey . '" does not exist.', TX_TER_ERROR_UPLOADEXTENSION_EXTENSIONDOESNTEXIST);
}
if (strtolower($extensionKeyRecordArr['ownerusername']) !== strtolower(
$accountData->username
) && $uploadUserRecordArr['admin'] !== true
$accountData->username
) && $uploadUserRecordArr['admin'] !== true
) {
throw new tx_ter_exception_unauthorized('Access denied.', TX_TER_ERROR_UPLOADEXTENSION_ACCESSDENIED);
}
......@@ -158,7 +160,8 @@ class tx_ter_api
throw new tx_ter_exception(
'Your version number "' . htmlspecialchars(
$extensionInfoData->version
) . '" is invalid. Allowed are three numbers with maximum 999, e.g. "7.8.999".', 1429912029
) . '" is invalid. Allowed are three numbers with maximum 999, e.g. "7.8.999".',
1429912029
);
}
......@@ -245,7 +248,8 @@ class tx_ter_api
throw new tx_ter_exception(
'Your version number "' . htmlspecialchars(
$extensionInfoData->version
) . '" is invalid. Allowed are three numbers with maximum 999, e.g. "7.8.999".', 1429912029
) . '" is invalid. Allowed are three numbers with maximum 999, e.g. "7.8.999".',
1429912029
);
}
......@@ -289,7 +293,9 @@ class tx_ter_api
{
if (TYPO3_DLOG) {
GeneralUtility::devLog(
'tx_ter_api->deleteExtension()', 'ter', 0,
'tx_ter_api->deleteExtension()',
'ter',
0,
'Deletion of extension ' . $extensionKey . ' (' . $version . ') by user ' . $accountData->username
);
}
......@@ -304,7 +310,8 @@ class tx_ter_api
$extensionKeyRecordArr = $this->helperObj->getExtensionKeyRecord($extensionKey);
if ($extensionKeyRecordArr == false) {
throw new tx_ter_exception_notFound(
'Extension does not exist.', TX_TER_ERROR_DELETEEXTENSION_EXTENSIONDOESNTEXIST
'Extension does not exist.',
TX_TER_ERROR_DELETEEXTENSION_EXTENSIONDOESNTEXIST
);
}
......@@ -403,27 +410,33 @@ class tx_ter_api
$whereClause = 'pid=' . (int)$this->parentObj->extensionsPID;
if (!empty($extensionKeyFilterOptions->username)) {
$whereClause .= ' AND ownerusername = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKeyFilterOptions->username, 'tx_ter_extensionkeys'
);
$extensionKeyFilterOptions->username,
'tx_ter_extensionkeys'
);
}
if (!empty($extensionKeyFilterOptions->title)) {
$whereClause .= ' AND title = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKeyFilterOptions->title, 'tx_ter_extensionkeys'
);
$extensionKeyFilterOptions->title,
'tx_ter_extensionkeys'
);
}
if (!empty($extensionKeyFilterOptions->description)) {
$whereClause .= ' AND description = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKeyFilterOptions->description, 'tx_ter_extensionkeys'
);
$extensionKeyFilterOptions->description,
'tx_ter_extensionkeys'
);
}
if (!empty($extensionKeyFilterOptions->extensionKey)) {
$whereClause .= ' AND extensionkey = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKeyFilterOptions->extensionKey, 'tx_ter_extensionkeys'
);
$extensionKeyFilterOptions->extensionKey,
'tx_ter_extensionkeys'
);
}
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'extensionkey,title,description,ownerusername', 'tx_ter_extensionkeys', $whereClause
'extensionkey,title,description,ownerusername',
'tx_ter_extensionkeys',
$whereClause
);
if ($res) {
......@@ -433,7 +446,8 @@ class tx_ter_api
$resultCode = TX_TER_RESULT_GENERAL_OK;
} else {
throw new tx_ter_exception_internalServerError(
'Database error while fetching extension keys.', TX_TER_ERROR_GENERAL_DATABASEERROR
'Database error while fetching extension keys.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
......@@ -465,15 +479,18 @@ class tx_ter_api
if (is_array($extensionKeyRecordArr)) {
if (strtolower($extensionKeyRecordArr['ownerusername']) != strtolower(
$accountData->username
) && $userRecordArr['admin'] !== true
$accountData->username
) && $userRecordArr['admin'] !== true
) {
throw new tx_ter_exception_unauthorized('Access denied.', TX_TER_ERROR_DELETEEXTENSIONKEY_ACCESSDENIED);
}
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'extensionkey', 'tx_ter_extensions', 'extensionkey=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKey, 'tx_ter_extensions'
'extensionkey',
'tx_ter_extensions',
'extensionkey=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKey,
'tx_ter_extensions'
) . ' AND pid=' . (int)$this->parentObj->extensionsPID
);
......@@ -482,13 +499,16 @@ class tx_ter_api
$resultCode = TX_TER_ERROR_DELETEEXTENSIONKEY_CANTDELETEBECAUSEVERSIONSEXIST;
} else {
$res = $GLOBALS['TYPO3_DB']->exec_DELETEquery(
'tx_ter_extensionkeys', 'extensionkey=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKey, 'tx_ter_extensions'
'tx_ter_extensionkeys',
'extensionkey=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKey,
'tx_ter_extensions'
) . ' AND pid=' . (int)$this->parentObj->extensionsPID
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
'Database error while deleting extension key.', TX_TER_ERROR_GENERAL_DATABASEERROR
'Database error while deleting extension key.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
......@@ -497,7 +517,8 @@ class tx_ter_api
}
} else {
throw new tx_ter_exception_internalServerError(
'Database error while fetching versions.', TX_TER_ERROR_GENERAL_DATABASEERROR
'Database error while fetching versions.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
} else {
......@@ -539,8 +560,8 @@ class tx_ter_api
if (is_array($extensionKeyRecordArr)) {
if (strtolower($extensionKeyRecordArr['ownerusername']) != strtolower(
$accountData->username
) && $userRecordArr['admin'] !== true
$accountData->username
) && $userRecordArr['admin'] !== true
) {
throw new tx_ter_exception_unauthorized('Access denied.', TX_TER_ERROR_MODIFYEXTENSIONKEY_ACCESSDENIED);
}
......@@ -614,7 +635,8 @@ class tx_ter_api
'DownloadCounter: Trying to increase extension download counters - user "' . $accountData->username . '" connected from IP "' . GeneralUtility::getIndpEnv(
'REMOTE_ADDR'
) . '" - number of results: ' . count($extensionVersionsAndIncrementors->extensionVersionAndIncrementor),
'tx_ter_api', 0
'tx_ter_api',
0
);
$userRecordArr = $this->helperObj->getValidUser($accountData);
......@@ -622,7 +644,9 @@ class tx_ter_api
if ($mirrorsFrontendUsergroupUid == 0) {
GeneralUtility::devLog(
'DownloadCounter: No usergroup for mirrors has been defined on the server side. Aborting ...', 'tx_ter_api', 3
'DownloadCounter: No usergroup for mirrors has been defined on the server side. Aborting ...',
'tx_ter_api',
3
);
throw new tx_ter_exception_internalServerError(
'Warning: No usergroup for mirrors has been defined on the server side. Aborting ...',
......@@ -631,7 +655,10 @@ class tx_ter_api
}
if (!GeneralUtility::inList($userRecordArr['usergroup'], $mirrorsFrontendUsergroupUid)) {
GeneralUtility::devLog(
'DownloadCounter: Access denied for user ' . $accountData->username, 'tx_ter_api', 3, $userRecordArr
'DownloadCounter: Access denied for user ' . $accountData->username,
'tx_ter_api',
3,
$userRecordArr
);
throw new tx_ter_exception_unauthorized('Access denied.', TX_TER_ERROR_INCREASEEXTENSIONDOWNLOADCOUNTER_ACCESSDENIED);
}
......@@ -658,7 +685,8 @@ class tx_ter_api
GeneralUtility::devLog(
'DownloadCounter: Increased download counter for ' . $counter . ' extensions. User "' . $accountData->username . '".',
'tx_ter_api', 0
'tx_ter_api',
0
);
// Update extension index file
$this->helperObj->requestUpdateOfExtensionIndexFile();
......@@ -666,7 +694,10 @@ class tx_ter_api
// Return results including list of error messages if any
if (!empty($errorMessages)) {
GeneralUtility::devLog(
'DownloadCounter: Errors occured for user "' . $accountData->username . '".', 'tx_ter_api', 2, $errorMessages
'DownloadCounter: Errors occured for user "' . $accountData->username . '".',
'tx_ter_api',
2,
$errorMessages
);
$result = [
'resultCode' => TX_TER_RESULT_ERRORS_OCCURRED,
......@@ -718,7 +749,8 @@ class tx_ter_api
{
if (!@is_dir($this->parentObj->repositoryDir)) {
throw new tx_ter_exception_internalServerError(
'Extension repository directory does not exist.', TX_TER_ERROR_GENERAL_EXTREPDIRDOESNTEXIST
'Extension repository directory does not exist.',
TX_TER_ERROR_GENERAL_EXTREPDIRDOESNTEXIST
);
}
if (!is_array($filesData->fileData)) {
......@@ -728,11 +760,11 @@ class tx_ter_api
// Prepare Files Data Array:
$preparedFilesDataArr = [];
foreach ($filesData->fileData as $fileData) {
$decodedContent = base64_decode($fileData->content);
if ($fileData->contentMD5 != md5($decodedContent)) {
throw new tx_ter_exception_notFound(
'MD5 does not match for file ' . (string)$fileData->name, TX_TER_ERROR_UPLOADEXTENSION_FILEMD5DOESNOTMATCH
'MD5 does not match for file ' . (string)$fileData->name,
TX_TER_ERROR_UPLOADEXTENSION_FILEMD5DOESNOTMATCH
);
}
......@@ -753,8 +785,10 @@ class tx_ter_api
foreach ($extensionInfoData->technicalData->dependencies as $dependency) {
$dependency = json_decode(json_encode($dependency), true);
if (!empty($dependency['kind']) && !empty($dependency['extensionKey']) && in_array(
$dependency['kind'], ['depends', 'conflicts', 'suggests'], true
)
$dependency['kind'],
['depends', 'conflicts', 'suggests'],
true
)
) {
$constraints[$dependency['kind']][$dependency['extensionKey']] = (string)$dependency['versionRange'];
}
......@@ -776,7 +810,9 @@ class tx_ter_api
'createDirs' => $extensionInfoData->technicalData->createDirs,
'modify_tables' => $extensionInfoData->technicalData->modifyTables,
'clearcacheonload' => in_array(
strtolower((string)$extensionInfoData->technicalData->clearCacheOnLoad), ['1', 'false'], true
strtolower((string)$extensionInfoData->technicalData->clearCacheOnLoad),
['1', 'false'],
true
),
'lockType' => $extensionInfoData->technicalData->lockType,
'author' => $extensionInfoData->metaData->authorName,
......@@ -820,7 +856,8 @@ class tx_ter_api
}
list($majorVersion, $minorVersion, $devVersion) = GeneralUtility::intExplode(
'.', $extensionInfoData->version
'.',
$extensionInfoData->version
);
$t3xFileName = $extensionKey . '_' . $majorVersion . '.' . $minorVersion . '.' . $devVersion . '.t3x';
......@@ -1021,15 +1058,20 @@ class tx_ter_api
{
if (!@is_dir($this->parentObj->repositoryDir)) {
throw new tx_ter_exception_internalServerError(
'Extension repository directory does not exist.', TX_TER_ERROR_GENERAL_EXTREPDIRDOESNTEXIST
'Extension repository directory does not exist.',
TX_TER_ERROR_GENERAL_EXTREPDIRDOESNTEXIST
);
}
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'uid', 'tx_ter_extensions', 'extensionkey=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKey, 'tx_ter_extensions'
'uid',
'tx_ter_extensions',
'extensionkey=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKey,
'tx_ter_extensions'
) . ' AND version=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$version, 'tx_ter_extensions'
$version,
'tx_ter_extensions'
) . ' AND pid=' . (int)$this->parentObj->extensionsPID
);
if (!$result) {
......@@ -1047,7 +1089,8 @@ class tx_ter_api
}
$result = $GLOBALS['TYPO3_DB']->exec_DELETEquery(
'tx_ter_extensiondetails', 'extensionuid = ' . (int)$extensionRow['uid']
'tx_ter_extensiondetails',
'extensionuid = ' . (int)$extensionRow['uid']
);
if (!$result) {
throw new tx_ter_exception_internalServerError(
......@@ -1056,8 +1099,10 @@ class tx_ter_api
);
}
$result = $GLOBALS['TYPO3_DB']->exec_DELETEquery(
'tx_ter_extensions', 'extensionkey=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKey, 'tx_ter_extensions'
'tx_ter_extensions',
'extensionkey=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKey,
'tx_ter_extensions'
) . ' AND version=' . $GLOBALS['TYPO3_DB']->fullquoteStr($version, 'tx_ter_extensions')
);
if (!$result) {
......@@ -1100,8 +1145,11 @@ class tx_ter_api
{
return $GLOBALS['TYPO3_DB']->sql_num_rows(
$GLOBALS['TYPO3_DB']->exec_SELECTquery(
'uid', 'tx_ter_extensions', 'extensionkey = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
strtolower($extensionInfoData->extensionKey), 'tx_ter_extensions'
'uid',
'tx_ter_extensions',
'extensionkey = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
strtolower($extensionInfoData->extensionKey),
'tx_ter_extensions'
) . ' AND version = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($extensionInfoData->version, 'tx_ter_extensions')
)
);
......@@ -1303,7 +1351,8 @@ class tx_ter_api
$result = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_ter_extensionkeys', $extensionKeysRow);
if (!$result) {
throw new tx_ter_exception_internalServerError(
'Database error while inserting extension key.', TX_TER_ERROR_REGISTEREXTENSIONKEY_DBERRORWHILEINSERTINGKEY
'Database error while inserting extension key.',
TX_TER_ERROR_REGISTEREXTENSIONKEY_DBERRORWHILEINSERTINGKEY
);
}
}
......@@ -1332,11 +1381,14 @@ class tx_ter_api
{
$updateValues = [];
if (isset ($modifyExtensionKeyData->ownerUsername)) {
if (isset($modifyExtensionKeyData->ownerUsername)) {
$modifyExtensionKeyData->ownerUsername;
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*', 'fe_users', 'username=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$modifyExtensionKeyData->ownerUsername, 'fe_users'
'*',
'fe_users',
'username=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$modifyExtensionKeyData->ownerUsername,
'fe_users'
) . $GLOBALS['TSFE']->sys_page->enableFields('fe_users')
);
if ($newOwnerUserRecordArr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
......@@ -1353,7 +1405,8 @@ class tx_ter_api
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
'Database error while updating extension key.', TX_TER_ERROR_GENERAL_DATABASEERROR
'Database error while updating extension key.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
......@@ -1383,30 +1436,38 @@ class tx_ter_api
protected function setReviewState_writeNewStateIntoDB($setReviewStateData)
{
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'uid', 'tx_ter_extensions', 'extensionkey =' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$setReviewStateData->extensionKey, 'tx_ter_extensions'
'uid',
'tx_ter_extensions',
'extensionkey =' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$setReviewStateData->extensionKey,
'tx_ter_extensions'
) . ' AND ' . 'version =' . $GLOBALS['TYPO3_DB']->fullQuoteStr($setReviewStateData->version, 'tx_ter_extensions')
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
'Database error while searching for extension record.', TX_TER_ERROR_GENERAL_DATABASEERROR
'Database error while searching for extension record.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) != 1) {
throw new tx_ter_exception_notFound(
'Extension version does not exist.', TX_TER_ERROR_SETREVIEWSTATE_EXTENSIONVERSIONDOESNOTEXIST
'Extension version does not exist.',
TX_TER_ERROR_SETREVIEWSTATE_EXTENSIONVERSIONDOESNOTEXIST
);
}
$res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
'tx_ter_extensions', 'extensionkey =' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$setReviewStateData->extensionKey, 'tx_ter_extensions'
'tx_ter_extensions',
'extensionkey =' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$setReviewStateData->extensionKey,
'tx_ter_extensions'
) . ' AND ' . 'version =' . $GLOBALS['TYPO3_DB']->fullQuoteStr($setReviewStateData->version, 'tx_ter_extensions'),
['reviewstate' => (int)$setReviewStateData->reviewState]
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
'Database error while updating extension review state.', TX_TER_ERROR_GENERAL_DATABASEERROR
'Database error while updating extension review state.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
}
......@@ -1435,20 +1496,26 @@ class tx_ter_api
protected function increaseExtensionDownloadCounter_increaseCounterInDB($extensionVersionDataAndIncrementor)
{
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'uid, downloadcounter', 'tx_ter_extensions', 'extensionkey =' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionVersionDataAndIncrementor->extensionKey, 'tx_ter_extensions'
'uid, downloadcounter',
'tx_ter_extensions',
'extensionkey =' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionVersionDataAndIncrementor->extensionKey,
'tx_ter_extensions'
) . ' AND ' . 'version =' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionVersionDataAndIncrementor->version, 'tx_ter_extensions'
$extensionVersionDataAndIncrementor->version,
'tx_ter_extensions'
)
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
'Database error while searching for extension record.', TX_TER_ERROR_GENERAL_DATABASEERROR
'Database error while searching for extension record.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) != 1) {
throw new tx_ter_exception_notFound(
'Extension version does not exist.', TX_TER_ERROR_INCREASEEXTENSIONDOWNLOADCOUNTER_EXTENSIONVERSIONDOESNOTEXIST
'Extension version does not exist.',
TX_TER_ERROR_INCREASEEXTENSIONDOWNLOADCOUNTER_EXTENSIONVERSIONDOESNOTEXIST
);
}
......@@ -1463,27 +1530,35 @@ class tx_ter_api
$newCounter = $currentRow['downloadcounter'] + $incrementor;
$res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
'tx_ter_extensions', 'uid=' . (int)$currentRow['uid'], ['downloadcounter' => $newCounter]
'tx_ter_extensions',
'uid=' . (int)$currentRow['uid'],
['downloadcounter' => $newCounter]
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
'Database error while updating extension download counter.', TX_TER_ERROR_GENERAL_DATABASEERROR
'Database error while updating extension download counter.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'uid, downloadcounter', 'tx_ter_extensionkeys', 'extensionkey =' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionVersionDataAndIncrementor->extensionKey, 'tx_ter_extensions'
'uid, downloadcounter',
'tx_ter_extensionkeys',
'extensionkey =' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionVersionDataAndIncrementor->extensionKey,
'tx_ter_extensions'
)
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
'Database error while searching for extension key record.', TX_TER_ERROR_GENERAL_DATABASEERROR
'Database error while searching for extension key record.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) != 1) {
throw new tx_ter_exception_notFound(
'Extension key does not exist.', TX_TER_ERROR_INCREASEEXTENSIONDOWNLOADCOUNTER_EXTENSIONKEYDOESNOTEXIST
'Extension key does not exist.',
TX_TER_ERROR_INCREASEEXTENSIONDOWNLOADCOUNTER_EXTENSIONKEYDOESNOTEXIST
);
}
......@@ -1491,11 +1566,14 @@ class tx_ter_api
$newCounter = $currentRow['downloadcounter'] + $incrementor;
$res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
'tx_ter_extensionkeys', 'uid=' . (int)$currentRow['uid'], ['downloadcounter' => $newCounter]
'tx_ter_extensionkeys',
'uid=' . (int)$currentRow['uid'],
['downloadcounter' => $newCounter]
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
'Database error while updating extension total download counter.', TX_TER_ERROR_GENERAL_DATABASEERROR
'Database error while updating extension total download counter.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
}
......
......@@ -14,4 +14,4 @@
*/
class tx_ter_exception extends Exception
{
}
\ No newline at end of file
}
......@@ -42,7 +42,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
// Make sure that we are executed only in TYPO3 context
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
die('Access denied.');
}
// Error codes:
......@@ -135,25 +135,30 @@ class tx_ter_helper
public function getValidUser($accountData)
{
if (!strlen($accountData->username) || (!strlen($accountData->password))) {
throw new tx_ter_exception_unauthorized ('No user or no password submitted.', TX_TER_ERROR_GENERAL_NOUSERORPASSWORD);
throw new tx_ter_exception_unauthorized('No user or no password submitted.', TX_TER_ERROR_GENERAL_NOUSERORPASSWORD);
}
$res = $this->getDatabaseConnection()->exec_SELECTquery(
'*', 'fe_users',
'*',
'fe_users',
'username=' . $this->getDatabaseConnection()->fullQuoteStr($accountData->username, 'fe_users') . $this->getTyposcriptFrontendObject()->sys_page->enableFields('fe_users')
);
if ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
if (!$this->userIsAlreadyLoggedIn($accountData) && !$this->ldapValidationSucceeded($accountData)) {
if (!$this->userIsAlreadyLoggedIn( $accountData
) && !$this->ldapValidationSucceeded($accountData)
) {
throw new tx_ter_exception_unauthorized ('Wrong password.', TX_TER_ERROR_GENERAL_WRONGPASSWORD);
}
} else {
throw new tx_ter_exception_unauthorized ('The specified user does not exist. You need to login first on extensions.typo3.org.', TX_TER_ERROR_GENERAL_USERNOTFOUND);
throw new tx_ter_exception_unauthorized('The specified user does not exist. You need to login first on extensions.typo3.org.', TX_TER_ERROR_GENERAL_USERNOTFOUND);
}
$row['admin'] = (intval($this->pluginObj->conf['adminFrontendUsergroupUid']) && GeneralUtility::inList(
$row['usergroup'], $this->pluginObj->conf['adminFrontendUsergroupUid']
));
$row['usergroup'],
$this->pluginObj->conf['adminFrontendUsergroupUid']
));
return $row;
}
......@@ -211,13 +216,18 @@ class tx_ter_helper
} else {
$success = false;
$res = $this->getDatabaseConnection()->exec_SELECTquery(
'*', 'fe_users', 'username=' . $this->getDatabaseConnection()->fullQuoteStr(
$accountData->username, 'fe_users'
'*',
'fe_users',
'username=' . $this->getDatabaseConnection()->fullQuoteStr(
$accountData->username,
'fe_users'
) . $GLOBALS['TSFE']->sys_page->enableFields('fe_users')
);
if ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
if ($this->ldapValidationSucceeded($accountData)) {