Exemplo n.º 1
0
 /**
  * get image page url
  * @param integer $wikiId
  * @param integer $pageId
  * @return string image page URL
  */
 public static function getImagePage($wikiId, $pageId)
 {
     $app = F::app();
     $app->wf->ProfileIn(__METHOD__);
     $title = GlobalTitle::newFromId($pageId, $wikiId);
     $imagePage = $title instanceof Title ? $title->getFullURL() : '';
     $app->wf->ProfileOut(__METHOD__);
     return $imagePage;
 }
Exemplo n.º 2
0
 function execute($params = null)
 {
     global $IP, $wgWikiaLocalSettingsPath;
     /*  go with each supplied wiki and delete the supplied article
     			load all configs for particular wikis before doing so
     			(from wikifactory, not by _obsolete_ maintenance scripts
     			and from LocalSettings as worked on fps)
     		 */
     $this->mTaskID = $params->task_id;
     $oUser = User::newFromId($params->task_user_id);
     if ($oUser instanceof User) {
         $oUser->load();
         $this->mUser = $oUser->getName();
     } else {
         $this->log("Invalid user - id: " . $params->task_user_id);
         return true;
     }
     $data = unserialize($params->task_arguments);
     foreach ($data['page_list'] as $imageData) {
         $retval = "";
         list($wikiId, $imageId) = $imageData;
         $dbname = WikiFactory::getWikiByID($wikiId);
         if (!$dbname) {
             continue;
         }
         $title = GlobalTitle::newFromId($imageId, $wikiId);
         if (!is_object($title)) {
             $this->log('Apparently the article does not exist anymore');
             continue;
         }
         $city_url = WikiFactory::getVarValueByName("wgServer", $wikiId);
         if (empty($city_url)) {
             continue;
         }
         $city_path = WikiFactory::getVarValueByName("wgScript", $wikiId);
         $city_lang = WikiFactory::getVarValueByName("wgLanguageCode", $wikiId);
         $reason = wfMsgExt('imagereview-reason', array('language' => $city_lang));
         $sCommand = "perl /usr/wikia/backend/bin/run_maintenance --id={$wikiId} --script=wikia/deleteOn.php ";
         $sCommand .= "-- ";
         $sCommand .= "-u " . escapeshellarg($this->mUser) . " ";
         $sCommand .= "-t " . escapeshellarg($title->getPrefixedText()) . " ";
         if ($reason) {
             $sCommand .= "-r " . escapeshellarg($reason) . " ";
         }
         $actual_title = wfShellExec($sCommand, $retval);
         if ($retval) {
             $this->addLog('Article deleting error! (' . $city_url . '). Error code returned: ' . $retval . ' Error was: ' . $actual_title);
         } else {
             $this->addLog('Removed: <a href="' . $city_url . $city_path . '?title=' . wfEscapeWikiText($actual_title) . '">' . $city_url . $city_path . '?title=' . $actual_title . '</a>');
         }
         $this->flagUser($imageId, $wikiId);
         $this->flagWiki($wikiId);
     }
     return true;
 }
