/** * recheck all the links in the page and update those links status code * * @param array $recheckLinks rechecking links * @param array $inputArray default input values * @param \HTTP_Request2 $request http_request object */ public function recheckPage($recheckLinks, $inputArray, \HTTP_Request2 $request) { if (is_array($recheckLinks) && $request) { foreach ($recheckLinks as $link => $text) { $linkAlreadyExist = $this->linkRepository->getLinkByPath($link); if (!$linkAlreadyExist) { try { $request->setUrl($link); $request->setConfig(array('ssl_verify_peer' => false, 'ssl_verify_host' => false, 'follow_redirects' => true)); $response = $request->send(); $urlStatus = $response->getStatus(); } catch (\Exception $e) { $urlStatus = preg_match('#^[mailto:|javascript:]# i', $link) ? 200 : 0; } $objFWUser = \FWUser::getFWUserObject(); $internalFlag = \Cx\Core_Modules\LinkManager\Controller\Url::isInternalUrl($link); $flagStatus = $urlStatus == '200' ? 1 : 0; $linkType = $internalFlag ? 'internal' : 'external'; $inputArray['requestedPath'] = contrexx_raw2db($link); $inputArray['linkStatusCode'] = contrexx_raw2db($urlStatus); $inputArray['flagStatus'] = contrexx_raw2db($flagStatus); $inputArray['linkRecheck'] = 1; $inputArray['requestedLinkType'] = contrexx_raw2db($linkType); $inputArray['linkStatus'] = 1; $inputArray['updatedBy'] = contrexx_raw2db($objFWUser->objUser->getId()); $inputArray['moduleName'] = ''; $inputArray['moduleAction'] = ''; $inputArray['moduleParams'] = ''; $inputArray['brokenLinkText'] = contrexx_raw2db($text); $this->modifyLink($inputArray); } } } }
/** * Recheck all the links in the page and update those links status code * * @param \Cx\Core_Modules\LinkManager\Model\Entity\Link $link Parent link obejct * @param array $subLinks Links in the parent link * * @return null */ public function recheckPage(\Cx\Core_Modules\LinkManager\Model\Entity\Link $link, $subLinks = array()) { //If there is no recheck links then return if (!$subLinks) { return; } foreach ($subLinks as $subLinkUrl => $subLinkName) { //If the link already exists then proceed with next link if ($this->linkRepository->getLinkByPath($subLinkUrl)) { continue; } $urlStatus = $this->getUrlStatus($subLinkUrl); $isInternalLink = $this->getController('Url')->isInternalUrl($subLinkUrl); $subLink = new \Cx\Core_Modules\LinkManager\Model\Entity\Link(); $subLink->setLang($link->getLang()); $subLink->setRefererPath($link->getRefererPath()); $subLink->setLeadPath($link->getLeadPath()); $subLink->setEntryTitle($link->getEntryTitle()); $subLink->setDetectedTime($link->getDetectedTime()); $subLink->setUpdatedBy(\FWUser::getFWUserObject()->objUser->getId()); $subLink->setBrokenLinkText($subLinkName); $subLink->setRequestedPath($subLinkUrl); $subLink->setLinkStatusCode($urlStatus); $subLink->setFlagStatus($urlStatus == 200 ? 1 : 0); $subLink->setLinkRecheck(1); $subLink->setRequestedLinkType($isInternalLink ? 'internal' : 'external'); $subLink->setLinkStatus(1); $this->em->persist($subLink); } $this->em->flush(); }
/** * Update the crawler status * * @param \Cx\Core_Modules\LinkManager\Model\Entity\Crawler $crawler Crawler instance * @param string $status Crawler status */ public function updateCrawlerStatus(\Cx\Core_Modules\LinkManager\Model\Entity\Crawler $crawler, $status) { $crawlerStartTime = $crawler->getStartTime()->format(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME); //Update the crawler's totalLinks, totalBrokenLinks and status $totalLinks = $this->linkRepo->getLinksCountByLang($crawlerStartTime, $this->langId); $totalBrokenLinks = $this->linkRepo->getDetectedBrokenLinksCount($crawlerStartTime, $this->langId); $crawler->updateEndTime(); $crawler->setRunStatus($status); $crawler->setTotalLinks($totalLinks); $crawler->setTotalBrokenLinks($totalBrokenLinks); $this->em->flush(); }
/** * update the crawler status * * @param integer $id current crawler run id * @param string $status current crawler run status * * @return boolean */ public function updateCrawlerStatus($id, $status) { if (empty($id)) { $objCrawler = $this->crawlerRepo->getLastRunByLang($this->langId); } else { $objCrawler = $this->crawlerRepo->findOneBy(array('id' => $id)); } if ($objCrawler) { $totalLinks = $this->linkRepo->getLinksCountByLang($objCrawler->getStartTime()->format(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME), $this->langId); $totalBrokenLinks = $this->linkRepo->getDetectedBrokenLinksCount($objCrawler->getStartTime()->format(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME), $this->langId); $objCrawler->updateEndTime(); $objCrawler->setRunStatus($status); $objCrawler->setTotalLinks($totalLinks); $objCrawler->setTotalBrokenLinks($totalBrokenLinks); $this->em->persist($objCrawler); $this->em->flush(); return true; } }
/** * Edit the link status(link resolved or not) * * @return array */ public function modifyLinkStatus() { //get post values $id = isset($_GET['id']) ? contrexx_input2raw($_GET['id']) : 0; $solvedLinkStat = isset($_GET['status']) ? $_GET['status'] : 0; $result = array(); $objUser = new \Cx\Core_Modules\LinkManager\Controller\User(); if ($objUser) { $user = $objUser->getUpdatedUserName(0, 1); } if (!empty($id)) { $linkStatus = $solvedLinkStat == 0 ? 1 : 0; $userId = $linkStatus ? $user['id'] : 0; $brokenLink = $this->linkRepo->findOneBy(array('id' => $id)); $brokenLink->setLinkStatus($linkStatus); $brokenLink->setUpdatedBy($userId); $this->em->persist($brokenLink); $this->em->flush(); $result['linkStatus'] = $linkStatus; $result['userName'] = $user['name']; } return $result; }