Пример #1
0
 /**
  * Erreurs et infos
  */
 public static function error($text = null)
 {
     global $client;
     // Tente de récupérer le message d'erreur du dédié
     if ($text === null) {
         $text = '[' . $client->getErrorCode() . '] ' . Utils::t($client->getErrorMessage());
     }
     AdminServLogs::add('error', $text);
     unset($_SESSION['info']);
     $_SESSION['error'] = $text;
 }
Пример #2
0
            $NextRoundCustomPointsArray = array();
            if (count($NextRoundCustomPoints) > 0) {
                foreach ($NextRoundCustomPoints as $point) {
                    $NextRoundCustomPointsArray[] = intval(trim($point));
                }
            }
            if (!$client->query('SetRoundCustomPoints', $NextRoundCustomPointsArray)) {
                AdminServ::error();
            }
        }
        // MatchSettings
        if (SERVER_MATCHSET) {
            $mapsDirectory = AdminServ::getMapsDirectoryPath();
            if (array_key_exists('SaveCurrentMatchSettings', $_POST)) {
                if (!$client->query('SaveMatchSettings', $mapsDirectory . SERVER_MATCHSET)) {
                    AdminServ::error();
                }
            }
        }
        AdminServLogs::add('action', 'Save game infos');
        Utils::redirection(false, '?p=' . USER_PAGE);
    }
}
// LECTURE
$gameInfos = AdminServ::getGameInfos();
$data['gameInfos'] = array('curr' => $gameInfos['curr'], 'next' => $gameInfos['next']);
$data['teamInfo'] = array('team1' => array('name' => Utils::t('Blue'), 'color' => '0.667', 'colorhex' => '#0000ff', 'country' => 'World|France'), 'team2' => array('name' => Utils::t('Red'), 'color' => '0', 'colorhex' => '#ff0000', 'country' => 'World|France'));
if (isset($_SESSION['adminserv']['teaminfo']) && count($_SESSION['adminserv']['teaminfo']) > 0) {
    $data['teamInfo'] = array('team1' => $_SESSION['adminserv']['teaminfo']['team1'], 'team2' => $_SESSION['adminserv']['teaminfo']['team2']);
}
unset($gameInfos);
Пример #3
0
                            if (isset($_POST['createPlaylistValid']) && isset($_POST['createPlaylistName']) && $_POST['createPlaylistName'] != null) {
                                // Fichier
                                $filename = Str::replaceChars($_POST['createPlaylistName']);
                                // Guestlist
                                if ($filename != Str::replaceChars(Utils::t('Playlist name'))) {
                                    if ($_POST['createPlaylistType'] == 'guestlist') {
                                        if (!$client->query('SaveGuestList', $filename)) {
                                            AdminServ::error();
                                        } else {
                                            AdminServLogs::add('action', 'Create playlist (guestlist): ' . $filename);
                                        }
                                    } elseif ($_POST['createPlaylistType'] == 'blacklist') {
                                        if (!$client->query('SaveBlackList', $filename)) {
                                            AdminServ::error();
                                        } else {
                                            AdminServLogs::add('action', 'Create playlist (blacklist): ' . $filename);
                                        }
                                    }
                                }
                                Utils::redirection(false, '?p=' . USER_PAGE);
                            }
                        }
                    }
                }
            }
        }
    }
}
// LECTURE
$client->addCall('GetBanList', array(AdminServConfig::LIMIT_PLAYERS_LIST, 0));
$client->addCall('GetBlackList', array(AdminServConfig::LIMIT_PLAYERS_LIST, 0));
Пример #4
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);
}
Пример #5
0
            $newPath = addslashes($_POST['optionFolderHiddenFieldValue']);
            if ($newPath == '.') {
                $newPath = $data['mapsDirectoryPath'];
            }
            $newPath .= basename($args['directory']) . '/';
            $newPathFromMapsPath = str_replace($data['mapsDirectoryPath'], '', $newPath);
            if ($newPathFromMapsPath) {
                $newPathFromMapsPath = '&d=' . $newPathFromMapsPath;
            }
            if (($result = Folder::rename($data['mapsDirectoryPath'] . $args['directory'], $newPath)) !== true) {
                AdminServ::error(Utils::t('Unable to move the folder') . ' : ' . $args['directory'] . ' (' . $result . ')');
            } else {
                AdminServLogs::add('action', 'Move folder: ' . $args['directory'] . ' to ' . $newPathFromMapsPath);
                Utils::redirection(false, '?p=' . USER_PAGE . $newPathFromMapsPath);
            }
        } else {
            if (isset($_POST['optionFolderHiddenFieldAction']) && $_POST['optionFolderHiddenFieldAction'] == 'delete') {
                if (($result = Folder::delete($data['mapsDirectoryPath'] . $args['directory'])) !== true) {
                    AdminServ::error(Utils::t('Unable to delete the folder') . ' : ' . $args['directory'] . ' (' . $result . ')');
                } else {
                    // Clean cache
                    $cache = new AdminServCache();
                    $cacheKey = 'mapslist-' . Str::replaceChars($data['mapsDirectoryPath'] . $args['directory']);
                    $cache->delete($cacheKey);
                    AdminServLogs::add('action', 'Delete folder: ' . $args['directory']);
                    Utils::redirection(false, '?p=' . USER_PAGE);
                }
            }
        }
    }
}
Пример #6
0
<?php