Exemplo n.º 3
0
 public function execute()
 {
     $this->dryRun = $this->hasOption('dry-run');
     $this->verbose = $this->hasOption('verbose');
     $wikiId = $this->getOption('wikiId', '');
     if (empty($wikiId)) {
         die("Error: Empty wiki id.\n");
     }
     $dbname = WikiFactory::IDtoDB($wikiId);
     if (empty($dbname)) {
         die("Error: Cannot find dbname.\n");
     }
     $pageLimit = 20000;
     $totalLimit = $this->getOption('limit', $pageLimit);
     if (empty($totalLimit) || $totalLimit < -1) {
         die("Error: invalid limit.\n");
     }
     if ($totalLimit == -1) {
         $totalLimit = $this->getTotalPages($dbname);
     }
     $maxSet = ceil($totalLimit / $pageLimit);
     $limit = $totalLimit > $pageLimit ? $pageLimit : $totalLimit;
     $totalPages = 0;
     for ($set = 1; $set <= $maxSet; $set++) {
         $cnt = 0;
         if ($set == $maxSet) {
             $limit = $totalLimit - $pageLimit * ($set - 1);
         }
         $offset = ($set - 1) * $pageLimit;
         $pages = $this->getAllPages($dbname, $limit, $offset);
         $total = count($pages);
         foreach ($pages as $page) {
             $cnt++;
             echo "Wiki {$wikiId} - Page {$page['id']} [{$cnt} of {$total}, set {$set} of {$maxSet}]: ";
             $title = GlobalTitle::newFromId($page['id'], $wikiId);
             if ($title instanceof GlobalTitle) {
                 $url = $title->getFullURL();
                 echo "{$url}\n";
                 if (!$this->dryRun) {
                     SquidUpdate::purge([$url]);
                 }
                 $this->success++;
             } else {
                 echo "ERROR: Cannot find global title for {$page['title']}\n";
             }
         }
         $totalPages = $totalPages + $total;
     }
     echo "\nWiki {$wikiId}: Total pages: {$totalPages}, Success: {$this->success}, Failed: " . ($totalPages - $this->success) . "\n\n";
 }
 /**
  * Get image list
  *
  * @param  integer $userId ID of the user to get the list for
  * @param  string  $from   Timestamp to get images before
  * @return array           List of images
  */
 public function getImageList($userId, $from = null)
 {
     wfProfileIn(__METHOD__);
     $imageList = [];
     $db = $this->getDatawareDB(DB_MASTER);
     $where = ['user_id' => $userId, 'state != ' . ImageReviewStatuses::STATE_DELETED . ' AND state != ' . ImageReviewStatuses::STATE_WIKI_DISABLED];
     $from = wfTimestampOrNull(TS_DB, $from);
     if (!empty($from)) {
         $where[] = 'last_edited < ' . $db->addQuotes($from);
     }
     $result = $db->select(['image_review'], ['wiki_id, page_id, state, flags, priority, last_edited'], $where, __METHOD__, ['ORDER BY' => 'last_edited desc', 'LIMIT' => self::LIMIT_IMAGES]);
     foreach ($result as $row) {
         $img = ImagesService::getImageSrc($row->wiki_id, $row->page_id);
         $wikiRow = WikiFactory::getWikiByID($row->wiki_id);
         $extension = pathinfo(strtolower($img['page']), PATHINFO_EXTENSION);
         $isThumb = true;
         if (empty($img['src'])) {
             // If we don't have a thumb by this point, we still need to display something, fall back to placeholder
             $globalTitle = GlobalTitle::newFromId($row->page_id, $row->wiki_id);
             if (is_object($globalTitle)) {
                 $img['page'] = $globalTitle->getFullUrl();
                 // @TODO this should be taken from the code instead of being hardcoded
                 $img['src'] = '//images.wikia.com/central/images/8/8c/Wikia_image_placeholder.png';
             } else {
                 // This should never happen
                 continue;
             }
         }
         if (in_array($extension, ['gif', 'svg'])) {
             $img = ImagesService::getImageOriginalUrl($row->wiki_id, $row->page_id);
             $isThumb = false;
         }
         $imageList[] = ['wikiId' => $row->wiki_id, 'pageId' => $row->page_id, 'state' => $row->state, 'src' => $img['src'], 'priority' => $row->priority, 'url' => $img['page'], 'isthumb' => $isThumb, 'flags' => $row->flags, 'wiki_url' => isset($wikiRow->city_url) ? $wikiRow->city_url : '', 'user_page' => '', 'last_edited' => $row->last_edited];
     }
     $db->freeResult($result);
     wfProfileOut(__METHOD__);
     return $imageList;
 }
 /**
  * @param int $imageId
  * @param string $destinationName
  * @param int $targetWikiId
  * @param int $sourceWikiId
  * @return array
  */
 public function uploadSingleImage($imageId, $destinationName, $targetWikiId, $sourceWikiId)
 {
     global $IP;
     $imageTitle = \GlobalTitle::newFromId($imageId, $sourceWikiId);
     $sourceFile = \GlobalFile::newFromText($imageTitle->getText(), $sourceWikiId);
     if ($sourceFile->exists()) {
         $sourceImageUrl = $sourceFile->getUrl();
     } else {
         $this->error('image is not accessible', ['city_id' => $sourceWikiId, 'title' => $imageTitle->getText()]);
         return ['status' => 1];
     }
     $cityUrl = \WikiFactory::getVarValueByName("wgServer", $targetWikiId);
     if (empty($cityUrl)) {
         $this->error('unable to get wgServer', ['wiki_id' => $targetWikiId]);
         return ['status' => 1];
     }
     $destinationName = \PromoImage::fromPathname($destinationName)->ensureCityIdIsSet($sourceWikiId)->getPathname();
     $command = "SERVER_ID={$targetWikiId} php {$IP}/maintenance/wikia/ImageReview/PromoteImage/upload.php" . ' --originalimageurl=' . escapeshellarg($sourceImageUrl) . ' --destimagename=' . escapeshellarg($destinationName) . ' --wikiid=' . escapeshellarg($sourceWikiId);
     $output = wfShellExec($command, $exitStatus);
     if ($exitStatus) {
         $this->error('uploadSingleImage error', ['command' => $command, 'city_url' => $cityUrl, 'output' => $output, 'exitStatus' => $exitStatus]);
     } else {
         $this->info('uploadSingleImage success', ['output' => $output, 'src_img_url' => $sourceImageUrl, 'dest_name' => $destinationName]);
     }
     $output = json_decode($output);
     return ['status' => $exitStatus, 'name' => $output->name, 'id' => $output->id];
 }
