@@ -1054,8 +1054,9 @@ discard block |
||
1054 | 1054 | $isAvailable = false; |
1055 | 1055 | $userArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('be_users', 'username', '_cli_crawler'); |
1056 | 1056 | |
1057 | - if (is_array($userArray)) |
|
1058 | - $isAvailable = true; |
|
1057 | + if (is_array($userArray)) { |
|
1058 | + $isAvailable = true; |
|
1059 | + } |
|
1059 | 1060 | |
1060 | 1061 | return $isAvailable; |
1061 | 1062 | } |
@@ -1073,8 +1074,9 @@ discard block |
||
1073 | 1074 | $isAvailable = false; |
1074 | 1075 | $userArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('be_users', 'username', '_cli_crawler'); |
1075 | 1076 | |
1076 | - if (is_array($userArray) && $userArray[0]['admin'] == 0) |
|
1077 | - $isAvailable = true; |
|
1077 | + if (is_array($userArray) && $userArray[0]['admin'] == 0) { |
|
1078 | + $isAvailable = true; |
|
1079 | + } |
|
1078 | 1080 | |
1079 | 1081 | return $isAvailable; |
1080 | 1082 | } |
@@ -1,4 +1,7 @@ |
||
1 | -<?php if (!defined('TYPO3_MODE')) die ('Access denied.'); ?> |
|
1 | +<?php if (!defined('TYPO3_MODE')) { |
|
2 | + die ('Access denied.'); |
|
3 | +} |
|
4 | +?> |
|
2 | 5 | |
3 | 6 | Page: |
4 | 7 | <?php for($currentPageOffset = 0; $currentPageOffset < $this->getTotalPagesCount(); $currentPageOffset++ ){ ?> |
@@ -1,4 +1,7 @@ discard block |
||
1 | -<?php if (!defined('TYPO3_MODE')) die ('Access denied.'); ?> |
|
1 | +<?php if (!defined('TYPO3_MODE')) { |
|
2 | + die ('Access denied.'); |
|
3 | +} |
|
4 | +?> |
|
2 | 5 | |
3 | 6 | <br /> |
4 | 7 | <div id="controll-panel"> |
@@ -69,8 +72,11 @@ discard block |
||
69 | 72 | </div> |
70 | 73 | <?php elseif ($process->getState() == 'cancelled'): ?> |
71 | 74 | <?php echo $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.cancelled'); ?> |
72 | - <?php else: ?> |
|
73 | - <?php echo $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.success'); ?> |
|
75 | + <?php else { |
|
76 | + : ?> |
|
77 | + <?php echo $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.success'); |
|
78 | +} |
|
79 | +?> |
|
74 | 80 | <?php endif; ?> |
75 | 81 | </td> |
76 | 82 | </tr> |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('TYPO3_cliMode')) die('You cannot run this script directly!'); |
|
2 | +if (!defined('TYPO3_cliMode')) { |
|
3 | + die('You cannot run this script directly!'); |
|
4 | +} |
|
3 | 5 | |
4 | 6 | $crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
5 | 7 |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('TYPO3_cliMode')) die('You cannot run this script directly!'); |
|
2 | +if (!defined('TYPO3_cliMode')) { |
|
3 | + die('You cannot run this script directly!'); |
|
4 | +} |
|
3 | 5 | |
4 | 6 | $crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
5 | 7 | $crawlerObj->CLI_main_im($_SERVER["argv"]); |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('TYPO3_cliMode')) die('You cannot run this script directly!'); |
|
2 | +if (!defined('TYPO3_cliMode')) { |
|
3 | + die('You cannot run this script directly!'); |
|
4 | +} |
|
3 | 5 | |
4 | 6 | $crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
5 | 7 | $crawlerObj->CLI_main_flush($_SERVER["argv"]); |
@@ -640,7 +640,9 @@ discard block |
||
640 | 640 | $sets = $pageTSconfig['tx_crawler.']['crawlerCfg.']['paramSets.']; |
641 | 641 | if(is_array($sets)) { |
642 | 642 | foreach($sets as $key=>$value) { |
643 | - if(!is_array($value)) continue; |
|
643 | + if(!is_array($value)) { |
|
644 | + continue; |
|
645 | + } |
|
644 | 646 | $configurationsForBranch[] = substr($key,-1)=='.'?substr($key,0,-1):$key; |
645 | 647 | } |
646 | 648 | } |
@@ -987,7 +989,9 @@ discard block |
||
987 | 989 | */ |
988 | 990 | public function addQueueEntry_callBack($setId,$params,$callBack,$page_id=0,$schedule=0) { |
989 | 991 | |
990 | - if (!is_array($params)) $params = array(); |
|
992 | + if (!is_array($params)) { |
|
993 | + $params = array(); |
|
994 | + } |
|
991 | 995 | $params['_CALLBACKOBJ'] = $callBack; |
992 | 996 | |
993 | 997 | // Compile value array: |
@@ -1079,7 +1083,7 @@ discard block |
||
1079 | 1083 | $rows[] = $uid; |
1080 | 1084 | $urlAdded = true; |
1081 | 1085 | tx_crawler_domain_events_dispatcher::getInstance()->post('urlAddedToQueue',$this->setID,array('uid' => $uid, 'fieldArray' => $fieldArray)); |
1082 | - }else{ |
|
1086 | + } else{ |
|
1083 | 1087 | tx_crawler_domain_events_dispatcher::getInstance()->post('duplicateUrlInQueue',$this->setID,array('rows' => $rows, 'fieldArray' => $fieldArray)); |
1084 | 1088 | } |
1085 | 1089 | } |
@@ -1108,7 +1112,7 @@ discard block |
||
1108 | 1112 | $timeBegin = $currentTime - 100; |
1109 | 1113 | $timeEnd = $currentTime + 100; |
1110 | 1114 | $where = ' ((scheduled BETWEEN '.$timeBegin.' AND '.$timeEnd.' ) OR scheduled <= '. $currentTime.') '; |
1111 | - }else{ |
|
1115 | + } else{ |
|
1112 | 1116 | $where = 'scheduled <= ' . $currentTime; |
1113 | 1117 | } |
1114 | 1118 | } elseif ($tstamp > $currentTime) { |
@@ -1301,18 +1305,24 @@ discard block |
||
1301 | 1305 | */ |
1302 | 1306 | public function requestUrl($originalUrl, $crawlerId, $timeout=2, $recursion=10) { |
1303 | 1307 | |
1304 | - if (!$recursion) return false; |
|
1308 | + if (!$recursion) { |
|
1309 | + return false; |
|
1310 | + } |
|
1305 | 1311 | |
1306 | 1312 | // Parse URL, checking for scheme: |
1307 | 1313 | $url = parse_url($originalUrl); |
1308 | 1314 | |
1309 | 1315 | if ($url === FALSE) { |
1310 | - if (TYPO3_DLOG) \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(sprintf('Could not parse_url() for string "%s"', $url), 'crawler', 4, array('crawlerId' => $crawlerId)); |
|
1316 | + if (TYPO3_DLOG) { |
|
1317 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(sprintf('Could not parse_url() for string "%s"', $url), 'crawler', 4, array('crawlerId' => $crawlerId)); |
|
1318 | + } |
|
1311 | 1319 | return FALSE; |
1312 | 1320 | } |
1313 | 1321 | |
1314 | 1322 | if (!in_array($url['scheme'], array('','http','https'))) { |
1315 | - if (TYPO3_DLOG) \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(sprintf('Scheme does not match for url "%s"', $url), 'crawler', 4, array('crawlerId' => $crawlerId)); |
|
1323 | + if (TYPO3_DLOG) { |
|
1324 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(sprintf('Scheme does not match for url "%s"', $url), 'crawler', 4, array('crawlerId' => $crawlerId)); |
|
1325 | + } |
|
1316 | 1326 | return FALSE; |
1317 | 1327 | } |
1318 | 1328 | |
@@ -1346,7 +1356,9 @@ discard block |
||
1346 | 1356 | $fp = fsockopen($host, $port, $errno, $errstr, $timeout); |
1347 | 1357 | |
1348 | 1358 | if (!$fp) { |
1349 | - if (TYPO3_DLOG) \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(sprintf('Error while opening "%s"', $url), 'crawler', 4, array('crawlerId' => $crawlerId)); |
|
1359 | + if (TYPO3_DLOG) { |
|
1360 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(sprintf('Error while opening "%s"', $url), 'crawler', 4, array('crawlerId' => $crawlerId)); |
|
1361 | + } |
|
1350 | 1362 | return FALSE; |
1351 | 1363 | } else { |
1352 | 1364 | // Request message: |
@@ -1374,7 +1386,9 @@ discard block |
||
1374 | 1386 | if (is_array($newRequestUrl)) { |
1375 | 1387 | $result = array_merge(array('parentRequest'=>$result), $newRequestUrl); |
1376 | 1388 | } else { |
1377 | - if (TYPO3_DLOG) \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(sprintf('Error while opening "%s"', $url), 'crawler', 4, array('crawlerId' => $crawlerId)); |
|
1389 | + if (TYPO3_DLOG) { |
|
1390 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(sprintf('Error while opening "%s"', $url), 'crawler', 4, array('crawlerId' => $crawlerId)); |
|
1391 | + } |
|
1378 | 1392 | return FALSE; |
1379 | 1393 | } |
1380 | 1394 | } |
@@ -1500,20 +1514,32 @@ discard block |
||
1500 | 1514 | * @return string URL from redirection |
1501 | 1515 | */ |
1502 | 1516 | protected function getRequestUrlFrom302Header($headers,$user='',$pass='') { |
1503 | - if(!is_array($headers)) return false; |
|
1504 | - if(!(stristr($headers[0],'301 Moved') || stristr($headers[0],'302 Found') || stristr($headers[0],'302 Moved'))) return false; |
|
1517 | + if(!is_array($headers)) { |
|
1518 | + return false; |
|
1519 | + } |
|
1520 | + if(!(stristr($headers[0],'301 Moved') || stristr($headers[0],'302 Found') || stristr($headers[0],'302 Moved'))) { |
|
1521 | + return false; |
|
1522 | + } |
|
1505 | 1523 | |
1506 | 1524 | foreach($headers as $hl) { |
1507 | 1525 | $tmp = explode(": ",$hl); |
1508 | 1526 | $header[trim($tmp[0])] = trim($tmp[1]); |
1509 | - if(trim($tmp[0])=='Location') break; |
|
1527 | + if(trim($tmp[0])=='Location') { |
|
1528 | + break; |
|
1529 | + } |
|
1530 | + } |
|
1531 | + if(!array_key_exists('Location',$header)) { |
|
1532 | + return false; |
|
1510 | 1533 | } |
1511 | - if(!array_key_exists('Location',$header)) return false; |
|
1512 | 1534 | |
1513 | 1535 | if($user!='') { |
1514 | - if(!($tmp = parse_url($header['Location']))) return false; |
|
1536 | + if(!($tmp = parse_url($header['Location']))) { |
|
1537 | + return false; |
|
1538 | + } |
|
1515 | 1539 | $newUrl = $tmp['scheme'] . '://' . $user . ':' . $pass . '@' . $tmp['host'] . $tmp['path']; |
1516 | - if($tmp['query']!='') $newUrl .= '?' . $tmp['query']; |
|
1540 | + if($tmp['query']!='') { |
|
1541 | + $newUrl .= '?' . $tmp['query']; |
|
1542 | + } |
|
1517 | 1543 | } else { |
1518 | 1544 | $newUrl = $header['Location']; |
1519 | 1545 | } |
@@ -1942,7 +1968,7 @@ discard block |
||
1942 | 1968 | $configurations = $this->getUrlsForPageId($pageId); |
1943 | 1969 | if(is_array($configurations)){ |
1944 | 1970 | $configurationKeys = array_keys($configurations); |
1945 | - }else{ |
|
1971 | + } else{ |
|
1946 | 1972 | $configurationKeys = array(); |
1947 | 1973 | } |
1948 | 1974 | } |
@@ -2274,7 +2300,9 @@ discard block |
||
2274 | 2300 | return false; //nothing to release |
2275 | 2301 | } |
2276 | 2302 | |
2277 | - if(!$withinLock) $this->db->sql_query('BEGIN'); |
|
2303 | + if(!$withinLock) { |
|
2304 | + $this->db->sql_query('BEGIN'); |
|
2305 | + } |
|
2278 | 2306 | |
2279 | 2307 | // some kind of 2nd chance algo - this way you need at least 2 processes to have a real cleanup |
2280 | 2308 | // this ensures that a single process can't mess up the entire process table |
@@ -2318,7 +2346,9 @@ discard block |
||
2318 | 2346 | ) |
2319 | 2347 | ); |
2320 | 2348 | |
2321 | - if(!$withinLock) $this->db->sql_query('COMMIT'); |
|
2349 | + if(!$withinLock) { |
|
2350 | + $this->db->sql_query('COMMIT'); |
|
2351 | + } |
|
2322 | 2352 | |
2323 | 2353 | return true; |
2324 | 2354 | } |
@@ -182,15 +182,13 @@ |
||
182 | 182 | if ($oFileHandler !== false) { |
183 | 183 | pclose($oFileHandler); |
184 | 184 | } |
185 | - } |
|
186 | - else { |
|
185 | + } else { |
|
187 | 186 | $sCompletePath = '(' .escapeshellcmd($this->getCrawlerCliPath()) . ' &) > /dev/null'; |
188 | 187 | $oFileHandler = system($sCompletePath); |
189 | 188 | } |
190 | 189 | if ($oFileHandler === false) { |
191 | 190 | throw new Exception('could not start process!'); |
192 | - } |
|
193 | - else { |
|
191 | + } else { |
|
194 | 192 | for ($i=0;$i<10;$i++) { |
195 | 193 | if ($this->processRepository->countNotTimeouted($ttl) > $current) { |
196 | 194 | return true; |
@@ -76,7 +76,9 @@ |
||
76 | 76 | if ($params['pObj']->applicationData['tx_crawler']['running']) { |
77 | 77 | $grList = $params['pObj']->applicationData['tx_crawler']['parameters']['feUserGroupList']; |
78 | 78 | if ($grList) { |
79 | - if (!is_array($params['pObj']->fe_user->user)) $params['pObj']->fe_user->user = array(); |
|
79 | + if (!is_array($params['pObj']->fe_user->user)) { |
|
80 | + $params['pObj']->fe_user->user = array(); |
|
81 | + } |
|
80 | 82 | $params['pObj']->fe_user->user['usergroup'] = $grList; |
81 | 83 | $params['pObj']->applicationData['tx_crawler']['log'][] = 'User Groups: '.$grList; |
82 | 84 | } |