Пример #1
0
 /**
  * Permet de changer de serveur
  */
 public static function switchServer()
 {
     if (isset($_GET['switch']) && $_GET['switch'] != null) {
         $_SESSION['adminserv']['sid'] = AdminServServerConfig::getServerId($_GET['switch']);
         $_SESSION['adminserv']['name'] = $_GET['switch'];
         unset($_SESSION['adminserv']['teaminfo']);
         Utils::addCookieData('adminserv', array($_SESSION['adminserv']['sid'], Utils::readCookieData('adminserv', 1)), AdminServConfig::COOKIE_EXPIRE);
         if (USER_PAGE && USER_PAGE != 'index') {
             Utils::redirection(false, '?p=' . USER_PAGE);
         } else {
             Utils::redirection();
         }
     }
 }
Пример #2
0
 if (AdminServServerConfig::hasServer()) {
     // Connexion
     if (isset($_POST['as_server']) && isset($_POST['as_password']) && isset($_POST['as_adminlevel'])) {
         // Récupération des valeurs
         $serverName = $_POST['as_server'];
         $password = addslashes(htmlspecialchars(trim($_POST['as_password'])));
         if (AdminServConfig::MD5_PASSWORD) {
             $password = md5($password);
         }
         $adminLevel = addslashes(htmlspecialchars($_POST['as_adminlevel']));
         // Vérification des valeurs
         if ($password == null) {
             AdminServ::error(Utils::t('Please put a password.'));
         } else {
             // Sessions & Cookies
             $_SESSION['adminserv']['sid'] = AdminServServerConfig::getServerId($serverName);
             $_SESSION['adminserv']['name'] = $serverName;
             $_SESSION['adminserv']['password'] = $password;
             $_SESSION['adminserv']['adminlevel'] = $adminLevel;
             Utils::addCookieData('adminserv', array($_SESSION['adminserv']['sid'], $adminLevel), AdminServConfig::COOKIE_EXPIRE);
             // Redirection
             if ($_SESSION['adminserv']['sid'] != -1 && $_SESSION['adminserv']['name'] != null && $_SESSION['adminserv']['password'] != null && $_SESSION['adminserv']['adminlevel'] != null) {
                 Utils::redirection();
             } else {
                 AdminServ::error(Utils::t('Connection error: invalid session.'));
             }
         }
     }
 } else {
     if (OnlineConfig::ACTIVATE === true) {
         Utils::redirection(false, './config/');
Пример #3
0
<?php

// ENREGISTREMENT
if (isset($_POST['savepassword'])) {
    $current = md5($_POST['changePasswordCurrent']);
    $new = md5($_POST['changePasswordNew']);
    if (isset($_SESSION['adminserv']['path'])) {
        $adminservPath = $_SESSION['adminserv']['path'];
    } else {
        $adminservPath = null;
    }
    $pathConfig = $adminservPath . 'config/';
    if (OnlineConfig::PASSWORD !== $current) {
        AdminServ::error(Utils::t('The current password doesn\'t match.'));
    } else {
        if (($result = AdminServServerConfig::savePasswordConfig($pathConfig . 'adminserv.cfg.php', $new)) !== true) {
            AdminServ::error(Utils::t('Unable to save password.') . ' (' . $result . ')');
        } else {
            $info = Utils::t('The password has been changed.');
            AdminServ::info($info);
            AdminServLogs::add('action', $info);
        }
    }
    Utils::redirection(false, '?p=' . USER_PAGE);
}
Пример #4
0
 /**
  * Vérifie si l'ip de l'utilisateur est autorisé dans le niveau admin
  *
  * @param string $level  -> Nom du niveau admin
  * @param string $server -> Nom du serveur
  * @return bool
  */
 public static function userAllowed($levelName, $serverName = null)
 {
     $out = false;
     if ($serverName === null && defined('SERVER_NAME')) {
         $serverName = SERVER_NAME;
     }
     if (AdminServServerConfig::hasServer($serverName)) {
         $levelType = self::getType($levelName);
         if ($levelType) {
             $serverLevelTypeAccess = ServerConfig::$SERVERS[$serverName]['adminlevel'][$levelType];
             if (is_array($serverLevelTypeAccess)) {
                 if (in_array($_SERVER['REMOTE_ADDR'], $serverLevelTypeAccess)) {
                     $out = true;
                 }
             } else {
                 if ($serverLevelTypeAccess === 'all') {
                     $out = true;
                 } elseif ($serverLevelTypeAccess === 'none') {
                     $out = false;
                 } else {
                     $out = Utils::isLocalhostIP();
                 }
             }
         }
     }
     return $out;
 }
Пример #5
0
    // SET
    $setServerData = array('name' => trim(htmlspecialchars(addslashes($_POST['server'][0] . ' - ' . Utils::t('copy')))), 'address' => trim($getServerData['address']), 'port' => intval($getServerData['port']), 'matchsettings' => trim($getServerData['matchsettings']), 'adminlevel' => array('SuperAdmin' => $getServerData['adminlevel']['SuperAdmin'], 'Admin' => $getServerData['adminlevel']['Admin'], 'User' => $getServerData['adminlevel']['User']));
    if (AdminServServerConfig::saveServerConfig($setServerData)) {
        $action = Utils::t('This server has been duplicated.');
        AdminServ::info($action);
        AdminServLogs::add('action', $action);
        Utils::redirection(false, '?p=' . USER_PAGE);
    } else {
        AdminServ::error(Utils::t('Unable to duplicate server.'));
    }
}
// SUPPRESSION
if (isset($_POST['deleteserver'])) {
    $servers = ServerConfig::$SERVERS;
    unset($servers[$_POST['server'][0]]);
    if (($result = AdminServServerConfig::saveServerConfig(array(), -1, $servers)) !== true) {
        AdminServ::error(Utils::t('Unable to delete server.') . ' (' . $result . ')');
    } else {
        $action = Utils::t('The "!serverName" server has been deleted.', array('!serverName' => $_POST['server'][0]));
        AdminServ::info($action);
        AdminServLogs::add('action', $action);
        Utils::redirection(false, '?p=' . USER_PAGE);
    }
}
// SERVERLIST
$data['servers'] = array();
if (is_array(ServerConfig::$SERVERS) && !empty(ServerConfig::$SERVERS)) {
    $data['servers'] = ServerConfig::$SERVERS;
}
$data['count'] = count($data['servers']);
$data['adminLevelsType'] = AdminServAdminLevel::getDefaultType();
Пример #6
0
         session_destroy();
         session_start();
         $_SESSION['adminserv']['allow_config_servers'] = true;
         if (OnlineConfig::ADD_ONLY === true || AdminServServerConfig::hasServer() === false) {
             Utils::redirection(false, '../?p=config-addserver');
         } else {
             Utils::redirection(false, '../?p=config-servers');
         }
     } else {
         AdminServ::error(Utils::t('You are not allowed to configure the servers'));
         Utils::redirection(false, '..');
     }
 } else {
     if (isset($_POST['configsavepassword'])) {
         $password = md5($_POST['savePassword']);
         if (($result = AdminServServerConfig::savePasswordConfig('./adminserv.cfg.php', $password)) !== true) {
             AdminServ::error(Utils::t('Unable to save password.') . ' (' . $result . ')');
             Utils::redirection(false, '..');
         } else {
             session_unset();
             session_destroy();
             session_start();
             $_SESSION['adminserv']['allow_config_servers'] = true;
             Utils::redirection(false, '../?p=config-addserver');
         }
     } else {
         // Création du mot de passe
         $_SESSION['adminserv']['get_password'] = true;
         Utils::redirection(false, '..');
     }
 }
