Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AbyssMorgan committed Dec 18, 2023
1 parent c9c0bd0 commit 37d30ea
Show file tree
Hide file tree
Showing 21 changed files with 729 additions and 101 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 "1.9.6"
#define MyAppVersion "2.0.0"
#define MyAppPublisher "Abyss Morgan"
#define MyAppURL "https://github.com/AbyssMorgan"
#define MyAppExeName "AVE-PHP.cmd"
Expand Down
6 changes: 3 additions & 3 deletions BuildLinux.ave-php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

$output = "$this->path/Setup";
$zip_name_a = $this->ave->get_file_path("$output/${app_name}_v$version"."_LINUX.tar");
$this->ave->unlink($zip_name_a);
$this->ave->delete($zip_name_a);

$zip_name_b = $this->ave->get_file_path("$output/${app_name}_v$version"."_LINUX.tar.gz");
$this->ave->unlink($zip_name_b);
$this->ave->delete($zip_name_b);

$this->ave->echo(" Compress \"$zip_name_a\"");
$this->ave->exec("7z", "a -mx0 -ttar -- \"$zip_name_a\" \"includes\" \"vendor\" \"AVE-PHP.sh\" \"composer.json\" \"Changelog.txt\" \"LICENSE\"");

$this->ave->echo(" Compress \"$zip_name_b\"");
$this->ave->exec("7z", "a -mx9 -tgzip -- \"$zip_name_b\" \"$zip_name_a\"");

$this->ave->unlink($zip_name_a);
$this->ave->delete($zip_name_a);

