public function initialise() { global $PRISM; $this->telnetVars = array('ip' => '', 'port' => 0); if ($this->loadIniFile($this->telnetVars, false)) { if ($PRISM->config->cvars['debugMode'] & PRISM_DEBUG_CORE) { console('Loaded ' . $this->iniFile); } } else { # We ask the client to manually input the connection details here. require_once ROOTPATH . '/modules/prism_interactive.php'; Interactive::queryTelnet($this->telnetVars); # Then build a telnet.ini file based on these details provided. $extraInfo = <<<ININOTES ; ; Telnet listen details (for remote console access). ; 0.0.0.0 (default) will bind the socket to all available network interfaces. ; To limit the bind to one interface only, you can enter its IP address here. ; If you do not want to use the telnet feature, you can comment or remove the ; lines, or enter "" and 0 for the ip and port. ; ININOTES; if ($this->createIniFile('Telnet Configuration (remote console)', array('telnet' => &$this->telnetVars), $extraInfo)) { console('Generated config/' . $this->iniFile); } } // Setup telnet socket to listen on if (!$this->setupListenSocket()) { return false; } return true; }
public function initialise() { global $PRISM; if ($this->loadIniFile($this->connvars)) { foreach ($this->connvars as $hostID => $v) { if (!is_array($v)) { console('Section error in ' . $this->iniFile . ' file!'); return FALSE; } } if ($PRISM->config->cvars['debugMode'] & PRISM_DEBUG_CORE) { console('Loaded ' . $this->iniFile); } } else { # We ask the client to manually input the connection details here. require_once ROOTPATH . '/modules/prism_interactive.php'; Interactive::queryHosts($this->connvars); # Then build a connections.ini file based on these details provided. if ($this->createIniFile('InSim Connection Hosts', $this->connvars)) { console('Generated config/' . $this->iniFile); } } // Cleanup any existing connections (in case of re-initialise) $this->hosts = array(); // Populate $this->hosts array from the connections.ini variables we've just read $this->populateHostsFromVars(); return true; }
public function initialise() { global $PRISM; $this->pluginvars = array(); if ($this->loadIniFile($this->pluginvars)) { foreach ($this->pluginvars as $pluginID => $v) { if (!is_array($v)) { console('Section error in ' . $this->iniFile . ' file!'); return false; } } if ($PRISM->config->cvars['debugMode'] & PRISM_DEBUG_CORE) { console('Loaded ' . $this->iniFile); } // Parse useHosts values of plugins foreach ($this->pluginvars as $pluginID => $details) { if (isset($details['useHosts'])) { $this->pluginvars[$pluginID]['useHosts'] = explode(',', $details['useHosts']); } else { unset($this->pluginvars[$pluginID]); } } } else { # We ask the client to manually input the plugin details here. require_once ROOTPATH . '/modules/prism_interactive.php'; Interactive::queryPlugins($this->pluginvars, $PRISM->hosts->getHostsInfo()); if ($this->createIniFile('PHPInSimMod Plugins', $this->pluginvars)) { console('Generated config/' . $this->iniFile); } // Parse useHosts values of plugins foreach ($this->pluginvars as $pluginID => $details) { $this->pluginvars[$pluginID]['useHosts'] = explode('","', $details['useHosts']); } } return true; }
public function initialise() { global $PRISM; $this->admins = array(); if ($this->loadIniFile($this->admins)) { if ($PRISM->config->cvars['debugMode'] & PRISM_DEBUG_CORE) { console('Loaded ' . $this->iniFile); } } else { # We ask the client to manually input the user details here. require_once ROOTPATH . '/modules/prism_interactive.php'; Interactive::queryAdmins($this->admins); # Then build a admins.ini file based on these details provided. $extraInfo = <<<ININOTES ; ; Line starting with ; is a comment ; ; Access flags: ; a - access to remote console (RCON) and rcon password cvar (by `!prism cvar` command) ; b - /ban and /unban commands (`prism ban` and `prism unban` commands) ; c - access to `prism cvar` command (not all cvars will be available) ; d - access to `prism cfg` command (allows you to change lfs configuration settings) ; e - Env commands (/wind, /weather) ; f - Functions (/restart, /qualify, /end & /names) ; g - game commands (/qual, /laps & /hours) ; h - host commands (/ip, /port, /maxguests, /insim & /reinit) ; i - immunity (cannot be kicked/baned/speced/pited and affected by other commmands) ; j - ; k - /kick command (`prism kick` command) ; l - ; m - access to /track `prism track` & `prism map` command ; n - /track command ; o - options (/maxguests, /adminslots, /carsmax, /carshost, /carsguest & /pps X) ; p - access to /pass cvar (by `!prism cvar` command) ; q - ; r - reservation (can join on reserved slots) ; s - /spec and /pit commands ; t - chat commands (`prism chat` and other chat commands) ; u - Unimmunized, given the ability to run commands on immunized admins. ; v - vote commands (/vote & `prism vote`) ; w - ; x - ; y - ; z - ; ; Format of admin account: ; [lfs username] ; Should always be lowercase. ; password = "******" ; accessFlags = "<Access flags>" ; connection = "<host id name>" ; realmDigest = "<md5 hash>" ; never change this yourself ; ; NOTE about the username - it should be lower case only. ; NOTE about the password - you can write it in plain text. ; When you then run PRISM, the password will be converted into a safer format & the username will be lowercased. ; ININOTES; if ($this->createIniFile('Admins Configuration File', $this->admins, $extraInfo)) { console('Generated config/' . $this->iniFile); } } // Read account vars to verify / maybe generate password hashes foreach ($this->admins as $username => &$details) { // Convert password? if (strlen($details['password']) != 40) { $details['realmDigest'] = md5($username . ':' . HTTP_AUTH_REALM . ':' . $details['password']); $details['password'] = sha1($details['password'] . $PRISM->config->cvars['secToken']); // Rewrite these particular config lines in admins.ini $this->rewriteLine($username, 'password', $details['password']); $this->rewriteLine($username, 'realmDigest', $details['realmDigest']); } // Convert flags? if (!is_numeric($details['accessFlags'])) { $details['accessFlags'] = flagsToInteger($details['accessFlags']); } else { $this->rewriteLine($username, 'accessFlags', flagsToString($details['accessFlags'])); } } # Crazy stuff we have to do to make sure that usernames are lowercase. $tempAdmins = array(); foreach ($this->admins as $username => &$details) { $tempAdmins[strToLower($username)] = $details; } $this->admins = $tempAdmins; return TRUE; }
public function initialise() { global $PRISM; $this->httpVars = array('ip' => '', 'port' => 0, 'path' => 'www-docs', 'siteDomain' => '', 'httpAuthPath' => '', 'httpAuthType' => 'Digest', 'logFile' => 'logs/http.log'); if ($this->loadIniFile($this->httpVars, false)) { if ($PRISM->config->cvars['debugMode'] & PRISM_DEBUG_CORE) { console('Loaded ' . $this->iniFile); } } else { # We ask the client to manually input the connection details here. require_once ROOTPATH . '/modules/prism_interactive.php'; Interactive::queryHttp($this->httpVars); # Then build a http.ini file based on these details provided. $extraInfo = <<<ININOTES ; ; Http listen details (for administration web pages). ; 0.0.0.0 will bind the listen socket to all available network interfaces. ; To limit the bind to one interface only, you can enter its IP address here. ; If you do not want to use the http feature, you can comment or remove the lines, ; or enter "" and 0 for the ip and port. ; ININOTES; if ($this->createIniFile('HTTP Configuration (web admin)', array('http' => &$this->httpVars), $extraInfo)) { console('Generated config/' . $this->iniFile); } } // Set docRoot if (!$this->setDocRoot()) { return false; } // Set logFile if (!$this->setLogFile()) { return false; } // Setup http socket to listen on if (!$this->setupListenSocket()) { return false; } // Setup site domain $this->setupSiteDomain(); // Validate httpAuthPath if (!$this->validateAuthPath()) { return false; } // Validate httpAuthType if ($this->httpVars['httpAuthType'] != 'Digest' & $this->httpVars['httpAuthType'] != 'Basic') { console('Invalid httpAuthType in ' . $this->iniFile); return false; } return true; }
case '/startPoll': if (isset($_GET['id']) && isset($_GET['size']) && isset($this->status['admin'])) { $this->startPoll($_GET['id'], (int) $_GET['size']); } break; case '/votePoll': if (isset($_GET['answer'])) { $this->votePoll((int) $_GET['answer']); } break; case '/endPoll': if (isset($this->status['admin'])) { $this->endPoll(); } break; case '/infoPoll': $response = $this->infoPoll(); break; } if ($response === null) { $response = $this->status; } $_SESSION[$this->key] = $this->status; return $response; } } $config = @(include __DIR__ . '/config.php'); $interactive = new Interactive($config); $response = $interactive->run(); header('Content-type: application/json'); echo json_encode($response);