/**
  * Creates hash integer to lock user to. Depends on configured keywords
  *
  * @return	integer		Hash integer
  * @access private
  */
 function hashLockClause_getHashInt()
 {
     $hashStr = '';
     if (t3lib_div::inList($this->lockHashKeyWords, 'useragent')) {
         $hashStr .= ':' . t3lib_div::getIndpEnv('HTTP_USER_AGENT');
     }
     return t3lib_div::md5int($hashStr);
 }
 /**
  * This is all about fetching the right TypoScript template structure. If it's not cached then it must be generated and cached!
  * The method traverses the rootline structure from out to in, fetches the hierarchy of template records and based on this either finds the cached TypoScript template structure or parses the template and caches it for next time.
  * Sets $this->setup to the parsed TypoScript template array
  *
  * @param	array		The rootline of the current page (going ALL the way to tree root)
  * @return	void
  * @see tslib_fe::getConfigArray()
  */
 function start($theRootLine)
 {
     if (is_array($theRootLine)) {
         $setupData = '';
         $hash = '';
         // Flag that indicates that the existing data in cache_pagesection
         // could be used (this is the case if $TSFE->all is set, and the
         // rowSum still matches). Based on this we decide if cache_pagesection
         // needs to be updated...
         $isCached = false;
         $this->runThroughTemplates($theRootLine);
         if ($GLOBALS['TSFE']->all) {
             $cc = $GLOBALS['TSFE']->all;
             // The two rowSums must NOT be different from each other - which they will be if start/endtime or hidden has changed!
             if (strcmp(serialize($this->rowSum), serialize($cc['rowSum']))) {
                 unset($cc);
                 // If the two rowSums differ, we need to re-make the current page data and therefore clear the existing values.
             } else {
                 // If $TSFE->all contains valid data, we don't need to update cache_pagesection (because this data was fetched from there already)
                 if (!strcmp(serialize($this->rootLine), serialize($cc['rootLine']))) {
                     $isCached = true;
                 }
                 // When the data is serialized below (ROWSUM hash), it must not contain the rootline by concept. So this must be removed (and added again later)...
                 unset($cc['rootLine']);
             }
         }
         // This is about getting the hash string which is used to fetch the cached TypoScript template.
         // If there was some cached currentPageData ($cc) then that's good (it gives us the hash).
         if (is_array($cc)) {
             // If currentPageData was actually there, we match the result (if this wasn't done already in $TSFE->getFromCache()...)
             if (!$cc['match']) {
                 // TODO: check if this can ever be the case - otherwise remove
                 $cc = $this->matching($cc);
                 ksort($cc);
             }
             $hash = md5(serialize($cc));
         } else {
             // If currentPageData was not there, we first find $rowSum (freshly generated). After that we try to see, if it is stored with a list of all conditions. If so we match the result.
             $rowSumHash = md5('ROWSUM:' . serialize($this->rowSum));
             $result = t3lib_pageSelect::getHash($rowSumHash);
             if ($result) {
                 $cc = array();
                 $cc['all'] = unserialize($result);
                 $cc['rowSum'] = $this->rowSum;
                 $cc = $this->matching($cc);
                 ksort($cc);
                 $hash = md5(serialize($cc));
             }
         }
         if ($hash) {
             // Get TypoScript setup array
             $setupData = t3lib_pageSelect::getHash($hash);
         }
         if ($setupData && !$this->forceTemplateParsing) {
             // If TypoScript setup structure was cached we unserialize it here:
             $this->setup = unserialize($setupData);
         } else {
             // Make configuration
             $this->generateConfig();
             // This stores the template hash thing
             $cc = array();
             $cc['all'] = $this->sections;
             // All sections in the template at this point is found
             $cc['rowSum'] = $this->rowSum;
             // The line of templates is collected
             $cc = $this->matching($cc);
             ksort($cc);
             $hash = md5(serialize($cc));
             // This stores the data.
             t3lib_pageSelect::storeHash($hash, serialize($this->setup), 'TS_TEMPLATE');
             if ($this->tt_track) {
                 $GLOBALS['TT']->setTSlogMessage('TS template size, serialized: ' . strlen(serialize($this->setup)) . ' bytes');
             }
             $rowSumHash = md5('ROWSUM:' . serialize($this->rowSum));
             t3lib_pageSelect::storeHash($rowSumHash, serialize($cc['all']), 'TMPL_CONDITIONS_ALL');
         }
         // Add rootLine
         $cc['rootLine'] = $this->rootLine;
         ksort($cc);
         // Make global and save
         $GLOBALS['TSFE']->all = $cc;
         // Matching must be executed for every request, so this must never be part of the pagesection cache!
         unset($cc['match']);
         if (!$isCached && !$this->simulationHiddenOrTime && !$GLOBALS['TSFE']->no_cache) {
             // Only save the data if we're not simulating by hidden/starttime/endtime
             $mpvarHash = t3lib_div::md5int($GLOBALS['TSFE']->MP);
             if (TYPO3_UseCachingFramework) {
                 $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
                 /* @var $pageSectionCache t3lib_cache_AbstractCache */
                 $pageSectionCache->set(intval($GLOBALS['TSFE']->id) . '_' . $mpvarHash, serialize($cc), array('pageId_' . intval($GLOBALS['TSFE']->id), 'mpvarHash_' . $mpvarHash));
             } else {
                 $dbFields = array('content' => serialize($cc), 'tstamp' => $GLOBALS['EXEC_TIME']);
                 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_pagesection', 'page_id=' . intval($GLOBALS['TSFE']->id) . ' AND mpvar_hash=' . $mpvarHash, $dbFields);
                 if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 0) {
                     $dbFields['page_id'] = intval($GLOBALS['TSFE']->id);
                     $dbFields['mpvar_hash'] = $mpvarHash;
                     $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pagesection', $dbFields);
                 }
             }
         }
         // If everything OK.
         if ($this->rootId && $this->rootLine && $this->setup) {
             $this->loaded = 1;
         }
     }
 }
	/**
	 * Processes submission
	 *
	 * @param	string	$error	Error message
	 * @return	boolean	true if successful
	 */
	protected function processRedirectSubmission(&$error) {
		$result = false; $error = '';
		if (t3lib_div::_GP('_edit_save')) {
			$data = t3lib_div::_GP('data');
			$databaseUpdateData = array();
			$databaseInsertData = array();
			foreach ($data as $fields) {
				//
				// Validate
				//
				$fields['source'] = strtolower(trim($fields['source']));
				$fields['target'] = trim($fields['target']);
				// Check empty or same
				if ($fields['source'] == $fields['target']) {
					// Either equal or empty, ignore the input
					continue;
				}
				// Check one field empty
				if (trim($fields['source']) == '' || trim($fields['target'] == '')) {
					$error = 'Please, fill in both source and destination URLs';
					return false;
				}
				// Check for duplicate source URLs
				$andWhere = ($fields['url_hash'] != '' ? ' AND url_hash<>' . intval($fields['url_hash']) : '');
				list($row) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('COUNT(*) AS t',
					'tx_realurl_redirects',
					'url=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($fields['source'], 'tx_realurl_redirects') .
						' AND domain_limit=' . intval($fields['domain_limit']) .
						$andWhere);
				if ($row['t'] > 0) {
					$error = 'Source URL \'/' . htmlspecialchars($fields['source']) . '\' already exists in the redirect list.';
					return false;
				}
				// Check for missing slash in destination
				$parse = @parse_url($fields['target']);
				if ($fields['target']{0} != '/' && ($parse === false || !isset($parse['scheme']))) {
					$fields['target'] = '/' . $fields['target'];
				}

				// Process
				if ($fields['url_hash'] == '') {
					// New entry
					$databaseInsertData[] = array(
						'url_hash' => t3lib_div::md5int($fields['source']),
						'url' => $fields['source'],
						'destination' => $fields['target'],
						'has_moved' => $fields['permanent'] ? 1 : 0,
						'domain_limit' => intval($fields['domain_limit'])
					);
				}
				else {
					// Existing entry
					$databaseUpdateData[$fields['uid']] = array(
						'url_hash' => t3lib_div::md5int($fields['source']),
						'url' => $fields['source'],
						'destination' => $fields['target'],
						'has_moved' => $fields['permanent'] ? 1 : 0,
						'domain_limit' => intval($fields['domain_limit'])
					);
				}
			}
			// Add/update data
			foreach ($databaseInsertData as $data) {
				$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_realurl_redirects', $data);
			}
			foreach ($databaseUpdateData as $uid => $data) {
				$GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_realurl_redirects',
					'uid=' . intval($uid),
					$data);
			}
			// Make sure we return success if the form is totally empty
			$result = true;
		}
		return $result;
	}
	/**
	 * Throws a 404 message.
	 *
	 * @param	string		Message string
	 * @return	void
	 */
	public function decodeSpURL_throw404($msg) {

		// Log error:
		if (!$this->extConf['init']['disableErrorLog']) {
			$hash = t3lib_div::md5int($this->speakingURIpath_procValue);
			$rootpage_id = intval($this->extConf['pagePath']['rootpage_id']);
			$cond = 'url_hash=' . intval($hash) . ' AND rootpage_id=' . $rootpage_id;
			$fields_values = array('url_hash' => $hash, 'url' => $this->speakingURIpath_procValue, 'error' => $msg, 'counter' => 1, 'tstamp' => time(), 'cr_date' => time(), 'rootpage_id' => $rootpage_id, 'last_referer' => t3lib_div::getIndpEnv('HTTP_REFERER'));
			if ($this->useMySQLExtendedSyntax) {
				$query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_realurl_errorlog', $fields_values);
				$query .= ' ON DUPLICATE KEY UPDATE ' . 'error=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($msg, 'tx_realurl_errorlog') . ',' . 'counter=counter+1,' . 'tstamp=' . $fields_values['tstamp'] . ',' . 'last_referer=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(t3lib_div::getIndpEnv('HTTP_REFERER'), 'tx_realurl_errorlog');
				$GLOBALS['TYPO3_DB']->sql_query($query);
			} else {
				$GLOBALS['TYPO3_DB']->sql_query('START TRANSACTION');
				list($error_row) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('counter', 'tx_realurl_errorlog', $cond);
				if (count($error_row)) {
					$fields_values = array('error' => $msg, 'counter' => $error_row['counter'] + 1, 'tstamp' => time(), 'last_referer' => t3lib_div::getIndpEnv('HTTP_REFERER'));
					$GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_realurl_errorlog', $cond, $fields_values);
				} else {
					$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_realurl_errorlog', $fields_values);
				}
				$GLOBALS['TYPO3_DB']->sql_query('COMMIT');
			}
		}

		// Call handler
		$this->pObj->pageNotFoundAndExit($msg);
	}
