try { $pageClass = $site->initPage($article, null, !$wgRequest->getSafeVal('getBool', 'nofollowredir')); } catch (BadTitle $e) { WebTool::toDie($phptemp->get_config_vars('nosuchpage', $e->getTitle())); } catch (Exception $e) { WebTool::toDie($e->getMessage()); } //Check for page existance $phptemp->assign("page", $pageClass->get_title()); if (!$pageClass->exists()) { WebTool::toDie($phptemp->get_config_vars('nosuchpage', $pageClass->get_title())); } //Start doing the DB request $history = Base::getVars($pageClass, $site, $wgRequest->getSafeVal('getBool', 'nofollowredir'), $wgRequest->getSafeVal('getBool', 'begin') ? $wgRequest->getSafeVal('begin') : false, $wgRequest->getSafeVal('getBool', 'end') ? $wgRequest->getSafeVal('end') : false); if (!count($history)) { WebTool::toDie($phptemp->get_config_vars('norevisions')); } if (count($history) == 50000) { $content->assign("notice", $phptemp->get_config_vars('toomanyrevisions')); } //Get logs, for Edits over Time graph $data = Base::parseHistory($history, $wgRequest->getSafeVal('getBool', 'begin') ? $wgRequest->getSafeVal('begin') : false, $wgRequest->getSafeVal('getBool', 'end') ? $wgRequest->getSafeVal('end') : false, $site, $pageClass); //Now we can assign the Smarty variables! $content->assign("info", true); $content->assign("page", $pageClass->get_title()); $content->assign("urlencodedpage", str_replace('+', '_', urlencode($pageClass->get_title()))); $content->assign("totaledits", number_format($data['count'])); $content->assign("minoredits", number_format($data['minor_count'])); $content->assign("minoredits", number_format($data['minor_count'])); $content->assign("anonedits", number_format($data['anon_count'])); $content->assign("minorpct", number_format($data['minor_count'] / $data['count'] * 100, 2));
if (!$wgRequest->getBool('approve')) { try { $res = $dbr->select('translations', '*', array('tr_done' => 0, 'tr_denied' => 0)); if (!count($res)) { WebTool::toDie("No pending translations"); } $submissions = array(); foreach ($res as $row) { $row['tr_date'] = date('r', strtotime($row['tr_date'])); $submissions[] = array_merge($row, array('tr_diff' => nl2br(getTextDiff('unified', htmlentities(@file_get_contents($tools[$row['tr_tool']]['uri'] . $row['tr_lang'] . '.conf')), htmlentities($row['tr_text']))))); } $content->assign("adminlist", true); $content->assign("submissionlist", $submissions); $content->assign("password", file_get_contents('/data/project/xtools/.password')); } catch (DBError $e) { WebTool::toDie($phptemp->get_config_vars('mysqlerror', $e->getMessage())); } } else { $post = $wgRequest->getValues(); foreach ($post as $name => $val) { if (substr($name, 0, 7) != "result-") { unset($post[$name]); } } foreach ($post as $name => $result) { if ($result == "approve") { $dbr->update('translations', array('tr_done' => '1'), array('tr_id' => str_replace(substr($name, 0, 7), '', $name))); $res = $dbr->select('translations', 'tr_text, tr_lang, tr_tool', array('tr_id' => str_replace(substr($name, 0, 7), '', $name)), array('LIMIT' => 1)); foreach ($res as $row) { file_put_contents($tools[$row['tr_tool']]['uri'] . $row['tr_lang'] . '.conf', $row['tr_text']); $content->assign('donemsg', "Done. See <a href='" . $tools[$row['tr_tool']]['uri'] . $row['tr_lang'] . '.conf' . ">~soxred93/pcount/configs/" . $row['tr_lang'] . ".conf</a>");
$dbr = $wt->loadDatabase($lang, $wiki); if ($page) { $site = $wt->loadPeachy($lang, $wiki); try { $pageObj = new Page($site, $page); $nsname = $pageObj->get_namespace(false); $nsid = $pageObj->get_namespace(); $nscolon = $nsid ? $nsname . ":" : ""; $page_title = $pageObj->get_title(false); $page_id = $pageObj->get_id(); } catch (Exception $e) { $wt->error = $e->getMessage() . " (topedits::pageObj)"; $wt->showPage(); } if (!$page_id || $page_id == 0) { $wt->toDie('nosuchpage', $page . " ({$domain})"); } $list = getPageEditsPerUser($dbr, $page_id, $domain, $users, $wi); $wt->content = getPageTemplate('resultpage'); $userprefix = ''; } else { $cnt = new Counter($dbr, $user, $domain, true); if ($cnt->optin) { $wt->content = getPageTemplate('resultns'); $nscolon = $page_title = ""; $nsnames = $cnt->getNamespaces(); $list = getTopEditsByNamespace($dbr, $wi, $ui, $nsnames, $namespace); } else { $nsnames = $cnt->getNamespaces(); $wt->content = getPageTemplate('resultns'); $list = $I18N->msg("nograph", array("variables" => array($cnt->getOptinLinkLocal(), $cnt->getOptinLinkGlobal()))) . "<br /> " . $I18N->msg('nograph2', array("variables" => array($wt->linkOauthHelp)));
$ttl = 1800; } if ($ui->editcount > 300000) { $ttl = 86400; } if (!$cnt->error) { $redis->setex($hash, $ttl, serialize($cnt)); } } else { $cnt = unserialize($lc); unset($lc); $perflog->add('CNT', 0, 'from Redis'); } if ($cnt->error) { $perflog->stack[] = $cnt->error; $wt->toDie('error. ec::index::cnt -> ' . $cnt->error); } require_once 'Graph.php'; //Output stuff $wt->content = getPageTemplate("result"); //Make Graphs $graphNS = xGraph::makePieGoogle($cnt->getNamespaceTotals()); $legendNS = xGraph::makeLegendTable($cnt->getNamespaceTotals(), $cnt->getNamespaces()); $graphMonths = xGraph::makeHorizontalBar("month", $cnt->getMonthTotals(), 800, $cnt->getNamespaces()); $graphYears = xGraph::makeHorizontalBar("year", $cnt->getMonthTotals(), 800, $cnt->getNamespaces()); $gcolor1 = '99CCFF'; $gcolor2 = '99CC00'; $msgBytes = $I18N->msg('bytes'); $gminorpct = $cnt->mMinorEditsByte / $cnt->mLive * 100; $mdata = array($cnt->mMinorEditsByte, $cnt->mLive - $cnt->mMinorEditsByte); $mlabels = array("< 20 {$msgBytes} · " . $wt->numFmt($gminorpct, 1) . '%', "≥ 20 {$msgBytes} · " . $wt->numFmt(100 - $gminorpct, 1) . '%');
$wtTranslate = true; WebTool::setMemLimit(); //Show form if &article parameter is not set (or empty) if (!$wgRequest->getSafeVal('getBool', 'user')) { $content->assign('form', $curlang); WebTool::assignContent(); } if ($lang == "en" && $wiki == "wikipedia") { //WebTool::toDie( "In order to both discourage editcountitis and give the English Wikipedia editors a chance to realize what editing is all about and why I created this tool in the first place, I have disabled my edit counters (pcount, simplecount, autoedits) until August 17 2010. Please use this time to reflect on why I made this tool in the first place: To serve curiosity, not to create false judgement descisions about editors. -X! 13 August 2010" ); } $user = WebTool::prettyTitle($wgRequest->getSafeVal('user'), true); //Initialize Peachy try { $userClass = $site->initUser($user); } catch (Exception $e) { WebTool::toDie($e->getMessage()); } $phptemp->assign("page", $user); if (!$userClass->exists()) { WebTool::toDieMsg('nosuchuser', $user); } $useLabs = true; $count = $userClass->get_editcount(false, $dbr); //Here if ($count > 100000) { WebTool::toDieMsg('toomanyedits', 100000); } //Start doing the DB request $data = AutoEditsBase::getMatchingEdits($user, $wgRequest->getSafeVal('getBool', 'begin') ? $wgRequest->getSafeVal('begin') : false, $wgRequest->getSafeVal('getBool', 'end') ? $wgRequest->getSafeVal('end') : false, $count); $content->assign('showedits', true); $content->assign('data', $data['counts']);
$wt->setLimits(); $wt->getPageTemplate('form'); $wi = $wt->wikiInfo; $lang = $wi->lang; $wiki = $wi->wiki; $domain = $wi->domain; $domain = $domain ? $domain : 'en.wikipedia.org'; switch ($domain) { case "en.wikipedia.org": $optionsProject = "\n\t\t\t\t\t<option selected value ='en.wikipedia'>en.wikipedia</option>\n\t\t\t\t\t<option value ='de.wikipedia'>de.wikipedia</option>\n\t\t\t\t\t"; break; case "de.wikipedia.org": $optionsProject = "\n\t\t\t\t\t<option value ='en.wikipedia'>en.wikipedia</option>\n\t\t\t\t\t<option selected value ='de.wikipedia'>de.wikipedia</option>\n\t\t\t\t\t"; break; default: $wt->toDie('nosupport', $domain); } $msgOnDeWiki = "on the German Wikipedia"; $msgOnEnWiki = "on the English Wikipedia"; if ($wt->uselang == "de") { $msgOnDeWiki = "in der deutschen Wikipedia"; $msgOnEnWiki = "in der englischen Wikipedia"; } $wt->assign('onEnWiki', $msgOnEnWiki); $wt->assign('onDeWiki', $msgOnDeWiki); $defaultPage["en.wikipedia.org"] = 'Wikipedia:Requests for adminship/Name of user'; $defaultPage["de.wikipedia.org"] = 'Wikipedia:Adminkandidaturen/Name des Benutzers'; $wt->assign('optionsProject', $optionsProject); $wt->assign('defaultPage', $defaultPage[$domain]); $wt->assign('optionsPage', getRecentRfXs($domain)); $p1 = $wgRequest->getVal('page');
$quote = $base->getRandomQuote(); $content->assign('random', true); $content->assign('quote', $quote['quote']); $content->assign('id', $quote['id']); $phptemp->assign('page', $quote['id']); $phptemp->assign('thisurl', "//tools.wmflabs.org" . $_SERVER['REQUEST_URI']); break; case 'showall': $quotes = $base->getAllQuotes(); $content->assign('showall', true); $content->assign('quotes', $quotes); break; case 'showone': $quote = $base->getQuoteFromId($wgRequest->getSafeVal('id')); $content->assign('showone', true); $content->assign('quote', $quote['quote']); $content->assign('id', $quote['id']); $phptemp->assign('page', $quote['id']); break; case 'search': $quotes = $base->getQuotesFromSearch($wgRequest->getSafeVal('search'), $wgRequest->getBool('regex')); $content->assign('search', true); $content->assign('quotes', $quotes); if (!count($quotes)) { $content->assign('error', $phptemp->get_config_vars('noresults')); } break; default: WebTool::toDie($phptemp->get_config_vars('invalidaction')); } WebTool::finishScript();
$list = $wgRequest->getText('list', $list); $list = $wgRequest->getText('text', $list); $limit = $wgRequest->getVal('limit', '20'); $display = $wgRequest->getVal('display'); $begin = $wt->checkDate($wgRequest->getVal('begin')); $end = $wt->checkDate($wgRequest->getVal('end')); $namespace = $wgRequest->getVal('namespace'); $wi = $wt->wikiInfo; $lang = $wi->lang; $wiki = $wi->wiki; $domain = $wi->domain; if (!$list || !$wiki || !$lang) { $wt->showPage(); } if ($begin == 'error' || $end == 'error') { $wt->toDie('invalid_date'); } //Create exec object $dbr = $wt->loadDatabase($lang, $wiki); $rc = new RangeContribs($dbr, $wt, $list, $begin, $end, $limit, $namespace); //Make output $listsum = makeListSum($rc->getItems()); if ($display != "bytime") { $listbyName = makeListRevs("byname", $rc->getContribs(), $wt->namespaces, $limit); } $listbyTime = makeListRevs("bytime", $rc->getContribs(), $wt->namespaces, $limit); //Output stuff $wt->content = getPageTemplate("result"); $wt->assign("listsum", $listsum); $wt->assign("listbyname", $listbyName); $wt->assign("listbytime", $listbyTime);
foreach ($quotes as $id => $quote) { $pageResult .= ' <h3>{#quote_number#} ' . $id . '</h3> <pre>' . $quote . '</pre>'; } break; case 'search': $quotes = $base->getQuotesFromSearch($search, $isRegex); $pageResult = '<h3>{#searchresults#}</h3>'; foreach ($quotes as $id => $quote) { $pageResult .= ' <h3>{#quote_number#} ' . $id . '</h3> <pre>' . $quote . '</pre>'; } if (!count($quotes)) { $wt->toDie('noresult', $search); } break; default: $wt->showPage(); } unset($base, $quotes); $wt->content = $pageResult; $wt->showPage(); /**************************************** templates **************************************** * */ function getPageTemplate($type) { $templateForm = ' <br />
$selectredir = ' <select name="redirects"> <option value="none">Include redirects and non-redirects</option> <option value="onlyredirects">Only include redirects</option> <option value="noredirects">Exclude redirects</option> </select><br /> '; $content->assign('selectns', $selectns); $content->assign('selectredir', $selectredir); //Show form if &article parameter is not set (or empty) if (!$wgRequest->getSafeVal('getBool', 'user')) { $content->assign('form', $curlang); WebTool::assignContent(); } //Get username & userid, quit if not exist $userData = PagesBase::getUserData($dbr, $wgRequest->getSafeVal('user')); if (!$userData) { WebTool::toDie("No such user"); } $result = PagesBase::getCreatedPages($dbr, $userData["user_id"], $wgRequest->getSafeVal('lang'), $wgRequest->getSafeVal('wiki'), $wgRequest->getSafeVal('namespace'), $wgRequest->getSafeVal('redirects')); $filtertextNS = $result->filterns == "all" ? " in all namespaces." : " in namespace " . $wgRequest->getSafeVal('namespace') . "."; #print_r($result->namespaces); $content->assign('showresult', true); $content->assign('graphs', true); $content->assign('totalcreated', "User " . $userData["user_name"] . " has created {$result->total} pages on " . $wgRequest->getSafeVal('lang') . "." . $wgRequest->getSafeVal('wiki') . $filtertextNS); $content->assign('filterredir', $result->filterredir); $content->assign('namespaces', $result->namespaces); $content->assign('nstotals', $result->listnum); $content->assign('nsnames', $result->listns); $content->assign('list', $result->list); WebTool::assignContent();
//Load WebTool class $wt = new WebTool('Blame', 'blame', array('getwikiinfo', 'peachy', 'database')); $wtTranslate = true; WebTool::setMemLimit(256); $siteNoticeClass = new siteNotice(); $sitenotice = $siteNoticeClass->checkSiteNoticeRaw(); if ($sitenotice) { $phptemp->assign("alert", $sitenotice); } // get params from query string $lang = $wgRequest->getSafeVal('lang'); $wiki = $wgRequest->getSafeVal('wiki'); $article = $wgRequest->getSafeVal('article'); $nofollowredir = $wgRequest->getBool('nofollowredir'); $text = isset($_GET["text"]) ? urldecode($_GET["text"]) : ""; $wikibase = $lang . '.' . $wiki . '.org'; //Show form if &article parameter is not set (or empty) if ($lang == "" || $wiki == "" || $article == "" || $text == "") { $content->assign('form', 'en'); WebTool::assignContent(); WebTool::toDie(""); } // execute the main logic $revs = BlameBase::getBlameResult($wikibase, $article, $nofollowredir, $text); $content->assign("revs", $revs); //Calculate time taken to execute $exectime = number_format(microtime(1) - $time, 2, '.', ''); $phptemp->assign("excecutedtime", "Executed in {$exectime} seconds"); $phptemp->assign("memory", "Taken " . number_format(memory_get_usage() / (1024 * 1024), 2, '.', '') . " megabytes of memory to execute."); WebTool::assignContent(); WebTool::finishScript();
$ttl = 1800; } if ($ai->historyCount > 100000) { $ttl = 86400; } if (!$ai->error) { $redis->setex($hash, $ttl, serialize($ai)); } } else { $ai = unserialize($lc); unset($lc); $perflog->add('AI', 0, 'from Redis'); } $perflog->add('create ai', microtime(true) - $m1); if ($ai->historyCount == 0) { $wt->toDie('norevisions', $article); } if ($ai->error) { $wt->toDie('error', $ai->error); } require_once 'Graph.php'; //Now we can assign the Smarty variables! $wt->content = getPageTemplate("result"); $wt->assign('reloadpurge', ''); #$wt->assign( 'reloadpurge', '<a title="reload & purge" href="//'.XTOOLS_BASE_WEB_DIR."/articleinfo/?".$_SERVER["QUERY_STRING"]."&reloadpurge=".$reloadhash."0".'"><img height=15px src="//upload.wikimedia.org/wikipedia/commons/d/dd/Reload_Icon_Red.svg" /></a>' ); $msgMonth = $I18N->msg('months', array("variables" => array(1))); $msgYear = $I18N->msg('years', array("variables" => array(1))); $wt->assign('avgeditspermonth', $I18N->msg('avg_edits_per_time_sign', array("variables" => array($msgMonth)))); $wt->assign('avgeditsperyear', $I18N->msg('avg_edits_per_time_sign', array("variables" => array($msgYear)))); $wt->assign("page", $ai->pagetitleFull); $wt->assign("urlencodedpage", $ai->pagetitleFullUrl);