Esempio n. 1
0
 private function adminSave()
 {
     global $PRISM;
     // Collect data from input fields
     $username = $this->actionType == TS_AACTION_ADD ? $this->getObjectById('adminUsername')->getText() : $this->username;
     $password = $this->getObjectById('adminPassword')->getText();
     $flags = $this->getObjectById('adminFlags')->getText();
     // Save admin
     if ($PRISM->admins->adminExists($username)) {
         // Update admin
         if ($password != '') {
             $PRISM->admins->changePassword($username, $password);
         }
         $PRISM->admins->setAccessFlags($username, flagsToInteger($flags));
     } else {
         // New admin
         if ($username == '' || $password == '') {
             return;
         }
         $PRISM->admins->addAccount($username, $password, flagsToInteger($flags));
         $PRISM->admins->setAccessFlags($username, flagsToInteger($flags));
     }
     $this->parentSection->redrawMenu();
     //        console('Save this admin '.$username.' / '.$password.' / '.$flags);
 }
Esempio n. 2
0
    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;
    }