Exemple #1
0
 public function write($path, $content, $type = "w")
 {
     return \Lobby\FS::write($this->dir . $path, $content, $type);
 }
Exemple #2
0
 /**
  * Make the config.php file
  */
 public static function makeConfigFile($db_type = "mysql")
 {
     $lobbyID = \Helper::randStr(10) . \Helper::randStr(15) . \Helper::randStr(20);
     // Lobby Global ID
     $lobbySID = hash("sha512", \Helper::randStr(15) . \Helper::randStr(30));
     // Lobby Secure ID
     $configFileLoc = L_DIR . "/config.php";
     $cfg = self::$database;
     /**
      * Make the configuration file
      */
     $config_sample = FS::get("/includes/lib/lobby/inc/config-sample.php");
     $config_file = $config_sample;
     if ($db_type === "mysql") {
         $config_file = preg_replace("/host'(.*?)'(.*?)'/", "host'\$1'{$cfg['host']}'", $config_file);
         $config_file = preg_replace("/port'(.*?)'(.*?)'/", "port'\$1'{$cfg['port']}'", $config_file);
         $config_file = preg_replace("/username'(.*?)''/", "username'\$1'{$cfg['username']}'", $config_file);
         $config_file = preg_replace("/password'(.*?)''/", "password'\$1'{$cfg['password']}'", $config_file);
         $config_file = preg_replace("/dbname'(.*?)''/", "dbname'\$1'{$cfg['dbname']}'", $config_file);
         $config_file = preg_replace("/prefix'(.*?)'(.*?)'/", "prefix'\$1'{$cfg['prefix']}'", $config_file);
     } else {
         $config_file = preg_replace("/type'(.*?)'(.*?)'/", "type'\$1'sqlite'", $config_file);
         $config_file = preg_replace("/port'(.*?)'(.*?)',/", "path'\$1'{$cfg['path']}',", $config_file);
         $config_file = preg_replace("/[[:blank:]]+(.*?)'host'(.*?)'(.*?)',\n/", "", $config_file);
         $config_file = preg_replace("/[[:blank:]]+(.*?)'username'(.*?)'',\n/", "", $config_file);
         $config_file = preg_replace("/[[:blank:]]+(.*?)'password'(.*?)'',\n/", "", $config_file);
         $config_file = preg_replace("/[[:blank:]]+(.*?)'dbname'(.*?)'',\n/", "", $config_file);
         $config_file = preg_replace("/prefix'(.*?)'(.*?)'/", "prefix'\$1'{$cfg['prefix']}'", $config_file);
     }
     $config_file = preg_replace("/lobbyID'(.*?)''/", "lobbyID'\$1'{$lobbyID}'", $config_file);
     $config_file = preg_replace("/secureID'(.*?)''/", "secureID'\$1'{$lobbySID}'", $config_file);
     /**
      * Create the config.php file
      */
     if (FS::write($configFileLoc, $config_file) === false) {
         echo ser("Failed Creating Config File", "Something happened while creating the file. Perhaps it was something that you did ?");
     } else {
         chmod(L_DIR . "/config.php", 0550);
     }
 }
Exemple #3
0
 /**
  * Make the config.php file
  */
 public static function makeConfigFile()
 {
     $lobbyID = self::randStr(10) . self::randStr(15) . self::randStr(20);
     // Lobby Global ID
     $lobbySID = hash("sha512", self::randStr(15) . self::randStr(30));
     // Lobby Secure ID
     $configFileLoc = L_DIR . "/config.php";
     $cfg = self::$database;
     /* Make the configuration file */
     $config_sample = \Lobby\FS::get("/includes/lib/core/Inc/config-sample.php");
     $config_file = $config_sample;
     $config_file = preg_replace("/host'(.*?)'(.*?)'/", "host'\$1'{$cfg['host']}'", $config_file);
     $config_file = preg_replace("/port'(.*?)'(.*?)'/", "port'\$1'{$cfg['port']}'", $config_file);
     $config_file = preg_replace("/username'(.*?)''/", "username'\$1'{$cfg['username']}'", $config_file);
     $config_file = preg_replace("/password'(.*?)''/", "password'\$1'{$cfg['password']}'", $config_file);
     $config_file = preg_replace("/dbname'(.*?)''/", "dbname'\$1'{$cfg['dbname']}'", $config_file);
     $config_file = preg_replace("/lobbyID'(.*?)''/", "lobbyID'\$1'{$lobbyID}'", $config_file);
     $config_file = preg_replace("/secureID'(.*?)''/", "secureID'\$1'{$lobbySID}'", $config_file);
     $config_file = preg_replace("/prefix'(.*?)'(.*?)'/", "prefix'\$1'{$cfg['prefix']}'", $config_file);
     /**
      * Create the config.php file
      */
     if (\Lobby\FS::write($configFileLoc, $config_file) === false) {
         ser("Failed Creating Config File", "Something happened while creating the file. Perhaps it was something that you did ?");
     } else {
         chmod(L_DIR . "/config.php", 0550);
     }
 }
