Esempio n. 1
0
 /**
  * Blocks view source page & make it so that users cannot create/edit
  * pages that are on the takedown list.
  *
  * @param EditPage $editPage edit page instance
  * @return bool show edit page form?
  */
 public static function onAlternateEdit(EditPage $editPage)
 {
     $wg = F::app()->wg;
     $wf = F::app()->wf;
     $title = $editPage->getTitle();
     // Block view-source on the certain pages.
     if ($title->exists()) {
         // Look at the page-props to see if this page is blocked.
         if (!$wg->user->isAllowed('editlyricfind')) {
             // some users (staff/admin) will be allowed to edit these to prevent vandalism/spam issues.
             $removedProp = $wf->GetWikiaPageProp(WPP_LYRICFIND_MARKED_FOR_REMOVAL, $title->getArticleID());
             if (!empty($removedProp)) {
                 $wg->Out->addHTML(Wikia::errorbox(wfMessage('lyricfind-editpage-blocked')));
                 $blockEdit = true;
             }
         }
     } else {
         // Page is being created. Prevent this if page is prohibited by LyricFind.
         $blockEdit = LyricFindTrackingService::isPageBlockedViaApi($amgId = "", $gracenoteId = "", $title->getText());
         if ($blockEdit) {
             $wg->Out->addHTML(Wikia::errorbox(wfMessage('lyricfind-creation-blocked')));
         }
     }
     return !$blockEdit;
 }
Esempio n. 2
0
 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");
     }
 }
Esempio n. 3
0
 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')));
     }
 }
Esempio n. 4
0
 function formatError($err)
 {
     $out = '';
     if (is_array($err)) {
         $out .= '<div class="errorbox">';
         foreach ($err as $value) {
             $out .= $value . "<br/>";
         }
         $out .= '</div><br style="clear: both;">';
     } else {
         $out .= Wikia::errorbox($err);
     }
     return $out;
 }
</form>
</fieldset>

<?php 
$vars = array();
$vars['L'] = array('city' => 0, '*' => null);
/****************************************************/
/*
get left stuff
*/
/****************************************************/
$vars['L']['city'] = $wiki->city_id;
$vars['L']['*'] = WikiFactory::getVariables("cv_id", $vars['L']['city'], 0, true);
if ($to && $to == $wiki->city_id) {
    $to = null;
    print Wikia::errorbox("cant compare to self");
}
#do we still have a R side?
if ($to) {
    /****************************************************/
    /*
    get right stuff
    */
    /****************************************************/
    $vars['R']['city'] = $to;
    $vars['R']['*'] = WikiFactory::getVariables("cv_id", $vars['R']['city'], 0, true);
}
$combined = array();
foreach ($vars as $side => $data) {
    foreach ($data['*'] as $item) {
        $combined[$item->cv_id]['*'] = $item->cv_name;
 function getCustomSettings()
 {
     global $wgExternalSharedDB;
     $city_list = 'city_list';
     $cv = 'city_variables';
     $cv_pool = 'city_variables_pool';
     $dbr = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
     $res = $dbr->select(array($city_list, $cv, $cv_pool), array('cv_value', 'city_url', 'city_id'), array("{$city_list}.city_id = {$cv}.cv_city_id", "{$cv}.cv_variable_id = {$cv_pool}.cv_id", "{$cv_pool}.cv_id     = '{$this->varid}'"), __METHOD__);
     $variable = WikiFactory::getVarById($this->varid, 0);
     $data = array();
     $values = array();
     $row_count = $dbr->numRows($res);
     if ($row_count == 0) {
         $dbr->freeResult($res);
         $out = "no settings found in WikiFactory\n";
         return $out;
     }
     $this->over_limit = false;
     if ($row_count > 1000) {
         $this->over_limit = true;
     }
     if ($this->disable_limit) {
         $this->over_limit = false;
     }
     while ($row = $dbr->fetchObject($res)) {
         $city_id = $row->city_id;
         $cv_value = unserialize($row->cv_value);
         $nom_value = $cv_value;
         if (is_array($cv_value)) {
             asort($cv_value);
             $cv_value = join(', ', $cv_value);
             $nom_value = 'array';
         } elseif (is_bool($cv_value)) {
             $cv_value = $cv_value ? 'true' : 'false';
             $nom_value = $cv_value;
         } else {
             #$cv_value = 'Error. Not an array?!?';
         }
         if (preg_match('/http:\\/\\/([\\w\\.\\-]+)\\//', $row->city_url, $matches)) {
             $city_url = str_ireplace('.wikia.com', '', $matches[1]);
         } else {
             $city_url = 'Error. Unknown wiki?!?';
         }
         if (!empty($cv_value)) {
             if (count($data) <= 1000 || $this->disable_limit) {
                 $data[] = array('value' => $cv_value, 'url' => $city_url, 'city' => $city_id);
             }
             $values[] = $nom_value;
         }
     }
     $dbr->freeResult($res);
     $acv = array_count_values($values);
     asort($acv);
     unset($values);
     global $wgCityId;
     if ($wgCityId == 177) {
         #we're on central (or are faking it), so link locallly
         $WF_title = SpecialPage::getTitleFor('WikiFactory');
         $wie_title = SpecialPage::getTitleFor('WhereIsExtension');
     } else {
         #we're away from home, so make sure the links link back right
         $WF_title = GlobalTitle::newFromText('WikiFactory', NS_SPECIAL, 177);
         $wie_title = GlobalTitle::newFromText('WhereIsExtension', NS_SPECIAL, 177);
     }
     $wie_query = array('var' => $variable->cv_variable_id, 'searchType' => 'full', 'val' => 0);
     #likeValue is appended manually inside the template;
     $wie_base = $wie_title->getFullURL(http_build_query($wie_query));
     unset($wie_query);
     unset($wie_title);
     $limit_message = '';
     if ($this->over_limit) {
         $limit_message = Wikia::errorbox("Warning, this variable has {$row_count} entries. Only first 1000 shown");
         $QS = http_build_query(array('varid' => $variable->cv_variable_id, 'nolimit' => 1));
         $limit_message .= "<a href='/index.php?title=Special:WikiFactoryReporter&{$QS}'>Click here to load all results</a>\n";
     }
     $groups = WikiFactory::getGroups();
     $variable->var_group = $groups[$variable->cv_variable_group];
     unset($groups);
     $sprites = array('search' => "<img src='" . wfBlankImgUrl() . "' class='sprite search' alt='search' height='16' width='22'>", 'edit' => "<img src='" . wfBlankImgUrl() . "' class='sprite edit-pencil' alt='edit'>");
     $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $tmpl->set_vars(array('th' => array($variable->cv_name, 'wiki', 'city_id'), 'data' => $data, 'variable' => $variable, 'acv' => $acv, 'wf_base' => $WF_title->getFullUrl(), 'limit_message' => $limit_message, 'sprites' => $sprites, 'wie_base' => $wie_base));
     $out = $tmpl->render('reporter');
     return $out;
 }
 /**
  * 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();
     }
 }
Esempio n. 9
0
 function addError($err)
 {
     global $wgOut;
     if (is_array($err)) {
         $wgOut->addHTML('<div class="errorbox">');
         foreach ($err as $value) {
             $wgOut->addHTML($value . "<br>");
         }
         $wgOut->addHTML('</div><br style="clear: both;">');
     } else {
         $wgOut->addHTML(Wikia::errorbox($err));
     }
 }