Example #1
0
 /**
  * Analyze a given JS script
  * @param string $inputFile
  * @param bool $string
  * @param array $config
  * @internal
  */
 public function __construct($inputFile = '', $string = FALSE, $config = array())
 {
     $this->configXML = $config;
     if ($string || ($string = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($inputFile))) {
         // we just look for double quote
         $string = str_replace("'", '"', $string);
         $result = array();
         $components = array();
         if (count($this->configXML) > 0) {
             // build the components array
             foreach ($this->configXML as $group) {
                 if (count($group['files']) > 0) {
                     foreach ($group['files'] as $file) {
                         $components[$file['name']] = $file;
                         $components[$file['name']]['groupname'] = $group['name'];
                     }
                 }
             }
             // search for
             foreach ($this->configXML as $group) {
                 if (count($group['files']) > 0) {
                     foreach ($group['files'] as $file) {
                         if ($this->contains($string, $file['sources']) === TRUE) {
                             $result = array_merge($result, array($components[$file['depends']]['name'] => $components[$file['depends']]['groupname']));
                             $result = array_merge($result, array($file['name'] => $components[$file['name']]['groupname']));
                         }
                     }
                 }
             }
         }
         $this->dependencies = $result;
     }
 }
 /**
  * The constructor for a finisher setting the component manager and the configuration.
  *
  * @param Tx_Formhandler_Component_Manager $componentManager
  * @param Tx_Formhandler_Configuration $configuration
  * @return void
  */
 public function __construct(Tx_Formhandler_Component_Manager $componentManager, Tx_Formhandler_Configuration $configuration, Tx_Formhandler_UtilityFuncs $utilityFuncs)
 {
     $this->componentManager = $componentManager;
     $this->configuration = $configuration;
     $this->templatePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('formhandler') . 'Resources/HTML/backend/';
     $this->templateFile = $this->templatePath . 'template.html';
     $this->templateCode = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($this->templateFile);
     $this->utilityFuncs = $utilityFuncs;
 }
Example #3
0
 /**
  * Loads a template file
  *
  * @param string  $templateFile
  * @param boolean $debug
  * @return boolean
  */
 public function initTemplate($templateFile, $debug = false)
 {
     $templateAbsPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($templateFile);
     if ($templateAbsPath !== null) {
         $this->templateContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($templateAbsPath);
         if ($debug === true) {
             if ($this->templateContent === null) {
                 \TYPO3\CMS\Core\Utility\DebugUtility::debug('Check the path template or the rights', 'Error');
             }
             \TYPO3\CMS\Core\Utility\DebugUtility::debug($this->templateContent, 'Content of ' . $templateFile);
         }
         return true;
     } else {
         return false;
     }
 }
Example #4
0
 public function init()
 {
     $this->data = array();
     $content = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($this->getHtmlUrl());
     switch ($this->getHtmlFetchType()) {
         case 'mailto':
             preg_match_all('|<a[^>]+href="mailto:([^"]+)"[^>]*>(.*)</a>|Ui', $content, $fetched_data);
             foreach ($fetched_data[1] as $i => $email) {
                 $this->data[] = array('email' => $email, 'name' => $fetched_data[2][$i]);
             }
             break;
         case 'regex':
         default:
             preg_match_all("|[\\.a-z0-9!#\$%&'*+-/=?^_`{\\|}]+@[a-z0-9_-][\\.a-z0-9_-]*\\.[a-z]{2,}|i", $content, $fetched_data);
             foreach ($fetched_data[0] as $address) {
                 $this->data[]['email'] = $address;
             }
     }
 }
Example #5
0
 /**
  * Download the content of the sourceFile
  *
  * @return bool true if the content could be downloaded successfully.
  */
 private static function getContentFromSourceFile()
 {
     $success = false;
     self::$sourceFile = self::getConfParam('sourceFile');
     if (substr(self::$sourceFile, 0, 4) !== 'http') {
         self::$sourceFile = (GeneralUtility::getIndpEnv('TYPO3_SSL') ? 'https:' : 'http:') . self::$sourceFile;
     }
     // Get file content
     self::$code = GeneralUtility::getURL(self::$sourceFile, 1, false, self::$report);
     if (self::$report['error'] === 0) {
         if (self::$report['http_code'] === '404') {
             self::setReport(true, 'getContentFromSourceFile.404', [self::linkSourceUrl()]);
         } elseif (strpos(self::$report['content_type'], 'text/javascript') !== 0) {
             self::setReport(true, 'getContentFromSourceFile.wrongType', [self::linkSourceUrl()]);
         } elseif (empty(self::$code)) {
             self::setReport(true, 'getContentFromSourceFile.emptyFile', [self::linkSourceUrl()]);
         } else {
             $success = true;
         }
     } else {
         self::setReport(true, 'getContentFromSourceFile.error', [self::linkSourceUrl(), self::$report['message']]);
     }
     return $success;
 }
Example #6
0
 /**
  * @param string $sourceUrl
  * @param string $destFile
  * @return string HTML
  */
 protected function download($sourceUrl, $destFile)
 {
     global $LANG;
     $destDir = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:wec_map/contribJS/');
     // Get file and cancel if not existing/accessible
     $remoteFileContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($sourceUrl);
     if ($remoteFileContent === FALSE) {
         return $LANG->getLL('downloadError') . $sourceUrl . '<br />';
     }
     // Create dir if not existing
     if (!file_exists($destDir)) {
         mkdir($destDir);
     }
     // Write content to disk
     $handle = fopen($destDir . $destFile, 'wb');
     fwrite($handle, $remoteFileContent);
     fclose($handle);
     return $LANG->getLL('downloadSuccess') . $destFile . '<br />';
 }
Example #7
0
 /**
  * Fetches an extensions l10n file from the given mirror
  *
  * @param string $extensionKey Extension Key
  * @param string $language The language code of the translation to fetch
  * @param string $mirrorUrl URL of mirror to use
  * @throws \TYPO3\CMS\Lang\Exception\XmlParser
  * @return array Array containing l10n data
  */
 protected function fetchTranslation($extensionKey, $language, $mirrorUrl)
 {
     $extensionPath = GeneralUtility::strtolower($extensionKey);
     // Typical non sysext path, Hungarian:
     // http://my.mirror/ter/a/n/anextension-l10n/anextension-l10n-hu.zip
     $packageUrl = $extensionPath[0] . '/' . $extensionPath[1] . '/' . $extensionPath . '-l10n/' . $extensionPath . '-l10n-' . $language . '.zip';
     try {
         $path = ExtensionManagementUtility::extPath($extensionPath);
         if (strpos($path, '/sysext/') !== false) {
             // This is a system extension and the package URL should be adapted
             list($majorVersion, ) = explode('.', TYPO3_branch);
             // Typical non sysext path, mind the additional version part, French
             // http://my.mirror/ter/b/a/backend-l10n/backend-l10n-fr.v7.zip
             $packageUrl = $extensionPath[0] . '/' . $extensionPath[1] . '/' . $extensionPath . '-l10n/' . $extensionPath . '-l10n-' . $language . '.v' . $majorVersion . '.zip';
         }
     } catch (\BadFunctionCallException $e) {
         // Nothing to do
     }
     $l10nResponse = GeneralUtility::getURL($mirrorUrl . $packageUrl, 0, array(TYPO3_user_agent));
     if ($l10nResponse === false) {
         throw new \TYPO3\CMS\Lang\Exception\XmlParser('Error: Translation could not be fetched.', 1345736785);
     } else {
         return array($l10nResponse);
     }
 }