if(file_exists($zip_name_b)){
$this->ave->pause(" Operation done, press any key to back to menu");
Expand Down
4 changes: 4 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v2.0.0:
- MySQL tool now support multiple data base into one connection label, you need set data base value to * for use that feature
- Fixed FTP Tools > Import FileZilla XML (Now you can import xml with single server)

v1.9.6:
- Tool: Generate video: CheckSum/Resolution/Thumbnail now can generate checksum for audio defined by AVE_EXTENSIONS_AUDIO
- Added compression .ave-guard in tool Check File Integrity
Expand Down
13 changes: 8 additions & 5 deletions includes/AVE.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Services\IniFile;
use App\Services\AveCore;
use App\Services\AppBuffer;

use App\Tools\AveSettings;
use App\Tools\AveConsole;
Expand All @@ -20,12 +21,11 @@
class AVE extends AveCore {

public IniFile $mkvmerge;

public AppBuffer $app_buffer;
public string $app_data;
public bool $abort = false;

public string $app_name = "AVE-PHP";
public string $version = "1.9.6";
public string $version = "2.0.0";

private array $folders_to_scan = [
'bin',
Expand Down Expand Up @@ -116,6 +116,7 @@ public function __construct(array $arguments){
$keys = [
'AVE_LOG_FOLDER',
'AVE_DATA_FOLDER',
'AVE_BUFFER_FOLDER',
];
foreach($keys as $key){
$this->config->set($key, $this->get_variable($this->config->get($key)));
Expand All @@ -127,6 +128,8 @@ public function __construct(array $arguments){
$config_default->close();

$this->init_logs();

$this->app_buffer = new AppBuffer($this->get_file_path($this->config->get('AVE_BUFFER_FOLDER')));
ini_set('memory_limit', -1);

$dev = file_exists($this->get_file_path("$this->path/.git"));
Expand All @@ -145,10 +148,10 @@ public function execute() : void {
switch(strtolower($this->command ?? '')){
case '--make-backup': {
if(empty($this->arguments[0] ?? '')){
$this->print_help([" Usage: --make-backup <label>"]);
$this->print_help([" Usage: --make-backup <label> [dbname]"]);
} else {
$this->tool = new MySQLTools($this);
$this->tool->ToolMakeBackupCMD($this->arguments[0] ?? '');
$this->tool->ToolMakeBackupCMD($this->arguments[0] ?? '', $this->arguments[1] ?? null);
}
break;
}
Expand Down
1 change: 1 addition & 0 deletions includes/config/linux.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
AVE_BUFFER_FOLDER="/etc/AVE-PHP/Buffer"
AVE_DATA_FOLDER="/etc/AVE-PHP/Data"
AVE_LOG_FOLDER="/var/log/AVE-PHP"
1 change: 1 addition & 0 deletions includes/config/windows.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AVE_BUFFER_FOLDER="%LOCALAPPDATA%\AVE-PHP\Buffer"
AVE_DATA_FOLDER="%LOCALAPPDATA%\AVE-PHP\Data"
AVE_LOG_FOLDER="%LOCALAPPDATA%\AVE-PHP\Logs"
AVE_COLOR="9F"
4 changes: 4 additions & 0 deletions includes/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
require_once("$includes_path/services/MediaFunctions.php");
require_once("$includes_path/services/StringConverter.php");
require_once("$includes_path/services/AveFtp.php");
require_once("$includes_path/services/BitFunctions.php");
require_once("$includes_path/services/BitArray.php");
require_once("$includes_path/services/JournalService.php");
require_once("$includes_path/services/AppBuffer.php");
require_once("$includes_path/AVE.php");
require_once("$includes_path/tools/AveSettings.php");
require_once("$includes_path/tools/AveConsole.php");
Expand Down
109 changes: 109 additions & 0 deletions includes/services/AppBuffer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

declare(strict_types=1);

namespace App\Services;

use Exception;

class AppBuffer {

protected string $path;

public int $version = 10000;

function __construct(string $path){
$this->path = $path;
if(!file_exists($this->path)) mkdir($this->path, 0755, true);
}

public function getPath() : string {
return $this->path;
}

public function getFile(string $key) : string {
$key = hash('sha256', $key);
return $this->path.DIRECTORY_SEPARATOR."$key.json";
}

public function get(string $key, int|bool|string|array|float|null $default = null) : mixed {
$file = $this->getFile($key);
if(!file_exists($file)) return $default;
$buffer = json_decode(file_get_contents($file), true);
if(!isset($buffer['expire']) || !isset($buffer['type'])) return $default;
if($buffer['expire'] != -1 && time() > $buffer['expire']) return $default;
switch(strtolower($buffer['type'])){
case 'integer': return (int)$buffer['value'];
case 'boolean': return ($buffer['value'] == 'true');
case 'string': return $buffer['value'];
case 'array': return json_decode(base64_decode($buffer['value']), true);
case 'float': (float)$buffer['value'];
case 'null': return null;
}
return null;
}

public function set(string $key, int|bool|string|array|float|null $value, int $expire = -1) : void {
$file = $this->getFile($key);
if($expire > 0) $expire = time() + $expire;
$type = strtolower(gettype($value));
switch($type){
case 'float':
case 'integer': {
$value = strval($value);
break;
}
case 'boolean': {
$value = $value ? 'true' : 'false';
break;
}
case 'array': {
$value = base64_encode(json_encode($value));
break;
}
case 'null': {
$value = 'null';
break;
}
}
file_put_contents($file, json_encode([
'key' => $key,
'type' => $type,
'value' => $value,
'expire' => $expire,
]));
}

public function forget(string $key) : void {
$this->delete($this->getFile($key));
}

public function clearExpired() : void {
$files = scandir($this->path);
foreach($files as $file){
$buffer = json_decode(file_get_contents($this->path.DIRECTORY_SEPARATOR.$file), true);
if($buffer['expire'] != -1 && time() > $buffer['expire']){
$this->delete($this->path.DIRECTORY_SEPARATOR.$file);
}
}
}

public function clear() : void {
$files = scandir($this->path);
foreach($files as $file){
$this->delete($this->path.DIRECTORY_SEPARATOR.$file);
}
}

private function delete(string $path) : void {
try {
if(file_exists($path)) unlink($path);
}
catch(Exception $e){

}
}

}

?>
31 changes: 22 additions & 9 deletions includes/services/AveCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class AveCore {

public int $core_version = 7;
public int $core_version = 8;

public IniFile $config;

Expand All @@ -37,7 +37,7 @@ class AveCore {
public string $utilities_path;
public string $utilities_version = "1.0.0";
public string $current_title;
public array $drives = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
public array $drives = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
public bool $can_exit = true;

public function __construct(array $arguments, bool $require_utilities){
Expand All @@ -51,7 +51,7 @@ public function __construct(array $arguments, bool $require_utilities){
$this->logo = '';
$this->current_title = '';
$this->utilities_path = $this->get_file_path($this->get_variable("%PROGRAMFILES%")."/AVE-UTILITIES");

if($require_utilities){
if($this->windows){
$ave_utilities = false;
Expand Down Expand Up @@ -366,7 +366,7 @@ public function rrmdir(string $dir) : bool {
if(is_dir($subdir) && !is_link($subdir)){
$this->rrmdir($subdir);
} else {
$this->unlink($subdir);
$this->delete($subdir);
}
}
$this->rmdir($dir);
Expand All @@ -385,7 +385,7 @@ public function rmdir(string $path, bool $log = true) : bool {
}
}

public function unlink(string $path, bool $log = true) : bool {
public function delete(string $path, bool $log = true) : bool {
if(!file_exists($path) || is_dir($path)) return false;
if(@unlink($path)){
if($log) $this->write_log("DELETE \"$path\"");
Expand Down Expand Up @@ -460,7 +460,7 @@ public function copy(string $from, string $to, bool $log = true) : bool {
public function delete_files(string $path, array|null $extensions = null, array|null $except = null) : void {
$files = $this->get_files($path, $extensions, $except);
foreach($files as $file){
$this->unlink($file);
$this->delete($file);
}
}

Expand Down Expand Up @@ -536,6 +536,10 @@ public function echo(string $string = '') : void {
echo "$string\r\n";
}

public function print(mixed $value) : void {
echo print_r($value, true);
}

public function get_variable(string $string) : string {
exec("echo $string", $var);
return $var[0] ?? '';
Expand Down Expand Up @@ -729,18 +733,18 @@ public function trash(string $path) : bool {
if($this->windows){
if(substr($path, 1, 1) == ':'){
$new_name = $this->get_file_path(substr($path, 0, 2)."/.Deleted/".substr($path, 3));
if(file_exists($new_name) && !$this->unlink($new_name)) return false;
if(file_exists($new_name) && !$this->delete($new_name)) return false;
return $this->rename($path, $new_name);
} else if(substr($path, 0, 2) == "\\\\"){
$device = substr($path, 2);
if(strpos($device, "\\") !== false){
$new_name = $this->get_file_path($device."/.Deleted/".str_replace("\\\\$device", "", $path));
if(file_exists($new_name) && !$this->unlink($new_name)) return false;
if(file_exists($new_name) && !$this->delete($new_name)) return false;
return $this->rename($path, $new_name);
}
}
} else {
return $this->unlink($path);
return $this->delete($path);
}
$this->write_error("FAILED TRASH \"$path\"");
return false;
Expand All @@ -766,6 +770,15 @@ public function windows_only() : bool {
return false;
}

/**
* @deprecated "Use delete instead"
*
* @return $this
*/
public function unlink(...$args) : bool {
return $this->delete(...$args);
}

}

?>
Loading

0 comments on commit 37d30ea

Please sign in to comment.