/** * Spam-Validation of given Params * see powermail/doc/SpamDetection for formula * * @param array $params * @return bool */ public function isValid($params) { if (!$this->settings['spamshield.']['_enable']) { return true; } $this->div = t3lib_div::makeInstance('Tx_Powermail_Utility_Div'); $spamFactor = $this->settings['spamshield.']['factor'] / 100; // Different checks to increase spam indicator $this->honeypodCheck($params, $this->settings['spamshield.']['indicator.']['honeypod']); $this->linkCheck($params, $this->settings['spamshield.']['indicator.']['link'], $this->settings['spamshield.']['indicator.']['linkLimit']); $this->nameCheck($params, $this->settings['spamshield.']['indicator.']['name']); $this->sessionCheck($this->settings['spamshield.']['indicator.']['session']); $this->uniqueCheck($params, $this->settings['spamshield.']['indicator.']['unique']); $this->blacklistStringCheck($params, $this->settings['spamshield.']['indicator.']['blacklistString']); $this->blacklistIpCheck($this->settings['spamshield.']['indicator.']['blacklistIp']); // spam formula with asymptote 1 (100%) if ($this->spamIndicator > 0) { $thisSpamFactor = -1 / $this->spamIndicator + 1; } else { $thisSpamFactor = 0; } // Save Spam Factor in session for db storage $GLOBALS['TSFE']->fe_user->setKey('ses', 'powermail_spamfactor', $this->formatSpamFactor($thisSpamFactor)); $GLOBALS['TSFE']->storeSessionData(); // Spam debugging if ($this->settings['debug.']['spamshield']) { t3lib_utility_Debug::debug($this->msg, 'powermail debug: Show Spamchecks - Spamfactor ' . $this->formatSpamFactor($thisSpamFactor)); } // if spam if ($thisSpamFactor >= $spamFactor) { $this->addError('spam_details', $this->formatSpamFactor($thisSpamFactor)); // Send notification email to admin if (t3lib_div::validEmail($this->settings['spamshield.']['email'])) { $subject = 'Spam in powermail form recognized'; $message = 'Possible spam in powermail form on page with PID ' . $GLOBALS['TSFE']->id; $message .= "\n\n"; $message .= 'Spamfactor of this mail: ' . $this->formatSpamFactor($thisSpamFactor) . "\n"; $message .= "\n\n"; $message .= 'Failed Spamchecks:' . "\n"; $message .= Tx_Powermail_Utility_Div::viewPlainArray($this->msg); $message .= "\n\n"; $message .= 'Given Form variables:' . "\n"; $message .= Tx_Powermail_Utility_Div::viewPlainArray($params); $header = 'MIME-Version: 1.0' . "\r\n"; $header .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $header .= 'From: powermail@' . t3lib_div::getIndpEnv('TYPO3_HOST_ONLY') . "\r\n"; t3lib_div::plainMailEncoded($this->settings['spamshield.']['email'], $subject, $message, $header); } return false; } return true; }
/** * Makes debug output * Prints $var in bold between two vertical lines * If not $var the word 'debug' is printed * If $var is an array, the array is printed by t3lib_div::print_array() * Wrapper method for TYPO3 debug methods * * @param mixed Variable to print * @param string The header. * @param string Group for the debug console * @return void */ public static function debug($var = '', $header = '', $group = 'Debug') { if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { return \TYPO3\CMS\Core\Utility\DebugUtility::debug($var, $header, $group); } else { return t3lib_utility_Debug::debug($var, $header, $group); } }
/** * Example can be found in the testsite package at the page-path "/Intro/TypoScript examples/Menu object examples/Loading multiple.../" * * @param array $I The menu item array, $this->I (in the parent object) * @param array $conf TypoScript configuration for the function. Notice that the property "parentObj" is a reference to the parent (calling) object (the tslib_Xmenu class instantiated) * @return array The processed $I array returned (and stored in $this->I of the parent object again) * @see tslib_menu::userProcess(), tslib_tmenu::writeMenu(), tslib_gmenu::writeMenu() */ function user_keepRolloverAtOnClick($I, $conf) { $itemRow = $conf['parentObj']->menuArr[$I['key']]; // Setting the document status content to the value of the page title // on mouse over if (!$I['linkHREF']['TARGET']) { $I['linkHREF']['HREF'] = '#'; $I['linkHREF']['onClick'] .= 'ARO_setLocation' . $conf['setLocation'] . '(' . $itemRow['uid'] . ',\'' . $I['theName'] . '\'); return false;'; } else { $I['linkHREF']['onClick'] .= 'ARO_setActiveImg' . '(\'' . $I['theName'] . '\');'; } if ($I['linkHREF']['onMouseover']) { $I['linkHREF']['onMouseover'] = 'ARO_' . $I['linkHREF']['onMouseover']; } if ($I['linkHREF']['onMouseout']) { $I['linkHREF']['onMouseout'] = 'ARO_' . $I['linkHREF']['onMouseout']; } if ($conf['parentObj']->isActive($itemRow['uid'])) { $conf['parentObj']->WMextraScript .= ' <script type="text/javascript"> /*<![CDATA[*/ ARO_Image = "' . $I['theName'] . '"; ' . $I['linkHREF']['onMouseover'] . ' /*]]>*/ </script> '; } // Update the link in the parent object: // setting internal $I - needed by setATagParts() function! $conf['parentObj']->I = $I; // Setting the A1 and A2 of the internal $I $conf['parentObj']->setATagParts(); // retrieving internal $I $I = $conf['parentObj']->I; // Setting the ATag_begin to the value of this $I $I['parts']['ATag_begin'] = $I['A1']; // Debug: if ($conf['debug']) { // Outputting for debug example: echo 'ITEM: <h2>' . htmlspecialchars($itemRow['uid'] . ': ' . $itemRow['title']) . '</h2>'; t3lib_utility_Debug::debug($itemRow); t3lib_utility_Debug::debug($I); echo '<hr />'; } // Returns $I: return $I; }
/** * Writes a message to the deprecation log. * * @param string $msg Message (in English). * @return void */ public static function deprecationLog($msg) { if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) { return; } $log = $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']; $date = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ': '); // legacy values (no strict comparison, $log can be boolean, string or int) if ($log === TRUE || $log == '1') { $log = 'file'; } if (stripos($log, 'file') !== FALSE) { // In case lock is acquired before autoloader was defined: if (class_exists('t3lib_lock') === FALSE) { require_once PATH_t3lib . 'class.t3lib_lock.php'; } // write a longer message to the deprecation log $destination = self::getDeprecationLogFileName(); $lockObject = self::makeInstance('t3lib_lock', $destination, $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']); /** @var t3lib_lock $lockObject */ $lockObject->setEnableLogging(FALSE); $lockObject->acquire(); $file = @fopen($destination, 'a'); if ($file) { @fwrite($file, $date . $msg . LF); @fclose($file); self::fixPermissions($destination); } $lockObject->release(); } if (stripos($log, 'devlog') !== FALSE) { // copy message also to the developer log self::devLog($msg, 'Core', self::SYSLOG_SEVERITY_WARNING); } // do not use console in login screen if (stripos($log, 'console') !== FALSE && isset($GLOBALS['BE_USER']->user['uid'])) { t3lib_utility_Debug::debug($msg, $date, 'Deprecation Log'); } }
/** * Writes a message to the deprecation log. * * @param string Message (in English). * @return void */ public static function deprecationLog($msg) { if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) { return; } $log = $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']; $date = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ': '); // legacy values (no strict comparison, $log can be boolean, string or int) if ($log === TRUE || $log == '1') { $log = 'file'; } if (stripos($log, 'file') !== FALSE) { // write a longer message to the deprecation log $destination = self::getDeprecationLogFileName(); $file = @fopen($destination, 'a'); if ($file) { flock($file, LOCK_EX); // try locking, but ignore if not available (eg. on NFS and FAT) @fwrite($file, $date . $msg . LF); flock($file, LOCK_UN); // release the lock @fclose($file); self::fixPermissions($destination); } } if (stripos($log, 'devlog') !== FALSE) { // copy message also to the developer log self::devLog($msg, 'Core', self::SYSLOG_SEVERITY_WARNING); } // do not use console in login screen if (stripos($log, 'console') !== FALSE && isset($GLOBALS['BE_USER']->user['uid'])) { t3lib_utility_Debug::debug($msg, $date, 'Deprecation Log'); } }
/** * Authenticate a user (Check various conditions for the user that might invalidate its authentication, eg. password match, domain, IP, etc.) * * @param array $user Data of user. * @return boolean */ public function authUser(array $user) { \t3lib_utility_Debug::debug($user); }
public function checkEvent($params, $obj) { $this->initializeAction(); $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 'woehrlSeminare', 'Eventlist'); //~ t3lib_utility_Debug::debug($params, 'addInformation: params: '); $gp = t3lib_div::_GP('tx_powermail_pi1'); $formUid = $gp['form']; $form = $this->formsRepository->findByUid($formUid); if (!method_exists($form, 'getPages')) { return $this->isValid = FALSE; } foreach ($form->getPages() as $page) { // every page in current form foreach ($page->getFields() as $field) { // every field in current page switch ($field->getMarker()) { case 'action': $action = $params[$field->getUid()]; break; case 'editcode': $editcode = $params[$field->getUid()]; break; case 'event': $formIdEvent = $field->getUid(); $eventId = $params[$formIdEvent]; break; case 'eventtitle': $formIdEventtitle = $field->getUid(); break; } } } //~ t3lib_utility_Debug::debug($editcode, 'checkEvent: editcode... '); switch ($action) { case 'delete': //~ $subscriber = $this->subscriberRepository->findAllByFeuser($frameworkConfiguration['persistence']['storagePid'])->getFirst(); $subscriber = $this->subscriberRepository->findAllByEditcode($editcode, $frameworkConfiguration['persistence']['storagePid'])->getFirst(); if (empty($subscriber)) { t3lib_utility_Debug::debug($subscriber, 'checkEvent: NO subscriber found... '); $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); break; } //~ t3lib_utility_Debug::debug($subscriber, 'saveSubscription: delete... '); $event = $this->eventRepository->findByUid($eventId); if (empty($event)) { $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); break; } $event->removeSubscriber($subscriber); break; case 'new': if ($eventId > 0) { $event = $this->eventRepository->findByUid($eventId); // limit reached already --> overbooked if (count($event->getSubscribers()) >= $event->getMaxSubscriber()) { $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); } } break; default: return; } return; //~ t3lib_utility_Debug::debug($eventId , 'checkEvent: eventId'); if ($eventId > 0) { $event = $this->eventRepository->findByUid($eventId); // limit reached already --> overbooked if (count($event->getSubscribers()) >= $event->getMaxSubscriber()) { $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); } } return; }
/** * store collected data of defined indexers to db * * @param integer $storagepid * @param string $title * @param string $type * @param string $targetpid * @param string $content * @param string $tags * @param string $params * @param string $abstract * @param string $language * @param integer $starttime * @param integer $endtime * @param string $fe_group * @param boolean $debugOnly * @param array $additionalFields */ function storeInIndex($storagePid, $title, $type, $targetPid, $content, $tags = '', $params = '', $abstract = '', $language = 0, $starttime = 0, $endtime = 0, $fe_group = '', $debugOnly = false, $additionalFields = array()) { // if there are errors found in current record return false and break processing if (!$this->checkIfRecordHasErrorsBeforeIndexing($storagePid, $title, $type, $targetPid)) { return false; } // optionally add tag set in the indexer configuration if (!empty($this->indexerConfig['filteroption']) && (substr($type, 0, 4) != 'file' || substr($type, 0, 4) == 'file' && $this->indexerConfig['index_use_page_tags_for_files'] || $this->indexerConfig['type'] == 'file')) { $indexerTag = $this->getTag($this->indexerConfig['filteroption']); $tagChar = $this->extConf['prePostTagChar']; if ($tags) { $tags .= ',' . $tagChar . $indexerTag . $tagChar; } else { $tags = $tagChar . $indexerTag . $tagChar; } if (TYPO3_VERSION_INTEGER >= 7000000) { $tags = TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList($tags); } else { $tags = t3lib_div::uniqueList($tags); } } $table = 'tx_kesearch_index'; $fieldValues = $this->createFieldValuesForIndexing($storagePid, $title, $type, $targetPid, $content, $tags, $params, $abstract, $language, $starttime, $endtime, $fe_group, $additionalFields); // check if record already exists if (substr($type, 0, 4) == 'file') { $recordExists = $this->checkIfFileWasIndexed($fieldValues['type'], $fieldValues['hash']); } else { $recordExists = $this->checkIfRecordWasIndexed($fieldValues['orig_uid'], $fieldValues['pid'], $fieldValues['type'], $fieldValues['language']); } if ($recordExists) { // update existing record $where = 'uid=' . intval($this->currentRow['uid']); unset($fieldValues['crdate']); if ($debugOnly) { // do not process - just debug query t3lib_utility_Debug::debug($GLOBALS['TYPO3_DB']->UPDATEquery($table, $where, $fieldValues), 1); } else { // process storing of index record and return uid $this->prepareRecordForUpdate($fieldValues); return true; } } else { // insert new record if ($debugOnly) { // do not process - just debug query t3lib_utility_Debug::debug($GLOBALS['TYPO3_DB']->INSERTquery($table, $fieldValues, FALSE)); } else { // process storing of index record and return uid $this->prepareRecordForInsert($fieldValues); return $GLOBALS['TYPO3_DB']->sql_insert_id(); } } }
t3lib_utility_Debug::debug($GLOBALS['TYPO3_DB']->debug_lastBuiltQuery, 'last built query'); } $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = false; } break; case 'tx_multishop_orders_products': foreach ($records as $record) { $record['orders_id'] = $tx_multishop_orders_ids[$record['orders_id']]; $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = true; $record = mslib_befe::rmNullValuedKeys($record); $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery($key, $record); $new_orders_products_id = $GLOBALS['TYPO3_DB']->sql_insert_id(); if ($new_orders_products_id) { $insert_records++; } else { t3lib_utility_Debug::debug($GLOBALS['TYPO3_DB']->debug_lastBuiltQuery, 'last built query'); } $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = false; } break; case 'tx_multishop_orders_status_history': foreach ($records as $record) { $record['orders_id'] = $tx_multishop_orders_ids[$record['orders_id']]; $record['crdate'] = strtotime($record['orders_id']); $record = mslib_befe::rmNullValuedKeys($record); $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery($key, $record); $insert_records++; } break; case 'tx_multishop_payment_methods': case 'tx_multishop_payment_shipping_mappings':
public static function debug($var = '', $header = '', $group = 'Debug') { $callingClassName = '\\TYPO3\\CMS\\Core\\Utility\\DebugUtility'; if (class_exists($callingClassName) && method_exists($callingClassName, 'debug')) { call_user_func($callingClassName . '::debug', $var, $header, $group); } else { if (class_exists('t3lib_utility_Debug') && method_exists('t3lib_utility_Debug', 'debug')) { t3lib_utility_Debug::debug($var, $header, $group); } else { if (class_exists('t3lib_div') && method_exists('t3lib_div', 'debug')) { t3lib_div::debug($var, $header, $group); } } } }
function debug($variable = '', $name = '*variable*', $line = '*line*', $file = '*file*', $recursiveDepth = 3, $debugLevel = E_DEBUG) { // If you wish to use the debug()-function, and it does not output something, please edit the IP mask in TYPO3_CONF_VARS if (!t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) { return; } if (is_object($GLOBALS['error']) && @is_callable(array($GLOBALS['error'], 'debug'))) { $GLOBALS['error']->debug($variable, $name, $line, $file, $recursiveDepth, $debugLevel); } else { $title = $name === '*variable*' ? '' : $name; $group = $line === '*line*' ? NULL : $line; t3lib_utility_Debug::debug($variable, $title, $group); } }
/** * Initializes the current action * * @return void */ protected function initializeAction() { $this->cObj = $this->configurationManager->getContentObject(); $typoScriptSetup = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); $this->conf = $typoScriptSetup['plugin.']['tx_powermail.']['settings.']['setup.']; $this->div = t3lib_div::makeInstance('Tx_Powermail_Utility_Div'); Tx_Powermail_Utility_Div::mergeTypoScript2FlexForm($this->settings); // merge typoscript to flexform (if flexform field also exists and is empty, take typoscript part) $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'Settings', array($this)); // check if ts is included if (!isset($this->settings['staticTemplate'])) { $this->flashMessageContainer->add(Tx_Extbase_Utility_Localization::translate('error_no_typoscript', 'powermail')); } // Debug Output if ($this->settings['debug']['settings']) { t3lib_utility_Debug::debug($this->settings, 'powermail debug: Show Settings'); } }
/** * Explain select queries * If $this->explainOutput is set, SELECT queries will be explained here. Only queries with more than one possible result row will be displayed. * The output is either printed as raw HTML output or embedded into the TS admin panel (checkbox must be enabled!) * * TODO: Feature is not DBAL-compliant * * @param string SQL query * @param string Table(s) from which to select. This is what comes right after "FROM ...". Required value. * @param integer Number of resulting rows * @return boolean True if explain was run, false otherwise */ protected function explain($query, $from_table, $row_count) { if ((int) $this->explainOutput == 1 || (int) $this->explainOutput == 2 && t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) { // raw HTML output $explainMode = 1; } elseif ((int) $this->explainOutput == 3 && is_object($GLOBALS['TT'])) { // embed the output into the TS admin panel $explainMode = 2; } else { return FALSE; } $error = $this->sql_error(); $trail = t3lib_utility_Debug::debugTrail(); $explain_tables = array(); $explain_output = array(); $res = $this->sql_query('EXPLAIN ' . $query, $this->link); if (is_resource($res)) { while ($tempRow = $this->sql_fetch_assoc($res)) { $explain_output[] = $tempRow; $explain_tables[] = $tempRow['table']; } $this->sql_free_result($res); } $indices_output = array(); // Notice: Rows are skipped if there is only one result, or if no conditions are set if ($explain_output[0]['rows'] > 1 || t3lib_div::inList('ALL', $explain_output[0]['type'])) { // only enable output if it's really useful $debug = TRUE; foreach ($explain_tables as $table) { $tableRes = $this->sql_query('SHOW TABLE STATUS LIKE \'' . $table . '\''); $isTable = $this->sql_num_rows($tableRes); if ($isTable) { $res = $this->sql_query('SHOW INDEX FROM ' . $table, $this->link); if (is_resource($res)) { while ($tempRow = $this->sql_fetch_assoc($res)) { $indices_output[] = $tempRow; } $this->sql_free_result($res); } } $this->sql_free_result($tableRes); } } else { $debug = FALSE; } if ($debug) { if ($explainMode) { $data = array(); $data['query'] = $query; $data['trail'] = $trail; $data['row_count'] = $row_count; if ($error) { $data['error'] = $error; } if (count($explain_output)) { $data['explain'] = $explain_output; } if (count($indices_output)) { $data['indices'] = $indices_output; } if ($explainMode == 1) { t3lib_utility_Debug::debug($data, 'Tables: ' . $from_table, 'DB SQL EXPLAIN'); } elseif ($explainMode == 2) { $GLOBALS['TT']->setTSselectQuery($data); } } return TRUE; } return FALSE; }
private function debug($var) { t3lib_utility_Debug::debug($var); }
/** * Pushes out some debug messages * * @return void */ protected function debug() { // Debug Output $this->debug_array['Main Table'] = $this->db_values; // array for debug view $this->debug_array['MM Table'] = (count($this->db_values_mm) > 0 ? $this->db_values_mm : 'no values or entry already exists'); // array for debug view if ($this->conf['debug.']['saveToTable']) { t3lib_utility_Debug::debug($this->debug_array, 'powermail debug: Show Values from "SaveToTable" Function'); } }
/** * Used in the menu item state example of the "testsite" package at page-path "/Intro/TypoScript examples/Menu object examples/Menu state test/" * * @param array $I The menu item array, $this->I (in the parent object) * @param array $conf TypoScript configuration for the function. Notice that the property "parentObj" is a reference to the parent (calling) object (the tslib_Xmenu class instantiated) * @return array The processed $I array returned (and stored in $this->I of the parent object again) * @see tslib_menu::userProcess(), tslib_tmenu::writeMenu(), tslib_gmenu::writeMenu() */ function user_IProcFuncTest($I, $conf) { $itemRow = $conf['parentObj']->menuArr[$I['key']]; // Setting the document status content to the value of the page title on mouse over $I['linkHREF']['onMouseover'] .= 'extraRollover(\'' . rawurlencode($itemRow['title']) . '\');'; $conf['parentObj']->I = $I; $conf['parentObj']->setATagParts(); $I = $conf['parentObj']->I; if ($I['parts']['ATag_begin']) { $I['parts']['ATag_begin'] = $I['A1']; } if ($conf['debug']) { // Outputting for debug example: echo 'ITEM: <h2>' . htmlspecialchars($itemRow['uid'] . ': ' . $itemRow['title']) . '</h2>'; t3lib_utility_Debug::debug($itemRow); t3lib_utility_Debug::debug($I); echo '<hr />'; } // Returns: return $I; }
/** * Powermail SendPost - Send values via curl to target * * @param array $fields Params from User * @param array $conf TypoScript Settings * @param object $configurationManager Configuration Manager * @return void */ public static function sendPost($fields, $conf, $configurationManager) { if (!$conf['marketing.']['sendPost.']['_enable']) { return; } $fields = self::getVariablesWithMarkers($fields); $cObj = $configurationManager->getContentObject(); $cObj->start($fields); $curl = array( 'url' => $conf['marketing.']['sendPost.']['targetUrl'], 'params' => $cObj->cObjGetSingle($conf['marketing.']['sendPost.']['values'], $conf['marketing.']['sendPost.']['values.']) ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $curl['url']); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $curl['params']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); curl_close($ch); // Debug Output if ($conf['marketing.']['sendPost.']['debug']) { t3lib_utility_Debug::debug($curl, 'powermail debug: Show SendPost Values'); } }