Exemplo n.º 1
0
         $parts[1] = trim($parts[1]);
     }
     $hash = crc32($parts[0] . $parts[1]);
     $pageList[$i] = array('src' => $page, 'hash' => $hash, 'wiki' => $parts[0], 'page' => $parts[1]);
     $wikiList[$parts[0]][] = $parts[1];
 }
 //api
 foreach (array_keys($wikiList) as $wiki) {
     $domain = $wt->metap[$wiki]["domain"];
     $apibase = "http://{$domain}/w/api.php?";
     $pages = array_values($wikiList[$wiki]);
     $data = array('action' => 'query', 'format' => 'json', 'prop' => 'info|revisions', 'inprop' => 'watched|watchers|notificationtimestamp|url', 'indexpageids' => '', 'converttitles' => '', 'titles' => implode('|', $pages));
     $query = $apibase . http_build_query($data);
     #print_r($apibase);
     #print_r($data);
     $res = json_decode($wt->gethttp($query))->query->pages;
     foreach ($res as $pageid => $row) {
         $hash = crc32($wiki . $row->title);
         foreach ($pageList as $i => $entry) {
             if ($hash == $entry["hash"]) {
                 try {
                     $diff = $wt->datediff(new DateTime($row->revisions[0]->timestamp));
                     $lastrev = $wt->dateFmt($row->revisions[0]->timestamp);
                     $err = false;
                 } catch (Exception $e) {
                     $err = true;
                 }
                 if ($err) {
                     $diff = $wt->datediff(null);
                     $lastrev = null;
                 }