Example #8
0
 function sendNotification(&$event, $email, $templatePath, $titleText, $unsubscribeLink, $acceptLink = '', $declineLink = '', $ics = '')
 {
     $absFile = GeneralUtility::getFileAbsFileName($templatePath);
     $template = GeneralUtility::getURL($absFile);
     $htmlTemplate = $this->cObj->getSubpart($template, '###HTML###');
     $plainTemplate = $this->cObj->getSubpart($template, '###PLAIN###');
     $switch = array();
     $rems = array();
     $wrapped = array();
     $event->getMarker($htmlTemplate, $switch, $rems, $wrapped, 'notification');
     $switch['###CURRENT_USER###'] = $this->getModifyingUser($template);
     $switch['###UNSUBSCRIBE_LINK###'] = $unsubscribeLink;
     $switch['###ACCEPT_LINK###'] = $acceptLink;
     $switch['###DECLINE_LINK###'] = $declineLink;
     $htmlTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($htmlTemplate, $switch, $rems, $wrapped);
     $switch = array();
     $rems = array();
     $wrapped = array();
     $event->getMarker($plainTemplate, $switch, $rems, $wrapped, 'notification');
     $switch['###UNSUBSCRIBE_LINK###'] = $unsubscribeLink;
     $switch['###ACCEPT_LINK###'] = $acceptLink;
     $switch['###DECLINE_LINK###'] = $declineLink;
     $plainTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($plainTemplate, $switch, $rems, $wrapped);
     $plainTemplate = $event->finish($plainTemplate);
     $htmlTemplate = $event->finish($htmlTemplate);
     $switch = array();
     $rems = array();
     $wrapped = array();
     $event->getMarker($titleText, $switch, $rems, $wrapped, 'title');
     if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) < 4005010) {
         $this->mailer->subject = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($titleText, $switch, $rems, $wrapped);
     } else {
         $this->mailer->setSubject(\TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($titleText, $switch, $rems, $wrapped));
     }
     $this->sendEmail($email, $htmlTemplate, $plainTemplate);
 }
