Пример #1
0
 public function testDeadlinksFalse()
 {
     $obj = new checkIfDead();
     $urls = array('https://en.wikipedia.org/wiki/Main_Page', 'https://en.wikipedia.org/w/index.php?title=Republic_of_India', 'https://astraldynamics.com', 'http://news.bbc.co.uk/2/hi/uk_news/england/coventry_warwickshire/6236900.stm', 'http://napavalleyregister.com/news/napa-pipe-plant-loads-its-final-rail-car/article_695e3e0a-8d33-5e3b-917c-07a7545b3594.html', 'http://content.onlinejacc.org/cgi/content/full/41/9/1633', 'http://flysunairexpress.com/#about', 'ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc');
     $result = $obj->checkDeadlinks($urls);
     $expected = array(false, false, false, false, false, false, false, false);
     $this->assertEquals($expected, $result['results']);
 }
Пример #2
0
 /**
  * Update the link details array with values stored in the DB, and vice versa
  * Updates the dead status of the given link
  * 
  * @param array $link Array of link with details
  * @param int $tid Array key to preserve index keys
  * @access public
  * @author Maximilian Doerr (Cyberpower678)
  * @license https://www.gnu.org/licenses/gpl.txt
  * @copyright Copyright (c) 2016, Maximilian Doerr
  * @return array Returns the same array with updated values, if any
  */
 public function updateLinkInfo($links)
 {
     $toCheck = array();
     foreach ($links as $tid => $link) {
         if (($this->commObject->TOUCH_ARCHIVE == 1 || $link['has_archive'] === false) && $this->commObject->VERIFY_DEAD == 1 && $this->commObject->db->dbValues[$tid]['live_state'] !== 0 && $this->commObject->db->dbValues[$tid]['live_state'] !== 5 && time() - $this->commObject->db->dbValues[$tid]['last_deadCheck'] > 259200) {
             $toCheck[$tid] = $link['url'];
         }
     }
     $results = $this->deadCheck->checkDeadlinks($toCheck);
     $results = $results['results'];
     foreach ($links as $tid => $link) {
         $link['is_dead'] = null;
         if (($this->commObject->TOUCH_ARCHIVE == 1 || $link['has_archive'] === false) && $this->commObject->VERIFY_DEAD == 1) {
             if ($this->commObject->db->dbValues[$tid]['live_state'] != 0 && $this->commObject->db->dbValues[$tid]['live_state'] != 5 && time() - $this->commObject->db->dbValues[$tid]['last_deadCheck'] > 259200) {
                 $link['is_dead'] = $results[$tid];
                 $this->commObject->db->dbValues[$tid]['last_deadCheck'] = time();
                 if ($link['tagged_dead'] === false && $link['is_dead'] === true) {
                     $this->commObject->db->dbValues[$tid]['live_state']--;
                 } elseif ($link['tagged_dead'] === false && $link['is_dead'] === false && $this->commObject->db->dbValues[$tid]['live_state'] != 3) {
                     $this->commObject->db->dbValues[$tid]['live_state'] = 3;
                 } elseif ($link['tagged_dead'] === true && ($this->commObject->TAG_OVERRIDE == 1 || $link['is_dead'] === true)) {
                     $this->commObject->db->dbValues[$tid]['live_state'] = 0;
                 } else {
                     $this->commObject->db->dbValues[$tid]['live_state'] = 3;
                 }
             }
             if ($this->commObject->db->dbValues[$tid]['live_state'] == 0) {
                 $link['is_dead'] = true;
             }
             if ($this->commObject->db->dbValues[$tid]['live_state'] != 0) {
                 $link['is_dead'] = false;
             }
             if (!isset($this->commObject->db->dbValues[$tid]['live_state']) || $this->commObject->db->dbValues[$tid]['live_state'] == 4 || $this->commObject->db->dbValues[$tid]['live_state'] == 5) {
                 $link['is_dead'] = null;
             }
         }
         if ($link['tagged_dead'] === true && $this->commObject->TAG_OVERRIDE == 1 && $this->commObject->db->dbValues[$tid]['live_state'] != 0) {
             $this->commObject->db->dbValues[$tid]['live_state'] = 0;
         }
         $links[$tid] = $link;
     }
     return $links;
 }