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."); } }
$hashTagName = $db->escapeString($requestData->hashTagName); $activationDateTime = $db->escapeString($requestData->activationDateTime); $activationDateTime = date("Y-m-d H:i:s", strtotime($activationDateTime)); $createdBy = $db->escapeString($requestData->createdBy); $createdTime = $db->escapeString($requestData->createdTime); $createdTime = date("Y-m-d H:i:s", strtotime($createdTime)); /*Local Server Time*/ $localServerTime = date("d-M-y, h:i A"); if (strtotime($activationDateTime) <= strtotime($localServerTime)) { $hashTagStatus = "1"; } elseif (strtotime($activationDateTime) > strtotime($localServerTime)) { $hashTagStatus = "2"; } if (!empty($hashTagName)) { $field_values = 'hashtagName = "' . $hashTagName . '", hashtagCreatedBy= "' . $createdBy . '", hashtagCreatedTime ="' . $createdTime . '", hashtagActivationTime = "' . $activationDateTime . '", hashtagStatus = "' . $hashTagStatus . '"'; $db->insertQuery("tbl_hashtag", $field_values); $data['message'] = "The hashtag has been added"; $data['destinationPage'] = "overview"; } else { $data['message'] = "The hashtag has not been added"; } echo $jsonHandle->encode($data); } elseif ($innerPage == "delete") { $hashtagName = $db->escapeString($requestData->hashtagName); $query = $db->query("DELETE FROM tbl_hashtag WHERE hashtagName = '{$hashtagName}'"); if ($query) { $data['message'] = "You have successfully deleted."; } else { $data['message'] = "deletion of hastag is failed"; } echo $jsonHandle->encode($data);
public function addTask($taskType, $info = "") { $d = array("type" => $taskType, "serverID" => $this->getData("id"), "addInfo" => $info); Database::insertQuery("tasks", $d); }
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 insert() { $database = new Database(); $database->insertQuery('users')->set('username', 'Pablo')->set('password', 'Sanchez'); $result = $database->execute(); $database->insertQuery('users')->set('username', 'Jorge')->set('password', 'Sanchez')->where('id', '5'); $result = $database->execute(); }
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; } }
/** * * Adds a Message to the defined log * * @param string $log The logname (equals database table without the "logs_" prefix * @param string $text The Log Text * @param integer $loglevel The LOGLEVEL_ of the Message. */ private static function _addToLog($log, $text, $loglevel = LOGLEVEL_INFO) { Database::insertQuery("logs_" . $log, array("message" => $text, "loglevel" => $loglevel)); }