示例#5
0
    /**
     * Shows the log of indexed URLs
     *
     * @return	string		HTML output
     */
    function drawLog()
    {
        global $BACK_PATH;
        $output = '';
        // Init:
        $this->crawlerObj = t3lib_div::makeInstance('tx_crawler_lib');
        $this->crawlerObj->setAccessMode('gui');
        $this->crawlerObj->setID = t3lib_div::md5int(microtime());
        $this->CSVExport = t3lib_div::_POST('_csv');
        // Read URL:
        if (t3lib_div::_GP('qid_read')) {
            $this->crawlerObj->readUrl(intval(t3lib_div::_GP('qid_read')), TRUE);
        }
        // Look for set ID sent - if it is, we will display contents of that set:
        $showSetId = intval(t3lib_div::_GP('setID'));
        // Show details:
        if (t3lib_div::_GP('qid_details')) {
            // Get entry record:
            list($q_entry) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_crawler_queue', 'qid=' . intval(t3lib_div::_GP('qid_details')));
            // Explode values:
            $resStatus = $this->getResStatus($q_entry);
            $q_entry['parameters'] = unserialize($q_entry['parameters']);
            $q_entry['result_data'] = unserialize($q_entry['result_data']);
            if (is_array($q_entry['result_data'])) {
                $q_entry['result_data']['content'] = unserialize($q_entry['result_data']['content']);
            }
            if (!$this->pObj->MOD_SETTINGS['log_resultLog']) {
                unset($q_entry['result_data']['content']['log']);
            }
            // Print rudimentary details:
            $output .= '
				<br /><br />
				<input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.back') . '" name="_back" />
				<input type="hidden" value="' . $this->pObj->id . '" name="id" />
				<input type="hidden" value="' . $showSetId . '" name="setID" />
				<br />
				Current server time: ' . date('H:i:s', time()) . '<br />' . 'Status: ' . $resStatus . '<br />' . (version_compare(TYPO3_version, '4.5.0', '<') ? t3lib_div::view_array($q_entry) : t3lib_utility_Debug::viewArray($q_entry));
        } else {
            // Show list:
            // If either id or set id, show list:
            if ($this->pObj->id || $showSetId) {
                if ($this->pObj->id) {
                    // Drawing tree:
                    $tree = t3lib_div::makeInstance('t3lib_pageTree');
                    $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
                    $tree->init('AND ' . $perms_clause);
                    // Set root row:
                    $HTML = t3lib_iconWorks::getSpriteIconForRecord('pages', $this->pObj->pageinfo);
                    $HTML = t3lib_iconWorks::getSpriteIconForRecord('pages', $this->pObj->pageinfo);
                    $tree->tree[] = array('row' => $this->pObj->pageinfo, 'HTML' => $HTML);
                    // Get branch beneath:
                    if ($this->pObj->MOD_SETTINGS['depth']) {
                        $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS['depth'], '');
                    }
                    // Traverse page tree:
                    $code = '';
                    $count = 0;
                    foreach ($tree->tree as $data) {
                        $code .= $this->drawLog_addRows($data['row'], $data['HTML'] . t3lib_BEfunc::getRecordTitle('pages', $data['row'], TRUE), intval($this->pObj->MOD_SETTINGS['itemsPerPage']));
                        if (++$count == 1000) {
                            break;
                        }
                    }
                } else {
                    $code = '';
                    $code .= $this->drawLog_addRows($showSetId, 'Set ID: ' . $showSetId);
                }
                if ($code) {
                    $output .= '
						<br /><br />
						<input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.reloadlist') . '" name="_reload" />
						<input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.downloadcsv') . '" name="_csv" />
						<input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.flushvisiblequeue') . '" name="_flush" onclick="return confirm(\'' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.confirmyouresure') . '\');" />
						<input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.flushfullqueue') . '" name="_flush_all" onclick="return confirm(\'' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.confirmyouresure') . '\');" />
						<input type="hidden" value="' . $this->pObj->id . '" name="id" />
						<input type="hidden" value="' . $showSetId . '" name="setID" />
						<br />
						' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.curtime') . ': ' . date('H:i:s', time()) . '
						<br /><br />


						<table class="lrPadding c-list crawlerlog">' . $this->drawLog_printTableHeader() . $code . '</table>';
                }
            } else {
                // Otherwise show available sets:
                $setList = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('set_id, count(*) as count_value, scheduled', 'tx_crawler_queue', '', 'set_id, scheduled', 'scheduled DESC');
                $code = '
					<tr class="bgColor5 tableheader">
						<td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.setid') . ':</td>
						<td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.count') . 't:</td>
						<td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time') . ':</td>
					</tr>
				';
                $cc = 0;
                foreach ($setList as $set) {
                    $code .= '
						<tr class="bgColor' . ($cc % 2 ? '-20' : '-10') . '">
							<td><a href="' . htmlspecialchars('index.php?setID=' . $set['set_id']) . '">' . $set['set_id'] . '</a></td>
							<td>' . $set['count_value'] . '</td>
							<td>' . t3lib_BEfunc::dateTimeAge($set['scheduled']) . '</td>
						</tr>
					';
                    $cc++;
                }
                $output .= '
					<br /><br />
					<table class="lrPadding c-list">' . $code . '</table>';
            }
        }
        if ($this->CSVExport) {
            $this->outputCsvFile();
        }
        // Return output
        return $output;
    }
 /**
  * Fetches the data for the tree
  *
  * @param	string		Abs file path
  * @param	integer		Max depth (recursivity limit)
  * @return	integer		The count of items on the level
  * @see getBrowsableTree()
  */
 function getFolderTree($files_path, $depth = 999, $type = '')
 {
     // This generates the directory tree
     $dirs = t3lib_div::get_dirs($files_path);
     if (!is_array($dirs)) {
         return 0;
     }
     sort($dirs);
     $c = count($dirs);
     $depth = intval($depth);
     $HTML = '';
     $a = 0;
     foreach ($dirs as $key => $val) {
         $a++;
         $this->tree[] = array();
         // Reserve space.
         end($this->tree);
         $treeKey = key($this->tree);
         // Get the key for this space
         $val = preg_replace('/^\\.\\//', '', $val);
         $title = $val;
         $path = $files_path . $val . '/';
         $specUID = t3lib_div::md5int($path);
         $this->specUIDmap[$specUID] = $path;
         $row = array();
         $row['path'] = $path;
         $row['uid'] = $specUID;
         $row['title'] = $title;
         // Make a recursive call to the next level
         if ($depth > 1 && $this->expandNext($specUID)) {
             $nextCount = $this->getFolderTree($path, $depth - 1, $this->makeHTML ? '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/' . ($a == $c ? 'blank' : 'line') . '.gif', 'width="18" height="16"') . ' alt="" />' : '', $type);
             $exp = 1;
             // Set "did expand" flag
         } else {
             $nextCount = $this->getCount($path);
             $exp = 0;
             // Clear "did expand" flag
         }
         // Set HTML-icons, if any:
         if ($this->makeHTML) {
             $HTML = $this->PMicon($row, $a, $c, $nextCount, $exp);
             $webpath = t3lib_BEfunc::getPathType_web_nonweb($path);
             if (is_writable($path)) {
                 $type = '';
                 $overlays = array();
             } else {
                 $type = 'readonly';
                 $overlays = array('status-overlay-locked' => array());
             }
             if ($webpath == 'web') {
                 $icon = 'apps-filetree-folder-default';
             } else {
                 $icon = 'apps-filetree-folder-default';
             }
             if ($val == '_temp_') {
                 $icon = 'apps-filetree-folder-temp';
                 $row['title'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:temp', true);
                 $row['_title'] = '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:temp', true) . '</strong>';
             }
             if ($val == '_recycler_') {
                 $icon = 'apps-filetree-folder-recycler';
                 $row['title'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:recycler', true);
                 $row['_title'] = '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:recycler', true) . '</strong>';
             }
             $HTML .= $this->wrapIcon(t3lib_iconWorks::getSpriteIcon($icon, array('title' => $row['title']), $overlays), $row);
         }
         // Finally, add the row/HTML content to the ->tree array in the reserved key.
         $this->tree[$treeKey] = array('row' => $row, 'HTML' => $HTML, 'hasSub' => $nextCount && $this->expandNext($specUID), 'isFirst' => $a == 1, 'isLast' => false, 'invertedDepth' => $depth, 'bank' => $this->bank);
     }
     if ($a) {
         $this->tree[$treeKey]['isLast'] = true;
     }
     return $c;
 }
    /**
     * Initialization of crawler hook.
     * This function is asked for each instance of the crawler and we must check if something is timed to happen and if so put entry(s) in the crawlers log to start processing.
     * In reality we select indexing configurations and evaluate if any of them needs to run.
     *
     * @param	object		Parent object (tx_crawler lib)
     * @return	void
     */
    function crawler_init(&$pObj)
    {
        // Select all indexing configuration which are waiting to be activated:
        $indexingConfigurations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'index_config', 'hidden=0
				AND (starttime=0 OR starttime<=' . $GLOBALS['EXEC_TIME'] . ')
				AND timer_next_indexing<' . $GLOBALS['EXEC_TIME'] . '
				AND set_id=0
				' . t3lib_BEfunc::deleteClause('index_config'));
        // For each configuration, check if it should be executed and if so, start:
        foreach ($indexingConfigurations as $cfgRec) {
            // Generate a unique set-ID:
            $setId = t3lib_div::md5int(microtime());
            // Get next time:
            $nextTime = $this->generateNextIndexingTime($cfgRec);
            // Start process by updating index-config record:
            $field_array = array('set_id' => $setId, 'timer_next_indexing' => $nextTime, 'session_data' => '');
            $GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_config', 'uid=' . intval($cfgRec['uid']), $field_array);
            // Based on configuration type:
            switch ($cfgRec['type']) {
                case 1:
                    // RECORDS:
                    // Parameters:
                    $params = array('indexConfigUid' => $cfgRec['uid'], 'procInstructions' => array('[Index Cfg UID#' . $cfgRec['uid'] . ']'), 'url' => 'Records (start)');
                    //
                    $pObj->addQueueEntry_callBack($setId, $params, $this->callBack, $cfgRec['pid']);
                    break;
                case 2:
                    // FILES:
                    // Parameters:
                    $params = array('indexConfigUid' => $cfgRec['uid'], 'procInstructions' => array('[Index Cfg UID#' . $cfgRec['uid'] . ']'), 'url' => $cfgRec['filepath'], 'depth' => 0);
                    $pObj->addQueueEntry_callBack($setId, $params, $this->callBack, $cfgRec['pid']);
                    break;
                case 3:
                    // External URL:
                    // Parameters:
                    $params = array('indexConfigUid' => $cfgRec['uid'], 'procInstructions' => array('[Index Cfg UID#' . $cfgRec['uid'] . ']'), 'url' => $cfgRec['externalUrl'], 'depth' => 0);
                    $pObj->addQueueEntry_callBack($setId, $params, $this->callBack, $cfgRec['pid']);
                    break;
                case 4:
                    // Page tree
                    // Parameters:
                    $params = array('indexConfigUid' => $cfgRec['uid'], 'procInstructions' => array('[Index Cfg UID#' . $cfgRec['uid'] . ']'), 'url' => intval($cfgRec['alternative_source_pid']), 'depth' => 0);
                    $pObj->addQueueEntry_callBack($setId, $params, $this->callBack, $cfgRec['pid']);
                    break;
                case 5:
                    // Meta configuration, nothing to do:
                    # NOOP
                    break;
                default:
                    if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['crawler'][$cfgRec['type']]) {
                        $hookObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['crawler'][$cfgRec['type']]);
                        if (is_object($hookObj)) {
                            // Parameters:
                            $params = array('indexConfigUid' => $cfgRec['uid'], 'procInstructions' => array('[Index Cfg UID#' . $cfgRec['uid'] . '/CUSTOM]'), 'url' => $hookObj->initMessage($message));
                            $pObj->addQueueEntry_callBack($setId, $params, $this->callBack, $cfgRec['pid']);
                        }
                    }
                    break;
            }
        }
        // Finally, look up all old index configurations which are finished and needs to be reset and done.
        $this->cleanUpOldRunningConfigurations();
    }
 /**
  * @param $str
  * @return int
  * @see t3lib_div::md5int()
  */
 public function md5int($str)
 {
     /** @noinspection PhpDeprecationInspection PhpUndefinedClassInspection */
     return t3lib_div::md5int($str);
 }
