public function execute($subpage) { global $wgOut, $wgRequest, $wgCookiePrefix; wfProfileIn(__METHOD__); $this->mRequest = RequestContext::getMain()->getRequest(); $this->mOut = RequestContext::getMain()->getOutput(); $this->setHeaders(); $this->mTitle = SpecialPage::getTitleFor("Datacenter"); /** * if posted change cookie value */ if ($this->mRequest->wasPosted()) { $val = $this->mRequest->getVal("iowacookie", 0); if ($val == 2) { $this->mOut->addHTML(Wikia::successbox("cookie set to sjc")); $this->mRequest->response()->setcookie($this->mCookieName, "sjc"); $this->mCookie = "sjc"; } elseif ($val == 1) { $this->mOut->addHTML(Wikia::successbox("cookie set to iowa")); $this->mRequest->response()->setcookie($this->mCookieName, "iowa"); $this->mCookie = "iowa"; } elseif ($val == 3) { $this->mOut->addHTML(Wikia::successbox("cookie set to ash")); $this->mRequest->response()->setcookie($this->mCookieName, "ash"); $this->mCookie = "ash"; } elseif ($val == 4) { $this->mOut->addHTML(Wikia::successbox("cookie set to closest")); $this->mRequest->response()->setcookie($this->mCookieName, "closest"); $this->mCookie = "closest"; } else { $this->mOut->addHTML(Wikia::successbox("cookie removed")); $this->mRequest->response()->setcookie($this->mCookieName, "sjc", 1); $this->mCookie = false; } } else { /** * show current value of cookie */ if (isset($_COOKIE[$wgCookiePrefix . $this->mCookieName])) { $this->mCookie = $_COOKIE[$wgCookiePrefix . $this->mCookieName]; } } $this->mOut->addHTML("Current value of cookie {$wgCookiePrefix}{$this->mCookieName}: <em>" . ($this->mCookie ? $this->mCookie : "not set") . "</em>"); /** * show input chooser */ $this->mOut->addHTML(Xml::openElement("form", array("action" => $this->mTitle->getFullURL(), "method" => "post"))); $select = new XMLSelect("iowacookie", "iowacookie"); $select->addOption("Switch to the closest", 4); $select->addOption("Switch to San Jose", 2); $select->addOption("Switch to Iowa", 1); $select->addOption("Switch to Ashburn", 3); $select->addOption("Remove preferences", 0); $this->mOut->addHTML($select->getHTML()); $this->mOut->addHTML(Xml::submitButton("submit")); $this->mOut->addHTML(Xml::closeElement("form")); wfProfileOut(__METHOD__); }
/** * @access public * @static */ public static function customSpecialStatistics(&$specialpage, &$text) { global $wgOut, $wgDBname, $wgLang, $wgRequest, $wgTitle, $wgUser, $wgCityId, $wgHTTPProxy; /** * read json file with dumps information */ $tmpl = new EasyTemplate(dirname(__FILE__) . "/templates/"); $index = array(); $proxy = array(); if (isset($wgHTTPProxy) && $wgHTTPProxy) { $proxy["proxy"] = $wgHTTPProxy; } else { $proxy["noProxy"] = true; } $url = self::getUrl($wgDBname, "index.json"); $json = Http::get($url, 5, $proxy); if ($json) { wfDebug(__METHOD__ . ": getting informations about last dump from {$url} succeded\n"); $index = (array) json_decode($json); } else { wfDebug(__METHOD__ . ": getting informations about last dump from {$url} failed\n"); } /** * get last dump request timestamp */ $wiki = WikiFactory::getWikiByID($wgCityId); if (strtotime(wfTimestampNow()) - strtotime($wiki->city_lastdump_timestamp) > 7 * 24 * 60 * 60) { $tmpl->set("available", true); } else { $tmpl->set("available", false); } $tmpl->set("title", $wgTitle); $tmpl->set("isAnon", $wgUser->isAnon()); $tmpl->set("curr", array("url" => self::getUrl($wgDBname, "pages_current.xml.gz"), "timestamp" => !empty($index["pages_current.xml.gz"]->mwtimestamp) ? $wgLang->timeanddate($index["pages_current.xml.gz"]->mwtimestamp) : "unknown")); $tmpl->set("full", array("url" => self::getUrl($wgDBname, "pages_full.xml.gz"), "timestamp" => !empty($index["pages_full.xml.gz"]->mwtimestamp) ? $wgLang->timeanddate($index["pages_full.xml.gz"]->mwtimestamp) : "unknown")); $tmpl->set("index", $index); $text .= $tmpl->render("dod"); if ($wgRequest->wasPosted() && !$wgUser->isAnon()) { self::sendMail(); wfDebug(__METHOD__, ": request for database dump was posted\n"); $text = Wikia::successbox(wfMsg("dump-database-request-requested")) . $text; } return true; }
/** * @access public * @static */ public static function customSpecialStatistics(&$specialpage, &$text) { global $wgOut, $wgDBname, $wgLang, $wgRequest, $wgTitle, $wgUser, $wgCityId, $wgHTTPProxy; $tmpl = new EasyTemplate(dirname(__FILE__) . "/templates/"); /** * get last dump request timestamp */ $wiki = WikiFactory::getWikiByID($wgCityId); if (strtotime(wfTimestampNow()) - strtotime($wiki->city_lastdump_timestamp) > 7 * 24 * 60 * 60) { $tmpl->set("available", true); } else { $tmpl->set("available", false); } $tmpl->set("title", $wgTitle); $tmpl->set("isAnon", $wgUser->isAnon()); $dumpInfo = self::getLatestDumpInfo($wgCityId); $sTimestamp = $dumpInfo ? $dumpInfo['timestamp'] : false; $sDumpExtension = self::getExtensionFromCompression($dumpInfo ? $dumpInfo['compression'] : false); $tmpl->set('nolink', false); if (empty($sTimestamp)) { $sTimestamp = wfMessage('dump-database-last-unknown')->escaped(); $tmpl->set('nolink', true); } $tmpl->set("curr", array("url" => 'http://s3.amazonaws.com/wikia_xml_dumps/' . self::getPath("{$wgDBname}_pages_current.xml{$sDumpExtension}"), "timestamp" => $sTimestamp)); $tmpl->set("full", array("url" => 'http://s3.amazonaws.com/wikia_xml_dumps/' . self::getPath("{$wgDBname}_pages_full.xml{$sDumpExtension}"), "timestamp" => $sTimestamp)); // The Community Central's value of the wgDumpRequestBlacklist variable contains an array of users who are not allowed to request dumps with this special page. $aDumpRequestBlacklist = (array) unserialize(WikiFactory::getVarByName('wgDumpRequestBlacklist', WikiFactory::COMMUNITY_CENTRAL)->cv_value); $bIsAllowed = $wgUser->isAllowed('dumpsondemand') && !in_array($wgUser->getName(), $aDumpRequestBlacklist); $tmpl->set('bIsAllowed', $bIsAllowed); $text .= $tmpl->render("dod"); if ($wgRequest->wasPosted() && $bIsAllowed) { self::queueDump($wgCityId); wfDebug(__METHOD__, ": request for database dump was posted\n"); $text = Wikia::successbox(wfMsg("dump-database-request-requested")) . $text; } return true; }
private function doPost() { global $wgOut, $wgRequest, $wgMemc; $method = $wgRequest->getVal('method'); if ($method == 'by_id') { $new_id = $wgRequest->getInt('new_sysop_id'); if (empty($new_id) || $new_id < 0) { $wgOut->addHTML(Wikia::errorbox("bad input")); return false; } if (!User::whois($new_id)) { $wgOut->addHTML(Wikia::errorbox("no user with that id")); return false; } #$wgOut->addHTML( "text['new_sysop_id']=" . $new_id . "<br/>\n"); // BugId:41817 - if ( 1 == $new_id ) { notify Mix } if (1 == $new_id) { $oTo = $oFrom = new MailAddress('*****@*****.**'); UserMailer::send($oTo, $oFrom, 'BugId:41817 Occurrence Report', sprintf("File: %s\nLine: %s, Date: %s\nOutput: %s", __FILE__, __LINE__, date('Y-m-d H:i:s'), var_export($new_id, true))); } $wgMemc->set(wfMemcKey("last-sysop-id"), $new_id, 86400); $wgOut->addHTML(Wikia::successbox("new value saved")); } elseif ($method == 'by_name') { $new_text = $wgRequest->getText('new_sysop_text'); if (empty($new_text)) { $wgOut->addHTML(Wikia::errorbox("bad input")); return false; } $new_id = User::idFromName($new_text); if (empty($new_id)) { $wgOut->addHTML(Wikia::errorbox("name not found as user")); return false; } #$wgOut->addHTML( "text['new_sysop_text']=[" . $new_text . "]<br/>\n"); // BugId:41817 - if ( 1 == $new_id ) { notify Mix } if (1 == $new_id) { $oTo = $oFrom = new MailAddress('*****@*****.**'); UserMailer::send($oTo, $oFrom, 'BugId:41817 Occurrence Report', sprintf("File: %s\nLine: %s, Date: %s\nOutput: %s", __FILE__, __LINE__, date('Y-m-d H:i:s'), var_export($new_id, true))); } $wgMemc->set(wfMemcKey("last-sysop-id"), $new_id, 86400); $wgOut->addHTML(Wikia::successbox("new value saved")); } elseif ($method == 'clear') { $wgMemc->delete(wfMemcKey("last-sysop-id")); $wgOut->addHTML(Wikia::successbox("cleared")); } else { $wgOut->addHTML("unknown method [{$method}] used to POST<br/>\n"); } }
private function process() { global $wgOut, $wgRequest; $wgOut->addHTML("<hr/>\n"); $username = trim($this->mTarget); if ($username == '') { $wgOut->addWikiMsg('cloakcheck-process-empty'); return; } $user = User::newFromName($username); if ($user === null || $user->getId() === 0) { $wgOut->addWikiMsg('cloakcheck-process-notexist'); return; } $wgOut->addWikiMsg('cloakcheck-process-username', $username); /***** account age *****/ $uReg = strtotime($user->getRegistration()); $cutoff = strtotime($this->mMinAge); if ($uReg < $cutoff) { $wgOut->addHTML(Wikia::successbox(wfMsg('cloakcheck-process-accountage-yes'))); } else { $wgOut->addHTML(Wikia::errorbox(wfMsg('cloakcheck-process-accountage-no'))); } /***** email *****/ if ($user->isEmailConfirmed()) { $wgOut->addHTML(Wikia::successbox(wfMsg('cloakcheck-process-emailconf-yes'))); } else { $wgOut->addHTML(Wikia::errorbox(wfMsg('cloakcheck-process-emailconf-no'))); } /***** global edits *****/ if ($this->getGlobalEdits($user->getId()) >= $this->mMinEC) { $wgOut->addHTML(Wikia::successbox(wfMsg('cloakcheck-process-edits-yes'))); } else { $wgOut->addHTML(Wikia::errorbox(wfMsg('cloakcheck-process-edits-no'))); } }
function submitForm() { global $wgRequest, $wgOut, $wgUser; #--- # used fields # "task-c-wiki" - name of closed wiki # "task-export" - checkbox, export articles to parent # "task-p-wiki" - name of parent wiki $bExport = $wgRequest->getCheck("task-export"); $sCWiki = self::normalizeName($wgRequest->getText("task-c-wiki")); $sPWiki = self::normalizeName($wgRequest->getText("task-p-wiki")); #--- check if closed wiki is valid $iCWikiId = self::checkWiki($sCWiki); #--- check if parent wiki is valid $iPWikiId = self::checkWiki($sPWiki); if (empty($iCWikiId) || empty($iPWikiId) && $bExport === true) { $aFormData = array(); $aFormData["errors"] = array(); $aFormData["values"] = array("task-export" => $bExport, "task-c-wiki" => $sCWiki, "task-p-wiki" => $sPWiki); if (empty($iCWikiId)) { $aFormData["errors"]["task-c-wiki"] = "Name <em>{$sCWiki}</em> is not valid wikia domain."; } if (empty($iPWikiId) && $bExport === true) { $aFormData["errors"]["task-p-wiki"] = "Name <em>{$sPWiki}</em> is not valid wikia domain."; } return $aFormData; } else { #--- all correct, put data into database $this->mTaskID = $this->createTask(array("export" => $bExport, "source_wikia_id" => $iCWikiId, "target_wikia_id" => $iPWikiId)); $wgOut->addHTML(Wikia::successbox("Task added")); } return true; }
/** * doMultiRemoveTags * * @access private * @author uberfuzzy@wikia-inc.com * * @return text message (use Wikia::*box functions) */ private function doMultiRemoveTags() { /* working data is stored in object prior to call $this->mRemoveTag; has the tag to remove $this->mRemoveTags; has int array of wiki id to remove from */ /* in theory, these should never trigger, but BSTS */ if (empty($this->mRemoveTag)) { return Wikia::errorbox("no tag to remove?"); } if (empty($this->mRemoveTags)) { return Wikia::errorbox("no items to remove?"); } /* turn the tag string into the tag id */ $tagID = WikiFactoryTags::idFromName($this->mRemoveTag); if ($tagID === false) { return Wikia::errorbox("tag [{$this->mRemoveTag}] doesnt exist"); } /* to get list of all wikis with this tag, and later, use this to cache clear */ $tagsQuery = new WikiFactoryTagsQuery($this->mRemoveTag); $fails = array(); foreach ($this->mRemoveTags as $wkid) { $oTag = new WikiFactoryTags($wkid); $ret = $oTag->removeTagsById(array($tagID)); if ($ret === false) { $fails[] = $wkid; } } /* force dump of the tag_map in memcache */ $tagsQuery->clearCache(); /* since we /hopefully/ removed some tags from wikis, force the search results for this pageload to be empty. */ $this->mTagWikiIds = array(); #print "(forcing mTagWikiIds to null at ".gmdate('r').")"; if (empty($fails)) { return Wikia::successbox("ok!"); } else { return Wikia::errorbox("ok, but failed at " . count($fails) . " wikis" . " (" . implode(", ", $fails) . ")"); } }
/** * execute * * main entry point * @author eloy@wikia.com * * @param string $subpage: subpage of Title * * @return nothing */ public function execute($subpage) { global $wgUser, $wgOut, $wgRequest, $wgWikiaBatchTasks; if ($wgUser->isBlocked()) { throw new UserBlockedError($this->getUser()->mBlock); } if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } if (!$wgUser->isAllowed('taskmanager')) { $this->displayRestrictionError(); return; } $wgOut->setPageTitle(wfMsg('taskmanager_title')); $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->setArticleRelated(false); $this->mTitle = Title::makeTitle(NS_SPECIAL, "TaskManager"); $this->mAction = $wgRequest->getVal("action"); if ($this->mAction) { switch ($this->mAction) { case "task": #--- get task type and class $sClass = $wgRequest->getText("wpType", null); if (is_subclass_of($sClass, "BatchTask")) { $oObject = new $sClass(); #--- get form for this class $wgOut->addHTML($oObject->getForm($this->mTitle)); } $wgOut->addHTML(XML::element("a", array("href" => $this->mTitle->getLocalUrl(), wfMsg("taskmanager_tasklist")))); break; case "save": #--- get task type and class $sType = $wgRequest->getText("wpType", null); $sClass = $wgWikiaBatchTasks[$sType]; if (is_subclass_of($sClass, "BatchTask")) { $oObject = new $sClass(); $aFormData = $oObject->submitForm(); if ($aFormData === true) { #--- all correct, show new task form $this->loadTaskForm(); } else { #--- errors, show again form for choosen task $wgOut->addHTML($oObject->getForm($this->mTitle, $aFormData)); } } $wgOut->addHTML(Wikia::linkTag($this->mTitle->getLocalUrl(), wfMsg("taskmanager_tasklist"))); break; /** * get task form for given id, NOTE - it should check if * task is editable or not */ /** * get task form for given id, NOTE - it should check if * task is editable or not */ case "edit": $oTask = $this->loadTaskData($wgRequest->getVal("id")); #--- nothing so far break; /** * remove task from database, carefull - without confirmation * so far */ /** * remove task from database, carefull - without confirmation * so far */ case "remove": #--- check if task exists $oTask = $this->loadTaskData($wgRequest->getVal("id")); if (!empty($oTask->task_id)) { $this->removeTask($oTask->task_id); $wgOut->addHTML(Wikia::successbox("Task nr {$oTask->task_id} removed")); } else { $wgOut->addHTML(Wikia::errorbox("Task doesn't exists")); } $this->loadTaskForm(); $this->loadPager(); break; /** * start task, possible only when task in TASK_WAITING state */ /** * start task, possible only when task in TASK_WAITING state */ case "start": #--- check if task exists $oTask = $this->loadTaskData($wgRequest->getVal("id")); if (!empty($oTask->task_id) && $oTask->task_status == TASK_WAITING) { $this->changeTaskStatus($oTask->task_id, TASK_QUEUED); $wgOut->addHTML(Wikia::successbox("Task nr {$oTask->task_id} queued")); } else { $wgOut->addHTML(Wikia::errorbox("Task doesn't exists")); } $this->loadTaskForm(); $this->loadPager(); break; /** * stop task, possible only when task in TASK_QUEUED state */ /** * stop task, possible only when task in TASK_QUEUED state */ case "stop": #--- check if task exists $oTask = $this->loadTaskData($wgRequest->getVal("id")); if (!empty($oTask->task_id) && $oTask->task_status == TASK_QUEUED) { $this->changeTaskStatus($oTask->task_id, TASK_WAITING); $wgOut->addHTML(Wikia::successbox("Task nr {$oTask->task_id} paused")); } else { $wgOut->addHTML(Wikia::errorbox("Task doesn't exists")); } $this->loadTaskForm(); $this->loadPager(); break; /** * terminate running task */ /** * terminate running task */ case "finish": $oTaskData = $this->loadTaskData($wgRequest->getVal("id")); if (!empty($oTaskData->task_id)) { $oTask = BatchTask::newFromData($oTaskData); $oTask->closeTask(); $wgOut->addHTML(Wikia::successbox("Task nr {$oTaskData->task_id} stopped")); } else { $wgOut->addHTML(Wikia::errorbox("Task doesn't exists")); } $this->loadTaskForm(); $this->loadPager(); break; /** * show log for closed task */ /** * show log for closed task */ case "log": #--- check if task exists $oTaskData = $this->loadTaskData($wgRequest->getVal("id")); if (!empty($oTaskData->task_id)) { $oTask = BatchTask::newFromData($oTaskData); $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/"); $oTmpl->set_vars(array("events" => $oTask->getLog(true))); $wgOut->addHTML($oTmpl->render("log")); } $this->loadTaskForm(); $this->loadPager(); break; /** * add a restore task for this specific task * currently it works only for COMPLETED MultiDelete tasks */ /** * add a restore task for this specific task * currently it works only for COMPLETED MultiDelete tasks */ case "undo": #--- check if task exists $oTaskData = $this->loadTaskData($wgRequest->getVal("id")); if (!empty($oTaskData->task_id)) { $oTask = BatchTask::newFromData($oTaskData); /* add a new restore task here todo differentiate between single and multi mode */ $thisTask = new MultiRestoreTask(true); if (TASK_FINISHED_UNDO != $oTaskData->task_status) { $arguments = unserialize($oTaskData->task_arguments); $thisTask->mArguments = $arguments; $thisTask->mMode = $arguments["mode"]; $thisTask->mAdmin = $wgUser->getName(); $thisTask->mMotherTask = $oTaskData->task_id; $submit_id = $thisTask->submitForm(); $wgOut->addHTML(Wikia::successbox("Task nr {$oTaskData->task_id} was scheduled to be undone")); $this->changeTaskStatus($oTaskData->task_id, TASK_FINISHED_UNDO); } else { $wgOut->addHTML(Wikia::errorbox("Task {$oTaskData->task_id} was already set to undo")); } } $this->loadTaskForm(); $this->loadPager(); break; /** * default action, just show task form */ /** * default action, just show task form */ default: $this->loadTaskForm(); break; } } else { $this->loadTaskForm(); $this->loadPager(); } }
/** * submitForm * * Creates the corresponding entry in the TaskManager queue. * * @return boolean true * @access public */ function submitForm() { global $wgOut, $wgUser, $wgRequest; $wikiDomain = Wikia::fixDomainName($wgRequest->getText('task-usp-wiki')); // check if the wiki exists $dbr = WikiFactory::db(DB_MASTER); $oRow = $dbr->selectRow(array('city_list', 'city_domains'), array('city_public', 'city_list.city_id'), array('city_list.city_id = city_domains.city_id', 'city_domain' => $wikiDomain), __METHOD__); if (empty($oRow->city_id) || 1 != $oRow->city_public) { return false; } $wikiId = $oRow->city_id; if (!empty($wikiId)) { $this->mTaskID = $this->createTask(array('wikiId' => $wikiId)); } $wgOut->addHTML(Wikia::successbox('Task added')); return true; }
/** * submitForm() * * Tasks with forms execute this method to put params from form to database * * @author eloy@wikia * @access public * * @return mixed: true if success, submitted params if error */ function submitForm() { global $wgRequest, $wgOut; $iTaskID = $wgRequest->getVal("task-source-task-id"); $sTargetWiki = $wgRequest->getVal("task-target-wiki"); $sTargetWikiID = WikiFactory::DomainToID($sTargetWiki); if (!is_numeric($iTaskID) || !is_numeric($sTargetWikiID) || is_null($sTargetWikiID)) { $aFormData = array(); $aFormData["values"] = array("task-source-task-id" => $iTaskID, "task-target-wiki" => $sTargetWiki); if (!is_numeric($iTaskID)) { $aFormData["errors"]["task-source-task-id"] = "This field must not be empty and must be integer."; } if (!is_numeric($sTargetWikiID) || is_null($sTargetWikiID)) { $aFormData["errors"]["task-target-wiki"] = "This field must not be empty. Domain must be wiki.factory domain."; } return $aFormData; } else { $this->createTask(array("source-task-id" => $iTaskID, "target-wiki-id" => $sTargetWikiID)); $wgOut->addHTML(Wikia::successbox("Task added")); return true; } }
/** * submitForm * * Creates the corresponding entry in the TaskManager queue. * * @return boolean true * @access public */ function submitForm() { global $wgOut; $this->mTaskID = $this->createTask(array()); $wgOut->addHTML(Wikia::successbox('Task added')); return true; }
#print "have to write [cns]<br/>\n"; ksort($cns); WikiFactory::setVarByName('wgContentNamespaces', $wiki->city_id, $cns, $reason); print Wikia::successbox("wgContentNamespaces saved"); } if ($write['nssd']) { #print "have to write [nssd]<br/>\n"; ksort($nssd); WikiFactory::setVarByName('wgNamespacesToBeSearchedDefault', $wiki->city_id, $nssd, $reason); print Wikia::successbox("wgNamespacesToBeSearchedDefault saved"); } if ($write['nssub']) { #print "have to write [nssub]<br/>\n"; ksort($nssub); WikiFactory::setVarByName('wgNamespacesWithSubpagesLocal', $wiki->city_id, $nssub, $reason); print Wikia::successbox("wgNamespacesWithSubpagesLocal saved"); } /***********************************************************************************************/ } ?> <form name="eznsForm" method="POST"> <table class='WikiaTable'> <caption>current namespace settings</caption> <tr> <th>wgExtraNamespaces</th> <th>wgExtraNamespacesLocal</th> </tr> <tr> <td style='vertical-align: top;'> <?php if (!empty($ens)) {