Example #9
0
 /**
  * Return the content of the given URL
  * @param string $url
  * @return string
  */
 protected function getURL($url)
 {
     return \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($url);
 }
 /**
  * @return string
  * @throws Exception
  */
 private function downloadLatestPiwik()
 {
     // tell installer where to grab piwik
     $settings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['piwikintegration']);
     if (array_key_exists('piwikDownloadSource', $settings) && $settings['piwikDownloadSource'] != '') {
         $downloadSource = $settings['piwikDownloadSource'];
     } else {
         $downloadSource = 'http://builds.piwik.org/latest.zip';
     }
     //download piwik into typo3temp
     $zipArchivePath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('typo3temp/piwiklatest.zip');
     \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($zipArchivePath, \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($downloadSource));
     if (@filesize($zipArchivePath) === FALSE) {
         throw new \Exception('Installation invalid, typo3temp ' . $zipArchivePath . ' can´t be created for some reason');
     }
     if (@filesize($zipArchivePath) < 10) {
         throw new \Exception('Installation invalid, typo3temp' . $zipArchivePath . ' is smaller than 10 bytes, download definitly failed');
     }
     return $zipArchivePath;
 }
    /**
     * Initialization
     *
     * @return void
     */
    public function init()
    {
        $language = $this->getLanguageService();
        $language->includeLLFile('EXT:commerce/Resources/Private/Language/locallang_mod_statistic.xml');
        $language->includeLLFile('EXT:lang/locallang_mod_web_list.php');
        parent::init();
        $this->extConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['extConf'];
        $this->excludePids = $this->extConf['excludeStatisticFolders'] != '' ? $this->extConf['excludeStatisticFolders'] : 0;
        $this->statistics = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Utility_StatisticsUtility');
        $this->statistics->init($this->extConf['excludeStatisticFolders'] != '' ? $this->extConf['excludeStatisticFolders'] : 0);
        $this->orderPageId = current(array_unique(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Orders', 'Commerce', 0, 'Commerce')));
        /**
         * If we get an id via GP use this, else use the default id
         */
        $this->id = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
        if (!$this->id) {
            $this->id = $this->orderPageId;
        }
        $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
        $this->doc->backPath = $GLOBALS['BACK_PATH'];
        $this->doc->docType = 'xhtml_trans';
        $this->doc->setModuleTemplate(PATH_TXCOMMERCE . 'Resources/Private/Backend/mod_index.html');
        if (!$this->doc->moduleTemplate) {
            \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('cannot set moduleTemplate', 'commerce', 2, array('backpath' => $this->doc->backPath, 'filename from TBE_STYLES' => $GLOBALS['TBE_STYLES']['htmlTemplates']['mod_index.html'], 'full path' => $this->doc->backPath . $GLOBALS['TBE_STYLES']['htmlTemplates']['mod_index.html']));
            $templateFile = PATH_TXCOMMERCE_REL . 'Resources/Private/Backend/mod_index.html';
            $this->doc->moduleTemplate = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL(PATH_site . $templateFile);
        }
        $this->doc->form = '<form action="" method="POST" name="editform">';
        // JavaScript
        $this->doc->JScode = $this->doc->wrapScriptTags('
			script_ended = 0;
			function jumpToUrl(URL) {
				document.location = URL;
			}
		');
        $this->doc->postCode = $this->doc->wrapScriptTags('
			script_ended = 1;
			if (top.fsMod) {
				top.fsMod.recentIds["web"] = ' . (int) $this->id . ';
			}
		');
    }
Example #12
0
    public function drawIcs(&$master_array, $getdate, $sendHeaders = true, $limitAttendeeToThisEmail = '')
    {
        $this->_init($master_array);
        $this->limitAttendeeToThisEmail = $limitAttendeeToThisEmail;
        $absFile = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->conf['view.']['ics.']['icsTemplate']);
        $page = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($absFile);
        if ($page == '') {
            // return '<h3>calendar: no ics template file found:</h3>'.$this->conf['view.']['ics.']['icsTemplate'];
            // falling back to default:
            $page = 'BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//TYPO3/NONSGML Calendar Base (cal) V###CAL_VERSION###//EN
METHOD:###METHOD###
<!--###EVENT### start-->
<!--###EVENT### end-->
END:VCALENDAR
			';
        }
        $ics_events = '';
        $select = 'tx_cal_event_deviation.*,tx_cal_index.start_datetime,tx_cal_index.end_datetime';
        $table = 'tx_cal_event_deviation right outer join tx_cal_index on tx_cal_event_deviation.uid = tx_cal_index.event_deviation_uid';
        $oldView = $this->conf['view'];
        $this->conf['view'] = 'single_ics';
        foreach ($this->master_array as $eventDate => $eventTimeArray) {
            if (is_subclass_of($eventTimeArray, 'TYPO3\\CMS\\Cal\\Model\\Model')) {
                $ics_events .= $eventTimeArray->renderEventFor('ics');
            } else {
                foreach ($eventTimeArray as $key => $eventArray) {
                    foreach ($eventArray as $eventUid => $event) {
                        if (is_object($event)) {
                            $ics_events .= $event->renderEventFor('ics');
                            $where = 'tx_cal_event_deviation.parentid = ' . $event->getUid() . $this->cObj->enableFields('tx_cal_event_deviation');
                            $deviationResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where);
                            if ($deviationResult) {
                                while ($deviationRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($deviationResult)) {
                                    $start = new \TYPO3\CMS\Cal\Model\CalDate(substr($deviationRow['start_datetime'], 0, 8));
                                    $start->setHour(substr($deviationRow['start_datetime'], 8, 2));
                                    $start->setMinute(substr($deviationRow['start_datetime'], 10, 2));
                                    $end = new \TYPO3\CMS\Cal\Model\CalDate(substr($deviationRow['end_datetime'], 0, 8));
                                    $end->setHour(substr($deviationRow['end_datetime'], 8, 2));
                                    $end->setMinute(substr($deviationRow['end_datetime'], 10, 2));
                                    unset($deviationRow['start_datetime']);
                                    unset($deviationRow['end_datetime']);
                                    $new_event = new \TYPO3\CMS\Cal\Model\EventRecDeviationModel($event, $deviationRow, $start, $end);
                                    $ics_events .= $new_event->renderEventFor('ics');
                                }
                                $GLOBALS['TYPO3_DB']->sql_free_result($deviationResult);
                            }
                        }
                    }
                }
            }
        }
        $this->conf['view'] = $oldView;
        $rems = array();
        $rems['###EVENT###'] = strip_tags($ics_events);
        $title = '';
        if (!empty($this->master_array)) {
            if (is_subclass_of($this->master_array[0], 'TYPO3\\CMS\\Cal\\Model\\Model')) {
                $title = $this->master_array[0]->getTitle();
            } else {
                $title = $this->appendCalendarTitle($title);
                $title = $this->appendCategoryTitle($title);
            }
        } else {
            $title = $this->appendCalendarTitle($title);
            $title = $this->appendCategoryTitle($title);
        }
        if ($title == '') {
            $title = $getdate;
        }
        $title .= '.ics';
        $title = strtr($title, array(' ' => '', ',' => '_'));
        if ($sendHeaders) {
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Content-Disposition: attachment; filename=' . $title);
            header('Content-Type: text/ics');
            header('Pragma: ');
            header('Cache-Control:');
        }
        include \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('cal') . 'ext_emconf.php';
        $myem_conf = array_pop($EM_CONF);
        $method = 'PUBLISH';
        if ($this->limitAttendeeToThisEmail) {
            $method = 'REQUEST';
        }
        $return = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array('###CAL_VERSION###' => $myem_conf['version'], '###METHOD###' => $method, '###TIMEZONE###' => $this->cObj->cObjGetSingle($this->conf['view.']['ics.']['timezone'], $this->conf['view.']['ics.']['timezone.'])), $rems, array());
        return \TYPO3\CMS\Cal\Utility\Functions::removeEmptyLines($return);
    }
Example #13
0
 /**
  * Returns the FlexForm configuration of a grid layout.
  *
  * @param string $layoutId : The current layout ID of the grid container
  *
  * @return string
  */
 public function getFlexformConfiguration($layoutId)
 {
     $layoutSetup = $this->getLayoutSetup($layoutId);
     // Get flexform file from pi_flexform_ds if pi_flexform_ds_file not set and "FILE:" found in pi_flexform_ds for backward compatibility.
     if ($layoutSetup['pi_flexform_ds_file']) {
         $flexformConfiguration = GeneralUtility::getURL(GeneralUtility::getFileAbsFileName($layoutSetup['pi_flexform_ds_file']));
     } else {
         if (strpos($layoutSetup['pi_flexform_ds'], 'FILE:') === 0) {
             $flexformConfiguration = GeneralUtility::getURL(GeneralUtility::getFileAbsFileName(substr($layoutSetup['pi_flexform_ds'], 5)));
         } else {
             if ($layoutSetup['pi_flexform_ds']) {
                 $flexformConfiguration = $layoutSetup['pi_flexform_ds'];
             } else {
                 $flexformConfiguration = GeneralUtility::getURL(GeneralUtility::getFileAbsFileName($this->flexformConfigurationPathAndFileName));
             }
         }
     }
     return $flexformConfiguration;
 }
 /**
  * Fetch content of a page (only internal and external page)
  *
  * @param array $row Directmail DB record
  * @param array $params Any default parameters (usually the ones from pageTSconfig)
  *
  * @return string Error or warning message during fetching the content
  */
 public static function fetchUrlContentsForDirectMailRecord(array $row, array $params)
 {
     $theOutput = '';
     $errorMsg = array();
     $warningMsg = array();
     $urls = self::getFullUrlsForDirectMailRecord($row);
     $plainTextUrl = $urls['plainTextUrl'];
     $htmlUrl = $urls['htmlUrl'];
     $urlBase = $urls['baseUrl'];
     // Make sure long_link_rdct_url is consistent with use_domain.
     $row['long_link_rdct_url'] = $urlBase;
     // Compile the mail
     /* @var $htmlmail Dmailer */
     $htmlmail = GeneralUtility::makeInstance('DirectMailTeam\\DirectMail\\Dmailer');
     if ($params['enable_jump_url']) {
         $htmlmail->jumperURL_prefix = $urlBase . '?id=' . $row['page'] . (intval($params['jumpurl_tracking_privacy']) ? '' : '&rid=###SYS_TABLE_NAME###_###USER_uid###') . '&mid=###SYS_MAIL_ID###' . '&aC=###SYS_AUTHCODE###' . '&jumpurl=';
         $htmlmail->jumperURL_useId = 1;
     }
     if ($params['enable_mailto_jump_url']) {
         $htmlmail->jumperURL_useMailto = 1;
     }
     $htmlmail->start();
     $htmlmail->charset = $row['charset'];
     $htmlmail->http_username = $params['http_username'];
     $htmlmail->http_password = $params['http_password'];
     $htmlmail->simulateUsergroup = $params['simulate_usergroup'];
     $htmlmail->includeMedia = $row['includeMedia'];
     if ($plainTextUrl) {
         $mailContent = GeneralUtility::getURL(self::addUserPass($plainTextUrl, $params));
         $htmlmail->addPlain($mailContent);
         if (!$mailContent || !$htmlmail->theParts['plain']['content']) {
             $errorMsg[] = $GLOBALS["LANG"]->getLL('dmail_no_plain_content');
         } elseif (!strstr($htmlmail->theParts['plain']['content'], '<!--DMAILER_SECTION_BOUNDARY')) {
             $warningMsg[] = $GLOBALS["LANG"]->getLL('dmail_no_plain_boundaries');
         }
     }
     // fetch the HTML url
     if ($htmlUrl) {
         // Username and password is added in htmlmail object
         $success = $htmlmail->addHTML(self::addUserPass($htmlUrl, $params));
         // If type = 1, we have an external page.
         if ($row['type'] == 1) {
             // Try to auto-detect the charset of the message
             $matches = array();
             $res = preg_match('/<meta[\\s]+http-equiv="Content-Type"[\\s]+content="text\\/html;[\\s]+charset=([^"]+)"/m', $htmlmail->theParts['html_content'], $matches);
             if ($res == 1) {
                 $htmlmail->charset = $matches[1];
             } elseif (isset($params['direct_mail_charset'])) {
                 $htmlmail->charset = $GLOBALS["LANG"]->csConvObj->parse_charset($params['direct_mail_charset']);
             } else {
                 $htmlmail->charset = 'iso-8859-1';
             }
         }
         if ($htmlmail->extractFramesInfo()) {
             $errorMsg[] = $GLOBALS["LANG"]->getLL('dmail_frames_not allowed');
         } elseif (!$success || !$htmlmail->theParts['html']['content']) {
             $errorMsg[] = $GLOBALS["LANG"]->getLL('dmail_no_html_content');
         } elseif (!strstr($htmlmail->theParts['html']['content'], '<!--DMAILER_SECTION_BOUNDARY')) {
             $warningMsg[] = $GLOBALS["LANG"]->getLL('dmail_no_html_boundaries');
         }
     }
     if (!count($errorMsg)) {
         // Update the record:
         $htmlmail->theParts['messageid'] = $htmlmail->messageid;
         $mailContent = base64_encode(serialize($htmlmail->theParts));
         $updateData = array('issent' => 0, 'charset' => $htmlmail->charset, 'mailContent' => $mailContent, 'renderedSize' => strlen($mailContent), 'long_link_rdct_url' => $urlBase);
         $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_dmail', 'uid=' . intval($row['uid']), $updateData);
         if (count($warningMsg)) {
             /* @var $flashMessage FlashMessage */
             $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', implode('<br />', $warningMsg), $GLOBALS['LANG']->getLL('dmail_warning'), FlashMessage::WARNING);
             $theOutput .= $flashMessage->render();
         }
     } else {
         /* @var $flashMessage FlashMessage */
         $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', implode('<br />', $errorMsg), $GLOBALS['LANG']->getLL('dmail_error'), FlashMessage::ERROR);
         $theOutput .= $flashMessage->render();
     }
     return $theOutput;
 }
 protected function replaceMarkersFromMaster()
 {
     $fieldMarkers = array();
     foreach ($this->masterTemplates as $idx => $masterTemplate) {
         $masterTemplateCode = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($this->utilityFuncs->resolvePath($masterTemplate));
         $matches = array();
         preg_match_all('/###(field|master)_([^#]*)###/', $masterTemplateCode, $matches);
         if (!empty($matches[0])) {
             $subparts = array_unique($matches[0]);
             $subpartsCodes = array();
             if (is_array($subparts)) {
                 foreach ($subparts as $index => $subpart) {
                     $subpartKey = str_replace('#', '', $subpart);
                     $code = $this->cObj->getSubpart($masterTemplateCode, $subpart);
                     if (!empty($code)) {
                         $subpartsCodes[$subpartKey] = $code;
                     }
                 }
             }
             foreach ($subpartsCodes as $subpart => $code) {
                 $matchesSlave = array();
                 preg_match_all('/###' . $subpart . '(###|_([^#]*)###)/', $this->template, $matchesSlave);
                 if (!empty($matchesSlave[0])) {
                     foreach ($matchesSlave[0] as $key => $markerName) {
                         $fieldName = $matchesSlave[2][$key];
                         $params = array();
                         if (strpos($fieldName, ';')) {
                             $parts = explode(';', $fieldName);
                             $fieldName = array_shift($parts);
                             $params = explode(',', array_shift($parts));
                         }
                         if ($fieldName) {
                             $markers = array('###fieldname###' => $fieldName, '###formValuesPrefix###' => $this->globals->getFormValuesPrefix());
                             foreach ($params as $key => $paramValue) {
                                 $markers['###param' . ++$key . '###'] = $paramValue;
                             }
                             $replacedCode = $this->cObj->substituteMarkerArray($code, $markers);
                         } else {
                             $replacedCode = $code;
                         }
                         $fieldMarkers[$markerName] = $replacedCode;
                     }
                 }
             }
         }
     }
     $this->template = $this->cObj->substituteMarkerArray($this->template, $fieldMarkers);
 }
 /**
  * Initializes the Page
  *
  * @return void
  */
 public function initPage()
 {
     $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
     $this->doc->backPath = $GLOBALS['BACK_PATH'];
     $this->doc->docType = 'xhtml_trans';
     $this->doc->setModuleTemplate(PATH_TXCOMMERCE . 'Resources/Private/Backend/mod_index.html');
     if (!$this->doc->moduleTemplate) {
         GeneralUtility::devLog('cannot set moduleTemplate', 'commerce', 2, array('backpath' => $this->doc->backPath, 'filename from TBE_STYLES' => $GLOBALS['TBE_STYLES']['htmlTemplates']['commerce/Resources/Private/Backend/mod_index.html'], 'full path' => $this->doc->backPath . $GLOBALS['TBE_STYLES']['htmlTemplates']['commerce/Resources/Private/Backend/mod_index.html']));
         $templateFile = PATH_TXCOMMERCE_REL . 'Resources/Private/Backend/mod_index.html';
         $this->doc->moduleTemplate = GeneralUtility::getURL(PATH_site . $templateFile);
     }
     $this->doc->form = '<form action="" method="POST">';
 }
 /**
  * Performs an address lookup using the google web service.
  *
  * @param	string $street	The street address.
  * @param	string $city	The city name.
  * @param	string $state	The state name.
  * @param	string $zip	The ZIP code.
  * @param	string $country	Optional API key for accessing third party geocoder.
  * @return	array $key		Array containing latitude and longitude.  If lookup failed, empty array is returned.
  */
 function lookup($street, $city, $state, $zip, $country, $key = '')
 {
     $addressString = '';
     $region = '';
     if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) {
         // format address for Google search based on local address-format for given $country
         // convert $country to ISO3
         $countryCodeType = self::isoCodeType($country);
         if ($countryCodeType == 'nr') {
             $countryArray = self::fetchCountries('', '', '', $country);
         } elseif ($countryCodeType == '2') {
             $countryArray = self::fetchCountries('', $country, '', '');
         } elseif ($countryCodeType == '3') {
             $countryArray = self::fetchCountries('', '', $country, '');
         } else {
             global $TYPO3_DB;
             $where = '';
             $table = 'static_countries';
             if ($country != '') {
                 $value = $TYPO3_DB->fullQuoteStr(trim($country), $table);
                 $where = 'cn_official_name_local=' . $value . ' OR cn_official_name_en=' . $value . ' OR cn_short_local=' . $value . ' OR cn_short_en=' . $value;
                 $res = $TYPO3_DB->exec_SELECTquery('*', $table, $where);
                 if ($res) {
                     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                         $countryArray[] = $row;
                     }
                 }
                 $GLOBALS['TYPO3_DB']->sql_free_result($res);
             }
             if (!is_array($countryArray)) {
                 $countryArray = self::fetchCountries($country, '', '', '');
             }
         }
         if (TYPO3_DLOG) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Google V3: countryArray for ' . $country, 'wec_map_geocode', -1, $countryArray);
         }
         if (is_array($countryArray) && count($countryArray) == 1) {
             $country = $countryArray[0]['cn_iso_3'];
             $region = $countryArray[0]['cn_tldomain'];
         }
         // format address accordingly
         $addressString = $this->formatAddress(',', $street, $city, $zip, $state, $country);
         // $country: alpha-3 ISO-code (e. g. DEU)
         if (TYPO3_DLOG) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Google V3 addressString', 'wec_map_geocode', -1, array(street => $street, city => $city, zip => $zip, state => $state, country => $country, addressString => $addressString));
         }
     }
     if (!$addressString) {
         $addressString = $street . ' ' . $city . ', ' . $state . ' ' . $zip . ', ' . $country;
         // default: US-format
     }
     // build URL
     $lookupstr = trim($addressString);
     $url = 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=' . urlencode($lookupstr);
     if ($region) {
         $url .= '&region=' . urlencode($region);
     }
     // request Google-service and parse JSON-response
     if (TYPO3_DLOG) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Google V3: URL ' . $url, 'wec_map_geocode', -1);
     }
     $attempt = 1;
     do {
         $jsonstr = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($url);
         $response_obj = json_decode($jsonstr, true);
         if (TYPO3_DLOG) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Google V3: ' . $jsonstr, 'wec_map_geocode', -1, $response_obj);
         }
         if ($response_obj['status'] == 'OVER_QUERY_LIMIT') {
             sleep(2);
         }
         $attempt++;
     } while ($attempt <= 3 && $response_obj['status'] == 'OVER_QUERY_LIMIT');
     $latlong = array();
     if (TYPO3_DLOG) {
         $addressArray = array('street' => $street, 'city' => $city, 'state' => $state, 'zip' => $zip, 'country' => $country, 'region' => $region);
         \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Google V3: ' . $addressString, 'wec_map_geocode', -1, $addressArray);
     }
     if ($response_obj['status'] == 'OK') {
         /*
          * Geocoding worked!
          */
         if (TYPO3_DLOG) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Google V3 Answer successful', 'wec_map_geocode', -1);
         }
         $latlong['lat'] = floatval($response_obj['results'][0]['geometry']['location']['lat']);
         $latlong['long'] = floatval($response_obj['results'][0]['geometry']['location']['lng']);
         if (TYPO3_DLOG) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Google V3 Answer', 'wec_map_geocode', -1, $latlong);
         }
     } else {
         if ($response_obj['status'] == 'REQUEST_DENIED' || $response_obj['status'] == 'INVALID_REQUEST') {
             /*
              * Geocoder can't run at all, so disable this service and
              * try the other geocoders instead.
              */
             if (TYPO3_DLOG) {
                 \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Google V3: ' . $response_obj['status'] . ': ' . $addressString . '. Disabling.', 'wec_map_geocode', 3);
             }
             $this->deactivateService();
             $latlong = null;
         } else {
             /*
              * Something is wrong with this address. Might work for other
              * addresses though.
              */
             if (TYPO3_DLOG) {
                 \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Google V3: ' . $response_obj['status'] . ': ' . $addressString . '. Disabling.', 'wec_map_geocode', 2);
             }
             $latlong = null;
         }
     }
     return $latlong;
 }
 /**
  * Function execute from the Scheduler
  *
  * @return bool TRUE on successful execution, FALSE on error
  * @throws \InvalidArgumentException if the email template file can not be read
  */
 public function execute()
 {
     $this->setCliArguments();
     $this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
     $successfullyExecuted = true;
     if (!file_exists($file = GeneralUtility::getFileAbsFileName($this->emailTemplateFile)) && !empty($this->email)) {
         if ($this->emailTemplateFile === 'EXT:linkvalidator/res/mailtemplate.html') {
             // Update the default email template file path
             $this->emailTemplateFile = 'EXT:linkvalidator/Resources/Private/Templates/mailtemplate.html';
             $this->save();
         } else {
             throw new \InvalidArgumentException($this->getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidEmailTemplateFile'), '1295476972');
         }
     }
     $htmlFile = GeneralUtility::getURL($file);
     $this->templateMail = $this->templateService->getSubpart($htmlFile, '###REPORT_TEMPLATE###');
     // The array to put the content into
     $pageSections = '';
     $this->isDifferentToLastRun = false;
     $pageList = GeneralUtility::trimExplode(',', $this->page, true);
     $modTs = $this->loadModTsConfig($this->page);
     if (is_array($pageList)) {
         foreach ($pageList as $page) {
             $pageSections .= $this->checkPageLinks($page);
         }
     }
     if ($this->totalBrokenLink != $this->oldTotalBrokenLink) {
         $this->isDifferentToLastRun = true;
     }
     if ($this->totalBrokenLink > 0 && (!$this->emailOnBrokenLinkOnly || $this->isDifferentToLastRun) && !empty($this->email)) {
         $successfullyExecuted = $this->reportEmail($pageSections, $modTs);
     }
     return $successfullyExecuted;
 }
Example #19
0
 /**
  * Load data from a CSV file.
  * @param $filename path to the CSV file may be on disk or remote URL
  */
 protected function loadCsvFromFile($filename)
 {
     $csvdata = null;
     if ($filename) {
         $csvdata = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($filename);
     }
     $this->loadCsvFromData($csvdata);
 }
Example #20
0
 /**
  * @test
  */
 public function extractExtensionDataFromT3x()
 {
     $content = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL('http://typo3.org/fileadmin/ter/a/d/additional_reports_2.6.4.t3x');
     $testExplode = explode(':', $content, 3);
     $this->assertTrue(preg_match('/^[a-f0-9]{32}$/', $testExplode[0]) > 0);
     $this->assertTrue($testExplode[1] === 'gzcompress');
     $this->assertTrue(strlen($testExplode[2]) === 474613);
     $files = tx_additionalreports_util::extractExtensionDataFromT3x($content);
     $this->testArray($files['FILES']);
 }
Example #21
0
 /**
  * Load the config from file
  *
  * @return array
  */
 protected function loadJqConf()
 {
     if ($formVars = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($this->configDir . 't3jquery.cfg')) {
         $return = unserialize($formVars);
         if (!is_array($return['files'])) {
             // fallback for old config files
             $temp = array();
             $temp['files'] = $return;
             $return = $temp;
         }
         // if no files are in config, empty array
         if (!$return['files']) {
             $return['files'] = array();
         }
         return $return;
     } else {
         return array('files' => array());
     }
 }
 /**
  * Read template file set in flexform or TypoScript, read the file's contents to $this->templateFile
  *
  * @param $settings The formhandler settings
  * @return string
  * @author    Reinhard Führicht <*****@*****.**>
  */
 public function readTemplateFile($templateFile, &$settings)
 {
     //template file was not set in flexform, search TypoScript for setting
     if (!$templateFile) {
         if (!$settings['templateFile'] && !$settings['templateFile.']) {
             return '';
         }
         $templateFile = $settings['templateFile'];
         if (isset($settings['templateFile.']) && is_array($settings['templateFile.'])) {
             $templateFile = $this->getSingle($settings, 'templateFile');
             if ($this->isTemplateFilePath($templateFile)) {
                 $templateFile = $this->resolvePath($templateFile);
                 if (!@file_exists($templateFile)) {
                     $this->throwException('template_file_not_found', $templateFile);
                 }
                 $templateCode = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($templateFile);
             } else {
                 //The setting "templateFile" was a cObject which returned HTML content. Just use that as template code.
                 $templateCode = $templateFile;
             }
         } else {
             $templateFile = $this->resolvePath($templateFile);
             if (!@file_exists($templateFile)) {
                 $this->throwException('template_file_not_found', $templateFile);
             }
             $templateCode = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($templateFile);
         }
     } else {
         if ($this->isTemplateFilePath($templateFile)) {
             $templateFile = $this->resolvePath($templateFile);
             if (!@file_exists($templateFile)) {
                 $this->throwException('template_file_not_found', $templateFile);
             }
             $templateCode = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($templateFile);
         } else {
             // given variable $templateFile already contains the template code
             $templateCode = $templateFile;
         }
     }
     if (strlen($templateCode) === 0) {
         $this->throwException('empty_template_file', $templateFile);
     }
     if (stristr($templateCode, '###TEMPLATE_') === FALSE) {
         $this->throwException('invalid_template_file', $templateFile);
     }
     return $templateCode;
 }
 /**
  * Builds the sitemap.
  *
  * @param string $eIdScriptUrl
  * @param string $sitemapFileName
  * @see tx_ddgooglesitemap_additionalfieldsprovider
  */
 protected function buildSitemap($eIdScriptUrl, $sitemapFileName)
 {
     $url = $eIdScriptUrl . sprintf('&offset=%d&limit=%d', $this->offset, $this->maxUrlsPerSitemap);
     $content = GeneralUtility::getURL($url);
     if ($content) {
         file_put_contents(PATH_site . $sitemapFileName, $content);
         $this->offset += $this->maxUrlsPerSitemap;
     }
 }
Example #24
0
 /**
  * This method will be used by the initial methods before and after the Order
  * will be moved to another Orderstate
  *
  * @param array $orderdata Containing the orderdatea like UID and PID
  * @param array $detaildata Containing the detaildata to Order like
  * 		order_id and CustomerUIDs
  * @param int $mailkind Mail kind
  *
  * @return void
  */
 protected function processOrdermails(array &$orderdata, array &$detaildata, $mailkind)
 {
     $pid = $orderdata['pid'] ? $orderdata['pid'] : $detaildata['pid'];
     $templates = $this->generateTemplateArray($mailkind, $pid, $detaildata['order_sys_language_uid']);
     foreach ($templates as $template) {
         $this->templateCode = GeneralUtility::getURL($this->templatePath . $template['mailtemplate']);
         $this->templateCodeHtml = GeneralUtility::getURL($this->templatePath . $template['htmltemplate']);
         $senderemail = $template['senderemail'] == '' ? $this->extConf['defEmailAddress'] : $template['senderemail'];
         if ($template['sendername'] == '') {
             if ($senderemail == $this->extConf['defEmailAddress']) {
                 $sendername = $this->extConf['defEmailSendername'];
             } else {
                 $sendername = $senderemail;
             }
         } else {
             $sendername = $template['sendername'];
         }
         // Mailconf for tx_commerce_div::sendMail($mailconf);
         $mailconf = array('plain' => array('content' => $this->generateMail($orderdata['order_id'], $detaildata, $this->templateCode)), 'html' => array('content' => $this->generateMail($orderdata['order_id'], $detaildata, $this->templateCodeHtml), 'path' => '', 'useHtml' => $this->templateCodeHtml ? '1' : ''), 'defaultCharset' => 'utf-8', 'encoding' => '8bit', 'attach' => '', 'alternateSubject' => 'TYPO3 :: commerce', 'recipient' => '', 'recipient_copy' => $template['BCC'], 'fromEmail' => $senderemail, 'fromName' => $sendername, 'replyTo' => $this->cObj->conf['usermail.']['from'], 'priority' => '3', 'callLocation' => 'processOrdermails');
         if ($template['otherreceiver'] != '') {
             $mailconf['recipient'] = $template['otherreceiver'];
             $this->ordermoveSendMail($mailconf, $orderdata, $template);
         } else {
             $mailconf['recipient'] = $this->customermailadress;
             $this->ordermoveSendMail($mailconf, $orderdata, $template);
         }
     }
 }
Example #25
0
 /**
  * Fetches an extensions l10n file from the given mirror
  *
  * @param string $extensionKey Extension Key
  * @param string $language The language code of the translation to fetch
  * @param string $mirrorUrl URL of mirror to use
  * @throws \TYPO3\CMS\Lang\Exception\XmlParser
  * @return array Array containing l10n data
  */
 protected function fetchTranslation($extensionKey, $language, $mirrorUrl)
 {
     $extensionPath = \TYPO3\CMS\Core\Utility\GeneralUtility::strtolower($extensionKey);
     $mirrorUrl .= $extensionPath[0] . '/' . $extensionPath[1] . '/' . $extensionPath . '-l10n/' . $extensionPath . '-l10n-' . $language . '.zip';
     $l10nResponse = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($mirrorUrl, 0, array(TYPO3_user_agent));
     if ($l10nResponse === FALSE) {
         throw new \TYPO3\CMS\Lang\Exception\XmlParser('Error: Translation could not be fetched.', 1345736785);
     } else {
         return array($l10nResponse);
     }
 }
Example #26
0
 /**
  * This method returns the label for a specified URL.
  * If the page is local and contains a fragment it returns the label of the content element linked to.
  * In any other case it simply fetches the page and extracts the <title> tag content as label
  *
  * @param string $url The statistics click-URL for which to return a label
  * @param string $urlStr  A processed variant of the url string. This could get appended to the label???
  * @param bool $forceFetch When this parameter is set to true the "fetch and extract <title> tag" method will get used
  * @param string $linkedWord The word to be linked
  *
  * @return string The label for the passed $url parameter
  */
 function getLinkLabel($url, $urlStr, $forceFetch = false, $linkedWord = '')
 {
     $pathSite = $this->getBaseURL();
     $label = $linkedWord;
     $contentTitle = '';
     $urlParts = parse_url($url);
     if (!$forceFetch && substr($url, 0, strlen($pathSite)) === $pathSite) {
         if ($urlParts['fragment'] && substr($urlParts['fragment'], 0, 1) == 'c') {
             // linking directly to a content
             $elementUid = intval(substr($urlParts['fragment'], 1));
             $row = BackendUtility::getRecord('tt_content', $elementUid);
             if ($row) {
                 $contentTitle = BackendUtility::getRecordTitle('tt_content', $row, false, true);
             }
         } else {
             $contentTitle = $this->getLinkLabel($url, $urlStr, true);
         }
     } else {
         if (empty($urlParts['host']) && substr($url, 0, strlen($pathSite)) !== $pathSite) {
             // it's internal
             $url = $pathSite . $url;
         }
         $content = GeneralUtility::getURL($url);
         if (preg_match('/\\<\\s*title\\s*\\>(.*)\\<\\s*\\/\\s*title\\s*\\>/i', $content, $matches)) {
             // get the page title
             $contentTitle = GeneralUtility::fixed_lgd_cs(trim($matches[1]), 50);
         } else {
             // file?
             $file = GeneralUtility::split_fileref($url);
             $contentTitle = $file['file'];
         }
     }
     if ($this->params['showContentTitle'] == 1) {
         $label = $contentTitle;
     }
     if ($this->params['prependContentTitle'] == 1) {
         $label = $contentTitle . ' (' . $linkedWord . ')';
     }
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['directmail']['getLinkLabel'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXT']['directmail']['getLinkLabel'] as $funcRef) {
             $params = array('pObj' => &$this, 'url' => $url, 'urlStr' => $urlStr, 'label' => $label);
             $label = GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
     if (isset($this->params['maxLabelLength']) && $this->params['maxLabelLength'] > 0) {
         $label = GeneralUtility::fixed_lgd_cs($label, $this->params['maxLabelLength']);
     }
     return $label;
 }
 /**
  * Returns the content of this newsletter with validation messages. The content
  * is also "fixed" automatically when possible.
  * @global type $LANG
  * @param string $language language of the content of the newsletter (the 'L' parameter in TYPO3 URL)
  * @return array ('content' => $content, 'errors' => $errors, 'warnings' => $warnings, 'infos' => $infos);
  */
 public function getValidatedContent($language = null)
 {
     // Here we need to include the locallization file for ExtDirect calls, otherwise we get empty strings
     global $LANG;
     if (is_null($LANG)) {
         $LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('language');
         // create language-object
         $LLkey = 'default';
         if ($GLOBALS['TSFE']->config['config']['language']) {
             $LLkey = $GLOBALS['TSFE']->config['config']['language'];
         }
         $LANG->init($LLkey);
         // initalize language-object with actual language
     }
     $LANG->includeLLFile('EXT:newsletter/Resources/Private/Language/locallang.xml');
     // We need to catch the exception if domain was not found/configured properly
     try {
         $url = $this->getContentUrl($language);
     } catch (Exception $e) {
         return array('content' => '', 'errors' => array($e->getMessage()), 'warnings' => array(), 'infos' => array());
     }
     $content = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($url);
     $errors = array();
     $warnings = array();
     $infos = array(sprintf($LANG->getLL('validation_content_url'), $url));
     // Content should be more that just a few characters. Apache error propably occured
     if (strlen($content) < 200) {
         $errors[] = $LANG->getLL('validation_mail_too_short');
     }
     // Content should not contain PHP-Warnings
     if (substr($content, 0, 22) == "<br />\n<b>Warning</b>:") {
         $errors[] = $LANG->getLL('validation_mail_contains_php_warnings');
     }
     // Content should not contain PHP-Warnings
     if (substr($content, 0, 26) == "<br />\n<b>Fatal error</b>:") {
         $errors[] = $LANG->getLL('validation_mail_contains_php_errors');
     }
     // If the page contains a "Pages is being generared" text... this is bad too
     if (strpos($content, 'Page is being generated.') && strpos($content, 'If this message does not disappear within')) {
         $errors[] = $LANG->getLL('validation_mail_being_generated');
     }
     // Find out the absolute domain. If specified in HTML source, use it as is.
     if (preg_match('|<base[^>]*href="([^"]*)"[^>]*/>|i', $content, $match)) {
         $absoluteDomain = $match[1];
     } else {
         $absoluteDomain = 'http://' . $this->getDomain() . '/';
     }
     // Fix relative URL to absolute URL
     $urlPatterns = array('hyperlinks' => '/<a [^>]*href="(.*)"/Ui', 'stylesheets' => '/<link [^>]*href="(.*)"/Ui', 'images' => '/ src="(.*)"/Ui', 'background images' => '/ background="(.*)"/Ui');
     foreach ($urlPatterns as $type => $urlPattern) {
         preg_match_all($urlPattern, $content, $urls);
         foreach ($urls[1] as $i => $url) {
             // If this is already an absolute link, dont replace it
             if (!preg_match('-^(http://|https://|ftp://|mailto:|#)-i', $url)) {
                 $replace_url = str_replace($url, $absoluteDomain . $url, $urls[0][$i]);
                 $content = str_replace($urls[0][$i], $replace_url, $content);
             }
         }
         if (count($urls[1])) {
             $infos[] = sprintf($LANG->getLL('validation_mail_converted_relative_url'), $type);
         }
     }
     // Find linked css and convert into a style-tag
     preg_match_all('|<link rel="stylesheet" type="text/css" href="([^"]+)"[^>]+>|Ui', $content, $urls);
     foreach ($urls[1] as $i => $url) {
         $content = str_replace($urls[0][$i], "<!-- fetched URL: {$url} -->\n<style type=\"text/css\">\n<!--\n" . \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($url) . "\n-->\n</style>", $content);
     }
     if (count($urls[1])) {
         $infos[] = $LANG->getLL('validation_mail_contains_linked_styles');
     }
     // We cant very well have attached javascript in a newsmail ... removing
     $content = preg_replace('|<script[^>]*type="text/javascript"[^>]*>[^<]*</script>|i', '', $content, -1, $count);
     if ($count) {
         $warnings[] = $LANG->getLL('validation_mail_contains_javascript');
     }
     // Images in CSS
     if (preg_match('|background-image: url\\([^\\)]+\\)|', $content) || preg_match('|list-style-image: url\\([^\\)]+\\)|', $content)) {
         $errors[] = $LANG->getLL('validation_mail_contains_css_images');
     }
     // CSS-classes
     if (preg_match('|<[a-z]+ [^>]*class="[^"]+"[^>]*>|', $content)) {
         $warnings[] = $LANG->getLL('validation_mail_contains_css_classes');
     }
     // Positioning & element sizes in CSS
     $forbiddenCssProperties = array('width' => '((min|max)+-)?width', 'height' => '((min|max)+-)?height', 'margin' => 'margin(-(bottom|left|right|top)+)?', 'padding' => 'padding(-(bottom|left|right|top)+)?', 'position' => 'position');
     $forbiddenCssPropertiesWarnings = array();
     if (preg_match_all('|<[a-z]+[^>]+style="([^"]*)"|', $content, $matches)) {
         foreach ($matches[1] as $stylepart) {
             foreach ($forbiddenCssProperties as $property => $regex) {
                 if (preg_match('/[^-]\\b' . $regex . '\\b[^-]/', $stylepart)) {
                     $forbiddenCssPropertiesWarnings[$property] = $property;
                 }
             }
         }
         foreach ($forbiddenCssPropertiesWarnings as $property) {
             $warnings[] = sprintf($LANG->getLL('validation_mail_contains_css_some_property'), $property);
         }
     }
     return array('content' => $content, 'errors' => $errors, 'warnings' => $warnings, 'infos' => $infos);
 }
Example #28
0
 function updateEvents($uid, $pid, $urlString, $md5, $cruser_id)
 {
     $urls = GeneralUtility::trimExplode("\n", $urlString, 1);
     $mD5Array = array();
     $contentArray = array();
     foreach ($urls as $key => $url) {
         /* If the calendar has a URL, get a checksum on the contents */
         if ($url != '') {
             $contents = GeneralUtility::getURL($url);
             $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_icalendar_service', 'importIcsContent', 'service');
             // Hook: configuration
             foreach ($hookObjectsArr as $hookObj) {
                 if (method_exists($hookObj, 'importIcsContent')) {
                     $hookObj->importIcsContent($contents);
                 }
             }
             $mD5Array[$key] = md5($contents);
             $contentArray[$key] = $contents;
         }
     }
     $newMD5 = md5(implode('', $mD5Array));
     /* If the calendar has changed */
     if ($newMD5 != $md5) {
         $notInUids = array();
         foreach ($contentArray as $contents) {
             /* Parse the contents into ICS data structure */
             $iCalendar = $this->getiCalendarFromICSFile($contents);
             /* Create new events belonging to the specified calendar */
             $notInUids = array_merge($notInUids, $this->insertCalEventsIntoDB($iCalendar->_components, $uid, $pid, $cruser_id));
         }
         $notInUids = array_unique($notInUids);
         /* Delete old events, that have not been updated */
         $this->deleteTemporaryEvents($uid, $notInUids);
         \TYPO3\CMS\Cal\Utility\Functions::clearCache();
         return $newMD5;
     } else {
         return false;
     }
 }
Example #29
0
 /**
  * Get coordinates by query google maps api
  *
  * @param array $parameter
  * @return \stdClass
  */
 protected function getCoordinateByApiCall($parameter)
 {
     $apiUrl = $this->settings['geocodeUrl'] . '&address=' . implode(',+', $parameter);
     $addressData = json_decode(utf8_encode(GeneralUtility::getURL($apiUrl)));
     if (is_object($addressData) && property_exists($addressData, 'status') && $addressData->status === 'OK') {
         $result = $addressData->results[0]->geometry->location;
     } else {
         $result = new \stdClass();
     }
     return $result;
 }
 function main($content, $conf)
 {
     // Parse with TypoScript
     if (isset($conf['url.'])) {
         $conf['url'] = $this->cObj->cObjGetSingle($conf['url'], $conf['url.']);
         unset($conf['url.']);
     }
     if (isset($conf['filename.'])) {
         $conf['filename'] = $this->cObj->cObjGetSingle($conf['filename'], $conf['filename.']);
         unset($conf['filename.']);
     }
     // Render filename / filepath
     if (empty($conf['filename'])) {
         $targetFile = $conf['targetPath'] . hash('adler32', $conf['url']) . '.' . $conf['fileExt'];
     } else {
         $targetFile = $conf['targetPath'] . $conf['filename'] . '.' . $conf['fileExt'];
     }
     // Return File or create file
     if (file_exists($targetFile) && filemtime($targetFile) + $conf['cacheTimeout'] > time()) {
         return $targetFile;
     } else {
         file_put_contents($targetFile, \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($conf['url']));
         return $targetFile;
     }
 }