示例#9
0
 /**
  * Function executed by crawler_im.php cli script.
  *
  * @return	void
  */
 function CLI_main_im()
 {
     $this->setAccessMode('cli_im');
     $cliObj = t3lib_div::makeInstance('tx_crawler_cli_im');
     // Force user to admin state and set workspace to "Live":
     $this->backendUser->user['admin'] = 1;
     $this->backendUser->setWorkspace(0);
     // Print help
     if (!isset($cliObj->cli_args['_DEFAULT'][1])) {
         $cliObj->cli_validateArgs();
         $cliObj->cli_help();
         exit;
     }
     $cliObj->cli_validateArgs();
     if ($cliObj->cli_argValue('-o') === 'exec') {
         $this->registerQueueEntriesInternallyOnly = TRUE;
     }
     if (isset($cliObj->cli_args['_DEFAULT'][2])) {
         // Crawler is called over TYPO3 BE
         $pageId = tx_crawler_api::forceIntegerInRange($cliObj->cli_args['_DEFAULT'][2], 0);
     } else {
         // Crawler is called over cli
         $pageId = tx_crawler_api::forceIntegerInRange($cliObj->cli_args['_DEFAULT'][1], 0);
     }
     $configurationKeys = $this->getConfigurationKeys($cliObj);
     if (!is_array($configurationKeys)) {
         $configurations = $this->getUrlsForPageId($pageId);
         if (is_array($configurations)) {
             $configurationKeys = array_keys($configurations);
         } else {
             $configurationKeys = array();
         }
     }
     if ($cliObj->cli_argValue('-o') === 'queue' || $cliObj->cli_argValue('-o') === 'exec') {
         $reason = new tx_crawler_domain_reason();
         $reason->setReason(tx_crawler_domain_reason::REASON_GUI_SUBMIT);
         $reason->setDetailText('The cli script of the crawler added to the queue');
         tx_crawler_domain_events_dispatcher::getInstance()->post('invokeQueueChange', $this->setID, array('reason' => $reason));
     }
     $this->setID = t3lib_div::md5int(microtime());
     $this->getPageTreeAndUrls(tx_crawler_api::forceIntegerInRange($pageId, 0), tx_crawler_api::forceIntegerInRange($cliObj->cli_argValue('-d'), 0, 99), $this->getCurrentTime(), tx_crawler_api::forceIntegerInRange($cliObj->cli_isArg('-n') ? $cliObj->cli_argValue('-n') : 30, 1, 1000), $cliObj->cli_argValue('-o') === 'queue' || $cliObj->cli_argValue('-o') === 'exec', $cliObj->cli_argValue('-o') === 'url', t3lib_div::trimExplode(',', $cliObj->cli_argValue('-proc'), 1), $configurationKeys);
     if ($cliObj->cli_argValue('-o') === 'url') {
         $cliObj->cli_echo(implode(chr(10), $this->downloadUrls) . chr(10), 1);
     } elseif ($cliObj->cli_argValue('-o') === 'exec') {
         $cliObj->cli_echo("Executing " . count($this->urlList) . " requests right away:\n\n");
         $cliObj->cli_echo(implode(chr(10), $this->urlList) . chr(10));
         $cliObj->cli_echo("\nProcessing:\n");
         foreach ($this->queueEntries as $queueRec) {
             $p = unserialize($queueRec['parameters']);
             $cliObj->cli_echo($p['url'] . ' (' . implode(',', $p['procInstructions']) . ') => ');
             $result = $this->readUrlFromArray($queueRec);
             $requestResult = unserialize($result['content']);
             if (is_array($requestResult)) {
                 $resLog = is_array($requestResult['log']) ? chr(10) . chr(9) . chr(9) . implode(chr(10) . chr(9) . chr(9), $requestResult['log']) : '';
                 $cliObj->cli_echo('OK: ' . $resLog . chr(10));
             } else {
                 $cliObj->cli_echo('Error checking Crawler Result: ' . substr(preg_replace('/\\s+/', ' ', strip_tags($result['content'])), 0, 30000) . '...' . chr(10));
             }
         }
     } elseif ($cliObj->cli_argValue('-o') === 'queue') {
         $cliObj->cli_echo("Putting " . count($this->urlList) . " entries in queue:\n\n");
         $cliObj->cli_echo(implode(chr(10), $this->urlList) . chr(10));
     } else {
         $cliObj->cli_echo(count($this->urlList) . " entries found for processing. (Use -o to decide action):\n\n", 1);
         $cliObj->cli_echo(implode(chr(10), $this->urlList) . chr(10), 1);
     }
 }
 function start($conf, $piVars, $cObj)
 {
     // config
     $this->conf = $conf;
     $this->piVars = $piVars;
     $this->cObj = $cObj;
     $this->pi_loadLL();
     $this->div = t3lib_div::makeInstance('tx_wtgallery_div');
     // Create new instance for div class
     $this->dynamicMarkers = t3lib_div::makeInstance('tx_wtgallery_dynamicmarkers');
     // Create new instance for dynamicmarker function
     $this->tmpl = $this->markerArray = $this->outerMarkerArray = $subpartArray = array();
     $content_item = '';
     // init
     $this->tmpl[$this->mode]['all'] = trim($this->cObj->getSubpart($this->cObj->fileResource($this->conf['template.'][$this->mode]), '###WTGALLERY_COOLIRIS_RSS###'));
     // Load HTML Template
     $this->tmpl[$this->mode]['item'] = $this->cObj->getSubpart($this->tmpl[$this->mode]['all'], '###ITEM###');
     // work on subpart 2
     // let's go
     if (!empty($this->conf['main.']['path'])) {
         // if startpath was set via typoscript
         $startpath = $this->div->validatePicturePath($this->piVars['category'] ? $this->div->hash2folder($this->piVars['category'], $this->conf['main.']['path']) : $this->conf['main.']['path']);
         // startpath from piVars or from ts
         $pictures = $this->div->getFiles($this->conf, $startpath, $this->conf[$this->mode . '.']['order'], $this->conf[$this->mode . '.']['limit']);
         // get all pictures from current folder
         if (count($pictures) > 0) {
             // if there are pictures
             for ($i = 0; $i < count($pictures); $i++) {
                 // one loop for every picture in current folder
                 // let's start
                 $row = array('picture' => $pictures[$i], 'tstamp' => filemtime($pictures[$i]), 'filename' => $this->div->fileInfo($pictures[$i], 'filename'), 'dirname' => $this->div->fileInfo($pictures[$i], 'dirname'), 'basename' => $this->div->fileInfo($pictures[$i], 'basename'), 'extension' => $this->div->fileInfo($pictures[$i], 'extension'), 'currentfolder' => $this->div->fileInfo($pictures[$i], 'currentfolder'), 'picturehash' => t3lib_div::md5int($pictures[$i]));
                 $metarow = $this->div->EXIForTXT($row['picture'], $this->conf[$this->mode . '.']['metainformation']);
                 // get metainformation
                 $row = array_merge((array) $row, (array) $metarow);
                 // add array from txt or exif to normal row
                 $this->cObj->start($row, 'tt_content');
                 // enable .field in typoscript for singleview
                 if (!empty($this->conf[$this->mode . '.']['width'])) {
                     $this->conf[$this->mode . '.']['image.']['file.']['width'] = $this->conf[$this->mode . '.']['width'];
                 }
                 // set width from config (e.g. flexform if not empty)
                 if (!empty($this->conf[$this->mode . '.']['height'])) {
                     $this->conf[$this->mode . '.']['image.']['file.']['height'] = $this->conf[$this->mode . '.']['height'];
                 }
                 // set height from config (e.g. flexform if not empty)
                 if (!is_array($this->conf[$this->mode . '.']['image'])) {
                     $this->markerArray['###IMAGE###'] = $this->cObj->cObjGetSingle($this->conf[$this->mode . '.']['image'], $this->conf[$this->mode . '.']['image.']);
                 }
                 // values from ts
                 foreach ($row as $key => $value) {
                     // one loop for every row entry
                     $this->markerArray['###' . strtoupper($key) . '###'] = $value;
                     // fill marker with value of row
                 }
                 $content_item .= $this->cObj->substituteMarkerArrayCached($this->tmpl[$this->mode]['item'], $this->markerArray, array(), $this->wrappedSubpartArray);
                 // add inner html to variable
             }
         }
         $subpartArray['###CONTENT###'] = $content_item;
         // work on subpart 3
         $this->outerMarkerArray['###TITLE###'] = $this->conf[$this->mode . '.']['title'];
         // Add title to RSS
         $this->outerMarkerArray['###URL###'] = $this->conf[$this->mode . '.']['url'];
         // Add url to RSS
         $this->outerMarkerArray['###DESCRIPTION###'] = $this->conf[$this->mode . '.']['description'];
         // Add description to RSS
         $this->content = $this->cObj->substituteMarkerArrayCached($this->tmpl[$this->mode]['all'], $this->outerMarkerArray, $subpartArray);
         // Get html template
         $this->content = $this->dynamicMarkers->main($this->conf, $this->cObj, $this->content);
         // Fill dynamic locallang or typoscript markers
         $this->content = preg_replace("|###.*?###|i", "", $this->content);
         // Finally clear not filled markers
         if (!empty($this->content) && count($pictures) > 0) {
             return $this->content;
         } else {
             return $this->pi_getLL('wtgallery_ll_coolirisError', 'no pictures to list on current url');
         }
         // return error message for dynamic RSS
     } else {
         // if startpath was not set via typoscript
         return $this->pi_getLL('wtgallery_ll_coolirisErrorNoPath', 'Please set the startpath via typoscript and not only in the plugin - this is needed for cooliris!');
         // return error message for dynamic RSS
     }
 }
 function hashCode($string)
 {
     if (!empty($string)) {
         return t3lib_div::md5int($string);
     }
 }