Exemple #4
0
 public static function finish_software_update($admin_previously_installed = false)
 {
     FS::write("/upgrade.lobby", "1", "w");
     if ($admin_previously_installed) {
         FS::remove("/contents/modules/admin/disabled.txt");
     }
     $latest_version = DB::getOption("lobby_latest_version");
     self::log("Updated Lobby to version {$latest_version}");
     /**
      * Remove Depreciated Files
      */
     $deprecatedFilesInfoLoc = "/contents/update/removeFiles.php";
     if (FS::exists($deprecatedFilesInfoLoc)) {
         $files = FS::get($deprecatedFilesInfoLoc);
         $files = explode("\n", $files);
         if (count($files) !== 0) {
             $files = array_filter($files);
             foreach ($files as $file) {
                 $fileLoc = L_DIR . "/{$file}";
                 if (file_exists($fileLoc) && $fileLoc != L_DIR) {
                     FS::remove($fileLoc);
                     self::log("Removed Deprecated File: {$fileLoc}");
                 }
             }
             copy(FS::loc($deprecatedFilesInfoLoc), FS::loc("{$deprecatedFilesInfoLoc}.txt"));
             FS::remove($deprecatedFilesInfoLoc);
             self::log("Finished Removing Deprecated Files");
         }
     }
     /**
      * Database Update
      */
     if (FS::exists("/update/sqlExecute.sql")) {
         self::log("Upgrading Lobby Database");
         $sqlCode = FS::get("/update/sqlExecute.sql");
         $sql = \Lobby\DB::prepare($sqlCode);
         if (!$sql->execute()) {
             echo ser("Error", "Database Update Couldn't be made. <a href='update.php'>Try again</a>");
         } else {
             FS::remove("/update/sqlExecute.sql");
         }
         self::log("Updated Lobby Database");
     }
     FS::remove("/upgrade.lobby");
     self::log("Lobby is successfully Updated.");
 }
Exemple #5
0
 /**
  * Add message to log files 
  */
 public static function log($msg = "", $file = "lobby.log")
 {
     $msg = !is_string($msg) ? serialize($msg) : $msg;
     if ($msg != "" && self::$debug === true) {
         $logFile = "/contents/extra/{$file}";
         $message = "[" . date("Y-m-d H:i:s") . "] {$msg}";
         \Lobby\FS::write($logFile, $message, "a");
     }
 }
Exemple #6
0
 public static function disableModule($module)
 {
     if (self::exists($module)) {
         \Lobby\FS::write(self::$mods[$module]["location"] . "/disabled.txt", "1");
         return true;
     } else {
         return false;
     }
 }
Exemple #7
0
 /**
  * Add message to log files 
  */
 public static function log($msg = null, $file = "lobby.log")
 {
     /**
      * If $msg is an array, it means the errors are SERIOUS
      * Array(
      *   0 => "Type of Error",
      *   1 => "Message"
      * )
      */
     if (is_array($msg)) {
         $type = $msg[0];
         $logMSG = ucfirst($type) . " Error - " . $msg[1];
     } else {
         if (self::$debug === false) {
             return false;
         }
     }
     if ($msg != null) {
         $logMSG = !is_string($msg) ? serialize($msg) : $msg;
     }
     /**
      * Write to Log File
      */
     if ($msg != null) {
         $logFile = "/contents/extra/logs/{$file}";
         /**
          * Format the log message 
          */
         $logMSG = "[" . date("Y-m-d H:i:s") . "] {$logMSG}";
         \Lobby\FS::write($logFile, $logMSG, "a");
     }
     /**
      * If error is Fatal, Lobby can't work
      * So register error in class
      */
     if (isset($type) && $type === "fatal") {
         Response::showError(ucfirst($msg[0]) . " Error", $msg[1]);
     }
 }