Exemplo n.º 6
0
<?php


ini_set( "include_path", dirname(__FILE__)."/.." );
//require_once( 'commandLine.inc' );

ini_set( 'display_errors', 'stdout' );
$options = array('help');
@require_once( '../../commandLine.inc' );

global $IP, $wgCityId, $wgDBname, $wgExternalDatawareDB;
$devboxuser = exec('hostname');

// $IP = '/home/pbablok/video/VideoRefactor/'; // HACK TO RUN ON SANDBOX
// echo( "$IP\n" );


$dbr = wfGetDB( DB_SLAVE, array(), $wgExternalDatawareDB );


$rows = $dbr->query( "SELECT * FROM video_interwiki" );

while( $file = $dbr->fetchObject( $rows ) ) {
	$title = GlobalTitle::newFromId( $file->article_id, $file->city_id );
	if ( $title )
		echo $title->getFullURL() . "\n";
}

?>
Exemplo n.º 7
0
 private static function allowResultsForEditedArticles($row, $from_db = false)
 {
     global $wgTTCache;
     wfProfileIn(__METHOD__);
     $result = array();
     $memkey = wfMemcKey(__METHOD__, 'oWikia', intval($row['wikia']));
     $oWikia = $wgTTCache->get($memkey);
     if (!isset($oWikia)) {
         $allowed = true;
         /*
          * check city list
          */
         $oWikia = WikiFactory::getWikiByID($row['wikia']);
         if (!$oWikia) {
             $allowed = false;
         }
         /*
          * check city lang
          */
         if ($allowed && !in_array($oWikia->city_lang, self::$allowedLanguages)) {
             $allowed = false;
         }
         /*
          * check sitename
          */
         if ($allowed) {
             $siteName = WikiFactory::getVarByName('wgSitename', $row['wikia']);
             if (!$siteName) {
                 $allowed = false;
             }
         }
         /*
          * check wikiname
          */
         $oWikia->city_sitename = "";
         if ($allowed) {
             $oWikia->city_sitename = unserialize($siteName->cv_value);
             if (!$oWikia->city_sitename) {
                 $allowed = false;
             } else {
                 foreach (self::$excludeNames as $search) {
                     $pos = stripos($oWikia->city_sitename, $search);
                     if ($pos !== false) {
                         $allowed = false;
                     }
                 }
             }
         }
         if (!$allowed) {
             $oWikia = 'ERROR';
         }
         # set in memc
         if ($oWikia != 'ERROR') {
             $wgTTCache->set($memkey, $oWikia, 60 * 60);
         }
     }
     if ($oWikia == 'ERROR') {
         wfProfileOut(__METHOD__);
         return false;
     }
     /* check article */
     $memkey = wfMemcKey(__METHOD__, 'article', intval($row['wikia']), intval($row['page']), $oWikia->city_dbname);
     $result = $from_db === true ? null : $wgTTCache->get($memkey);
     if (!isset($result)) {
         $allowedPage = true;
         /*
          * check Title && Wiki domain
          */
         $oGTitle = GlobalTitle::newFromId($row['page'], $row['wikia'], $oWikia->city_dbname);
         if (!is_object($oGTitle)) {
             $allowedPage = false;
         }
         if ($allowedPage) {
             $wikiaUrl = $oGTitle->getServer();
             $pageUrl = $oGTitle->getFullURL();
             $articleName = $oGTitle->getArticleName();
             $oRegexCore = new TextRegexCore(self::$excludeWikiDomainsKey, 0);
             if (is_object($oRegexCore)) {
                 $allowed = $oRegexCore->isAllowedText($wikiaUrl, "", false);
                 if (!$allowed) {
                     $allowedPage = false;
                 }
             }
         }
         /*
          * check hub name
          */
         if ($allowedPage) {
             $hubName = WikiFactoryHub::getInstance()->getCategoryName($row['wikia']);
             if (in_array($hubName, self::$excludeWikiHubs)) {
                 $allowedPage = false;
             }
         }
         /*
          * check article name
          */
         if ($allowedPage) {
             $oRegexArticles = new TextRegexCore(self::$excludeWikiArticles, 0);
             if (is_object($oRegexArticles)) {
                 $filterText = sprintf("%s:%s", $oWikia->city_dbname, $articleName);
                 $allowed = $oRegexArticles->isAllowedText($filterText, "", false);
                 if (!$allowed) {
                     $allowedPage = false;
                 }
             }
         }
         if (!$allowedPage) {
             $result = 'ERROR';
         } else {
             /*
              * ok
              */
             $result = array('wikia' => $oWikia->city_sitename, 'db' => $oWikia->city_dbname, 'hub' => $hubName, 'page_name' => $articleName, 'wikia_url' => $wikiaUrl, 'page_url' => $pageUrl, 'count' => $row['count']);
             # set in memc
             $wgTTCache->set($memkey, $result, 60 * 30);
         }
     }
     if ($result == 'ERROR') {
         $result = false;
     }
     wfProfileOut(__METHOD__);
     return $result;
 }
