Пример #1
0
 public function actionCheckReady()
 {
     //check databse
     $database = getSQLDB();
     if (!$database) {
         $this->result["status"] = -2;
         $this->result["msg"] = "Cannot connect to DB";
         return;
     }
     if ($this->checkReady() != true) {
         $this->result["status"] = -1;
         return;
     }
     //gather system info
     $info = array();
     $info["version"] = $this->version;
     dispatchEventToModules("onSystemInfo", $info);
     $this->result["info"] = $info;
     $this->result["status"] = 1;
 }
Пример #2
0
 public function searchFilesFromDBByCategory($unit_id, $category, $limit = 50, $offset = 0)
 {
     $category = addslashes($category);
     $database = getSQLDB();
     $query = "SELECT * FROM `" . DB_PREFIX . "files` WHERE `category` = '" . $category . "' AND unit_id = " . intval($unit_id) . " LIMIT " . intval($offset) . "," . intval($limit);
     //debug($query);
     $result = $database->query($query);
     if (!$result) {
         return null;
     }
     $files = array();
     while ($file = $result->fetch_object()) {
         $files[] = $file;
     }
     return $files;
 }
Пример #3
0
 public function createTables()
 {
     $database = getSQLDB();
     //USERS table
     $query = "CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "users (\r\n\t\t  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\r\n\t\t  `username` varchar(255) NOT NULL,\r\n\t\t  `password` varchar(255) NOT NULL,\r\n\t\t  `email` varchar(255) NOT NULL,\r\n\t\t  `roles` varchar(255) NOT NULL,\r\n\t\t  `data` text NOT NULL,\r\n\t\t  `used_space` int(10),\r\n\t\t  `total_space` int(10),\r\n\t\t  PRIMARY KEY (`id`),\r\n\t\t  UNIQUE KEY `email` (`email`),\r\n\t\t  `status` ENUM('PENDING','VALID','BANNED') NOT NULL\r\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
     $result = $database->query($query);
     if ($result !== TRUE) {
         debug("Users table not created");
         $this->result["msg"] = "Users table not created";
         $this->result["status"] = -1;
         return false;
     } else {
         debug("Users table created");
     }
     //SESSIONS table
     $query = "CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "sessions (\r\n\t\t  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\r\n\t\t  `user_id` int(10) NOT NULL,\r\n\t\t  `token` varchar(255) NOT NULL,\r\n\t\t  `timestamp` TIMESTAMP NOT NULL,\r\n\t\t  PRIMARY KEY (id)\r\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
     $result = $database->query($query);
     if ($result !== TRUE) {
         debug("Users sessions table not created");
         $this->result["msg"] = "Users sessions table not created";
         $this->result["status"] = -1;
         return false;
     } else {
         debug("Users sessions table created");
     }
     //PASS RECOVERY table
     $query = "CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "pass_recovery (\r\n\t\t  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\r\n\t\t  `user_id` int(10) NOT NULL,\r\n\t\t  `token` varchar(255) NOT NULL,\r\n\t\t  `timestamp` TIMESTAMP NOT NULL,\r\n\t\t  PRIMARY KEY (id)\r\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
     $result = $database->query($query);
     if ($result !== TRUE) {
         debug("Password recovery table not created");
         $this->result["msg"] = "Password recovery table not created";
         $this->result["status"] = -1;
         return false;
     } else {
         debug("Password recovery table created");
     }
     return true;
 }
Пример #4
0
if (!file_exists(__DIR__ . "/include/config.php")) {
    showMessage("Cannot find <strong>include/config.php</strong> file, please remember to create a copy of  <strong>config.sample.php</strong> as  <strong>config.php </strong> and edit it with your DB values.");
    die($end_string);
} else {
    showMessage("config.php found, testing database connection", "success");
}
//include core
require_once 'include/core.php';
loadModules("*");
//check config has valid values
if (ADMIN_PASS == "" || ADMIN_MAIL == "") {
    showMessage("Error: Config.php must be changed, edit the config.php and add a password and an email for the admin account.");
    die($end_string);
}
//check if config works
$database = getSQLDB();
if (!$database) {
    showMessage("Cannot connect to database, check that the info inside config.php is correct and your databse running.");
    die($end_string);
} else {
    showMessage("Database connection established", "success");
}
//check if there is data still
$system = getModule("system");
$is_ready = $system->checkReady();
if ($is_ready && $console && count($argv) > 1 && $argv[1] == "upgrade") {
    showMessage("Upgrading system...", "primary");
    $system->upgradeSystem();
    showMessage("System upgraded", "success");
    die($end_string);
}