Esempio n. 1
0
 function __construct()
 {
     // extract version info from configuration file
     $this->config = Config::getInstance();
     $this->myLogger = new Logger("autoUpgrade", $this->config->getEnv("debug_level"));
     $this->current_version = $this->config->getEnv("version_date");
     // connect database with proper permissions
     $this->conn = DBConnection::getRootConnection();
     if ($this->conn->connect_error) {
         throw new Exception("Cannot perform upgrade process: database::dbConnect()");
     }
 }
Esempio n. 2
0
 public function restore()
 {
     // we need root database access to re-create tables
     $rconn = DBConnection::getRootConnection();
     if ($rconn->connect_error) {
         throw new Exception("Cannot perform upgrade process: database::dbConnect()");
     }
     session_start();
     unset($_SESSION['progress']);
     session_write_close();
     // phase 1: retrieve file from http request
     $data = $this->retrieveDBFile();
     // phase 2: verify received file
     if (strpos(substr($data, 0, 25), "-- AgilityContest") === FALSE) {
         throw new Exception("Provided file is not an AgilityContest backup file");
     }
     // phase 3: delete all tables and structures from database
     $this->dropAllTables($rconn);
     // phase 4: parse sql file and populate tables into database
     $this->readIntoDB($rconn, $data);
     // phase 5 final tests
     DBConnection::closeConnection($rconn);
     return "";
 }
Esempio n. 3
0
 public function dropTable()
 {
     // To create database we need root DB access
     $rconn = DBConnection::getRootConnection();
     if ($rconn->connect_error) {
         throw new Exception("Cannot perform import process: database::dbConnect()");
     }
     $str = "DROP Table IF EXISTS {$this->tablename};";
     $res = $rconn->query($str);
     if (!$res) {
         $error = $rconn->error;
         $str = "ImportExcel(dogs)::dropTable(): Error deleting temporary table: '{$error}'";
         $this->myLogger->error($str);
         throw new Exception($str);
     }
     return 0;
 }