Exemplo n.º 8
0
 function uploadSingleImage($imageId, $destinationName, $targetWikiId, $sourceWikiId)
 {
     global $IP, $wgWikiaLocalSettingsPath;
     $retval = "";
     $imageTitle = GlobalTitle::newFromId($imageId, $sourceWikiId);
     $sourceImageUrl = null;
     $sourceFile = \GlobalFile::newFromText($imageTitle->getText(), $sourceWikiId);
     if ($sourceFile->exists()) {
         $sourceImageUrl = $sourceFile->getUrl();
     } else {
         $this->log('Apparently the image from city_id=' . $sourceWikiId . ' ' . $imageTitle->getText() . ' is unaccessible');
         return array('status' => 1);
     }
     $city_url = WikiFactory::getVarValueByName("wgServer", $targetWikiId);
     if (empty($city_url)) {
         $this->log('Apparently the server for ' . $targetWikiId . ' is not available via WikiFactory');
         return array('status' => 1);
     }
     $destinationName = PromoImage::fromPathname($destinationName)->ensureCityIdIsSet($sourceWikiId)->getPathname();
     $sCommand = "SERVER_ID={$targetWikiId} php {$IP}/maintenance/wikia/ImageReview/PromoteImage/upload.php";
     $sCommand .= " --originalimageurl=" . escapeshellarg($sourceImageUrl);
     $sCommand .= " --destimagename=" . escapeshellarg($destinationName);
     $sCommand .= " --wikiid=" . escapeshellarg($sourceWikiId);
     $sCommand .= " --conf {$wgWikiaLocalSettingsPath}";
     $logdata = ['command' => $sCommand, 'city_url' => $city_url];
     $output = wfShellExec($sCommand, $retval);
     $logdata['output'] = $output;
     $logdata['retval'] = $retval;
     if ($retval) {
         $this->log('Upload error! (' . $city_url . '). Error code returned: ' . $retval . ' Error was: ' . $output);
     } else {
         $this->log('Upload successful: ' . $output);
     }
     $output = json_decode($output);
     return array('status' => $retval, 'name' => $output->name, 'id' => $output->id);
 }
 public function fetchContributionsDataTables()
 {
     wfProfileIn(__METHOD__);
     //error_log( "start" );
     $aColumns = array('rev_timestamp', 'user_id', 'event_type', 'wiki_id', 'page_id', 'page_ns', 'rev_size', 'rev_id', 'ip');
     $dbr = $this->getDb(DB_SLAVE);
     $users = explode(",", $_GET['users']);
     $users = array_map("intval", $users);
     $limitS = 0;
     $limitL = 10;
     if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') {
         $limitS = mysql_real_escape_string($_GET['iDisplayStart']);
         $limitL = mysql_real_escape_string($_GET['iDisplayLength']);
     }
     $orderBy = array();
     if (isset($_GET['iSortCol_0'])) {
         for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) {
             if ($_GET['bSortable_' . intval($_GET['iSortCol_' . $i])] == "true") {
                 $orderBy[] = $aColumns[intval($_GET['iSortCol_' . $i])] . " " . mysql_real_escape_string($_GET['sSortDir_' . $i]);
             }
         }
     }
     $results = array();
     $table = array('events');
     $vars = $aColumns;
     $conds = array('user_id' => $users);
     if (!empty($orderBy)) {
         $options = array('LIMIT' => $limitL, 'OFFSET' => $limitS, 'ORDER BY' => implode(",", $orderBy));
     } else {
         $options = array('LIMIT' => $limitL, 'OFFSET' => $limitS);
     }
     $res = $dbr->select($table, 'COUNT(1) as c', $conds, __METHOD__);
     $row = $dbr->fetchRow($res);
     $iTotal = $row['c'];
     //error_log( $iTotal );
     $iFilteredTotal = $iTotal;
     $output = array("sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => array());
     $res = $dbr->select($table, $vars, $conds, __METHOD__, $options);
     while ($row = $dbr->fetchRow($res)) {
         $wiki = WikiFactory::getWikiById($row['wiki_id']);
         if (is_object($wiki) && $wiki->city_public != 0) {
             $wikiSitename = WikiFactory::getVarValueByName('wgSitename', $row['wiki_id']);
             $url = WikiFactory::getLocalEnvURL($wiki->city_url);
             $wikiLink = Xml::element('a', array('class' => 'wiki_name', 'href' => $url), $wikiSitename);
             $row['wiki_id'] = $wikiLink . Xml::element('span', array('class' => 'wiki_id'), $row['wiki_id']);
             if (!empty($row['user_id'])) {
                 $name = User::newFromId($row['user_id'])->getName();
             } else {
                 $name = long2ip($row['ip']);
             }
             $nameLink = Xml::element('a', array('class' => 'user_name', 'href' => GlobalTitle::newFromText($name, NS_USER, $wiki->city_id)->getFullURL()), $name);
             $row['user_id'] = $nameLink . Xml::element('span', array('class' => 'user_id'), $row['user_id']);
             global $wgDevelEnvironment;
             $pageId = $row['page_id'];
             $row['page_id'] = 'db not found' . Xml::element('span', array('class' => 'page_id'), $row['page_id']);
             if (!$wgDevelEnvironment) {
                 $title = GlobalTitle::newFromId($row['page_id'], $wiki->city_id);
                 if (is_object($title)) {
                     $pageLink = Xml::element('a', array('class' => 'page_name', 'href' => $title->getFullURL()), $title->getPrefixedText());
                     $row['page_id'] = $pageLink . Xml::element('span', array('class' => 'page_id'), $row['page_id']);
                 }
             }
         }
         $row['ip'] = long2ip($row['ip']);
         $rawtimestamp = wfTimestamp(TS_ISO_8601, $row['rev_timestamp']);
         $reltimestamp = Xml::element('div', array('class' => "timeago", 'title' => $rawtimestamp), '.');
         $row['rev_timestamp'] .= " " . $reltimestamp;
         $namespaceName = MWNamespace::getCanonicalName($row['page_ns']);
         if ($namespaceName) {
             $row['page_ns'] = $namespaceName;
         } elseif ($row['page_ns'] == NS_MAIN) {
             $row['page_ns'] = 'main';
         }
         switch ($row['event_type']) {
             case ScribeEventProducer::EDIT_CATEGORY_INT:
                 $row['event_type'] = 'edit';
                 break;
             case ScribeEventProducer::CREATEPAGE_CATEGORY_INT:
                 $row['event_type'] = 'create';
                 break;
             case ScribeEventProducer::DELETE_CATEGORY_INT:
                 $row['event_type'] = 'delete';
                 break;
             case ScribeEventProducer::UNDELETE_CATEGORY_INT:
                 $row['event_type'] = 'undelete';
         }
         $output_row = array();
         for ($i = 0; $i < count($aColumns); $i++) {
             $output_row[] = $row[$aColumns[$i]];
         }
         $output['aaData'][] = $output_row;
     }
     echo json_encode($output);
     $this->skipRendering();
     wfProfileOut(__METHOD__);
     return false;
 }
