public function __construct($smarty, $smartyTemplate, $mode = null) { if (null == $mode) { if (!empty($_GET['mode'])) { if ("json" == $_GET['mode']) { $mode = MODE_JSON; } } } if (null == $mode) { $mode = MODE_WEB; } $this->_mode = $mode; $this->_smarty = $smarty; $this->_smartyTemplate = $smartyTemplate; // User specified global information if (UserManager::GetLocalUser() != null) { $this->_assigns["t_User"] = UserManager::GetLocalUser(); $this->_assigns["t_GameserverList"] = UserManager::GetLocalUser()->getAllGameserver(); $this->_assigns["t_Gameserver"] = UserManager::GetLocalUser()->getSelectedGameserver(); } // Javascript File $jsscript = str_replace("pages/", "", str_replace(".tpl", ".js", $smartyTemplate)); $jsfile = Core::GetConfig("dirIntRoot") . "assets/js/custom/{$jsscript}"; if (file_exists($jsfile)) { $smarty->assign("t_JS", $jsscript); } }
/** * * Get the connection Reference statically * * @global array $config Global Config from config file * @return MySQLi Connection */ public static function getCon() { if (Database::$con == null) { global $config; Database::$con = new mysqli(Core::GetConfig("db_host"), Core::GetConfig("db_user"), Core::GetConfig("db_password"), Core::GetConfig("db_db")); if (Database::$con->connect_error) { die('Connect Error (' . Database::$con->connect_errno . ') ' . Database::$con->connect_error); } } return Database::$con; }
public function send() { global $config; $mail = file_get_contents($this->file); foreach ($this->vars as $key => $value) { $mail = str_replace("{" . $key . "}", $value, $mail); } $mail = nl2br($mail); $mh = 'From: "' . Core::GetConfig("email_sender_name") . '" <' . Core::GetConfig("email_sender") . ">\r\n"; $mh .= 'Reply-To: ' . Core::GetConfig("email_sender") . "\r\n"; $mh .= 'Content-Type: text/html;charset=UTF-8' . "\r\n"; // //$mh .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n"; $mh .= 'X-Mailer: class SMTPMail'; mail($this->mail, $this->caption, $mail, $mh); }
public function __construct($ip, $port, $username, $password) { $this->_username = $username; if (Utils::checkPingToIPAndPort($ip, $port)) { $this->_con = ssh2_connect($ip, $port); if (!ssh2_auth_password($this->_con, $username, $password)) { die("Ungültige SSH-Login Daten."); } else { $this->_serverWriteFile = "/home/" . Core::GetConfig("sshUserName") . "/PanelLog"; $this->_sftp = @ssh2_sftp($this->_con); } } else { die("Konnte Server nicht erreichen."); } }
public static function createServer($server, $user, $template, $port, $slots) { // Create Database Entry for new server $data = array(); $data["port"] = $port; $data["userID"] = $user->getData("id"); $data["serverID"] = $server->getData("id"); $data["templateID"] = $template->getData("id"); $data["status"] = GAMESERVER_STATUS_PENDING; $data["slots"] = $slots; $id = Database::insertQuery("gameserver", $data); // Create Task Core::addTask(TASK_GAMESERVER_INSTALL, $id); // Send E-Mail if (Core::GetConfig("sendEmails")) { $mail = new Mail($user->getData("email"), "GameserverCreated.tpl", "Gameserver created"); $mail->assignVar("username", $user->getData("username")); $mail->assignVar("gamename", $template->getData("gameName")); $mail->assignVar("ip", $server->getData("ip")); $mail->assignVar("port", $port); $mail->assignVar("website", Core::GetConfig("pubURI")); $mail->send(); } }
public function installOnServer($server, $gameServer = null) { if ($this->isInstalledOnServer($server, $gameServer)) { return; } // variables $templateFile = $this->getZipFile(); $tempDirectory = Core::GetConfig("dirIntScripts") . "preparing"; $targetZipFile = Core::GetConfig("dirIntScripts") . "preparing.zip"; // remove temporary directory if exists if (is_dir($tempDirectory)) { Utils::rmdir_recursive($tempDirectory); } // Unzip the Template .zip file Utils::unzip($templateFile, $tempDirectory); // Info XML exists? if (file_exists($tempDirectory . "/info.xml")) { // Load files from xml $xml = simplexml_load_file($tempDirectory . "/info.xml"); $data = Utils::xmlToArray($xml); // Prepare all files with variables $files = $this->getFilesWithVariables(); if ($files != null) { foreach ($files as $file) { $this->_replaceVariablesWithValues($tempDirectory . "/" . $file, $gameServer); } } // create shell if ($gameServer != null) { $shell = $gameServer->getShell(); } else { $shell = $server->createShell($data["RootUser"] == "True" ? true : false); } // Variables v2 if ($gameServer != null) { $remoteDirectory = $this->getGameserverFolder($shell, $server, $gameServer->getUser(), $gameServer)['directoryDirect']; $shell->executeInHome("mkdir {$remoteDirectory} -p"); } else { $remoteDirectory = $this->getStaticFolder($shell)['directoryDirect']; } $installScript["dir"] = $remoteDirectory; $installScript["script"] = $this->getData("infoxmlar", "InstallScript"); // Zip File Creation if (file_exists($targetZipFile)) { unlink($targetZipFile); } Utils::zip($tempDirectory, $targetZipFile); if (is_dir($tempDirectory)) { Utils::rmdir_recursive($tempDirectory); } // Copy Zip File and run the setup. $shell->uploadFileToHomePath($targetZipFile, "prepared.zip"); unlink($targetZipFile); $shell->executeInHome("unzip -o prepared.zip -d {$remoteDirectory}"); $shell->executeInHome("rm prepared.zip"); // FilesWithRight if (isset($data['FilesWithRights'])) { // If there is only one File if (isset($data['FilesWithRights']["File"]["Mod"])) { $shell->execute($remoteDirectory, "chmod " . $data['FilesWithRights']["File"]["Mod"] . " " . $data['FilesWithRights']["File"]["FileName"]); } else { foreach ($data['FilesWithRights']["File"] as $file) { $file = Utils::xmlToArray($file); $shell->execute($remoteDirectory, "chmod " . $file["Mod"] . " " . $file["FileName"]); } } } // User null -> All Files have to be static. if ($gameServer != null) { $remoteStaticDir = $this->getStaticFolder($shell)['directoryDirect']; // Static Files? if (isset($data['StaticFiles'])) { $shell->executeInHome("mkdir {$remoteStaticDir} -p"); foreach ($data['StaticFiles']['File'] as $file) { if ($file == $this->getData("infoxmlar", "InstallScript")) { $installScript["dir"] = $remoteStaticDir; } $shell->executeInHome("mv {$remoteDirectory}{$file} {$remoteStaticDir}{$file}"); } } } $shell->runShellScript($installScript["dir"], $installScript["script"]); if ($gameServer != null) { $gameServer->settingsUpdateOnServer(); } echo "INSTALLING: " . $installScript["dir"] . $installScript["script"]; // Save Changes to Database if ($this->isBaseTemplate()) { $data = array(); $data["serverID"] = $server->getData("id"); $data["templateID"] = $this->getData("id"); $data["templateVersion"] = $this->getData("scriptVersion"); Database::insertQuery("physicalserver_templates", $data); } } else { throw new Exception("info xml doesnt exist."); } }
echo "Code: " . $code; echo "Text: " . $text; echo "File: " . $file; echo "Row: " . $row; debug_print_backtrace(); });*/ if (!is_dir(Core::getConfig("tempDir"))) { mkdir(Core::getConfig("tempDir")); } include $config["dirIntRoot"] . "assets/frameworks/smarty-3.1.27/Smarty.class.php"; $smarty = new Smarty(); Core::initSmarty($smarty); PageManager::assignSmarty($smarty); UserManager::initialize(); // Breadcrumbs $baseDir = Core::GetConfig("dirRoot"); if (isset($_SERVER['REQUEST_URI'])) { $uri = str_replace($baseDir, "", $_SERVER['REQUEST_URI']); if (strpos($uri, "?") !== false) { $uri = explode("?", $uri); $uri = $uri[0]; } $bc = explode("/", $uri); $bcc = array(); foreach ($bc as $key => $value) { $bcc[$key][0] = $value; $bcc[$key][1] = $baseDir . $value; } } else { $bcc["Dashboard"] = "Dashboard"; }
public static function loadTemplateByRemote($folder) { $path = Core::GetConfig("templateProvider") . "?do=download&folderName=" . $folder; $remoteFileURL = Utils::getWebContent($path); $localFile = Core::GetConfig("dirIntScripts") . "installing.zip"; $tempDirectory = Core::GetConfig("dirIntScripts") . "installing/"; if (file_exists($localFile)) { unlink($localFile); } if (is_dir($tempDirectory)) { Utils::rmdir_recursive($tempDirectory); } // Download and prepare Utils::downloadFile($localFile, $remoteFileURL); Utils::unzip($localFile, $tempDirectory); // XML and Data if (file_exists($tempDirectory . "info.xml")) { $xmltext = file_get_contents($tempDirectory . "info.xml"); $xml = simplexml_load_string($xmltext); $data = TemplateManager::_validateTemplateInformation(Utils::xmlToArray($xml)); // Create Template $t = new Template(); $t->setSetting("scriptVersion", $data["scriptVersion"]); $t->setSetting("gameName", $data["gameName"]); $t->setSetting("iconFile", $data["iconFile"]); $t->setSetting("folderName", $folder); $t->setSetting("infoxml", $xmltext); if (isset($data["settingsFile"])) { $t->setSetting("settingsxml", Template::replaceVariablesWithValues(file_get_contents($tempDirectory . $data["settingsFile"]))); } // Base Template (One-Time-Install. No Gameserver) if (isset($data['isBaseTemplate'])) { if ($data['isBaseTemplate'] == "True") { $t->setSetting("baseTemplate", 1); } else { $t->setSetting("baseTemplate", 0); } } else { $t->setSetting("baseTemplate", 0); } $t->saveToDatabase(); // Move Icon File $tempIcon = $tempDirectory . $t->getData("iconFile"); $newIcon = $t->getIconFile(); copy($tempIcon, $newIcon); Utils::rmdir_recursive($tempDirectory); if ($t->getData("id") != 0) { rename($localFile, $t->getZipFile()); } else { unlink($localFile); } return $t; } else { throw new Exception("Info.xml doesnt exists in downloaded script. Aborting."); } }
<?php /* * WolfPanel (c) 2015 by Fursystems.de (Marcel Kallen) * * WolfPanel is licensed under a * Creative Commons Attribution-NonCommercial 4.0 International License. * * You should have received a copy of the license along with this * work. If not, see <http://creativecommons.org/licenses/by-nc/4.0/>. */ include "../core.php"; header("Content-type: application/json"); echo Utils::getWebContent(Core::GetConfig("templateProvider"));
public function _getFreePorts() { $allPorts = array(); for ($i = Core::GetConfig("port_min"); $i < Core::GetConfig("port_max"); $i++) { $allPorts[] = $i; } $freePorts = array_diff($allPorts, $this->getUsedPorts()); if (count($freePorts) != 0) { return $freePorts; } else { return false; } }
* You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ include "../core.php"; // Admin Check $user = UserManager::getLocalUser(); if (!$user->isAdmin()) { PageManager::displayErrorPage("access"); return; } include "assets/classes/PhysicalServerManager.class.php"; include "assets/classes/PhysicalServer.class.php"; include "assets/classes/TemplateManager.class.php"; include "assets/classes/Template.class.php"; $page = new Page($smarty, "modals/TemplateInstallOnServer.tpl"); if (empty($_GET['templateid'])) { $page->assign("t_Report", Reporting::error("No template id given.")); } else { if (!TemplateManager::existsById($_GET['templateid'])) { $page->assign("t_Report", Reporting::error("The given template id doesn't exist.")); } else { $page->assign("template", new Template($_GET['templateid'])); } } $sc = PhysicalServerManager::getCount(); if ($sc == 0) { $page->assign("t_Report", Reporting::info("There are no servers yet. Try <a href='" . Core::GetConfig("dirRoot") . "Server'>adding one</a>.")); } else { $page->assign("serverArrayData", PhysicalServerManager::getAllPhysicalServer()); } $page->display();
$error = array(); if (!UserManager::checkValidEmail($email)) { $error[] = "Ungültige E-Mail Adresse."; } if (!UserManager::checkValidPassword($pass)) { $error[] = "Ungültiges Passwort."; } if (count($error) == 0 && !UserManager::tryLogin($email, $pass)) { $error[] = "Es wurde kein Nutzer mit den angegeben Login-Daten gefunden."; } if (count($error) == 0) { if (isset($_POST['keepLoggedIn'])) { setcookie("username", $email, time() + 60 * 60 * 24 * 30 * 12 * 4); setcookie("password", $pass, time() + 60 * 60 * 24 * 30 * 12 * 4); } $page->assign("t_Report", Reporting::success("Sie wurden erfolgreich eingeloggt!<br />Sie werden in Kürze weitergeleitet.")); $page->assign("t_Redirect", array("seconds" => 2, "link" => Core::GetConfig("dirRoot") . "Dashboard")); } else { $msg = "Es sind Fehler aufgetreten!<ul>"; foreach ($error as $e) { $msg .= "<li>" . $e . "</li>"; } $msg .= "</ul>"; $page->assign("t_Report", Reporting::error($msg)); $page->assign("error", 1); } } if (is_dir("install")) { $page->assign("t_StaticInformation", Reporting::info("<br />Standard Werte für den Admin Nutzer: <br />E-Mail: admin@admin.de<br />Passwort: admin<br />Um diese Nachricht auszublenden, lösche das Verzeichnis 'install'")); } $page->display();
public static function addServer($i) { if (count(PhysicalServerManager::validateInformation($i)) != 0) { die("Err psm.c.p - 01"); } $data = PhysicalServerManager::getClearInformationArray($i); $data["sshPanelUser"] = Core::GetConfig("sshUserName"); Database::insertQuery("physicalserver", $i); }
public static function addUser($username, $prename, $lastname, $email) { $error = array(); $err = @Utils::checkInput($_POST['username'], "Username", 3, 64, INPUT_TYPE_STRING); if (strlen($err) != 0) { $error[] = $err; } $err = @Utils::checkInput($_POST['prename'], "Prename", 3, 64, INPUT_TYPE_STRING); if (strlen($err) != 0) { $error[] = $err; } $err = @Utils::checkInput($_POST['lastname'], "Lastname", 3, 64, INPUT_TYPE_STRING); if (strlen($err) != 0) { $error[] = $err; } $err = @Utils::checkInput($_POST['email'], "E-Mail", 3, 64, INPUT_TYPE_EMAIL); if (strlen($err) != 0) { $error[] = $err; } if (count($error) == 0) { $con = Database::getCon(); $pass = $con->escape_string(Utils::rand_string(8)); $passHashed = md5($pass); $data = array(); $data["username"] = $username; $data["prename"] = $prename; $data["lastname"] = $lastname; $data["email"] = $email; $data["password"] = $passHashed; Database::insertQuery("users", $data); if (Core::GetConfig("sendEmails")) { $mail = new Mail($email, "CustomerAdd.tpl", "User Creation Wolfpanel"); $mail->assignVar("username", $username); $mail->assignVar("email", $email); $mail->assignVar("website", Core::GetConfig("pubURI")); $mail->assignVar("password", $pass); $mail->send(); } } else { return $error; } }
/** * * Redirects a user if he isnt logged in. * * @return boolean True if redirected. */ public static function forceRedirect() { $red = false; $redLink = ""; $scriptFileName = explode("/", $_SERVER['SCRIPT_FILENAME']); $scriptFileName = $scriptFileName[count($scriptFileName) - 1]; // Login Page if (null == UserManager::getLocalUser() && "login.php" != $scriptFileName) { $red = true; $redLink = Core::GetConfig("dirRoot") . "Login"; } if ($scriptFileName == "login.php" && UserManager::getLocalUser() != null) { $red = true; $redLink = Core::GetConfig("dirRoot") . "Dashboard"; } if ($red) { header("Location: " . $redLink); return true; } else { return false; } }