Пример #7
0
 /**
  * Récupère la liste des serveurs configurés
  *
  * @return string
  */
 public static function getServerList()
 {
     $out = null;
     if (class_exists('ServerConfig') && AdminServServerConfig::hasServer()) {
         if (isset($_GET['server']) && $_GET['server'] != null) {
             $currentServerId = intval($_GET['server']);
         } else {
             $currentServerId = Utils::readCookieData('adminserv', 0);
         }
         foreach (ServerConfig::$SERVERS as $server => $values) {
             $selected = AdminServServerConfig::getServerId($server) == $currentServerId ? ' selected="selected"' : null;
             $out .= '<option value="' . $server . '"' . $selected . '>' . $server . '</option>';
         }
     } else {
         $out = '<option value="null">' . Utils::t('No server available') . '</option>';
     }
     return $out;
 }
Пример #8
0
            ?>
										<li class="accesslink"><a tabindex="7" class="button light" href="<?php 
            echo AdminServ::getProtocolLink('#spectate=' . SERVER_LOGIN);
            ?>
"><?php 
            echo Utils::t('Access relay');
            ?>
</a></li>
									<?php 
        } else {
            ?>
										<li class="accesslink"><a tabindex="8" class="button light" href="<?php 
            echo AdminServ::getProtocolLink('#join=' . SERVER_LOGIN);
            ?>
"><?php 
            echo Utils::t('Access server');
            ?>
</a></li>
									<?php 
        }
        ?>
								<?php 
    }
    ?>
								<?php 
    if (AdminServPlugin::hasPlugin() && AdminServAdminLevel::hasAccess('plugins_list')) {
        ?>
									<li><a tabindex="9" class="button light<?php 
        if (USER_PAGE == 'plugins-list' || USER_PLUGIN) {
            echo ' active';
        }
Пример #9
0
<?php

// ACTIONS
if (isset($_POST['save']) && isset($_POST['list']) && $_POST['list'] != null) {
    $serverList = ServerConfig::$SERVERS;
    $list = explode(',', $_POST['list']);
    $newServerList = array();
    foreach ($list as $listServerName) {
        $newServerList[$listServerName] = array('address' => $serverList[$listServerName]['address'], 'port' => $serverList[$listServerName]['port'], 'mapsbasepath' => isset($serverList[$listServerName]['mapsbasepath']) ? $serverList[$listServerName]['mapsbasepath'] : '', 'matchsettings' => $serverList[$listServerName]['matchsettings'], 'adminlevel' => $serverList[$listServerName]['adminlevel']);
    }
    AdminServServerConfig::saveServerConfig(array(), -1, $newServerList);
    AdminServLogs::add('action', 'Order server list');
    Utils::redirection(false, '?p=' . USER_PAGE);
}
// SERVERLIST
$data['servers'] = array();
if (is_array(ServerConfig::$SERVERS) && !empty(ServerConfig::$SERVERS)) {
    $data['servers'] = ServerConfig::$SERVERS;
}
Пример #10
0
    } else {
        if (($result = AdminServServerConfig::saveServerConfig($serverData)) !== true) {
            AdminServ::error(Utils::t('Unable to add the server.') . ' (' . $result . ')');
        } else {
            $action = Utils::t('This server has been added.');
            AdminServ::info($action);
            AdminServLogs::add('action', $action);
            Utils::redirection(false, '?p=' . USER_PAGE);
        }
    }
}
// LECTURE
$data = array('name' => null, 'address' => 'localhost', 'port' => 5000, 'mapsbasepath' => null, 'matchsettings' => 'MatchSettings/', 'adminlevel' => array('SuperAdmin' => 'all', 'Admin' => 'all', 'User' => 'all'));
if ($args['id'] !== -1) {
    define('IS_SERVER_EDITION', true);
    $data['name'] = AdminServServerConfig::getServerName($args['id']);
    if ($data['name']) {
        $serverData = AdminServServerConfig::getServer($data['name']);
        $data['address'] = $serverData['address'];
        $data['port'] = $serverData['port'];
        $data['mapsbasepath'] = isset($serverData['mapsbasepath']) ? $serverData['mapsbasepath'] : '';
        $data['matchsettings'] = $serverData['matchsettings'];
        foreach ($serverData['adminlevel'] as $admLvlId => $admLvlValue) {
            if (is_array($admLvlValue)) {
                $data['adminlevel'][$admLvlId] = implode(', ', $admLvlValue);
            } else {
                $data['adminlevel'][$admLvlId] = $admLvlValue;
            }
        }
    }
}