// ACTIONS
if (isset($_POST['save']) && isset($_POST['list']) && $_POST['list'] != null) {
    $adminLevelList = AdminLevelConfig::$ADMINLEVELS;
    $list = explode(',', $_POST['list']);
    $newAdminLevelList = array();
    foreach ($list as $listLevelName) {
        $newAdminLevelList[$listLevelName] = array('adminlevel' => $adminLevelList[$listLevelName]['adminlevel'], 'access' => $adminLevelList[$listLevelName]['access'], 'permission' => $adminLevelList[$listLevelName]['permission']);
    }
    AdminServAdminLevel::saveConfig(array(), -1, $newAdminLevelList);
    AdminServLogs::add('action', 'Order admin level list');
    Utils::redirection(false, '?p=' . USER_PAGE);
}
// LEVELLIST
$data['levels'] = array();
if (AdminServAdminLevel::hasLevel()) {
    $data['levels'] = AdminLevelConfig::$ADMINLEVELS;
}
Пример #7
0
                                AdminServ::error(Utils::t('Unable to move the map') . ' : ' . $map . ' (' . $result . ')');
                                break;
                            } else {
                                AdminServLogs::add('action', 'Move map: ' . $map . ' to ' . $newPath . basename($map));
                            }
                        }
                        Utils::redirection(false, '?p=' . USER_PAGE . $hasDirectory);
                    } else {
                        if (isset($_POST['deleteMap']) && isset($_POST['map']) && count($_POST['map']) > 0) {
                            foreach ($_POST['map'] as $map) {
                                $result = File::delete($data['mapsDirectoryPath'] . $map);
                                if ($result !== true) {
                                    AdminServ::error(Utils::t('Unable to delete the map') . ' : ' . $map . ' (' . $result . ')');
                                    break;
                                } else {
                                    AdminServLogs::add('action', 'Delete map: ' . $map);
                                }
                            }
                            Utils::redirection(false, '?p=' . USER_PAGE . $hasDirectory);
                        }
                    }
                }
            }
        }
    }
}
// Save MatchSettings
if ((isset($_POST['addMap']) || isset($_POST['insertMap'])) && SERVER_MATCHSET) {
    if (isset($_POST['SaveCurrentMatchSettings']) && array_key_exists('SaveCurrentMatchSettings', $_POST)) {
        if (!$client->query('SaveMatchSettings', $data['mapsDirectoryPath'] . SERVER_MATCHSET)) {
            AdminServ::error();
Пример #8
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;
}
Пример #9
0
                foreach ($_POST['matchset'] as $matchset) {
                    if (!$client->query('InsertPlaylistFromMatchSettings', $data['mapsDirectoryPath'] . $matchset)) {
                        AdminServ::error();
                    } else {
                        AdminServLogs::add('action', 'Insert playlist from matchsettings: ' . $matchset);
                    }
                }
                Utils::redirection(false, '?p=' . USER_PAGE . $data['hasDirectory']);
            } else {
                if (isset($_POST['editMatchset']) && isset($_POST['matchset']) && count($_POST['matchset']) > 0) {
                    AdminServLogs::add('action', 'Edit matchsettings: ' . $_POST['matchset'][0]);
                    // Redirection sur la page de création d'un matchsettings
                    Utils::redirection(false, '?p=maps-creatematchset' . $data['hasDirectory'] . '&f=' . $_POST['matchset'][0]);
                } else {
                    if (isset($_POST['deleteMatchset']) && isset($_POST['matchset']) && count($_POST['matchset']) > 0) {
                        foreach ($_POST['matchset'] as $matchset) {
                            if (!File::delete($data['mapsDirectoryPath'] . $matchset)) {
                                AdminServ::error(Utils::t('Unable to delete the playlist') . ' : ' . $matchset);
                            } else {
                                AdminServLogs::add('action', 'Delete matchsettings: ' . $matchset);
                            }
                        }
                        Utils::redirection(false, '?p=' . USER_PAGE . $data['hasDirectory']);
                    }
                }
            }
        }
    }
}
// MATCH SETTINGS LIST
$data['matchsettingsList'] = AdminServ::getLocalMatchSettingList($data['currentDir'], $args['directory']);
Пример #10
0
 /**
  * Inclue les fichiers pour le rendu d'un plugin
  *
  * @param string $pluginName -> Le nom du dossier plugin
  * @return html
  */
 public static function renderPlugin($pluginName = null)
 {
     global $client, $translate, $args;
     if ($pluginName === null) {
         $pluginName = USER_PLUGIN;
     }
     // Tente de récupérer les plugins d'une autre config
     self::setPluginsList();
     // Création du rendu du plugin
     $pluginPath = AdminServConfig::$PATH_PLUGINS . $pluginName . '/';
     $scriptFile = $pluginPath . 'script.php';
     $viewFile = $pluginPath . 'view.php';
     if (file_exists($scriptFile) && file_exists($viewFile)) {
         // Process
         require_once $scriptFile;
         // Terminate client
         if (isset($client) && $client->socket != null) {
             $client->Terminate();
         }
         // Header
         AdminServUI::getHeader();
         // Content
         echo '<section class="plugins hasMenu">' . '<section class="cadre left menu">' . self::getMenuList() . '</section>' . '<section class="cadre right">' . '<h1>' . self::getConfig($pluginName, 'name') . '</h1>';
         require_once $viewFile;
         echo '</section>' . '</section>';
         // Footer
         AdminServUI::getFooter();
         AdminServLogs::add('access', 'Plugin: ' . $pluginName);
     } else {
         AdminServ::error(Utils::t('Plugin error: script.php or view.php file is missing.'));
         AdminServUI::getHeader();
         AdminServUI::getFooter();
     }
 }
