Example #1
0
 /**
  * @test
  */
 public function isRequestUrlProcessedCorrectlyWithDefinedBasePath()
 {
     $this->crawlerLibrary->setExtensionSettings(array('frontendBasePath' => '/cms/', 'phpPath' => 'PHPPATH'));
     $testUrl = 'http://localhost/' . uniqid();
     $testHeader = 'X-Test: ' . uniqid();
     $testHeaderArray = array($testHeader);
     $testCrawlerId = 13;
     $testContent = uniqid('Content');
     $frontendBasePath = '/cms/';
     $expectedCommand = escapeshellcmd('PHPPATH') . ' ' . escapeshellarg(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('crawler') . 'cli/bootstrap.php') . ' ' . escapeshellarg($frontendBasePath) . ' ' . escapeshellarg($testUrl) . ' ' . escapeshellarg(base64_encode(serialize($testHeaderArray)));
     $this->crawlerLibrary->expects($this->once())->method('buildRequestHeaderArray')->will($this->returnValue($testHeaderArray));
     $this->crawlerLibrary->expects($this->once())->method('executeShellCommand')->with($expectedCommand)->will($this->returnValue($testContent));
     $result = $this->crawlerLibrary->requestUrl($testUrl, $testCrawlerId);
     $this->assertEquals($testHeader . str_repeat("\r\n", 2), $result['request']);
     $this->assertEquals($testContent, $result['content']);
 }
    /**
     * Create the rows for display of the page tree
     * For each page a number of rows are shown displaying GET variable configuration
     *
     * @param	array		Page row or set-id
     * @param	string		Title string
     * @param	int			Items per Page setting
     * @return	string		HTML <tr> content (one or more)
     */
    function drawLog_addRows($pageRow_setId, $titleString, $itemsPerPage = 10)
    {
        // If Flush button is pressed, flush tables instead of selecting entries:
        if (t3lib_div::_POST('_flush')) {
            $doFlush = true;
            $doFullFlush = false;
        } elseif (t3lib_div::_POST('_flush_all')) {
            $doFlush = true;
            $doFullFlush = true;
        } else {
            $doFlush = false;
            $doFullFlush = false;
        }
        // Get result:
        if (is_array($pageRow_setId)) {
            $res = $this->crawlerObj->getLogEntriesForPageId($pageRow_setId['uid'], $this->pObj->MOD_SETTINGS['log_display'], $doFlush, $doFullFlush, intval($itemsPerPage));
        } else {
            $res = $this->crawlerObj->getLogEntriesForSetId($pageRow_setId, $this->pObj->MOD_SETTINGS['log_display'], $doFlush, $doFullFlush, intval($itemsPerPage));
        }
        // Init var:
        $colSpan = 9 + ($this->pObj->MOD_SETTINGS['log_resultLog'] ? -1 : 0) + ($this->pObj->MOD_SETTINGS['log_feVars'] ? 3 : 0);
        if (count($res)) {
            // Traverse parameter combinations:
            $c = 0;
            $content = '';
            foreach ($res as $kk => $vv) {
                // Title column:
                if (!$c) {
                    $titleClm = '<td rowspan="' . count($res) . '">' . $titleString . '</td>';
                } else {
                    $titleClm = '';
                }
                // Result:
                $resLog = $this->getResultLog($vv);
                $resStatus = $this->getResStatus($vv);
                $resFeVars = $this->getResFeVars($vv);
                // Compile row:
                $parameters = unserialize($vv['parameters']);
                // Put data into array:
                $rowData = array();
                if ($this->pObj->MOD_SETTINGS['log_resultLog']) {
                    $rowData['result_log'] = $resLog;
                } else {
                    $rowData['scheduled'] = $vv['scheduled'] > 0 ? t3lib_BEfunc::datetime($vv['scheduled']) : ' ' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.immediate');
                    $rowData['exec_time'] = $vv['exec_time'] ? t3lib_BEfunc::datetime($vv['exec_time']) : '-';
                }
                $rowData['result_status'] = t3lib_div::fixed_lgd_cs($resStatus, 50);
                $rowData['url'] = '<a href="' . htmlspecialchars($parameters['url']) . '" target="_newWIndow">' . htmlspecialchars($parameters['url']) . '</a>';
                $rowData['feUserGroupList'] = $parameters['feUserGroupList'];
                $rowData['procInstructions'] = is_array($parameters['procInstructions']) ? implode('; ', $parameters['procInstructions']) : '';
                $rowData['set_id'] = $vv['set_id'];
                if ($this->pObj->MOD_SETTINGS['log_feVars']) {
                    $rowData['tsfe_id'] = $resFeVars['id'];
                    $rowData['tsfe_gr_list'] = $resFeVars['gr_list'];
                    $rowData['tsfe_no_cache'] = $resFeVars['no_cache'];
                }
                $setId = intval(t3lib_div::_GP('setID'));
                // Put rows together:
                $content .= '
					<tr class="bgColor' . ($c % 2 ? '-20' : '-10') . '">
						' . $titleClm . '
						<td><a href="index.php?id=' . $this->pObj->id . '&qid_details=' . $vv['qid'] . '&setID=' . $setId . '">' . htmlspecialchars($vv['qid']) . '</a></td>
						<td><a href="index.php?id=' . $this->pObj->id . '&qid_read=' . $vv['qid'] . '&setID=' . $setId . '"><img src="' . $GLOBALS['BACK_PATH'] . 'gfx/refresh_n.gif" width="14" hspace="1" vspace="2" height="14" border="0" title="' . htmlspecialchars('Read') . '" alt="" /></a></td>';
                foreach ($rowData as $fKey => $value) {
                    if (t3lib_div::inList('url', $fKey)) {
                        $content .= '
						<td>' . $value . '</td>';
                    } else {
                        $content .= '
						<td>' . nl2br(htmlspecialchars($value)) . '</td>';
                    }
                }
                $content .= '
					</tr>';
                $c++;
                if ($this->CSVExport) {
                    // Only for CSV (adding qid and scheduled/exec_time if needed):
                    $rowData['result_log'] = implode('// ', explode(chr(10), $resLog));
                    $rowData['qid'] = $vv['qid'];
                    $rowData['scheduled'] = t3lib_BEfunc::datetime($vv['scheduled']);
                    $rowData['exec_time'] = $vv['exec_time'] ? t3lib_BEfunc::datetime($vv['exec_time']) : '-';
                    $this->CSVaccu[] = $rowData;
                }
            }
        } else {
            // Compile row:
            $content = '
				<tr class="bgColor-20">
					<td>' . $titleString . '</td>
					<td colspan="' . $colSpan . '"><em>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noentries') . '</em></td>
				</tr>';
        }
        return $content;
    }
 public function getHttpResponseFromStream($filePointer)
 {
     return parent::getHttpResponseFromStream($filePointer);
 }