@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | class tx_crawler_lib { |
30 | 30 | |
31 | 31 | var $setID = 0; |
32 | - var $processID =''; |
|
33 | - var $max_CLI_exec_time = 3600; // One hour is max stalled time for the CLI (If the process has had the status "start" for 3600 seconds it will be regarded stalled and a new process is started. |
|
32 | + var $processID = ''; |
|
33 | + var $max_CLI_exec_time = 3600; // One hour is max stalled time for the CLI (If the process has had the status "start" for 3600 seconds it will be regarded stalled and a new process is started. |
|
34 | 34 | |
35 | 35 | var $duplicateTrack = array(); |
36 | 36 | var $downloadUrls = array(); |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | var $queueEntries = array(); |
44 | 44 | var $urlList = array(); |
45 | 45 | |
46 | - var $debugMode=FALSE; |
|
46 | + var $debugMode = FALSE; |
|
47 | 47 | |
48 | - var $extensionSettings=array(); |
|
48 | + var $extensionSettings = array(); |
|
49 | 49 | |
50 | 50 | var $MP = false; // mount point |
51 | 51 | |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | private $backendUser; |
70 | 70 | |
71 | 71 | const CLI_STATUS_NOTHING_PROCCESSED = 0; |
72 | - const CLI_STATUS_REMAIN = 1; //queue not empty |
|
73 | - const CLI_STATUS_PROCESSED = 2; //(some) queue items where processed |
|
74 | - const CLI_STATUS_ABORTED = 4; //instance didn't finish |
|
72 | + const CLI_STATUS_REMAIN = 1; //queue not empty |
|
73 | + const CLI_STATUS_PROCESSED = 2; //(some) queue items where processed |
|
74 | + const CLI_STATUS_ABORTED = 4; //instance didn't finish |
|
75 | 75 | const CLI_STATUS_POLLABLE_PROCESSED = 8; |
76 | 76 | |
77 | 77 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $this->extensionSettings['countInARun'] = 100; |
163 | 163 | } |
164 | 164 | |
165 | - $this->extensionSettings['processLimit'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->extensionSettings['processLimit'],1,99,1); |
|
165 | + $this->extensionSettings['processLimit'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->extensionSettings['processLimit'], 1, 99, 1); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | if (!$skipPage) { |
198 | - if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('3,4', $pageRow['doktype']) || $pageRow['doktype']>=199) { |
|
198 | + if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('3,4', $pageRow['doktype']) || $pageRow['doktype'] >= 199) { |
|
199 | 199 | $skipPage = true; |
200 | 200 | $skipMessage = 'Because doktype is not allowed'; |
201 | 201 | } |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | if (!$skipPage) { |
217 | 217 | // veto hook |
218 | 218 | if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['pageVeto'])) { |
219 | - foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['pageVeto'] as $key => $func) { |
|
219 | + foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['pageVeto'] as $key => $func) { |
|
220 | 220 | $params = array( |
221 | 221 | 'pageRow' => $pageRow |
222 | 222 | ); |
223 | 223 | // expects "false" if page is ok and "true" or a skipMessage if this page should _not_ be crawled |
224 | 224 | $veto = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($func, $params, $this); |
225 | - if ($veto !== false) { |
|
225 | + if ($veto !== false) { |
|
226 | 226 | $skipPage = true; |
227 | 227 | if (is_string($veto)) { |
228 | 228 | $skipMessage = $veto; |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | * @param string $configurationHash |
272 | 272 | * @return boolean |
273 | 273 | */ |
274 | - protected function noUnprocessedQueueEntriesForPageWithConfigurationHashExist($uid,$configurationHash) { |
|
275 | - $configurationHash = $this->db->fullQuoteStr($configurationHash,'tx_crawler_queue'); |
|
276 | - $res = $this->db->exec_SELECTquery('count(*) as anz','tx_crawler_queue',"page_id=".intval($uid)." AND configuration_hash=".$configurationHash." AND exec_time=0"); |
|
274 | + protected function noUnprocessedQueueEntriesForPageWithConfigurationHashExist($uid, $configurationHash) { |
|
275 | + $configurationHash = $this->db->fullQuoteStr($configurationHash, 'tx_crawler_queue'); |
|
276 | + $res = $this->db->exec_SELECTquery('count(*) as anz', 'tx_crawler_queue', "page_id=".intval($uid)." AND configuration_hash=".$configurationHash." AND exec_time=0"); |
|
277 | 277 | $row = $this->db->sql_fetch_assoc($res); |
278 | 278 | |
279 | 279 | return ($row['anz'] == 0); |
@@ -338,26 +338,26 @@ discard block |
||
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
341 | - if (is_array($vv['URLs'])) { |
|
342 | - $configurationHash = md5(serialize($vv)); |
|
343 | - $skipInnerCheck = $this->noUnprocessedQueueEntriesForPageWithConfigurationHashExist($pageRow['uid'],$configurationHash); |
|
341 | + if (is_array($vv['URLs'])) { |
|
342 | + $configurationHash = md5(serialize($vv)); |
|
343 | + $skipInnerCheck = $this->noUnprocessedQueueEntriesForPageWithConfigurationHashExist($pageRow['uid'], $configurationHash); |
|
344 | 344 | |
345 | - foreach($vv['URLs'] as $urlQuery) { |
|
345 | + foreach ($vv['URLs'] as $urlQuery) { |
|
346 | 346 | |
347 | - if ($this->drawURLs_PIfilter($vv['subCfg']['procInstrFilter'], $incomingProcInstructions)) { |
|
347 | + if ($this->drawURLs_PIfilter($vv['subCfg']['procInstrFilter'], $incomingProcInstructions)) { |
|
348 | 348 | |
349 | 349 | // Calculate cHash: |
350 | - if ($vv['subCfg']['cHash']) { |
|
350 | + if ($vv['subCfg']['cHash']) { |
|
351 | 351 | /* @var $cacheHash \TYPO3\CMS\Frontend\Page\CacheHashCalculator */ |
352 | 352 | $cacheHash = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\Page\CacheHashCalculator'); |
353 | - $urlQuery .= '&cHash=' . $cacheHash->generateForParameters($urlQuery); |
|
353 | + $urlQuery .= '&cHash='.$cacheHash->generateForParameters($urlQuery); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | // Create key by which to determine unique-ness: |
357 | 357 | $uKey = $urlQuery.'|'.$vv['subCfg']['userGroups'].'|'.$vv['subCfg']['baseUrl'].'|'.$vv['subCfg']['procInstrFilter']; |
358 | 358 | |
359 | 359 | // realurl support (thanks to Ingo Renner) |
360 | - $urlQuery = 'index.php' . $urlQuery; |
|
360 | + $urlQuery = 'index.php'.$urlQuery; |
|
361 | 361 | if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl') && $vv['subCfg']['realurl']) { |
362 | 362 | $params = array( |
363 | 363 | 'LD' => array( |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | // Scheduled time: |
373 | - $schTime = $scheduledTime + round(count($duplicateTrack)*(60/$reqMinute)); |
|
374 | - $schTime = floor($schTime/60)*60; |
|
373 | + $schTime = $scheduledTime + round(count($duplicateTrack) * (60 / $reqMinute)); |
|
374 | + $schTime = floor($schTime / 60) * 60; |
|
375 | 375 | |
376 | 376 | if (isset($duplicateTrack[$uKey])) { |
377 | 377 | |
@@ -383,10 +383,10 @@ discard block |
||
383 | 383 | $urlList = '['.date('d.m.y H:i', $schTime).'] '.htmlspecialchars($urlQuery); |
384 | 384 | $this->urlList[] = '['.date('d.m.y H:i', $schTime).'] '.$urlQuery; |
385 | 385 | |
386 | - $theUrl = ($vv['subCfg']['baseUrl'] ? $vv['subCfg']['baseUrl'] : \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL')) . $urlQuery; |
|
386 | + $theUrl = ($vv['subCfg']['baseUrl'] ? $vv['subCfg']['baseUrl'] : \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL')).$urlQuery; |
|
387 | 387 | |
388 | 388 | // Submit for crawling! |
389 | - if ($submitCrawlUrls) { |
|
389 | + if ($submitCrawlUrls) { |
|
390 | 390 | $added = $this->addUrl( |
391 | 391 | $pageRow['uid'], |
392 | 392 | $theUrl, |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | if ($added === false) { |
399 | 399 | $urlList .= ' (Url already existed)'; |
400 | 400 | } |
401 | - } elseif ($downloadCrawlUrls) { |
|
401 | + } elseif ($downloadCrawlUrls) { |
|
402 | 402 | $downloadUrls[$theUrl] = $theUrl; |
403 | 403 | } |
404 | 404 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | return TRUE; |
428 | 428 | } |
429 | 429 | |
430 | - foreach($incomingProcInstructions as $pi) { |
|
430 | + foreach ($incomingProcInstructions as $pi) { |
|
431 | 431 | if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($piString, $pi)) { |
432 | 432 | return TRUE; |
433 | 433 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @return array |
441 | 441 | */ |
442 | 442 | public function getPageTSconfigForId($id) { |
443 | - if(!$this->MP){ |
|
443 | + if (!$this->MP) { |
|
444 | 444 | $pageTSconfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($id); |
445 | 445 | } else { |
446 | 446 | list(,$mountPointId) = explode('-', $this->MP); |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | * @param integer $id Page ID |
469 | 469 | * @return array Configurations from pages and configuration records |
470 | 470 | */ |
471 | - protected function getUrlsForPageId($id) { |
|
471 | + protected function getUrlsForPageId($id) { |
|
472 | 472 | |
473 | 473 | /** |
474 | 474 | * Get configuration from tsConfig |
@@ -479,24 +479,24 @@ discard block |
||
479 | 479 | |
480 | 480 | $res = array(); |
481 | 481 | |
482 | - if (is_array($pageTSconfig) && is_array($pageTSconfig['tx_crawler.']['crawlerCfg.'])) { |
|
482 | + if (is_array($pageTSconfig) && is_array($pageTSconfig['tx_crawler.']['crawlerCfg.'])) { |
|
483 | 483 | $crawlerCfg = $pageTSconfig['tx_crawler.']['crawlerCfg.']; |
484 | 484 | |
485 | - if (is_array($crawlerCfg['paramSets.'])) { |
|
486 | - foreach($crawlerCfg['paramSets.'] as $key => $values) { |
|
487 | - if (!is_array($values)) { |
|
485 | + if (is_array($crawlerCfg['paramSets.'])) { |
|
486 | + foreach ($crawlerCfg['paramSets.'] as $key => $values) { |
|
487 | + if (!is_array($values)) { |
|
488 | 488 | |
489 | 489 | // Sub configuration for a single configuration string: |
490 | - $subCfg = (array)$crawlerCfg['paramSets.'][$key.'.']; |
|
490 | + $subCfg = (array) $crawlerCfg['paramSets.'][$key.'.']; |
|
491 | 491 | $subCfg['key'] = $key; |
492 | 492 | |
493 | - if (strcmp($subCfg['procInstrFilter'],'')) { |
|
494 | - $subCfg['procInstrFilter'] = implode(',',\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',',$subCfg['procInstrFilter'])); |
|
493 | + if (strcmp($subCfg['procInstrFilter'], '')) { |
|
494 | + $subCfg['procInstrFilter'] = implode(',', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $subCfg['procInstrFilter'])); |
|
495 | 495 | } |
496 | - $pidOnlyList = implode(',',\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',',$subCfg['pidsOnly'],1)); |
|
496 | + $pidOnlyList = implode(',', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $subCfg['pidsOnly'], 1)); |
|
497 | 497 | |
498 | 498 | // process configuration if it is not page-specific or if the specific page is the current page: |
499 | - if (!strcmp($subCfg['pidsOnly'],'') || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($pidOnlyList,$id)) { |
|
499 | + if (!strcmp($subCfg['pidsOnly'], '') || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($pidOnlyList, $id)) { |
|
500 | 500 | |
501 | 501 | // add trailing slash if not present |
502 | 502 | if (!empty($subCfg['baseUrl']) && substr($subCfg['baseUrl'], -1) != '/') { |
@@ -507,14 +507,14 @@ discard block |
||
507 | 507 | $res[$key] = array(); |
508 | 508 | $res[$key]['subCfg'] = $subCfg; |
509 | 509 | $res[$key]['paramParsed'] = $this->parseParams($values); |
510 | - $res[$key]['paramExpanded'] = $this->expandParameters($res[$key]['paramParsed'],$id); |
|
510 | + $res[$key]['paramExpanded'] = $this->expandParameters($res[$key]['paramParsed'], $id); |
|
511 | 511 | $res[$key]['origin'] = 'pagets'; |
512 | 512 | |
513 | 513 | // recognize MP value |
514 | - if(!$this->MP){ |
|
515 | - $res[$key]['URLs'] = $this->compileUrls($res[$key]['paramExpanded'],array('?id='.$id)); |
|
514 | + if (!$this->MP) { |
|
515 | + $res[$key]['URLs'] = $this->compileUrls($res[$key]['paramExpanded'], array('?id='.$id)); |
|
516 | 516 | } else { |
517 | - $res[$key]['URLs'] = $this->compileUrls($res[$key]['paramExpanded'],array('?id='.$id.'&MP='.$this->MP)); |
|
517 | + $res[$key]['URLs'] = $this->compileUrls($res[$key]['paramExpanded'], array('?id='.$id.'&MP='.$this->MP)); |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | } |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | 'tx_crawler_configuration', |
536 | 536 | 'pid', |
537 | 537 | intval($page['uid']), |
538 | - \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_crawler_configuration') . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_crawler_configuration') |
|
538 | + \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_crawler_configuration').\TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_crawler_configuration') |
|
539 | 539 | ); |
540 | 540 | |
541 | 541 | if (is_array($configurationRecordsForCurrentPage)) { |
@@ -544,10 +544,10 @@ discard block |
||
544 | 544 | // check access to the configuration record |
545 | 545 | if (empty($configurationRecord['begroups']) || $GLOBALS['BE_USER']->isAdmin() || $this->hasGroupAccess($GLOBALS['BE_USER']->user['usergroup_cached_list'], $configurationRecord['begroups'])) { |
546 | 546 | |
547 | - $pidOnlyList = implode(',',\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',',$configurationRecord['pidsonly'],1)); |
|
547 | + $pidOnlyList = implode(',', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $configurationRecord['pidsonly'], 1)); |
|
548 | 548 | |
549 | 549 | // process configuration if it is not page-specific or if the specific page is the current page: |
550 | - if (!strcmp($configurationRecord['pidsonly'],'') || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($pidOnlyList,$id)) { |
|
550 | + if (!strcmp($configurationRecord['pidsonly'], '') || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($pidOnlyList, $id)) { |
|
551 | 551 | $key = $configurationRecord['name']; |
552 | 552 | |
553 | 553 | // don't overwrite previously defined paramSets |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | $res[$key]['subCfg'] = $subCfg; |
578 | 578 | $res[$key]['paramParsed'] = $this->parseParams($configurationRecord['configuration']); |
579 | 579 | $res[$key]['paramExpanded'] = $this->expandParameters($res[$key]['paramParsed'], $id); |
580 | - $res[$key]['URLs'] = $this->compileUrls($res[$key]['paramExpanded'], array('?id=' . $id)); |
|
580 | + $res[$key]['URLs'] = $this->compileUrls($res[$key]['paramExpanded'], array('?id='.$id)); |
|
581 | 581 | $res[$key]['origin'] = 'tx_crawler_configuration_'.$configurationRecord['uid']; |
582 | 582 | } |
583 | 583 | } |
@@ -587,8 +587,8 @@ discard block |
||
587 | 587 | } |
588 | 588 | } |
589 | 589 | |
590 | - if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['processUrls'])) { |
|
591 | - foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['processUrls'] as $func) { |
|
590 | + if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['processUrls'])) { |
|
591 | + foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['processUrls'] as $func) { |
|
592 | 592 | $params = array( |
593 | 593 | 'res' => &$res, |
594 | 594 | ); |
@@ -613,8 +613,8 @@ discard block |
||
613 | 613 | $res = $this->db->exec_SELECTquery( |
614 | 614 | '*', |
615 | 615 | 'sys_domain', |
616 | - 'uid = '.$sysDomainUid . |
|
617 | - \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('sys_domain') . |
|
616 | + 'uid = '.$sysDomainUid. |
|
617 | + \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('sys_domain'). |
|
618 | 618 | \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('sys_domain') |
619 | 619 | ); |
620 | 620 | $row = $this->db->sql_fetch_assoc($res); |
@@ -638,24 +638,24 @@ discard block |
||
638 | 638 | $pageTSconfig = $this->getPageTSconfigForId($rootId); |
639 | 639 | if (is_array($pageTSconfig) && is_array($pageTSconfig['tx_crawler.']['crawlerCfg.']) && is_array($pageTSconfig['tx_crawler.']['crawlerCfg.']['paramSets.'])) { |
640 | 640 | $sets = $pageTSconfig['tx_crawler.']['crawlerCfg.']['paramSets.']; |
641 | - if(is_array($sets)) { |
|
642 | - foreach($sets as $key=>$value) { |
|
643 | - if(!is_array($value)) continue; |
|
644 | - $configurationsForBranch[] = substr($key,-1)=='.'?substr($key,0,-1):$key; |
|
641 | + if (is_array($sets)) { |
|
642 | + foreach ($sets as $key=>$value) { |
|
643 | + if (!is_array($value)) continue; |
|
644 | + $configurationsForBranch[] = substr($key, -1) == '.' ? substr($key, 0, -1) : $key; |
|
645 | 645 | } |
646 | 646 | } |
647 | 647 | } |
648 | 648 | $pids = array(); |
649 | 649 | $rootLine = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($rootId); |
650 | - foreach($rootLine as $node) { |
|
650 | + foreach ($rootLine as $node) { |
|
651 | 651 | $pids[] = $node['uid']; |
652 | 652 | } |
653 | 653 | /* @var \TYPO3\CMS\Backend\Tree\View\PageTreeView */ |
654 | 654 | $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Backend\Tree\View\PageTreeView'); |
655 | 655 | $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); |
656 | - $tree->init('AND ' . $perms_clause); |
|
656 | + $tree->init('AND '.$perms_clause); |
|
657 | 657 | $tree->getTree($rootId, $depth, ''); |
658 | - foreach($tree->tree as $node) { |
|
658 | + foreach ($tree->tree as $node) { |
|
659 | 659 | $pids[] = $node['row']['uid']; |
660 | 660 | } |
661 | 661 | |
@@ -663,12 +663,12 @@ discard block |
||
663 | 663 | '*', |
664 | 664 | 'tx_crawler_configuration', |
665 | 665 | 'pid IN ('.implode(',', $pids).') '. |
666 | - \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_crawler_configuration') . |
|
666 | + \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_crawler_configuration'). |
|
667 | 667 | \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_crawler_configuration').' '. |
668 | 668 | \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('tx_crawler_configuration').' ' |
669 | 669 | ); |
670 | 670 | |
671 | - while($row = $this->db->sql_fetch_assoc($res)) { |
|
671 | + while ($row = $this->db->sql_fetch_assoc($res)) { |
|
672 | 672 | $configurationsForBranch[] = $row['name']; |
673 | 673 | } |
674 | 674 | $this->db->sql_free_result($res); |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | if (empty($accessList)) { |
691 | 691 | return true; |
692 | 692 | } |
693 | - foreach(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $groupList) as $groupUid) { |
|
693 | + foreach (\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $groupList) as $groupUid) { |
|
694 | 694 | if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($accessList, $groupUid)) { |
695 | 695 | return true; |
696 | 696 | } |
@@ -709,9 +709,9 @@ discard block |
||
709 | 709 | $paramKeyValues = array(); |
710 | 710 | $GETparams = explode('&', $inputQuery); |
711 | 711 | |
712 | - foreach($GETparams as $paramAndValue) { |
|
713 | - list($p,$v) = explode('=', $paramAndValue, 2); |
|
714 | - if (strlen($p)) { |
|
712 | + foreach ($GETparams as $paramAndValue) { |
|
713 | + list($p, $v) = explode('=', $paramAndValue, 2); |
|
714 | + if (strlen($p)) { |
|
715 | 715 | $paramKeyValues[rawurldecode($p)] = rawurldecode($v); |
716 | 716 | } |
717 | 717 | } |
@@ -734,84 +734,84 @@ discard block |
||
734 | 734 | * @param integer Current page ID |
735 | 735 | * @return array Array with key (GET var name) with the value being an array of all possible values for that key. |
736 | 736 | */ |
737 | - protected function expandParameters($paramArray, $pid) { |
|
737 | + protected function expandParameters($paramArray, $pid) { |
|
738 | 738 | global $TCA; |
739 | 739 | |
740 | 740 | // Traverse parameter names: |
741 | - foreach($paramArray as $p => $v) { |
|
741 | + foreach ($paramArray as $p => $v) { |
|
742 | 742 | $v = trim($v); |
743 | 743 | |
744 | 744 | // If value is encapsulated in square brackets it means there are some ranges of values to find, otherwise the value is literal |
745 | - if (substr($v,0,1)==='[' && substr($v,-1)===']') { |
|
745 | + if (substr($v, 0, 1) === '[' && substr($v, -1) === ']') { |
|
746 | 746 | // So, find the value inside brackets and reset the paramArray value as an array. |
747 | - $v = substr($v,1,-1); |
|
747 | + $v = substr($v, 1, -1); |
|
748 | 748 | $paramArray[$p] = array(); |
749 | 749 | |
750 | 750 | // Explode parts and traverse them: |
751 | - $parts = explode('|',$v); |
|
752 | - foreach($parts as $pV) { |
|
751 | + $parts = explode('|', $v); |
|
752 | + foreach ($parts as $pV) { |
|
753 | 753 | |
754 | 754 | // Look for integer range: (fx. 1-34 or -40--30 // reads minus 40 to minus 30) |
755 | - if (preg_match('/^(-?[0-9]+)\s*-\s*(-?[0-9]+)$/',trim($pV),$reg)) { // Integer range: |
|
755 | + if (preg_match('/^(-?[0-9]+)\s*-\s*(-?[0-9]+)$/', trim($pV), $reg)) { // Integer range: |
|
756 | 756 | |
757 | 757 | // Swap if first is larger than last: |
758 | - if ($reg[1] > $reg[2]) { |
|
758 | + if ($reg[1] > $reg[2]) { |
|
759 | 759 | $temp = $reg[2]; |
760 | 760 | $reg[2] = $reg[1]; |
761 | 761 | $reg[1] = $temp; |
762 | 762 | } |
763 | 763 | |
764 | 764 | // Traverse range, add values: |
765 | - $runAwayBrake = 1000; // Limit to size of range! |
|
766 | - for($a=$reg[1]; $a<=$reg[2];$a++) { |
|
765 | + $runAwayBrake = 1000; // Limit to size of range! |
|
766 | + for ($a = $reg[1]; $a <= $reg[2]; $a++) { |
|
767 | 767 | $paramArray[$p][] = $a; |
768 | 768 | $runAwayBrake--; |
769 | - if ($runAwayBrake<=0) { |
|
769 | + if ($runAwayBrake <= 0) { |
|
770 | 770 | break; |
771 | 771 | } |
772 | 772 | } |
773 | - } elseif (substr(trim($pV),0,7)=='_TABLE:') { |
|
773 | + } elseif (substr(trim($pV), 0, 7) == '_TABLE:') { |
|
774 | 774 | |
775 | 775 | // Parse parameters: |
776 | - $subparts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(';',$pV); |
|
776 | + $subparts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(';', $pV); |
|
777 | 777 | $subpartParams = array(); |
778 | - foreach($subparts as $spV) { |
|
779 | - list($pKey,$pVal) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':',$spV); |
|
778 | + foreach ($subparts as $spV) { |
|
779 | + list($pKey, $pVal) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':', $spV); |
|
780 | 780 | $subpartParams[$pKey] = $pVal; |
781 | 781 | } |
782 | 782 | |
783 | 783 | // Table exists: |
784 | - if (isset($TCA[$subpartParams['_TABLE']])) { |
|
784 | + if (isset($TCA[$subpartParams['_TABLE']])) { |
|
785 | 785 | $lookUpPid = isset($subpartParams['_PID']) ? intval($subpartParams['_PID']) : $pid; |
786 | 786 | $pidField = isset($subpartParams['_PIDFIELD']) ? trim($subpartParams['_PIDFIELD']) : 'pid'; |
787 | 787 | $where = isset($subpartParams['_WHERE']) ? $subpartParams['_WHERE'] : ''; |
788 | 788 | $addTable = isset($subpartParams['_ADDTABLE']) ? $subpartParams['_ADDTABLE'] : ''; |
789 | 789 | |
790 | 790 | $fieldName = $subpartParams['_FIELD'] ? $subpartParams['_FIELD'] : 'uid'; |
791 | - if ($fieldName==='uid' || $TCA[$subpartParams['_TABLE']]['columns'][$fieldName]) { |
|
791 | + if ($fieldName === 'uid' || $TCA[$subpartParams['_TABLE']]['columns'][$fieldName]) { |
|
792 | 792 | |
793 | 793 | $andWhereLanguage = ''; |
794 | 794 | $transOrigPointerField = $TCA[$subpartParams['_TABLE']]['ctrl']['transOrigPointerField']; |
795 | 795 | |
796 | 796 | if ($subpartParams['_ENABLELANG'] && $transOrigPointerField) { |
797 | - $andWhereLanguage = ' AND ' . $this->db->quoteStr($transOrigPointerField, $subpartParams['_TABLE']) .' <= 0 '; |
|
797 | + $andWhereLanguage = ' AND '.$this->db->quoteStr($transOrigPointerField, $subpartParams['_TABLE']).' <= 0 '; |
|
798 | 798 | } |
799 | 799 | |
800 | - $where = $this->db->quoteStr($pidField, $subpartParams['_TABLE']) .'='.intval($lookUpPid) . ' ' . |
|
801 | - $andWhereLanguage . $where; |
|
800 | + $where = $this->db->quoteStr($pidField, $subpartParams['_TABLE']).'='.intval($lookUpPid).' '. |
|
801 | + $andWhereLanguage.$where; |
|
802 | 802 | |
803 | 803 | $rows = $this->db->exec_SELECTgetRows( |
804 | 804 | $fieldName, |
805 | - $subpartParams['_TABLE'] . $addTable, |
|
806 | - $where . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($subpartParams['_TABLE']), |
|
805 | + $subpartParams['_TABLE'].$addTable, |
|
806 | + $where.\TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($subpartParams['_TABLE']), |
|
807 | 807 | '', |
808 | 808 | '', |
809 | 809 | '', |
810 | 810 | $fieldName |
811 | 811 | ); |
812 | 812 | |
813 | - if (is_array($rows)) { |
|
814 | - $paramArray[$p] = array_merge($paramArray[$p],array_keys($rows)); |
|
813 | + if (is_array($rows)) { |
|
814 | + $paramArray[$p] = array_merge($paramArray[$p], array_keys($rows)); |
|
815 | 815 | } |
816 | 816 | } |
817 | 817 | } |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | 'currentValue' => $pV, |
828 | 828 | 'pid' => $pid |
829 | 829 | ); |
830 | - foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['crawler/class.tx_crawler_lib.php']['expandParameters'] as $key => $_funcRef) { |
|
830 | + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['crawler/class.tx_crawler_lib.php']['expandParameters'] as $key => $_funcRef) { |
|
831 | 831 | \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $this); |
832 | 832 | } |
833 | 833 | } |
@@ -863,11 +863,11 @@ discard block |
||
863 | 863 | |
864 | 864 | // Traverse value set: |
865 | 865 | $newUrls = array(); |
866 | - foreach($urls as $url) { |
|
867 | - foreach($valueSet as $val) { |
|
868 | - $newUrls[] = $url.(strcmp($val,'') ? '&'.rawurlencode($varName).'='.rawurlencode($val) : ''); |
|
866 | + foreach ($urls as $url) { |
|
867 | + foreach ($valueSet as $val) { |
|
868 | + $newUrls[] = $url.(strcmp($val, '') ? '&'.rawurlencode($varName).'='.rawurlencode($val) : ''); |
|
869 | 869 | |
870 | - if (count($newUrls) > \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->extensionSettings['maxCompileUrls'], 1, 1000000000, 10000)) { |
|
870 | + if (count($newUrls) > \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->extensionSettings['maxCompileUrls'], 1, 1000000000, 10000)) { |
|
871 | 871 | break; |
872 | 872 | } |
873 | 873 | } |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | */ |
898 | 898 | public function getLogEntriesForPageId($id, $filter = '', $doFlush = FALSE, $doFullFlush = FALSE, $itemsPerPage = 10) { |
899 | 899 | // FIXME: Write Unit tests for Filters |
900 | - switch($filter) { |
|
900 | + switch ($filter) { |
|
901 | 901 | case 'pending': |
902 | 902 | $addWhere = ' AND exec_time=0'; |
903 | 903 | break; |
@@ -911,13 +911,13 @@ discard block |
||
911 | 911 | |
912 | 912 | // FIXME: Write unit test that ensures that the right records are deleted. |
913 | 913 | if ($doFlush) { |
914 | - $this->flushQueue( ($doFullFlush?'1=1':('page_id='.intval($id))) .$addWhere); |
|
914 | + $this->flushQueue(($doFullFlush ? '1=1' : ('page_id='.intval($id))).$addWhere); |
|
915 | 915 | return array(); |
916 | 916 | } else { |
917 | 917 | return $this->db->exec_SELECTgetRows('*', |
918 | 918 | 'tx_crawler_queue', |
919 | - 'page_id=' . intval($id) . $addWhere, '', 'scheduled DESC', |
|
920 | - (intval($itemsPerPage)>0 ? intval($itemsPerPage) : '')); |
|
919 | + 'page_id='.intval($id).$addWhere, '', 'scheduled DESC', |
|
920 | + (intval($itemsPerPage) > 0 ? intval($itemsPerPage) : '')); |
|
921 | 921 | } |
922 | 922 | } |
923 | 923 | |
@@ -930,9 +930,9 @@ discard block |
||
930 | 930 | * @param integer Limit the amount of entires per page default is 10 |
931 | 931 | * @return array |
932 | 932 | */ |
933 | - public function getLogEntriesForSetId($set_id,$filter='',$doFlush=FALSE, $doFullFlush=FALSE, $itemsPerPage=10) { |
|
933 | + public function getLogEntriesForSetId($set_id, $filter = '', $doFlush = FALSE, $doFullFlush = FALSE, $itemsPerPage = 10) { |
|
934 | 934 | // FIXME: Write Unit tests for Filters |
935 | - switch($filter) { |
|
935 | + switch ($filter) { |
|
936 | 936 | case 'pending': |
937 | 937 | $addWhere = ' AND exec_time=0'; |
938 | 938 | break; |
@@ -944,14 +944,14 @@ discard block |
||
944 | 944 | break; |
945 | 945 | } |
946 | 946 | // FIXME: Write unit test that ensures that the right records are deleted. |
947 | - if ($doFlush) { |
|
948 | - $this->flushQueue($doFullFlush?'':('set_id='.intval($set_id).$addWhere)); |
|
947 | + if ($doFlush) { |
|
948 | + $this->flushQueue($doFullFlush ? '' : ('set_id='.intval($set_id).$addWhere)); |
|
949 | 949 | return array(); |
950 | 950 | } else { |
951 | 951 | return $this->db->exec_SELECTgetRows('*', |
952 | 952 | 'tx_crawler_queue', |
953 | - 'set_id='.intval($set_id).$addWhere,'','scheduled DESC', |
|
954 | - (intval($itemsPerPage)>0 ? intval($itemsPerPage) : '')); |
|
953 | + 'set_id='.intval($set_id).$addWhere, '', 'scheduled DESC', |
|
954 | + (intval($itemsPerPage) > 0 ? intval($itemsPerPage) : '')); |
|
955 | 955 | } |
956 | 956 | } |
957 | 957 | |
@@ -961,14 +961,14 @@ discard block |
||
961 | 961 | * @param $where SQL related filter for the entries which should be removed |
962 | 962 | * @return void |
963 | 963 | */ |
964 | - protected function flushQueue($where='') { |
|
964 | + protected function flushQueue($where = '') { |
|
965 | 965 | |
966 | - $realWhere = strlen($where)>0?$where:'1=1'; |
|
966 | + $realWhere = strlen($where) > 0 ? $where : '1=1'; |
|
967 | 967 | |
968 | - if(tx_crawler_domain_events_dispatcher::getInstance()->hasObserver('queueEntryFlush')) { |
|
969 | - $groups = $this->db->exec_SELECTgetRows('DISTINCT set_id','tx_crawler_queue',$realWhere); |
|
970 | - foreach($groups as $group) { |
|
971 | - tx_crawler_domain_events_dispatcher::getInstance()->post('queueEntryFlush',$group['set_id'], $this->db->exec_SELECTgetRows('uid, set_id','tx_crawler_queue',$realWhere.' AND set_id="'.$group['set_id'].'"')); |
|
968 | + if (tx_crawler_domain_events_dispatcher::getInstance()->hasObserver('queueEntryFlush')) { |
|
969 | + $groups = $this->db->exec_SELECTgetRows('DISTINCT set_id', 'tx_crawler_queue', $realWhere); |
|
970 | + foreach ($groups as $group) { |
|
971 | + tx_crawler_domain_events_dispatcher::getInstance()->post('queueEntryFlush', $group['set_id'], $this->db->exec_SELECTgetRows('uid, set_id', 'tx_crawler_queue', $realWhere.' AND set_id="'.$group['set_id'].'"')); |
|
972 | 972 | } |
973 | 973 | } |
974 | 974 | |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | * @param integer Time at which to activate |
986 | 986 | * @return void |
987 | 987 | */ |
988 | - public function addQueueEntry_callBack($setId,$params,$callBack,$page_id=0,$schedule=0) { |
|
988 | + public function addQueueEntry_callBack($setId, $params, $callBack, $page_id = 0, $schedule = 0) { |
|
989 | 989 | |
990 | 990 | if (!is_array($params)) $params = array(); |
991 | 991 | $params['_CALLBACKOBJ'] = $callBack; |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | 'result_data' => '', |
1001 | 1001 | ); |
1002 | 1002 | |
1003 | - $this->db->exec_INSERTquery('tx_crawler_queue',$fieldArray); |
|
1003 | + $this->db->exec_INSERTquery('tx_crawler_queue', $fieldArray); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | /************************************ |
@@ -1020,13 +1020,13 @@ discard block |
||
1020 | 1020 | * @param bool (optional) skip inner duplication check |
1021 | 1021 | * @return bool true if the url was added, false if it already existed |
1022 | 1022 | */ |
1023 | - protected function addUrl ( |
|
1023 | + protected function addUrl( |
|
1024 | 1024 | $id, |
1025 | 1025 | $url, |
1026 | 1026 | array $subCfg, |
1027 | 1027 | $tstamp, |
1028 | - $configurationHash='', |
|
1029 | - $skipInnerDuplicationCheck=false |
|
1028 | + $configurationHash = '', |
|
1029 | + $skipInnerDuplicationCheck = false |
|
1030 | 1030 | ) { |
1031 | 1031 | |
1032 | 1032 | $urlAdded = false; |
@@ -1037,14 +1037,14 @@ discard block |
||
1037 | 1037 | ); |
1038 | 1038 | |
1039 | 1039 | // fe user group simulation: |
1040 | - $uGs = implode(',',array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',',$subCfg['userGroups'],1))); |
|
1041 | - if ($uGs) { |
|
1040 | + $uGs = implode(',', array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $subCfg['userGroups'], 1))); |
|
1041 | + if ($uGs) { |
|
1042 | 1042 | $parameters['feUserGroupList'] = $uGs; |
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | // Setting processing instructions |
1046 | - $parameters['procInstructions'] = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',',$subCfg['procInstrFilter']); |
|
1047 | - if (is_array($subCfg['procInstrParams.'])) { |
|
1046 | + $parameters['procInstructions'] = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $subCfg['procInstrFilter']); |
|
1047 | + if (is_array($subCfg['procInstrParams.'])) { |
|
1048 | 1048 | $parameters['procInstrParams'] = $subCfg['procInstrParams.']; |
1049 | 1049 | } |
1050 | 1050 | |
@@ -1063,14 +1063,14 @@ discard block |
||
1063 | 1063 | 'configuration' => $subCfg['key'], |
1064 | 1064 | ); |
1065 | 1065 | |
1066 | - if ($this->registerQueueEntriesInternallyOnly) { |
|
1066 | + if ($this->registerQueueEntriesInternallyOnly) { |
|
1067 | 1067 | //the entries will only be registered and not stored to the database |
1068 | 1068 | $this->queueEntries[] = $fieldArray; |
1069 | 1069 | } else { |
1070 | 1070 | |
1071 | - if(!$skipInnerDuplicationCheck){ |
|
1071 | + if (!$skipInnerDuplicationCheck) { |
|
1072 | 1072 | // check if there is already an equal entry |
1073 | - $rows = $this->getDuplicateRowsIfExist($tstamp,$fieldArray); |
|
1073 | + $rows = $this->getDuplicateRowsIfExist($tstamp, $fieldArray); |
|
1074 | 1074 | } |
1075 | 1075 | |
1076 | 1076 | if (count($rows) == 0) { |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | $uid = $this->db->sql_insert_id(); |
1079 | 1079 | $rows[] = $uid; |
1080 | 1080 | $urlAdded = true; |
1081 | - tx_crawler_domain_events_dispatcher::getInstance()->post('urlAddedToQueue',$this->setID,array('uid' => $uid, 'fieldArray' => $fieldArray)); |
|
1082 | - }else{ |
|
1083 | - tx_crawler_domain_events_dispatcher::getInstance()->post('duplicateUrlInQueue',$this->setID,array('rows' => $rows, 'fieldArray' => $fieldArray)); |
|
1081 | + tx_crawler_domain_events_dispatcher::getInstance()->post('urlAddedToQueue', $this->setID, array('uid' => $uid, 'fieldArray' => $fieldArray)); |
|
1082 | + } else { |
|
1083 | + tx_crawler_domain_events_dispatcher::getInstance()->post('duplicateUrlInQueue', $this->setID, array('rows' => $rows, 'fieldArray' => $fieldArray)); |
|
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | |
@@ -1097,34 +1097,34 @@ discard block |
||
1097 | 1097 | * |
1098 | 1098 | * @return array; |
1099 | 1099 | */ |
1100 | - protected function getDuplicateRowsIfExist($tstamp,$fieldArray){ |
|
1100 | + protected function getDuplicateRowsIfExist($tstamp, $fieldArray) { |
|
1101 | 1101 | $rows = array(); |
1102 | 1102 | |
1103 | 1103 | $currentTime = $this->getCurrentTime(); |
1104 | 1104 | |
1105 | 1105 | //if this entry is scheduled with "now" |
1106 | 1106 | if ($tstamp <= $currentTime) { |
1107 | - if($this->extensionSettings['enableTimeslot']){ |
|
1107 | + if ($this->extensionSettings['enableTimeslot']) { |
|
1108 | 1108 | $timeBegin = $currentTime - 100; |
1109 | - $timeEnd = $currentTime + 100; |
|
1110 | - $where = ' ((scheduled BETWEEN '.$timeBegin.' AND '.$timeEnd.' ) OR scheduled <= '. $currentTime.') '; |
|
1111 | - }else{ |
|
1112 | - $where = 'scheduled <= ' . $currentTime; |
|
1109 | + $timeEnd = $currentTime + 100; |
|
1110 | + $where = ' ((scheduled BETWEEN '.$timeBegin.' AND '.$timeEnd.' ) OR scheduled <= '.$currentTime.') '; |
|
1111 | + } else { |
|
1112 | + $where = 'scheduled <= '.$currentTime; |
|
1113 | 1113 | } |
1114 | 1114 | } elseif ($tstamp > $currentTime) { |
1115 | 1115 | //entry with a timestamp in the future need to have the same schedule time |
1116 | - $where = 'scheduled = ' . $tstamp ; |
|
1116 | + $where = 'scheduled = '.$tstamp; |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | - if(!empty($where)){ |
|
1119 | + if (!empty($where)) { |
|
1120 | 1120 | $result = $this->db->exec_SELECTgetRows( |
1121 | 1121 | 'qid', |
1122 | 1122 | 'tx_crawler_queue', |
1123 | 1123 | $where. |
1124 | - ' AND NOT exec_time' . |
|
1124 | + ' AND NOT exec_time'. |
|
1125 | 1125 | ' AND NOT process_id '. |
1126 | 1126 | ' AND page_id='.intval($fieldArray['page_id']). |
1127 | - ' AND parameters_hash = ' . $this->db->fullQuoteStr($fieldArray['parameters_hash'], 'tx_crawler_queue') |
|
1127 | + ' AND parameters_hash = '.$this->db->fullQuoteStr($fieldArray['parameters_hash'], 'tx_crawler_queue') |
|
1128 | 1128 | ); |
1129 | 1129 | |
1130 | 1130 | if (is_array($result)) { |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | * |
1146 | 1146 | * @codeCoverageIgnore |
1147 | 1147 | */ |
1148 | - public function getCurrentTime(){ |
|
1148 | + public function getCurrentTime() { |
|
1149 | 1149 | return time(); |
1150 | 1150 | } |
1151 | 1151 | |
@@ -1166,18 +1166,18 @@ discard block |
||
1166 | 1166 | public function readUrl($queueId, $force = FALSE) { |
1167 | 1167 | $ret = 0; |
1168 | 1168 | if ($this->debugMode) { |
1169 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devlog('crawler-readurl start ' . microtime(true), __FUNCTION__); |
|
1169 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devlog('crawler-readurl start '.microtime(true), __FUNCTION__); |
|
1170 | 1170 | } |
1171 | 1171 | // Get entry: |
1172 | 1172 | list($queueRec) = $this->db->exec_SELECTgetRows('*', 'tx_crawler_queue', |
1173 | - 'qid=' . intval($queueId) . ($force ? '' : ' AND exec_time=0 AND process_scheduled > 0')); |
|
1173 | + 'qid='.intval($queueId).($force ? '' : ' AND exec_time=0 AND process_scheduled > 0')); |
|
1174 | 1174 | |
1175 | 1175 | if (!is_array($queueRec)) { |
1176 | 1176 | return; |
1177 | 1177 | } |
1178 | 1178 | |
1179 | - $pageUidRootTypoScript = \AOE\Crawler\Utility\TypoScriptUtility::getPageUidForTypoScriptRootTemplateInRootLine((int)$queueRec['page_id']); |
|
1180 | - $this->initTSFE((int)$pageUidRootTypoScript); |
|
1179 | + $pageUidRootTypoScript = \AOE\Crawler\Utility\TypoScriptUtility::getPageUidForTypoScriptRootTemplateInRootLine((int) $queueRec['page_id']); |
|
1180 | + $this->initTSFE((int) $pageUidRootTypoScript); |
|
1181 | 1181 | |
1182 | 1182 | \AOE\Crawler\Utility\SignalSlotUtility::emitSignal( |
1183 | 1183 | __CLASS__, |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | //if mulitprocessing is used we need to store the id of the process which has handled this entry |
1193 | 1193 | $field_array['process_id_completed'] = $this->processID; |
1194 | 1194 | } |
1195 | - $this->db->exec_UPDATEquery('tx_crawler_queue', 'qid=' . intval($queueId), $field_array); |
|
1195 | + $this->db->exec_UPDATEquery('tx_crawler_queue', 'qid='.intval($queueId), $field_array); |
|
1196 | 1196 | |
1197 | 1197 | $result = $this->readUrl_exec($queueRec); |
1198 | 1198 | $resultData = unserialize($result['content']); |
@@ -1221,11 +1221,11 @@ discard block |
||
1221 | 1221 | array($queueId, &$field_array) |
1222 | 1222 | ); |
1223 | 1223 | |
1224 | - $this->db->exec_UPDATEquery('tx_crawler_queue', 'qid=' . intval($queueId), $field_array); |
|
1224 | + $this->db->exec_UPDATEquery('tx_crawler_queue', 'qid='.intval($queueId), $field_array); |
|
1225 | 1225 | |
1226 | 1226 | |
1227 | 1227 | if ($this->debugMode) { |
1228 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devlog('crawler-readurl stop ' . microtime(true), __FUNCTION__); |
|
1228 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devlog('crawler-readurl stop '.microtime(true), __FUNCTION__); |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | return $ret; |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | * |
1239 | 1239 | * @return string |
1240 | 1240 | */ |
1241 | - protected function readUrlFromArray($field_array) { |
|
1241 | + protected function readUrlFromArray($field_array) { |
|
1242 | 1242 | |
1243 | 1243 | // Set exec_time to lock record: |
1244 | 1244 | $field_array['exec_time'] = $this->getCurrentTime(); |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | // Set result in log which also denotes the end of the processing of this entry. |
1251 | 1251 | $field_array = array('result_data' => serialize($result)); |
1252 | - $this->db->exec_UPDATEquery('tx_crawler_queue','qid='.intval($queueId), $field_array); |
|
1252 | + $this->db->exec_UPDATEquery('tx_crawler_queue', 'qid='.intval($queueId), $field_array); |
|
1253 | 1253 | |
1254 | 1254 | return $result; |
1255 | 1255 | } |
@@ -1260,17 +1260,17 @@ discard block |
||
1260 | 1260 | * @param array $queueRec Queue record |
1261 | 1261 | * @return string Result output. |
1262 | 1262 | */ |
1263 | - protected function readUrl_exec($queueRec) { |
|
1263 | + protected function readUrl_exec($queueRec) { |
|
1264 | 1264 | // Decode parameters: |
1265 | 1265 | $parameters = unserialize($queueRec['parameters']); |
1266 | 1266 | $result = 'ERROR'; |
1267 | - if (is_array($parameters)) { |
|
1268 | - if ($parameters['_CALLBACKOBJ']) { // Calling object: |
|
1267 | + if (is_array($parameters)) { |
|
1268 | + if ($parameters['_CALLBACKOBJ']) { // Calling object: |
|
1269 | 1269 | $objRef = $parameters['_CALLBACKOBJ']; |
1270 | 1270 | $callBackObj = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($objRef); |
1271 | - if (is_object($callBackObj)) { |
|
1271 | + if (is_object($callBackObj)) { |
|
1272 | 1272 | unset($parameters['_CALLBACKOBJ']); |
1273 | - $result = array('content' => serialize($callBackObj->crawler_execute($parameters,$this))); |
|
1273 | + $result = array('content' => serialize($callBackObj->crawler_execute($parameters, $this))); |
|
1274 | 1274 | } else { |
1275 | 1275 | $result = array('content' => 'No object: '.$objRef); |
1276 | 1276 | } |
@@ -1280,9 +1280,9 @@ discard block |
||
1280 | 1280 | $crawlerId = $queueRec['qid'].':'.md5($queueRec['qid'].'|'.$queueRec['set_id'].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']); |
1281 | 1281 | |
1282 | 1282 | // Get result: |
1283 | - $result = $this->requestUrl($parameters['url'],$crawlerId); |
|
1283 | + $result = $this->requestUrl($parameters['url'], $crawlerId); |
|
1284 | 1284 | |
1285 | - tx_crawler_domain_events_dispatcher::getInstance()->post('urlCrawled',$queueRec['set_id'],array('url' => $parameters['url'], 'result' => $result)); |
|
1285 | + tx_crawler_domain_events_dispatcher::getInstance()->post('urlCrawled', $queueRec['set_id'], array('url' => $parameters['url'], 'result' => $result)); |
|
1286 | 1286 | } |
1287 | 1287 | } |
1288 | 1288 | |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | * @param integer $recursion Recursion limiter for 302 redirects |
1300 | 1300 | * @return array Array with content |
1301 | 1301 | */ |
1302 | - public function requestUrl($originalUrl, $crawlerId, $timeout=2, $recursion=10) { |
|
1302 | + public function requestUrl($originalUrl, $crawlerId, $timeout = 2, $recursion = 10) { |
|
1303 | 1303 | |
1304 | 1304 | if (!$recursion) return false; |
1305 | 1305 | |
@@ -1311,7 +1311,7 @@ discard block |
||
1311 | 1311 | return FALSE; |
1312 | 1312 | } |
1313 | 1313 | |
1314 | - if (!in_array($url['scheme'], array('','http','https'))) { |
|
1314 | + if (!in_array($url['scheme'], array('', 'http', 'https'))) { |
|
1315 | 1315 | if (TYPO3_DLOG) \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(sprintf('Scheme does not match for url "%s"', $url), 'crawler', 4, array('crawlerId' => $crawlerId)); |
1316 | 1316 | return FALSE; |
1317 | 1317 | } |
@@ -1329,14 +1329,14 @@ discard block |
||
1329 | 1329 | |
1330 | 1330 | if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] && $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']) { |
1331 | 1331 | $rurl = parse_url($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']); |
1332 | - $url['path'] = $url['scheme'] . '://' . $url['host'] . ($url['port'] > 0 ? ':' . $url['port'] : '') . $url['path']; |
|
1332 | + $url['path'] = $url['scheme'].'://'.$url['host'].($url['port'] > 0 ? ':'.$url['port'] : '').$url['path']; |
|
1333 | 1333 | $reqHeaders = $this->buildRequestHeaderArray($url, $crawlerId); |
1334 | 1334 | } |
1335 | 1335 | |
1336 | 1336 | $host = $rurl['host']; |
1337 | 1337 | |
1338 | 1338 | if ($url['scheme'] == 'https') { |
1339 | - $host = 'ssl://' . $host; |
|
1339 | + $host = 'ssl://'.$host; |
|
1340 | 1340 | $port = ($rurl['port'] > 0) ? $rurl['port'] : 443; |
1341 | 1341 | } else { |
1342 | 1342 | $port = ($rurl['port'] > 0) ? $rurl['port'] : 80; |
@@ -1350,24 +1350,24 @@ discard block |
||
1350 | 1350 | return FALSE; |
1351 | 1351 | } else { |
1352 | 1352 | // Request message: |
1353 | - $msg = implode("\r\n",$reqHeaders)."\r\n\r\n"; |
|
1354 | - fputs ($fp, $msg); |
|
1353 | + $msg = implode("\r\n", $reqHeaders)."\r\n\r\n"; |
|
1354 | + fputs($fp, $msg); |
|
1355 | 1355 | |
1356 | 1356 | // Read response: |
1357 | 1357 | $d = $this->getHttpResponseFromStream($fp); |
1358 | - fclose ($fp); |
|
1358 | + fclose($fp); |
|
1359 | 1359 | |
1360 | 1360 | $time = microtime(true) - $startTime; |
1361 | - $this->log($originalUrl .' '.$time); |
|
1361 | + $this->log($originalUrl.' '.$time); |
|
1362 | 1362 | |
1363 | 1363 | // Implode content and headers: |
1364 | 1364 | $result = array( |
1365 | 1365 | 'request' => $msg, |
1366 | 1366 | 'headers' => implode('', $d['headers']), |
1367 | - 'content' => implode('', (array)$d['content']) |
|
1367 | + 'content' => implode('', (array) $d['content']) |
|
1368 | 1368 | ); |
1369 | 1369 | |
1370 | - if (($this->extensionSettings['follow30x']) && ($newUrl = $this->getRequestUrlFrom302Header($d['headers'],$url['user'],$url['pass']))) { |
|
1370 | + if (($this->extensionSettings['follow30x']) && ($newUrl = $this->getRequestUrlFrom302Header($d['headers'], $url['user'], $url['pass']))) { |
|
1371 | 1371 | $result = array_merge(array('parentRequest'=>$result), $this->requestUrl($newUrl, $crawlerId, $recursion--)); |
1372 | 1372 | $newRequestUrl = $this->requestUrl($newUrl, $crawlerId, $timeout, --$recursion); |
1373 | 1373 | |
@@ -1406,8 +1406,8 @@ discard block |
||
1406 | 1406 | |
1407 | 1407 | // Base path must be '/<pathSegements>/': |
1408 | 1408 | if ($frontendBasePath != '/') { |
1409 | - $frontendBasePath = '/' . ltrim($frontendBasePath, '/'); |
|
1410 | - $frontendBasePath = rtrim($frontendBasePath, '/') . '/'; |
|
1409 | + $frontendBasePath = '/'.ltrim($frontendBasePath, '/'); |
|
1410 | + $frontendBasePath = rtrim($frontendBasePath, '/').'/'; |
|
1411 | 1411 | } |
1412 | 1412 | |
1413 | 1413 | return $frontendBasePath; |
@@ -1440,7 +1440,7 @@ discard block |
||
1440 | 1440 | |
1441 | 1441 | if (is_resource($streamPointer)) { |
1442 | 1442 | // read headers |
1443 | - while($line = fgets($streamPointer, '2048')) { |
|
1443 | + while ($line = fgets($streamPointer, '2048')) { |
|
1444 | 1444 | $line = trim($line); |
1445 | 1445 | if ($line !== '') { |
1446 | 1446 | $response['headers'][] = $line; |
@@ -1450,7 +1450,7 @@ discard block |
||
1450 | 1450 | } |
1451 | 1451 | |
1452 | 1452 | // read content |
1453 | - while($line = fgets($streamPointer, '2048')) { |
|
1453 | + while ($line = fgets($streamPointer, '2048')) { |
|
1454 | 1454 | $response['content'][] = $line; |
1455 | 1455 | } |
1456 | 1456 | } |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | */ |
1464 | 1464 | protected function log($message) { |
1465 | 1465 | if (!empty($this->extensionSettings['logFileName'])) { |
1466 | - @file_put_contents($this->extensionSettings['logFileName'], date('Ymd His') . $message . "\n", FILE_APPEND); |
|
1466 | + @file_put_contents($this->extensionSettings['logFileName'], date('Ymd His').$message."\n", FILE_APPEND); |
|
1467 | 1467 | } |
1468 | 1468 | } |
1469 | 1469 | |
@@ -1479,12 +1479,12 @@ discard block |
||
1479 | 1479 | $reqHeaders = array(); |
1480 | 1480 | $reqHeaders[] = 'GET '.$url['path'].($url['query'] ? '?'.$url['query'] : '').' HTTP/1.0'; |
1481 | 1481 | $reqHeaders[] = 'Host: '.$url['host']; |
1482 | - if (stristr($url['query'],'ADMCMD_previewWS')) { |
|
1482 | + if (stristr($url['query'], 'ADMCMD_previewWS')) { |
|
1483 | 1483 | $reqHeaders[] = 'Cookie: $Version="1"; be_typo_user="1"; $Path=/'; |
1484 | 1484 | } |
1485 | 1485 | $reqHeaders[] = 'Connection: close'; |
1486 | - if ($url['user']!='') { |
|
1487 | - $reqHeaders[] = 'Authorization: Basic '. base64_encode($url['user'].':'.$url['pass']); |
|
1486 | + if ($url['user'] != '') { |
|
1487 | + $reqHeaders[] = 'Authorization: Basic '.base64_encode($url['user'].':'.$url['pass']); |
|
1488 | 1488 | } |
1489 | 1489 | $reqHeaders[] = 'X-T3crawler: '.$crawlerId; |
1490 | 1490 | $reqHeaders[] = 'User-Agent: TYPO3 crawler'; |
@@ -1499,21 +1499,21 @@ discard block |
||
1499 | 1499 | * @param string HTTP Auth. Password |
1500 | 1500 | * @return string URL from redirection |
1501 | 1501 | */ |
1502 | - 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; |
|
1502 | + 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; |
|
1505 | 1505 | |
1506 | - foreach($headers as $hl) { |
|
1507 | - $tmp = explode(": ",$hl); |
|
1506 | + foreach ($headers as $hl) { |
|
1507 | + $tmp = explode(": ", $hl); |
|
1508 | 1508 | $header[trim($tmp[0])] = trim($tmp[1]); |
1509 | - if(trim($tmp[0])=='Location') break; |
|
1509 | + if (trim($tmp[0]) == 'Location') break; |
|
1510 | 1510 | } |
1511 | - if(!array_key_exists('Location',$header)) return false; |
|
1511 | + if (!array_key_exists('Location', $header)) return false; |
|
1512 | 1512 | |
1513 | - if($user!='') { |
|
1514 | - if(!($tmp = parse_url($header['Location']))) return false; |
|
1515 | - $newUrl = $tmp['scheme'] . '://' . $user . ':' . $pass . '@' . $tmp['host'] . $tmp['path']; |
|
1516 | - if($tmp['query']!='') $newUrl .= '?' . $tmp['query']; |
|
1513 | + if ($user != '') { |
|
1514 | + if (!($tmp = parse_url($header['Location']))) return false; |
|
1515 | + $newUrl = $tmp['scheme'].'://'.$user.':'.$pass.'@'.$tmp['host'].$tmp['path']; |
|
1516 | + if ($tmp['query'] != '') $newUrl .= '?'.$tmp['query']; |
|
1517 | 1517 | } else { |
1518 | 1518 | $newUrl = $header['Location']; |
1519 | 1519 | } |
@@ -1534,15 +1534,15 @@ discard block |
||
1534 | 1534 | * @param object TSFE object (reference under PHP5) |
1535 | 1535 | * @return void |
1536 | 1536 | */ |
1537 | - function fe_init(&$params, $ref) { |
|
1537 | + function fe_init(&$params, $ref) { |
|
1538 | 1538 | |
1539 | 1539 | // Authenticate crawler request: |
1540 | - if (isset($_SERVER['HTTP_X_T3CRAWLER'])) { |
|
1541 | - list($queueId,$hash) = explode(':', $_SERVER['HTTP_X_T3CRAWLER']); |
|
1542 | - list($queueRec) = $this->db->exec_SELECTgetRows('*','tx_crawler_queue','qid='.intval($queueId)); |
|
1540 | + if (isset($_SERVER['HTTP_X_T3CRAWLER'])) { |
|
1541 | + list($queueId, $hash) = explode(':', $_SERVER['HTTP_X_T3CRAWLER']); |
|
1542 | + list($queueRec) = $this->db->exec_SELECTgetRows('*', 'tx_crawler_queue', 'qid='.intval($queueId)); |
|
1543 | 1543 | |
1544 | 1544 | // If a crawler record was found and hash was matching, set it up: |
1545 | - if (is_array($queueRec) && $hash === md5($queueRec['qid'].'|'.$queueRec['set_id'].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
|
1545 | + if (is_array($queueRec) && $hash === md5($queueRec['qid'].'|'.$queueRec['set_id'].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
|
1546 | 1546 | $params['pObj']->applicationData['tx_crawler']['running'] = TRUE; |
1547 | 1547 | $params['pObj']->applicationData['tx_crawler']['parameters'] = unserialize($queueRec['parameters']); |
1548 | 1548 | $params['pObj']->applicationData['tx_crawler']['log'] = array(); |
@@ -1600,7 +1600,7 @@ discard block |
||
1600 | 1600 | /* @var $tree \TYPO3\CMS\Backend\Tree\View\PageTreeView */ |
1601 | 1601 | $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Backend\Tree\View\PageTreeView'); |
1602 | 1602 | $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); |
1603 | - $tree->init('AND ' . $perms_clause); |
|
1603 | + $tree->init('AND '.$perms_clause); |
|
1604 | 1604 | |
1605 | 1605 | $pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($id, $perms_clause); |
1606 | 1606 | |
@@ -1611,7 +1611,7 @@ discard block |
||
1611 | 1611 | ); |
1612 | 1612 | |
1613 | 1613 | // Get branch beneath: |
1614 | - if ($depth) { |
|
1614 | + if ($depth) { |
|
1615 | 1615 | $tree->getTree($id, $depth, ''); |
1616 | 1616 | } |
1617 | 1617 | |
@@ -1623,7 +1623,7 @@ discard block |
||
1623 | 1623 | $this->MP = false; |
1624 | 1624 | |
1625 | 1625 | // recognize mount points |
1626 | - if($data['row']['doktype'] == 7){ |
|
1626 | + if ($data['row']['doktype'] == 7) { |
|
1627 | 1627 | $mountpage = $this->db->exec_SELECTgetRows('*', 'pages', 'uid = '.$data['row']['uid']); |
1628 | 1628 | |
1629 | 1629 | // fetch mounted pages |
@@ -1633,15 +1633,15 @@ discard block |
||
1633 | 1633 | $mountTree->init('AND '.$perms_clause); |
1634 | 1634 | $mountTree->getTree($mountpage[0]['mount_pid'], $depth, ''); |
1635 | 1635 | |
1636 | - foreach($mountTree->tree as $mountData) { |
|
1636 | + foreach ($mountTree->tree as $mountData) { |
|
1637 | 1637 | $code .= $this->drawURLs_addRowsForPage( |
1638 | 1638 | $mountData['row'], |
1639 | - $mountData['HTML'].\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages',$mountData['row'],TRUE) |
|
1639 | + $mountData['HTML'].\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages', $mountData['row'], TRUE) |
|
1640 | 1640 | ); |
1641 | 1641 | } |
1642 | 1642 | |
1643 | 1643 | // replace page when mount_pid_ol is enabled |
1644 | - if($mountpage[0]['mount_pid_ol']){ |
|
1644 | + if ($mountpage[0]['mount_pid_ol']) { |
|
1645 | 1645 | $data['row']['uid'] = $mountpage[0]['mount_pid']; |
1646 | 1646 | } else { |
1647 | 1647 | // if the mount_pid_ol is not set the MP must not be used for the mountpoint page |
@@ -1651,7 +1651,7 @@ discard block |
||
1651 | 1651 | |
1652 | 1652 | $code .= $this->drawURLs_addRowsForPage( |
1653 | 1653 | $data['row'], |
1654 | - $data['HTML'] . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages', $data['row'], TRUE) |
|
1654 | + $data['HTML'].\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages', $data['row'], TRUE) |
|
1655 | 1655 | ); |
1656 | 1656 | } |
1657 | 1657 | |
@@ -1675,7 +1675,7 @@ discard block |
||
1675 | 1675 | if (!empty($excludeString)) { |
1676 | 1676 | /* @var $tree \TYPO3\CMS\Backend\Tree\View\PageTreeView */ |
1677 | 1677 | $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Backend\Tree\View\PageTreeView'); |
1678 | - $tree->init('AND ' . $this->backendUser->getPagePermsClause(1)); |
|
1678 | + $tree->init('AND '.$this->backendUser->getPagePermsClause(1)); |
|
1679 | 1679 | |
1680 | 1680 | $excludeParts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $excludeString); |
1681 | 1681 | |
@@ -1684,7 +1684,7 @@ discard block |
||
1684 | 1684 | |
1685 | 1685 | // default is "page only" = "depth=0" |
1686 | 1686 | if (empty($depth)) { |
1687 | - $depth = ( stristr($excludePart,'+')) ? 99 : 0; |
|
1687 | + $depth = (stristr($excludePart, '+')) ? 99 : 0; |
|
1688 | 1688 | } |
1689 | 1689 | |
1690 | 1690 | $pidList[] = $pid; |
@@ -1717,7 +1717,7 @@ discard block |
||
1717 | 1717 | * @param string Page icon and title for row |
1718 | 1718 | * @return string HTML <tr> content (one or more) |
1719 | 1719 | */ |
1720 | - public function drawURLs_addRowsForPage(array $pageRow, $pageTitleAndIcon) { |
|
1720 | + public function drawURLs_addRowsForPage(array $pageRow, $pageTitleAndIcon) { |
|
1721 | 1721 | |
1722 | 1722 | $skipMessage = ''; |
1723 | 1723 | |
@@ -1738,7 +1738,7 @@ discard block |
||
1738 | 1738 | $cc = 0; |
1739 | 1739 | $content = ''; |
1740 | 1740 | if (count($configurations)) { |
1741 | - foreach($configurations as $confKey => $confArray) { |
|
1741 | + foreach ($configurations as $confKey => $confArray) { |
|
1742 | 1742 | |
1743 | 1743 | // Title column: |
1744 | 1744 | if (!$c) { |
@@ -1767,47 +1767,47 @@ discard block |
||
1767 | 1767 | $paramExpanded = ''; |
1768 | 1768 | $calcAccu = array(); |
1769 | 1769 | $calcRes = 1; |
1770 | - foreach($confArray['paramExpanded'] as $gVar => $gVal) { |
|
1771 | - $paramExpanded.= ' |
|
1770 | + foreach ($confArray['paramExpanded'] as $gVar => $gVal) { |
|
1771 | + $paramExpanded .= ' |
|
1772 | 1772 | <tr> |
1773 | 1773 | <td class="bgColor4-20">'.htmlspecialchars('&'.$gVar.'=').'<br/>'. |
1774 | 1774 | '('.count($gVal).')'. |
1775 | 1775 | '</td> |
1776 | - <td class="bgColor4" nowrap="nowrap">'.nl2br(htmlspecialchars(implode(chr(10),$gVal))).'</td> |
|
1776 | + <td class="bgColor4" nowrap="nowrap">'.nl2br(htmlspecialchars(implode(chr(10), $gVal))).'</td> |
|
1777 | 1777 | </tr> |
1778 | 1778 | '; |
1779 | - $calcRes*= count($gVal); |
|
1779 | + $calcRes *= count($gVal); |
|
1780 | 1780 | $calcAccu[] = count($gVal); |
1781 | 1781 | } |
1782 | 1782 | $paramExpanded = '<table class="lrPadding c-list param-expanded">'.$paramExpanded.'</table>'; |
1783 | - $paramExpanded.= 'Comb: '.implode('*',$calcAccu).'='.$calcRes; |
|
1783 | + $paramExpanded .= 'Comb: '.implode('*', $calcAccu).'='.$calcRes; |
|
1784 | 1784 | |
1785 | 1785 | // Options |
1786 | 1786 | $optionValues = ''; |
1787 | - if ($confArray['subCfg']['userGroups']) { |
|
1788 | - $optionValues.='User Groups: '.$confArray['subCfg']['userGroups'].'<br/>'; |
|
1787 | + if ($confArray['subCfg']['userGroups']) { |
|
1788 | + $optionValues .= 'User Groups: '.$confArray['subCfg']['userGroups'].'<br/>'; |
|
1789 | 1789 | } |
1790 | - if ($confArray['subCfg']['baseUrl']) { |
|
1791 | - $optionValues.='Base Url: '.$confArray['subCfg']['baseUrl'].'<br/>'; |
|
1790 | + if ($confArray['subCfg']['baseUrl']) { |
|
1791 | + $optionValues .= 'Base Url: '.$confArray['subCfg']['baseUrl'].'<br/>'; |
|
1792 | 1792 | } |
1793 | - if ($confArray['subCfg']['procInstrFilter']) { |
|
1794 | - $optionValues.='ProcInstr: '.$confArray['subCfg']['procInstrFilter'].'<br/>'; |
|
1793 | + if ($confArray['subCfg']['procInstrFilter']) { |
|
1794 | + $optionValues .= 'ProcInstr: '.$confArray['subCfg']['procInstrFilter'].'<br/>'; |
|
1795 | 1795 | } |
1796 | 1796 | |
1797 | 1797 | // Compile row: |
1798 | 1798 | $content .= ' |
1799 | - <tr class="bgColor' . ($c%2 ? '-20':'-10') . '"> |
|
1800 | - ' . $titleClm . ' |
|
1801 | - <td>' . htmlspecialchars($confKey) . '</td> |
|
1802 | - <td>' . nl2br(htmlspecialchars(rawurldecode(trim(str_replace('&', chr(10) . '&', \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $confArray['paramParsed'])))))) . '</td> |
|
1799 | + <tr class="bgColor' . ($c % 2 ? '-20' : '-10').'"> |
|
1800 | + ' . $titleClm.' |
|
1801 | + <td>' . htmlspecialchars($confKey).'</td> |
|
1802 | + <td>' . nl2br(htmlspecialchars(rawurldecode(trim(str_replace('&', chr(10).'&', \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $confArray['paramParsed'])))))).'</td> |
|
1803 | 1803 | <td>'.$paramExpanded.'</td> |
1804 | - <td nowrap="nowrap">' . $urlList . '</td> |
|
1805 | - <td nowrap="nowrap">' . $optionValues . '</td> |
|
1806 | - <td nowrap="nowrap">' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($confArray['subCfg']['procInstrParams.']) . '</td> |
|
1804 | + <td nowrap="nowrap">' . $urlList.'</td> |
|
1805 | + <td nowrap="nowrap">' . $optionValues.'</td> |
|
1806 | + <td nowrap="nowrap">' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($confArray['subCfg']['procInstrParams.']).'</td> |
|
1807 | 1807 | </tr>'; |
1808 | 1808 | } else { |
1809 | 1809 | |
1810 | - $content .= '<tr class="bgColor'.($c%2 ? '-20':'-10') . '"> |
|
1810 | + $content .= '<tr class="bgColor'.($c % 2 ? '-20' : '-10').'"> |
|
1811 | 1811 | '.$titleClm.' |
1812 | 1812 | <td>'.htmlspecialchars($confKey).'</td> |
1813 | 1813 | <td colspan="5"><em>No entries</em> (Page is excluded in this configuration)</td> |
@@ -1822,7 +1822,7 @@ discard block |
||
1822 | 1822 | $message = !empty($skipMessage) ? ' ('.$skipMessage.')' : ''; |
1823 | 1823 | |
1824 | 1824 | // Compile row: |
1825 | - $content.= ' |
|
1825 | + $content .= ' |
|
1826 | 1826 | <tr class="bgColor-20" style="border-bottom: 1px solid black;"> |
1827 | 1827 | <td>'.$pageTitleAndIcon.'</td> |
1828 | 1828 | <td colspan="6"><em>No entries</em>'.$message.'</td> |
@@ -1883,7 +1883,7 @@ discard block |
||
1883 | 1883 | // Run process: |
1884 | 1884 | $result = $this->CLI_run($countInARun, $sleepTime, $sleepAfterFinish); |
1885 | 1885 | } catch (Exception $e) { |
1886 | - $this->CLI_debug(get_class($e) . ': ' . $e->getMessage()); |
|
1886 | + $this->CLI_debug(get_class($e).': '.$e->getMessage()); |
|
1887 | 1887 | $result = self::CLI_STATUS_ABORTED; |
1888 | 1888 | } |
1889 | 1889 | |
@@ -1894,7 +1894,7 @@ discard block |
||
1894 | 1894 | $releaseStatus = $this->CLI_releaseProcesses($this->CLI_buildProcessId()); |
1895 | 1895 | |
1896 | 1896 | $this->CLI_debug("Unprocessed Items remaining:".$this->getUnprocessedItemsCount()." (".$this->CLI_buildProcessId().")"); |
1897 | - $result |= ( $this->getUnprocessedItemsCount() > 0 ? self::CLI_STATUS_REMAIN : self::CLI_STATUS_NOTHING_PROCCESSED ); |
|
1897 | + $result |= ($this->getUnprocessedItemsCount() > 0 ? self::CLI_STATUS_REMAIN : self::CLI_STATUS_NOTHING_PROCCESSED); |
|
1898 | 1898 | } else { |
1899 | 1899 | $result |= self::CLI_STATUS_ABORTED; |
1900 | 1900 | } |
@@ -1907,7 +1907,7 @@ discard block |
||
1907 | 1907 | * |
1908 | 1908 | * @return void |
1909 | 1909 | */ |
1910 | - function CLI_main_im() { |
|
1910 | + function CLI_main_im() { |
|
1911 | 1911 | $this->setAccessMode('cli_im'); |
1912 | 1912 | |
1913 | 1913 | $cliObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_cli_im'); |
@@ -1917,7 +1917,7 @@ discard block |
||
1917 | 1917 | $this->backendUser->setWorkspace(0); |
1918 | 1918 | |
1919 | 1919 | // Print help |
1920 | - if (!isset($cliObj->cli_args['_DEFAULT'][1])) { |
|
1920 | + if (!isset($cliObj->cli_args['_DEFAULT'][1])) { |
|
1921 | 1921 | $cliObj->cli_validateArgs(); |
1922 | 1922 | $cliObj->cli_help(); |
1923 | 1923 | exit; |
@@ -1925,8 +1925,8 @@ discard block |
||
1925 | 1925 | |
1926 | 1926 | $cliObj->cli_validateArgs(); |
1927 | 1927 | |
1928 | - if ($cliObj->cli_argValue('-o')==='exec') { |
|
1929 | - $this->registerQueueEntriesInternallyOnly=TRUE; |
|
1928 | + if ($cliObj->cli_argValue('-o') === 'exec') { |
|
1929 | + $this->registerQueueEntriesInternallyOnly = TRUE; |
|
1930 | 1930 | } |
1931 | 1931 | |
1932 | 1932 | if (isset($cliObj->cli_args['_DEFAULT'][2])) { |
@@ -1939,16 +1939,16 @@ discard block |
||
1939 | 1939 | |
1940 | 1940 | $configurationKeys = $this->getConfigurationKeys($cliObj); |
1941 | 1941 | |
1942 | - if(!is_array($configurationKeys)){ |
|
1942 | + if (!is_array($configurationKeys)) { |
|
1943 | 1943 | $configurations = $this->getUrlsForPageId($pageId); |
1944 | - if(is_array($configurations)){ |
|
1944 | + if (is_array($configurations)) { |
|
1945 | 1945 | $configurationKeys = array_keys($configurations); |
1946 | - }else{ |
|
1946 | + } else { |
|
1947 | 1947 | $configurationKeys = array(); |
1948 | 1948 | } |
1949 | 1949 | } |
1950 | 1950 | |
1951 | - if($cliObj->cli_argValue('-o')==='queue' || $cliObj->cli_argValue('-o')==='exec'){ |
|
1951 | + if ($cliObj->cli_argValue('-o') === 'queue' || $cliObj->cli_argValue('-o') === 'exec') { |
|
1952 | 1952 | |
1953 | 1953 | $reason = new tx_crawler_domain_reason(); |
1954 | 1954 | $reason->setReason(tx_crawler_domain_reason::REASON_GUI_SUBMIT); |
@@ -1956,7 +1956,7 @@ discard block |
||
1956 | 1956 | tx_crawler_domain_events_dispatcher::getInstance()->post( |
1957 | 1957 | 'invokeQueueChange', |
1958 | 1958 | $this->setID, |
1959 | - array( 'reason' => $reason ) |
|
1959 | + array('reason' => $reason) |
|
1960 | 1960 | ); |
1961 | 1961 | } |
1962 | 1962 | |
@@ -1967,42 +1967,42 @@ discard block |
||
1967 | 1967 | $this->setID = \TYPO3\CMS\Core\Utility\GeneralUtility::md5int(microtime()); |
1968 | 1968 | $this->getPageTreeAndUrls( |
1969 | 1969 | $pageId, |
1970 | - \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cliObj->cli_argValue('-d'),0,99), |
|
1970 | + \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cliObj->cli_argValue('-d'), 0, 99), |
|
1971 | 1971 | $this->getCurrentTime(), |
1972 | - \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cliObj->cli_isArg('-n') ? $cliObj->cli_argValue('-n') : 30,1,1000), |
|
1973 | - $cliObj->cli_argValue('-o')==='queue' || $cliObj->cli_argValue('-o')==='exec', |
|
1974 | - $cliObj->cli_argValue('-o')==='url', |
|
1975 | - \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',',$cliObj->cli_argValue('-proc'),1), |
|
1972 | + \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cliObj->cli_isArg('-n') ? $cliObj->cli_argValue('-n') : 30, 1, 1000), |
|
1973 | + $cliObj->cli_argValue('-o') === 'queue' || $cliObj->cli_argValue('-o') === 'exec', |
|
1974 | + $cliObj->cli_argValue('-o') === 'url', |
|
1975 | + \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $cliObj->cli_argValue('-proc'), 1), |
|
1976 | 1976 | $configurationKeys |
1977 | 1977 | ); |
1978 | 1978 | |
1979 | - if ($cliObj->cli_argValue('-o')==='url') { |
|
1980 | - $cliObj->cli_echo(implode(chr(10),$this->downloadUrls).chr(10),1); |
|
1981 | - } elseif ($cliObj->cli_argValue('-o')==='exec') { |
|
1979 | + if ($cliObj->cli_argValue('-o') === 'url') { |
|
1980 | + $cliObj->cli_echo(implode(chr(10), $this->downloadUrls).chr(10), 1); |
|
1981 | + } elseif ($cliObj->cli_argValue('-o') === 'exec') { |
|
1982 | 1982 | $cliObj->cli_echo("Executing ".count($this->urlList)." requests right away:\n\n"); |
1983 | - $cliObj->cli_echo(implode(chr(10),$this->urlList).chr(10)); |
|
1983 | + $cliObj->cli_echo(implode(chr(10), $this->urlList).chr(10)); |
|
1984 | 1984 | $cliObj->cli_echo("\nProcessing:\n"); |
1985 | 1985 | |
1986 | - foreach($this->queueEntries as $queueRec) { |
|
1986 | + foreach ($this->queueEntries as $queueRec) { |
|
1987 | 1987 | $p = unserialize($queueRec['parameters']); |
1988 | - $cliObj->cli_echo($p['url'].' ('.implode(',',$p['procInstructions']).') => '); |
|
1988 | + $cliObj->cli_echo($p['url'].' ('.implode(',', $p['procInstructions']).') => '); |
|
1989 | 1989 | |
1990 | 1990 | $result = $this->readUrlFromArray($queueRec); |
1991 | 1991 | |
1992 | 1992 | $requestResult = unserialize($result['content']); |
1993 | - if (is_array($requestResult)) { |
|
1994 | - $resLog = is_array($requestResult['log']) ? chr(10).chr(9).chr(9).implode(chr(10).chr(9).chr(9),$requestResult['log']) : ''; |
|
1993 | + if (is_array($requestResult)) { |
|
1994 | + $resLog = is_array($requestResult['log']) ? chr(10).chr(9).chr(9).implode(chr(10).chr(9).chr(9), $requestResult['log']) : ''; |
|
1995 | 1995 | $cliObj->cli_echo('OK: '.$resLog.chr(10)); |
1996 | 1996 | } else { |
1997 | - $cliObj->cli_echo('Error checking Crawler Result: '.substr(preg_replace('/\s+/',' ',strip_tags($result['content'])),0,30000).'...'.chr(10)); |
|
1997 | + $cliObj->cli_echo('Error checking Crawler Result: '.substr(preg_replace('/\s+/', ' ', strip_tags($result['content'])), 0, 30000).'...'.chr(10)); |
|
1998 | 1998 | } |
1999 | 1999 | } |
2000 | - } elseif ($cliObj->cli_argValue('-o')==='queue') { |
|
2000 | + } elseif ($cliObj->cli_argValue('-o') === 'queue') { |
|
2001 | 2001 | $cliObj->cli_echo("Putting ".count($this->urlList)." entries in queue:\n\n"); |
2002 | - $cliObj->cli_echo(implode(chr(10),$this->urlList).chr(10)); |
|
2002 | + $cliObj->cli_echo(implode(chr(10), $this->urlList).chr(10)); |
|
2003 | 2003 | } else { |
2004 | - $cliObj->cli_echo(count($this->urlList)." entries found for processing. (Use -o to decide action):\n\n",1); |
|
2005 | - $cliObj->cli_echo(implode(chr(10),$this->urlList).chr(10),1); |
|
2004 | + $cliObj->cli_echo(count($this->urlList)." entries found for processing. (Use -o to decide action):\n\n", 1); |
|
2005 | + $cliObj->cli_echo(implode(chr(10), $this->urlList).chr(10), 1); |
|
2006 | 2006 | } |
2007 | 2007 | } |
2008 | 2008 | |
@@ -2027,12 +2027,12 @@ discard block |
||
2027 | 2027 | } |
2028 | 2028 | |
2029 | 2029 | $cliObj->cli_validateArgs(); |
2030 | - $pageId = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cliObj->cli_args['_DEFAULT'][1],0); |
|
2030 | + $pageId = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cliObj->cli_args['_DEFAULT'][1], 0); |
|
2031 | 2031 | $fullFlush = ($pageId == 0); |
2032 | 2032 | |
2033 | 2033 | $mode = $cliObj->cli_argValue('-o'); |
2034 | 2034 | |
2035 | - switch($mode) { |
|
2035 | + switch ($mode) { |
|
2036 | 2036 | case 'all': |
2037 | 2037 | $result = $this->getLogEntriesForPageId($pageId, '', true, $fullFlush); |
2038 | 2038 | break; |
@@ -2055,7 +2055,7 @@ discard block |
||
2055 | 2055 | * @param tx_crawler_cli_im $cliObj Command line object |
2056 | 2056 | * @return mixed Array of keys or null if no keys found |
2057 | 2057 | */ |
2058 | - protected function getConfigurationKeys(tx_crawler_cli_im &$cliObj) { |
|
2058 | + protected function getConfigurationKeys(tx_crawler_cli_im & $cliObj) { |
|
2059 | 2059 | $parameter = trim($cliObj->cli_argValue('-conf')); |
2060 | 2060 | return ($parameter != '' ? \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $parameter) : array()); |
2061 | 2061 | } |
@@ -2080,7 +2080,7 @@ discard block |
||
2080 | 2080 | $purgeDate = $this->getCurrentTime() - 24 * 60 * 60 * intval($this->extensionSettings['purgeQueueDays']); |
2081 | 2081 | $del = $this->db->exec_DELETEquery( |
2082 | 2082 | 'tx_crawler_queue', |
2083 | - 'exec_time!=0 AND exec_time<' . $purgeDate |
|
2083 | + 'exec_time!=0 AND exec_time<'.$purgeDate |
|
2084 | 2084 | ); |
2085 | 2085 | } |
2086 | 2086 | |
@@ -2097,10 +2097,10 @@ discard block |
||
2097 | 2097 | intval($countInARun) |
2098 | 2098 | ); |
2099 | 2099 | |
2100 | - if (count($rows)>0) { |
|
2100 | + if (count($rows) > 0) { |
|
2101 | 2101 | $quidList = array(); |
2102 | 2102 | |
2103 | - foreach($rows as $r) { |
|
2103 | + foreach ($rows as $r) { |
|
2104 | 2104 | $quidList[] = $r['qid']; |
2105 | 2105 | } |
2106 | 2106 | |
@@ -2111,7 +2111,7 @@ discard block |
||
2111 | 2111 | //TODO make sure we're not taking assigned queue-entires |
2112 | 2112 | $this->db->exec_UPDATEquery( |
2113 | 2113 | 'tx_crawler_queue', |
2114 | - 'qid IN ('.implode(',',$quidList).')', |
|
2114 | + 'qid IN ('.implode(',', $quidList).')', |
|
2115 | 2115 | array( |
2116 | 2116 | 'process_scheduled' => intval($this->getCurrentTime()), |
2117 | 2117 | 'process_id' => $processId |
@@ -2122,32 +2122,32 @@ discard block |
||
2122 | 2122 | $numberOfAffectedRows = $this->db->sql_affected_rows(); |
2123 | 2123 | $this->db->exec_UPDATEquery( |
2124 | 2124 | 'tx_crawler_process', |
2125 | - "process_id = '".$processId."'" , |
|
2125 | + "process_id = '".$processId."'", |
|
2126 | 2126 | array( |
2127 | 2127 | 'assigned_items_count' => intval($numberOfAffectedRows) |
2128 | 2128 | ) |
2129 | 2129 | ); |
2130 | 2130 | |
2131 | - if($numberOfAffectedRows == count($quidList)) { |
|
2131 | + if ($numberOfAffectedRows == count($quidList)) { |
|
2132 | 2132 | $this->db->sql_query('COMMIT'); |
2133 | - } else { |
|
2133 | + } else { |
|
2134 | 2134 | $this->db->sql_query('ROLLBACK'); |
2135 | 2135 | $this->CLI_debug("Nothing processed due to multi-process collision (".$this->CLI_buildProcessId().")"); |
2136 | - return ( $result | self::CLI_STATUS_ABORTED ); |
|
2136 | + return ($result | self::CLI_STATUS_ABORTED); |
|
2137 | 2137 | } |
2138 | 2138 | |
2139 | 2139 | |
2140 | 2140 | |
2141 | - foreach($rows as $r) { |
|
2141 | + foreach ($rows as $r) { |
|
2142 | 2142 | $result |= $this->readUrl($r['qid']); |
2143 | 2143 | |
2144 | 2144 | $counter++; |
2145 | - usleep(intval($sleepTime)); // Just to relax the system |
|
2145 | + usleep(intval($sleepTime)); // Just to relax the system |
|
2146 | 2146 | |
2147 | 2147 | // if during the start and the current read url the cli has been disable we need to return from the function |
2148 | 2148 | // mark the process NOT as ended. |
2149 | 2149 | if ($this->getDisabled()) { |
2150 | - return ( $result | self::CLI_STATUS_ABORTED ); |
|
2150 | + return ($result | self::CLI_STATUS_ABORTED); |
|
2151 | 2151 | } |
2152 | 2152 | |
2153 | 2153 | if (!$this->CLI_checkIfProcessIsActive($this->CLI_buildProcessId())) { |
@@ -2155,7 +2155,7 @@ discard block |
||
2155 | 2155 | |
2156 | 2156 | //TODO might need an additional returncode |
2157 | 2157 | $result |= self::CLI_STATUS_ABORTED; |
2158 | - break; //possible timeout |
|
2158 | + break; //possible timeout |
|
2159 | 2159 | } |
2160 | 2160 | } |
2161 | 2161 | |
@@ -2168,7 +2168,7 @@ discard block |
||
2168 | 2168 | $this->CLI_debug("Nothing within queue which needs to be processed (".$this->CLI_buildProcessId().")"); |
2169 | 2169 | } |
2170 | 2170 | |
2171 | - if($counter > 0) { |
|
2171 | + if ($counter > 0) { |
|
2172 | 2172 | $result |= self::CLI_STATUS_PROCESSED; |
2173 | 2173 | } |
2174 | 2174 | |
@@ -2180,12 +2180,12 @@ discard block |
||
2180 | 2180 | * |
2181 | 2181 | * @return void |
2182 | 2182 | */ |
2183 | - function CLI_runHooks() { |
|
2183 | + function CLI_runHooks() { |
|
2184 | 2184 | global $TYPO3_CONF_VARS; |
2185 | - if (is_array($TYPO3_CONF_VARS['EXTCONF']['crawler']['cli_hooks'])) { |
|
2186 | - foreach($TYPO3_CONF_VARS['EXTCONF']['crawler']['cli_hooks'] as $objRef) { |
|
2185 | + if (is_array($TYPO3_CONF_VARS['EXTCONF']['crawler']['cli_hooks'])) { |
|
2186 | + foreach ($TYPO3_CONF_VARS['EXTCONF']['crawler']['cli_hooks'] as $objRef) { |
|
2187 | 2187 | $hookObj = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($objRef); |
2188 | - if (is_object($hookObj)) { |
|
2188 | + if (is_object($hookObj)) { |
|
2189 | 2189 | $hookObj->crawler_init($this); |
2190 | 2190 | } |
2191 | 2191 | } |
@@ -2222,7 +2222,7 @@ discard block |
||
2222 | 2222 | |
2223 | 2223 | $currentTime = $this->getCurrentTime(); |
2224 | 2224 | |
2225 | - while($row = $this->db->sql_fetch_assoc($res)) { |
|
2225 | + while ($row = $this->db->sql_fetch_assoc($res)) { |
|
2226 | 2226 | if ($row['ttl'] < $currentTime) { |
2227 | 2227 | $orphanProcesses[] = $row['process_id']; |
2228 | 2228 | } else { |
@@ -2232,7 +2232,7 @@ discard block |
||
2232 | 2232 | |
2233 | 2233 | // if there are less than allowed active processes then add a new one |
2234 | 2234 | if ($processCount < intval($this->extensionSettings['processLimit'])) { |
2235 | - $this->CLI_debug("add process ".$this->CLI_buildProcessId()." (".($processCount+1)."/".intval($this->extensionSettings['processLimit']).")"); |
|
2235 | + $this->CLI_debug("add process ".$this->CLI_buildProcessId()." (".($processCount + 1)."/".intval($this->extensionSettings['processLimit']).")"); |
|
2236 | 2236 | |
2237 | 2237 | // create new process record |
2238 | 2238 | $this->db->exec_INSERTquery( |
@@ -2265,17 +2265,17 @@ discard block |
||
2265 | 2265 | * @param boolean $withinLock show whether the DB-actions are included within an existing lock |
2266 | 2266 | * @return boolean |
2267 | 2267 | */ |
2268 | - function CLI_releaseProcesses($releaseIds, $withinLock=false) { |
|
2268 | + function CLI_releaseProcesses($releaseIds, $withinLock = false) { |
|
2269 | 2269 | |
2270 | 2270 | if (!is_array($releaseIds)) { |
2271 | 2271 | $releaseIds = array($releaseIds); |
2272 | 2272 | } |
2273 | 2273 | |
2274 | 2274 | if (!count($releaseIds) > 0) { |
2275 | - return false; //nothing to release |
|
2275 | + return false; //nothing to release |
|
2276 | 2276 | } |
2277 | 2277 | |
2278 | - if(!$withinLock) $this->db->sql_query('BEGIN'); |
|
2278 | + if (!$withinLock) $this->db->sql_query('BEGIN'); |
|
2279 | 2279 | |
2280 | 2280 | // some kind of 2nd chance algo - this way you need at least 2 processes to have a real cleanup |
2281 | 2281 | // this ensures that a single process can't mess up the entire process table |
@@ -2305,21 +2305,21 @@ discard block |
||
2305 | 2305 | // mark all requested processes as non-active |
2306 | 2306 | $this->db->exec_UPDATEquery( |
2307 | 2307 | 'tx_crawler_process', |
2308 | - 'process_id IN (\''.implode('\',\'',$releaseIds).'\') AND deleted=0', |
|
2308 | + 'process_id IN (\''.implode('\',\'', $releaseIds).'\') AND deleted=0', |
|
2309 | 2309 | array( |
2310 | 2310 | 'active'=>'0' |
2311 | 2311 | ) |
2312 | 2312 | ); |
2313 | 2313 | $this->db->exec_UPDATEquery( |
2314 | 2314 | 'tx_crawler_queue', |
2315 | - 'exec_time=0 AND process_id IN ("'.implode('","',$releaseIds).'")', |
|
2315 | + 'exec_time=0 AND process_id IN ("'.implode('","', $releaseIds).'")', |
|
2316 | 2316 | array( |
2317 | 2317 | 'process_scheduled'=>0, |
2318 | 2318 | 'process_id'=>'' |
2319 | 2319 | ) |
2320 | 2320 | ); |
2321 | 2321 | |
2322 | - if(!$withinLock) $this->db->sql_query('COMMIT'); |
|
2322 | + if (!$withinLock) $this->db->sql_query('COMMIT'); |
|
2323 | 2323 | |
2324 | 2324 | return true; |
2325 | 2325 | } |
@@ -2347,13 +2347,13 @@ discard block |
||
2347 | 2347 | $this->db->sql_query('BEGIN'); |
2348 | 2348 | $res = $this->db->exec_SELECTquery( |
2349 | 2349 | 'process_id,active,ttl', |
2350 | - 'tx_crawler_process','process_id = \''.$pid.'\' AND deleted=0', |
|
2350 | + 'tx_crawler_process', 'process_id = \''.$pid.'\' AND deleted=0', |
|
2351 | 2351 | '', |
2352 | 2352 | 'ttl', |
2353 | 2353 | '0,1' |
2354 | 2354 | ); |
2355 | - if($row = $this->db->sql_fetch_assoc($res)) { |
|
2356 | - $ret = intVal($row['active'])==1; |
|
2355 | + if ($row = $this->db->sql_fetch_assoc($res)) { |
|
2356 | + $ret = intVal($row['active']) == 1; |
|
2357 | 2357 | } |
2358 | 2358 | $this->db->sql_query('COMMIT'); |
2359 | 2359 | |
@@ -2366,8 +2366,8 @@ discard block |
||
2366 | 2366 | * @return string the ID |
2367 | 2367 | */ |
2368 | 2368 | protected function CLI_buildProcessId() { |
2369 | - if(!$this->processID) { |
|
2370 | - $this->processID= \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($this->microtime(true)); |
|
2369 | + if (!$this->processID) { |
|
2370 | + $this->processID = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($this->microtime(true)); |
|
2371 | 2371 | } |
2372 | 2372 | return $this->processID; |
2373 | 2373 | } |
@@ -2379,7 +2379,7 @@ discard block |
||
2379 | 2379 | * |
2380 | 2380 | * @codeCoverageIgnore |
2381 | 2381 | */ |
2382 | - protected function microtime($get_as_float = false ) |
|
2382 | + protected function microtime($get_as_float = false) |
|
2383 | 2383 | { |
2384 | 2384 | return microtime($get_as_float); |
2385 | 2385 | } |
@@ -2392,7 +2392,7 @@ discard block |
||
2392 | 2392 | * @codeCoverageIgnore |
2393 | 2393 | */ |
2394 | 2394 | function CLI_debug($msg) { |
2395 | - if(intval($this->extensionSettings['processDebug'])) { |
|
2395 | + if (intval($this->extensionSettings['processDebug'])) { |
|
2396 | 2396 | echo $msg."\n"; flush(); |
2397 | 2397 | } |
2398 | 2398 | } |
@@ -2411,7 +2411,7 @@ discard block |
||
2411 | 2411 | |
2412 | 2412 | $cmd = escapeshellcmd($this->extensionSettings['phpPath']); |
2413 | 2413 | $cmd .= ' '; |
2414 | - $cmd .= escapeshellarg(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('crawler') . 'cli/bootstrap.php'); |
|
2414 | + $cmd .= escapeshellarg(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('crawler').'cli/bootstrap.php'); |
|
2415 | 2415 | $cmd .= ' '; |
2416 | 2416 | $cmd .= escapeshellarg($this->getFrontendBasePath()); |
2417 | 2417 | $cmd .= ' '; |
@@ -2421,10 +2421,10 @@ discard block |
||
2421 | 2421 | |
2422 | 2422 | $startTime = microtime(true); |
2423 | 2423 | $content = $this->executeShellCommand($cmd); |
2424 | - $this->log($url . (microtime(true) - $startTime)); |
|
2424 | + $this->log($url.(microtime(true) - $startTime)); |
|
2425 | 2425 | |
2426 | 2426 | $result = array( |
2427 | - 'request' => implode("\r\n", $requestHeaders) . "\r\n\r\n", |
|
2427 | + 'request' => implode("\r\n", $requestHeaders)."\r\n\r\n", |
|
2428 | 2428 | 'headers' => '', |
2429 | 2429 | 'content' => $content |
2430 | 2430 | ); |
@@ -2444,7 +2444,7 @@ discard block |
||
2444 | 2444 | $scheduledAgeInSeconds = $this->extensionSettings['cleanUpScheduledAge'] * 86400; |
2445 | 2445 | |
2446 | 2446 | $now = time(); |
2447 | - $condition = '(exec_time<>0 AND exec_time<' . ($now - $processedAgeInSeconds) . ') OR scheduled<=' . ($now - $scheduledAgeInSeconds); |
|
2447 | + $condition = '(exec_time<>0 AND exec_time<'.($now - $processedAgeInSeconds).') OR scheduled<='.($now - $scheduledAgeInSeconds); |
|
2448 | 2448 | $this->flushQueue($condition); |
2449 | 2449 | } |
2450 | 2450 | |
@@ -2465,7 +2465,7 @@ discard block |
||
2465 | 2465 | $GLOBALS['TT']->start(); |
2466 | 2466 | } |
2467 | 2467 | |
2468 | - $GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $id, $typeNum); |
|
2468 | + $GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $id, $typeNum); |
|
2469 | 2469 | $GLOBALS['TSFE']->sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); |
2470 | 2470 | $GLOBALS['TSFE']->sys_page->init(TRUE); |
2471 | 2471 | $GLOBALS['TSFE']->connectToDB(); |
@@ -2478,6 +2478,6 @@ discard block |
||
2478 | 2478 | } |
2479 | 2479 | } |
2480 | 2480 | |
2481 | -if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/class.tx_crawler_lib.php']) { |
|
2481 | +if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/class.tx_crawler_lib.php']) { |
|
2482 | 2482 | include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/class.tx_crawler_lib.php']); |
2483 | 2483 | } |