Exemplo n.º 10
0
 private function getEventsInfo()
 {
     wfProfileIn(__METHOD__);
     $where = array();
     $where['wiki_id'] = intval($this->mCityId);
     # bot
     if (empty($this->params['bot'])) {
         $where['user_is_bot'] = 'N';
     }
     # content
     if ($this->params['content'] == 1) {
         $where['is_content'] = 'Y';
     }
     # anons
     if (empty($this->params['anons'])) {
         $where[] = 'user_id > 0';
     }
     $db = $this->getDB();
     if (is_null($db)) {
         return false;
     }
     $this->profileDBIn();
     $oRes = $db->select('events', array('wiki_id', 'page_id', 'rev_id', 'log_id', 'user_id', 'user_is_bot', 'page_ns', 'is_content', 'is_redirect', 'ip', 'rev_timestamp', 'image_links', 'video_links', 'total_words', 'rev_size', 'wiki_lang_id', 'wiki_cat_id', 'event_type', 'event_date', 'media_type'), $where, __METHOD__, array('ORDER BY' => 'rev_timestamp DESC', 'LIMIT' => $this->params['limit'], 'OFFSET' => $this->params['offset']));
     $i = 0;
     $data = array();
     while ($row = $db->fetchObject($oRes)) {
         # wiki
         $oWiki = WikiFactory::getWikiByID($row->wiki_id);
         if (empty($oWiki)) {
             continue;
         }
         # server name
         $server = WikiFactory::getVarValueByName("wgServer", $row->wiki_id);
         # user
         $oUser = null;
         $username = long2ip($row->ip);
         if ($row->user_id > 0) {
             $oUser = User::newFromId($row->user_id);
             $username = $oUser->getName();
         }
         # page
         $url = "";
         if ($row->event_type == 1 || $row->event_type == 2) {
             // edit or create
             $oGTitle = GlobalTitle::newFromId($row->page_id, $row->wiki_id);
             if (is_object($oGTitle)) {
                 $url = $oGTitle->getFullURL();
             }
         }
         if (empty($url)) {
             if (is_object($oUser)) {
                 $url = $oUser->getUserPage()->getFullURL();
             } else {
                 $url = $server;
             }
         }
         # avatar
         $avatar = AvatarService::getAvatarUrl($username, 75);
         $data[$i] = array('wiki_id' => $row->wiki_id, 'wiki_url' => $server, 'page_id' => $row->page_id, 'page_url' => $url, 'namespace' => $row->page_ns, 'action' => $row->log_id > 0 ? 'remove' : 'edit', 'user_id' => $row->user_id, 'user_name' => $username, 'user_avatar' => $avatar, 'bot' => $row->user_is_bot, 'content' => $row->is_content, 'redirect' => $row->is_redirect, 'edited' => $row->rev_timestamp);
         $i++;
     }
     $db->freeResult($oRes);
     $this->profileDBOut();
     wfProfileOut(__METHOD__);
     return $data;
 }
				$dataBase = $fileRow->wiki_id ;


			}

			$fileURL = $wiki->city_url . "wiki/File:" . $fileRow->img_name ;
			echo $fileURL;

			$rows = $dbw->query( "SELECT distinct il_from FROM imagelinks WHERE il_to ='".mysql_real_escape_string($fileRow->img_name)."'");
			$rowCount = $rows->numRows();

			echo " (" . $rowCount ." backlinks) \n";

			while( $file = $dbw->fetchObject( $rows ) ) {
				$articleId = $file->il_from;
				$oTitle = GlobalTitle::newFromId($articleId, $fileRow->wiki_id); //::newFromId( $articleId );

				echo "* " . $oTitle->getFullURL() . " [contains File:{$fileRow->img_name} ] \n";
			}


			//$allChangesArticleURLs[ str_replace('http://localhost/', $wikiUrl, $oTitle->getFullURL()) ] = $fileRow->sanitized_title;
			//$allChangesArticleURLs[ $wikiUrl . 'wiki/'. str_replace(" ", "_",$fileRow->article_title) ] = $fileRow->sanitized_title;
		//}
}
if (count ($allChangesArticleURLs) > 0 ) {

	foreach( $allChangesArticleURLs as $url => $v ) {
		echo str_replace("::", ":", "$url -> Video:$v \n");
	}
}
Exemplo n.º 12
0
 /**
  * Checks if response code is different than 404. WE don't care about 503 etc as they might change
  * @param $wikiaid
  * @param $pageid
  * @return bool
  */
 protected function checkTitleExists($wikiaid, $pageid)
 {
     $t = GlobalTitle::newFromId($pageid, $wikiaid);
     return $t instanceof GlobalTitle && $t->exists();
 }
 protected function getNewsPageDOM()
 {
     $t = GlobalTitle::newFromId(self::WOOKIEENEWS_PAGE_ID, self::STAR_WARS_WIKIA_ID);
     $doc = new \DOMDocument();
     $doc->loadHTML(Http::request("GET", $t->getFullURL(), ['followRedirects' => true]));
     return $doc;
 }