Пример #11
0
 /**
  * Inclue les fichiers pour le rendu d'une page
  */
 public static function renderPage($pageName)
 {
     global $client, $data, $args;
     // Preprocess
     if (strstr($pageName, '-')) {
         $pageNameEx = explode('-', $pageName);
         $pagePreprocess = AdminServConfig::$PATH_RESOURCES . 'process/' . $pageNameEx[0] . '.preprocess.php';
         if (file_exists($pagePreprocess)) {
             require_once $pagePreprocess;
         }
     }
     // Process
     $pageProcess = AdminServConfig::$PATH_RESOURCES . 'process/' . $pageName . '.php';
     if (file_exists($pageProcess)) {
         require_once $pageProcess;
     }
     // Terminate client
     if (isset($client) && $client->socket != null) {
         $client->Terminate();
     }
     // Header
     self::getHeader();
     // Template
     self::getTemplate($pageName);
     // Footer
     self::getFooter();
     AdminServLogs::add('access', isset($GLOBALS['page_title']) ? $GLOBALS['page_title'] : $pageName);
 }
Пример #12
0
            } else {
                $_SESSION['adminserv']['transfer_billid'] = $client->getResponse();
                AdminServLogs::add('action', 'Transfer ' . $serverToPlayerAmount . ' planets to ' . $serverToPlayerLogin . ' player login');
            }
        }
    }
    // Server < Player
    if (isset($_POST['playerToServerAmount']) && isset($_POST['playerToServerLogin'])) {
        $playerToServerAmount = intval($_POST['playerToServerAmount']);
        $playerToServerLogin = trim($_POST['playerToServerLogin']);
        if ($playerToServerAmount > 0) {
            if (!$client->query('SendBill', $playerToServerLogin, $playerToServerAmount, Utils::t('Confirmation of the transfer by AdminServ'), SERVER_LOGIN)) {
                AdminServ::error();
            } else {
                $_SESSION['adminserv']['transfer_billid'] = $client->getResponse();
                AdminServLogs::add('action', 'Transfer ' . $playerToServerAmount . ' planets from to ' . $playerToServerLogin . ' player login');
            }
        }
    }
    Utils::redirection(false, '?p=' . USER_PAGE);
}
/* GET */
$client->addCall('GetServerPlanets');
if (isset($_SESSION['adminserv']['transfer_billid']) && $_SESSION['adminserv']['transfer_billid'] != null) {
    $client->addCall('GetBillState', array($_SESSION['adminserv']['transfer_billid']));
}
if (!$client->multiquery()) {
    AdminServ::error();
} else {
    $queriesData = $client->getMultiqueryResponse();
    // Planets number
Пример #13
0
        $srvoptsImportExport = $_POST['srvoptsImportExport'];
    }
    // Enregistrement
    if ($ChangeAuthPassword) {
        if (USER_ADMINLEVEL === $ChangeAuthLevel) {
            $_SESSION['adminserv']['password'] = $ChangeAuthPassword;
        }
        AdminServ::info(Utils::t('You changed the password "!authLevel", remember it at the next connection!', array('!authLevel' => $ChangeAuthLevel)));
        AdminServLogs::add('action', 'Change authentication password for ' . $ChangeAuthLevel . ' level');
    } elseif ($srvoptsImportExport) {
        // Import
        if ($srvoptsImportExport == 'Import') {
            $srvoptsImportName = $_POST['srvoptsImportName'];
            if ($srvoptsImportName != 'none') {
                $struct = AdminServ::importServerOptions($srvoptsConfigDirectory . $srvoptsImportName);
                if (AdminServ::setServerOptions($struct)) {
                    AdminServLogs::add('action', 'Import server options from ' . $srvoptsConfigDirectory . $srvoptsImportName);
                }
            }
        } elseif ($srvoptsImportExport == 'Export') {
            $srvoptsExportName = Str::replaceChars($_POST['srvoptsExportName']);
            AdminServ::exportServerOptions($srvoptsConfigDirectory . $srvoptsExportName . '.txt', $struct);
        }
    } elseif (AdminServ::setServerOptions($struct)) {
        AdminServLogs::add('action', 'Save server options');
    }
    Utils::redirection(false, '?p=' . USER_PAGE);
}
// LECTURE
$data['srvOpt'] = AdminServ::getServerOptions();
$data['adminLevels'] = AdminServAdminLevel::getServerList();
Пример #14
0
                         AdminServLogs::add('action', 'Force player in ' . $color . ' team: ' . $player);
                     }
                 }
             } else {
                 if (isset($_POST['ForceScores']) && isset($_POST['ScoreTeamBlue']) && isset($_POST['ScoreTeamRed'])) {
                     $scoreTeamBlue = intval($_POST['ScoreTeamBlue']);
                     $scoreTeamRed = intval($_POST['ScoreTeamRed']);
                     $scores = array(array('PlayerId' => 0, 'Score' => $scoreTeamBlue), array('PlayerId' => 1, 'Score' => $scoreTeamRed));
                     if (!$client->query('ForceScores', $scores, true)) {
                         AdminServ::error();
                     } else {
                         $action = '[Admin] ' . Utils::t('The scores have been modified : $00fblue team $fffhas !scoreTeamBlue and $f00red team $fffhas !scoreTeamRed', array('!scoreTeamBlue' => $scoreTeamBlue, '!scoreTeamRed' => $scoreTeamRed));
                         if (!$client->query('ChatSendServerMessage', $action)) {
                             AdminServ::error();
                         } else {
                             AdminServLogs::add('action', $action);
                         }
                     }
                 } else {
                     if (isset($_POST['CancelVote'])) {
                         if (!$client->query('CancelVote')) {
                             AdminServ::error();
                         } else {
                             Utils::redirection();
                         }
                     }
                 }
             }
         }
     }
 }
