Skip to content

Commit

Permalink
v2.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
AbyssMorgan committed Jul 7, 2024
1 parent fa89c7d commit a7ab2bb
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 7 deletions.
2 changes: 1 addition & 1 deletion AVE-PHP.iss
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion includes/AVE.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
88 changes: 88 additions & 0 deletions includes/avecore/Migration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

declare(strict_types=1);

namespace AveCore;

use PDO;

class Migration extends MySQL {

protected string $table_version = 'ave_version';
protected string $table_config = 'ave_config';

public function __construct(){
parent::__construct();
}

public function table_exists(string $table) : bool {
$result = $this->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'");
}
}

}

?>
1 change: 1 addition & 0 deletions includes/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions includes/services/MediaFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.2
2.2.3

0 comments on commit a7ab2bb

Please sign in to comment.