Exemplo n.º 14
0
 /**
  * get image list
  * @return array imageList
  */
 public function getImageList($timestamp, $state = ImageReviewStatuses::STATE_UNREVIEWED, $order = self::ORDER_LATEST)
 {
     wfProfileIn(__METHOD__);
     $oDB = $this->getDatawareDB(DB_MASTER);
     $oDatabaseHelper = $this->getDatabaseHelper();
     $oResults = $oDatabaseHelper->selectImagesForList($this->getOrder($order), self::LIMIT_IMAGES_FROM_DB, $state);
     $rows = array();
     $updateWhere = array();
     $iconsWhere = array();
     while ($row = $oDB->fetchObject($oResults)) {
         $rows[] = $row;
         $updateWhere[] = "(wiki_id = {$row->wiki_id} and page_id = {$row->page_id})";
     }
     $oDB->freeResult($oResults);
     # update records
     if (count($updateWhere) > 0) {
         $review_start = wfTimestamp(TS_DB, $timestamp);
         switch ($state) {
             case ImageReviewStatuses::STATE_QUESTIONABLE:
                 $target_state = ImageReviewStatuses::STATE_QUESTIONABLE_IN_REVIEW;
                 break;
             case ImageReviewStatuses::STATE_REJECTED:
                 $target_state = ImageReviewStatuses::STATE_REJECTED_IN_REVIEW;
                 break;
             default:
                 $target_state = ImageReviewStatuses::STATE_IN_REVIEW;
         }
         $values = array('reviewer_id' => $this->user_id, 'review_start' => $review_start, 'state' => $target_state);
         if ($state == ImageReviewStatuses::STATE_QUESTIONABLE || $state == ImageReviewStatuses::STATE_REJECTED) {
             $values[] = "review_end = '0000-00-00 00:00:00'";
         }
         $oDB->update('image_review', $values, array(implode(' OR ', $updateWhere)), __METHOD__);
     }
     $oDB->commit();
     $imageList = $unusedImages = $aDeleteFromQueueList = [];
     foreach ($rows as $row) {
         $record = "(wiki_id = {$row->wiki_id} and page_id = {$row->page_id})";
         if (count($imageList) < self::LIMIT_IMAGES) {
             $bDisplayImage = true;
             $oImagePage = GlobalTitle::newFromId($row->page_id, $row->wiki_id);
             if ($oImagePage instanceof GlobalTitle !== true) {
                 $bDisplayImage = false;
                 $sReason = 'Page does not exist';
             } elseif ($oImagePage->isRedirect() === true) {
                 $bDisplayImage = false;
                 $sReason = 'Page is a redirect';
             } else {
                 $oImageGlobalFile = new GlobalFile($oImagePage);
                 if ($oImageGlobalFile->exists() === false) {
                     $bDisplayImage = false;
                     $sReason = 'File does not exist';
                 }
             }
             if ($bDisplayImage === true && $oImageGlobalFile instanceof GlobalFile) {
                 $sThumbUrl = $oImageGlobalFile->getUrlGenerator()->width(self::IMAGE_REVIEW_THUMBNAIL_SIZE)->height(self::IMAGE_REVIEW_THUMBNAIL_SIZE)->thumbnailDown()->url();
                 $aImageInfo = array('src' => $sThumbUrl, 'page' => $oImagePage->getFullUrl(), 'extension' => $oImageGlobalFile->getMimeType());
                 if (strpos('ico', $aImageInfo['extension'])) {
                     $iconsWhere[] = $record;
                     continue;
                 } else {
                     $isThumb = true;
                     // Vignette handles .gif and .svg files
                     $wikiRow = WikiFactory::getWikiByID($row->wiki_id);
                     $imageList[] = array('wikiId' => $row->wiki_id, 'pageId' => $row->page_id, 'state' => $row->state, 'src' => $aImageInfo['src'], 'url' => $aImageInfo['page'], 'priority' => $row->priority, 'flags' => $row->flags, 'isthumb' => $isThumb, 'wiki_url' => isset($wikiRow->city_url) ? $wikiRow->city_url : '');
                 }
             } else {
                 $aDeleteFromQueueList[] = ['wiki_id' => $row->wiki_id, 'page_id' => $row->page_id, 'reason' => $sReason];
                 continue;
             }
         } else {
             $unusedImages[] = $record;
         }
     }
     /**
      * Invalid images
      */
     if (!empty($aDeleteFromQueueList)) {
         $this->createDeleteFromQueueTask($aDeleteFromQueueList);
     }
     /**
      * Icons
      */
     if (!empty($iconsWhere)) {
         $aIconsValues = ['state' => ImageReviewStatuses::STATE_ICO_IMAGE];
         $aIconsWhere = [implode('OR', $iconsWhere)];
         $this->imageListAdditionalAction('icons', $oDB, $aIconsValues, $aIconsWhere);
     }
     /**
      * Unused images
      */
     if (!empty($unusedImages)) {
         $aUnusedValues = ['reviewer_id = null', 'state' => $state];
         $aUnusedWhere = [implode('OR', $unusedImages)];
         $this->imageListAdditionalAction('unused', $oDB, $aUnusedValues, $aUnusedWhere);
     }
     /**
      * Return valid images list
      */
     WikiaLogger::instance()->info("ImageReviewLog", ['method' => __METHOD__, 'message' => 'Fetched ' . count($imageList) . ' new images']);
     wfProfileOut(__METHOD__);
     return $imageList;
 }