Пример #15
0
<?php

// GAME VERSION
if (SERVER_VERSION_NAME == 'TmForever') {
    $queries = array('chooseNextMap' => 'ChooseNextChallengeList');
} else {
    $queries = array('chooseNextMap' => 'ChooseNextMapList');
}
// ACTIONS
if (isset($_POST['save']) && isset($_POST['list']) && $_POST['list'] != null) {
    $list = explode(',', $_POST['list']);
    if (!$client->query($queries['chooseNextMap'], $list)) {
        AdminServ::error();
    } else {
        AdminServLogs::add('action', 'Order map list');
        Utils::redirection(false, '?p=' . USER_PAGE);
    }
}
// MAPLIST
$data['maps'] = AdminServ::getMapList();
unset($data['maps']['lst'][$data['maps']['cid']]);
Пример #16
0
// THEME
define('USER_THEME', AdminServUI::theme($args['theme']));
// LANG
define('USER_LANG', AdminServUI::lang($args['lang']));
// VÉRIFICATION DES DROITS
$checkRightsList = array('./config/adminserv.cfg.php' => 666, './config/servers.cfg.php' => 666, './config/adminlevel.cfg.php' => 666);
if (in_array(true, AdminServConfig::$LOGS)) {
    if (!Utils::isWinServer()) {
        $checkRightsList['./logs/'] = 777;
    }
}
AdminServ::checkRights($checkRightsList);
// LOGOUT
AdminServEvent::logout();
// LOGS
AdminServLogs::initialize();
// PLUGINS
define('USER_PLUGIN', AdminServPlugin::getCurrent());
// INDEX
unset($args['theme'], $args['lang']);
if (AdminServEvent::isLoggedIn()) {
    // SWITCH SERVER
    AdminServEvent::switchServer();
    // SERVER CONNECTION
    if (AdminServ::initialize()) {
        // PAGES BACKOFFICE
        AdminServUI::initBackPage();
    }
} else {
    // PAGES FRONTOFFICE
    AdminServUI::initFrontPage();
Пример #17
0
<?php

// GAME
if (SERVER_VERSION_NAME == 'TmForever') {
    $queries = array('removeMap' => 'RemoveChallengeList', 'chooseNextMap' => 'ChooseNextChallengeList');
} else {
    $queries = array('removeMap' => 'RemoveMapList', 'chooseNextMap' => 'ChooseNextMapList');
}
// ACTIONS
if (isset($_POST['removeMap']) && isset($_POST['map']) && count($_POST['map']) > 0) {
    if (!$client->query($queries['removeMap'], $_POST['map'])) {
        AdminServ::error();
    } else {
        AdminServLogs::add('action', 'Remove map (' . count($_POST['map']) . ')');
        Utils::redirection(false, '?p=' . USER_PAGE);
    }
} else {
    if (isset($_POST['chooseNextMap']) && isset($_POST['map']) && count($_POST['map']) > 0) {
        if (!$client->query($queries['chooseNextMap'], $_POST['map'])) {
            AdminServ::error();
        } else {
            AdminServLogs::add('action', 'Choose next map (' . count($_POST['map']) . ')');
            Utils::redirection(false, '?p=' . USER_PAGE);
        }
    }
}
// MAPLIST
$data['maps'] = AdminServ::getMapList();