Commit 8912153a authored by Carsten  Rose's avatar Carsten Rose
Browse files

Exception: rewrote getting T3 parameter without using Store(). Always report...

Exception: rewrote getting T3 parameter without using Store(). Always report pages.uid, tt_content.uid.
 T3Info.php: new class
 Sip.php: penalty time for broken sip.
 Store.php: moved T3 code to T3Info.php
parent 5229fb63
......@@ -10,5 +10,5 @@ $EM_CONF[$_EXTKEY] = array(
'dependencies' => 'fluid,extbase',
'clearcacheonload' => true,
'state' => 'alpha',
'version' => '0.16.0'
'version' => '0.16.1'
);
\ No newline at end of file
......@@ -821,3 +821,4 @@ const COLUMN_PAGES = "pages";
const FORM_NAME_FORM = 'form';
const FORM_NAME_FORM_ELEMENT = 'formElement';
const PENALTY_TIME_BROKEN_SIP = 5;
\ No newline at end of file
......@@ -8,9 +8,10 @@
namespace qfq;
require_once(__DIR__ . '/../../qfq/store/Store.php');
require_once(__DIR__ . '/../store/Store.php');
require_once(__DIR__ . '/UserFormException.php');
require_once(__DIR__ . '/../Constants.php');
require_once(__DIR__ . '/../store/T3Info.php');
class AbstractException extends \Exception {
......@@ -43,38 +44,40 @@ class AbstractException extends \Exception {
$this->messageArray['Message'] = $this->getMessage();
$this->messageArray['Code'] = $this->getCode();
$this->messageArray['Timestamp'] = date('Y.m.d H:i:s O');
//TODO: 'Client' will remove any HTML Tags before displaying. Formatting needs to be solved together with 'Client',
// Respect mode: 'form load' (plain HTML), 'Ajax alert'
$this->messageArray['Stacktrace'] = $this->getTraceAsString();
// $this->messageArray['Stacktrace'] = $this->getTrace();
if ($store !== null) {
$this->messageArray['Page Id'] = $store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);
$this->messageArray['Content Id'] = $store->getVar(TYPO3_TT_CONTENT_UID, STORE_TYPO3);
}
$arr = require_once(__DIR__ . '/../../qfq/store/T3Info.php');
$html .= "Code: " . htmlspecialchars($this->messageArray['Code']) . "<br>";
$html .= "Message: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray['Message'])) . "</br>";
$html .= "Message: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray['Message'])) . "<br>";
$t3Vars = T3Info::getVars();
$html .= 'Page Id: ' . $t3Vars[TYPO3_PAGE_ID] . '<br>';
$html .= 'Content Id: ' . $t3Vars[TYPO3_TT_CONTENT_UID] . '<br>';
// Form
if (isset($this->messageArray['Form'])) {
$html .= "Form: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray['Form'])) . "</br>";
if (isset($this->messageArray['Form']) && $this->messageArray['Form'] != '') {
$html .= "Form: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray['Form'])) . "<br>";
}
if (isset($this->messageArray['Form Element'])) {
$html .= "Form Element: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray['Form Element'])) . "</br>";
if (isset($this->messageArray['Form Element']) && $this->messageArray['Form Element'] != '') {
$html .= "Form Element: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray['Form Element'])) . "<br>";
}
// Report
if (isset($this->messageArray[SYSTEM_REPORT_COLUMN_INDEX])) {
$html .= "Column index: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray[SYSTEM_REPORT_COLUMN_INDEX])) . "</br>";
$html .= "Column index: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray[SYSTEM_REPORT_COLUMN_INDEX])) . "<br>";
}
if (isset($this->messageArray[SYSTEM_REPORT_COLUMN_NAME])) {
$html .= "Column name: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray[SYSTEM_REPORT_COLUMN_NAME])) . "</br>";
$html .= "Column name: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray[SYSTEM_REPORT_COLUMN_NAME])) . "<br>";
}
if (isset($this->messageArray[SYSTEM_REPORT_COLUMN_VALUE])) {
$html .= "Column value: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray[SYSTEM_REPORT_COLUMN_VALUE])) . "</br>";
$html .= "Column value: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray[SYSTEM_REPORT_COLUMN_VALUE])) . "<br>";
}
$html = "<h2>Error</h2>" . Support::wrapTag('<p>', $html);
......
......@@ -263,6 +263,7 @@ class Sip {
# Check if parameter is manipulated
if (strlen($s) != SIP_TOKEN_LENGTH) {
sleep(PENALTY_TIME_BROKEN_SIP);
throw new UserFormException("Broken Parameter", ERROR_BROKEN_PARAMETER);
}
......
......@@ -17,7 +17,7 @@ require_once(__DIR__ . '/../../qfq/helper/KeyValueStringParser.php');
require_once(__DIR__ . '/../../qfq/helper/Sanitize.php');
require_once(__DIR__ . '/../../qfq/Constants.php');
require_once(__DIR__ . '/../../qfq/store/Sip.php');
//require_once(__DIR__ . '/../../qfq/store/Session.php');
require_once(__DIR__ . '/../../qfq/store/T3Info.php');
require_once(__DIR__ . '/../../qfq/Database.php');
require_once(__DIR__ . '/../../qfq/store/Config.php');
......@@ -332,36 +332,7 @@ class Store {
$arr = KeyValueStringParser::parse($bodytext, "=", "\n");
if (isset($GLOBALS["TSFE"])) {
if (isset($GLOBALS["TSFE"]->fe_user->user["username"])) {
$arr[TYPO3_FE_USER] = $GLOBALS["TSFE"]->fe_user->user["username"];
}
if (isset($GLOBALS["TSFE"]->fe_user->user["uid"])) {
$feUid = $GLOBALS["TSFE"]->fe_user->user["uid"];
$arr[TYPO3_FE_USER_UID] = $GLOBALS["TSFE"]->fe_user->user["uid"];
}
if (isset($GLOBALS["TSFE"]->fe_user->user["usergroup"])) {
$arr[TYPO3_FE_USER_GROUP] = $GLOBALS["TSFE"]->fe_user->user["usergroup"];
}
if (isset($GLOBALS["TSFE"]->page["uid"])) {
$arr[TYPO3_TT_CONTENT_UID] = $GLOBALS["TSFE"]->page["uid"];
}
if (isset($GLOBALS["TSFE"]->id)) {
$arr[TYPO3_PAGE_ID] = $GLOBALS["TSFE"]->id;
}
if (isset($GLOBALS["TSFE"]->type)) {
$arr[TYPO3_PAGE_TYPE] = $GLOBALS["TSFE"]->type;
}
if (isset($GLOBALS["TSFE"]->sys_language_uid)) {
$arr[TYPO3_PAGE_LANGUAGE] = $GLOBALS["TSFE"]->sys_language_uid;
}
$arr = array_merge($arr, T3Info::getVars());
} else {
// No T3 environment (called by API): restore from SESSION
......
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 4/8/17
* Time: 6:53 PM
*/
namespace qfq;
class T3Info {
/**
* Collect some global T3 variables and return them as array.
*
* @return array
*/
public static function getVars() {
$t3vars = array();
if (isset($GLOBALS["TSFE"]->fe_user->user["username"])) {
$t3vars[TYPO3_FE_USER] = $GLOBALS["TSFE"]->fe_user->user["username"];
}
if (isset($GLOBALS["TSFE"]->fe_user->user["uid"])) {
$t3vars[TYPO3_FE_USER_UID] = $GLOBALS["TSFE"]->fe_user->user["uid"];
}
if (isset($GLOBALS["TSFE"]->fe_user->user["usergroup"])) {
$t3vars[TYPO3_FE_USER_GROUP] = $GLOBALS["TSFE"]->fe_user->user["usergroup"];
}
if (isset($GLOBALS["TSFE"]->page["uid"])) {
$t3vars[TYPO3_TT_CONTENT_UID] = $GLOBALS["TSFE"]->page["uid"];
}
if (isset($GLOBALS["TSFE"]->id)) {
$t3vars[TYPO3_PAGE_ID] = $GLOBALS["TSFE"]->id;
}
if (isset($GLOBALS["TSFE"]->type)) {
$t3vars[TYPO3_PAGE_TYPE] = $GLOBALS["TSFE"]->type;
}
if (isset($GLOBALS["TSFE"]->sys_language_uid)) {
$t3vars[TYPO3_PAGE_LANGUAGE] = $GLOBALS["TSFE"]->sys_language_uid;
}
return $t3vars;
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment