for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/******************************************************************************
* Wikipedia Account Creation Assistance tool *
* *
* All code in this file is released into the public domain by the ACC *
* Development Team. Please see team.json for a list of contributors. *
******************************************************************************/
namespace Waca;
use Smarty;
/**
* Handles the tool offline messages
*/
class Offline
{
* Determines if the tool is offline
* @return bool
public static function isOffline()
global $dontUseDb;
return (bool)$dontUseDb;
}
* Gets the offline message
*
* @param bool $external
* @param null $message
* @return string
public static function getOfflineMessage($external, $message = null)
global $dontUseDbCulprit, $dontUseDbReason, $baseurl;
global
Instead of relying on global state, we recommend one of these alternatives:
function myFunction($a, $b) { // Do something }
class MyClass { private $a; private $b; public function __construct($a, $b) { $this->a = $a; $this->b = $b; } public function myFunction() { // Do something } }
$smarty = new Smarty();
$smarty->assign("baseurl", $baseurl);
$smarty->assign("toolversion", Environment::getToolVersion());
if (!headers_sent()) {
header("HTTP/1.1 503 Service Unavailable");
if ($external) {
return $smarty->fetch("offline/external.tpl");
else {
$hideCulprit = true;
// Use the provided message if possible
if ($message === null) {
$hideCulprit = false;
$message = $dontUseDbReason;
$smarty->assign("hideCulprit", $hideCulprit);
$smarty->assign("dontUseDbCulprit", $dontUseDbCulprit);
$smarty->assign("dontUseDbReason", $message);
$smarty->assign("alerts", array());
return $smarty->fetch("offline/internal.tpl");
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state