diff --git a/AVE-PHP.iss b/AVE-PHP.iss index c27b0a5..3e8f3cc 100644 --- a/AVE-PHP.iss +++ b/AVE-PHP.iss @@ -1,5 +1,5 @@ #define MyAppName "AVE-PHP" -#define MyAppVersion "2.2.2" +#define MyAppVersion "2.2.3" #define MyAppPublisher "Abyss Morgan" #define MyAppURL "https://github.com/AbyssMorgan" #define MyAppExeName "AVE-PHP.cmd" diff --git a/includes/AVE.php b/includes/AVE.php index 73cf09f..77421d4 100644 --- a/includes/AVE.php +++ b/includes/AVE.php @@ -27,7 +27,7 @@ class AVE extends Core { public string $app_data; public bool $abort = false; public string $app_name = "AVE-PHP"; - public string $version = "2.2.2"; + public string $version = "2.2.3"; private array $folders_to_scan = [ 'bin', diff --git a/includes/avecore/Migration.php b/includes/avecore/Migration.php new file mode 100644 index 0000000..a49e299 --- /dev/null +++ b/includes/avecore/Migration.php @@ -0,0 +1,88 @@ +query("SHOW TABLES LIKE '$table'"); + return ($result && $result->rowCount() == 1); + } + + public function migrate() : void { + if(!$this->table_exists($this->table_version)){ + $this->query(" + CREATE TABLE `$this->table_version` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `table_name` varchar(32) NOT NULL, + `version` int(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci + "); + } + + $version = $this->get_version($this->table_config, false); + if($version < 1){ + $this->query(" + CREATE TABLE `$this->table_config` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(128) DEFAULT NULL, + `value` text DEFAULT NULL, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci + "); + $this->set_version($this->table_config, 1); + } + } + + public function get_version(string $table, bool $migrate = true) : int { + if($migrate) $this->migrate(); + if(!$this->table_exists($table)) return 0; + $result = $this->query("SELECT `version` FROM `$this->table_version` WHERE `table_name` = '$table'", PDO::FETCH_OBJ); + if($result && $result->rowCount() == 1){ + $row = $result->fetch(); + return intval($row->version); + } + return 0; + } + + public function set_version(string $table, int $version) : void { + if($version == 1){ + $this->query("INSERT INTO `$this->table_version` SET `table_name` = '$table', `version` = '$version'"); + } else { + $this->query("UPDATE `$this->table_version` SET `version` = '$version' WHERE `table_name` = '$table'"); + } + } + + public function get_value(string $name, ?string $default = null) : ?string { + $result = $this->query("SELECT `value` FROM `$this->table_config` WHERE `name` = '$name'", PDO::FETCH_OBJ); + if($result && $result->rowCount() == 1){ + $row = $result->fetch(); + return $row->value; + } + return $default; + } + + public function set_value(string $name, string $value) : void { + $value = $this->escape($value); + if(is_null($this->get_value($name))){ + $this->query("INSERT INTO `$this->table_config` SET `name` = '$name', `value` = '$value'"); + } else { + $this->query("UPDATE `$this->table_config` SET `value` = '$value' WHERE `name` = '$name'"); + } + } + +} + +?> diff --git a/includes/main.php b/includes/main.php index 5baa3f3..01f9a1e 100644 --- a/includes/main.php +++ b/includes/main.php @@ -19,6 +19,7 @@ require_once("$includes_path/avecore/IniFile.php"); require_once("$includes_path/avecore/Core.php"); require_once("$includes_path/avecore/MySQL.php"); + require_once("$includes_path/avecore/Migration.php"); require_once("$includes_path/avecore/Request.php"); require_once("$includes_path/avecore/FtpService.php"); require_once("$includes_path/avecore/BitFunctions.php"); diff --git a/includes/services/MediaFunctions.php b/includes/services/MediaFunctions.php index ccc749a..ecbf1f1 100644 --- a/includes/services/MediaFunctions.php +++ b/includes/services/MediaFunctions.php @@ -49,10 +49,10 @@ public function get_image_resolution(string $path) : string { $image = $this->get_image_from_path($path); if(!$image){ try { - $image = new Imagick($path); - $w = $image->getImageWidth(); - $h = $image->getImageHeight(); - $image->clear(); + @$image = new Imagick($path); + $w = @$image->getImageWidth(); + $h = @$image->getImageHeight(); + @$image->clear(); return $w."x".$h; } catch(Exception $e){ diff --git a/version b/version index 7e541ae..6b4d157 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.2.2 \ No newline at end of file +2.2.3 \ No newline at end of file