require_once 'db_connect.php'; require_once 'autoload.php'; if (empty($_REQUEST['action'])) { die(json_encode(array('error' => 'wrong action'))); } // array of required arguments for each action (when needed) $requiredArgs = array('get_periods_list' => array('page', 'rows')); if (array_key_exists($_REQUEST['action'], $requiredArgs)) { foreach ($requiredArgs[$_REQUEST['action']] as $arg) { if (!isset($_REQUEST[$arg])) { echo json_encode(array('error' => 'args')); return; } } } $instances = new Instances(); switch ($_REQUEST['action']) { case 'get_instances_list': //gj([X.X.X] - sanitize input, register patterns globally for readability and consistency. email, adword, instance, etc)^M error_log("sidx: {$sidx} sord: {$sord}"); $page = (int) $_REQUEST['page']; // get the requested page $limit = (int) $_REQUEST['rows']; // get how many rows we want to have into the grid $sidx = preg_replace("/[^a-zA-Z0-9\\-\\.\\_\\ \\,]/", "", $_REQUEST['sidx']); // get index row - i.e. user click to sort $sord = preg_replace("/[^a-zA-Z0-9\\-\\.\\_\\ \\,]/", "", $_REQUEST['sord']); // get the direction $filtreInstances = preg_replace("/[^a-zA-Z0-9\\-\\.\\_]/", "", $_REQUEST['filtreInstances']); if (!$sidx) { $sidx = 1;
public function verifyActiveInstances() { $instances = new Instances(); $actives = $instances->getActiveInstancesName(); $activesWithError = array(); $activesAvailable = array(); $jj = 0; if (count($actives) == 0) { die("getActiveInstancesName return no active instance"); } while ($jj < count($actives)) { $ret = $this->checkRedeemViewForInstance($actives[$jj]); if (isset($ret['error'])) { $activesWithError[] = array("error" => $ret['error']); } else { $activesAvailable[] = $actives[$jj]; } $jj++; } if (count($activesAvailable) == 0) { die("We found " . count($actives) . " active instances, but the redeem view creation return error in all those instances" . var_dump($activesWithError)); } $_SESSION["activesInstancesWithError"] = $activesWithError; return $activesAvailable; }
namespace MFF\ppanel; require_once 'php/DB.php'; require_once 'php/ITZR.php'; require_once 'php/Server.php'; require_once 'php/ServerList.php'; require_once 'php/Session.php'; require_once 'php/OutputHandler.php'; class Instances { public static $itzr, $db, $sess, $servers; public static function init() { self::$servers = new ServerList(); $serversJson = json_decode(file_get_contents(dirname(__FILE__) . '/config/servers.json'), true); foreach ($serversJson['servers'] as $srv) { self::$servers->add(new Server($srv['id'], $srv['name'], $srv['itzrName'], $srv['host'], $srv['port'], $srv['shortName'], $srv['color'], $srv['worldpath'], $srv['pageTags'])); } self::$sess = new Session(); self::$itzr = new ITZR(); self::$itzr->loadManifest('lang/manifest.itzm'); self::$itzr->setLang(self::$sess->getLanguage()); self::$db = new DB(); } } Instances::init(); $servers = Instances::$servers; $itzr = Instances::$itzr; $db = Instances::$db; $sess = Instances::$sess;