示例#12
0
 /**
  * Method to get an instance of the internal crawler singleton
  *
  * @return tx_crawler_lib Instance of the crawler lib
  */
 protected function findCrawler()
 {
     if (!is_object($this->crawlerObj)) {
         $this->crawlerObj = t3lib_div::makeInstance('tx_crawler_lib');
         $this->crawlerObj->setID = t3lib_div::md5int(microtime());
     }
     if (is_object($this->crawlerObj)) {
         return $this->crawlerObj;
     } else {
         throw new Exception("no crawler object");
     }
 }
 /**
  * Processing of the submitted form; Will create and write the XML file and tell the new file name.
  *
  * @param	string		Absolute path to the locallang.php file to convert.
  * @param	string		The new file name to write to (absolute path, .xml ending). The locallang-xml file is in UTF-8
  * @return	string		HTML text string message
  */
 function renderSaveDone($phpFile, $newFileName)
 {
     // Initialize variables:
     $outputArray = array();
     $formContent = t3lib_div::_POST('_DAT');
     $LOCAL_LANG = $this->getLLarray($phpFile);
     $LOCAL_LANG = $this->convertLLarrayToUTF8($LOCAL_LANG);
     // Setting meta data:
     $outputArray['meta'] = $formContent['meta'];
     // Setting label context dummy tags:
     $outputArray['meta']['labelContext'] = array();
     /*	foreach($LOCAL_LANG['default'] as $labelKey => $labelValue)	{
     			$outputArray['meta']['labelContext'][$labelKey] = '';
     		}
     */
     // Setting data content:
     $outputArray['data'] = $LOCAL_LANG;
     // Setting orig-hash/content
     foreach ($LOCAL_LANG as $langKey => $labelsArray) {
         $outputArray['orig_hash'][$langKey] = array();
         $outputArray['orig_text'][$langKey] = array();
         foreach ($labelsArray as $labelKey => $_temp) {
             $outputArray['orig_hash'][$langKey][$labelKey] = t3lib_div::md5int($LOCAL_LANG['default'][$labelKey]);
             #$outputArray['orig_text'][$langKey][$labelKey] = $LOCAL_LANG['default'][$labelKey];
         }
     }
     // Options:
     $options = array('parentTagMap' => array('data' => 'languageKey', 'orig_hash' => 'languageKey', 'orig_text' => 'languageKey', 'labelContext' => 'label', 'languageKey' => 'label'));
     // Creating XML file from $outputArray:
     $XML = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>' . chr(10);
     $XML .= t3lib_div::array2xml($outputArray, '', 0, 'T3locallang', 4, $options);
     if (!file_exists($newFileName)) {
         #		debug(array($XML));
         t3lib_div::writeFile($newFileName, $XML);
         return 'File written to disk: ' . $newFileName;
     }
 }
 /**
  * Is wt_gallery on the current page?
  *
  * @param	string		$startpath: Start path like fileadmin/
  * @return	array		$newArray: Array with folders and its hash code
  */
 public function folderChange($startpath)
 {
     // config
     $subfolder = '';
     // let's go
     $folderArray = $newArray = array();
     // init empty array
     $folderArray = t3lib_div::getAllFilesAndFoldersInPath($folderArray, t3lib_div::getFileAbsFileName($startpath), 'wt_gallery', 1);
     // get all folders of the startpath in an array
     $folderArray = array_flip($folderArray);
     // flip array
     foreach ((array) $folderArray as $key => $value) {
         // one loop for every array content
         if (substr($key, -1) === '/') {
             // if last sign is '/'
             $key = substr($key, 0, -1);
             // delete last sign
         }
         if (t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '/' != t3lib_div::getIndpEnv('TYPO3_SITE_URL')) {
             // if request_host is different to site_url (TYPO3 runs in a subfolder)
             $subfolder = str_replace(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '/', '', t3lib_div::getIndpEnv('TYPO3_SITE_URL'));
             // get the folder (like "subfolder/")
         }
         $newArray[str_replace(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT') . '/' . $subfolder, '', $key)] = t3lib_div::md5int(str_replace(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT') . '/' . $subfolder, '', $key));
         // rewrite array like 12345 => fileadmin/pics
     }
     if (!empty($newArray)) {
         return $newArray;
     }
 }
 /**
  * Adds new words to db
  *
  * @param	array		Word List array (where each word has information about position etc).
  * @return	void
  */
 function submitWords($wl)
 {
     $hashArr = array();
     foreach ($wl as $w) {
         $hashArr[] = t3lib_div::md5int($w);
     }
     $wl = array_flip($wl);
     if (count($hashArr)) {
         $cwl = implode(',', $hashArr);
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('baseword', 'sys_refindex_words', 'wid IN (' . $cwl . ')');
         if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) != count($wl)) {
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 unset($wl[$row['baseword']]);
             }
             foreach ($wl as $key => $val) {
                 $insertFields = array('wid' => t3lib_div::md5int($key), 'baseword' => $key);
                 // A duplicate-key error will occur here if a word is NOT unset in the unset() line. However as long as the words in $wl are NOT longer as 60 chars (the baseword varchar is 60 characters...) this is not a problem.
                 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_refindex_words', $insertFields);
             }
         }
     }
 }