Skip to content

Commit

Permalink
v1.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
AbyssMorgan committed Dec 13, 2023
1 parent f43583b commit 5b63be2
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 33 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.5"
#define MyAppVersion "1.9.6"
#define MyAppPublisher "Abyss Morgan"
#define MyAppURL "https://github.com/AbyssMorgan"
#define MyAppExeName "AVE-PHP.cmd"
Expand Down
5 changes: 5 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
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
- Replace FTP command mlsd to rawlist due to lack support of some FTP servers

v1.9.5:
- Fixed MySQL Tools save empty value for integer zero value from text column
- Added tool: File Editor > Pretty file content
Expand Down
2 changes: 1 addition & 1 deletion includes/AVE.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AVE extends AveCore {
public bool $abort = false;

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

private array $folders_to_scan = [
'bin',
Expand Down
66 changes: 40 additions & 26 deletions includes/services/AveFtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,56 @@ public function __construct(FtpClient $ftp){
$this->ftp = $ftp;
}

public function unix_permission(string $permission) : string {
$map = ['-' => 0, 'r' => 4, 'w' => 2, 'x' => 1];
$num = '';
for($p = 0; $p < 3; $p++){
$n = $map[$permission[$p]] + $map[$permission[$p+1]] + $map[$permission[$p+2]];
$num .= strval($n);
}
return "0$num";
}

public function get_files(string $path, array|null $extensions = null, array|null $except = null, array|null $filters = null) : array {
$data = [];
$files = $this->ftp->mlsd($path);
$files = $this->ftp->rawlist($path);
if($files === false) return [];
foreach($files as $file){
if($file['name'] == '.' || $file['name'] == '..') continue;
if($file['type'] == 'dir'){
$data = array_merge($data, $this->get_files($path.'/'.$file['name'], $extensions, $except));
} else if($file['type'] == 'file'){
$ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
$chunks = preg_split("/\s+/", $file);
if($chunks[8] == '.' || $chunks[8] == '..') continue;
if(substr($chunks[0], 0, 1) == 'd'){
$data = array_merge($data, $this->get_files($path.'/'.$chunks[8], $extensions, $except));
} else {
$ext = strtolower(pathinfo($chunks[8], PATHINFO_EXTENSION));
if(!is_null($extensions) && !in_array($ext, $extensions)) continue;
if(!is_null($except) && in_array($ext, $except)) continue;
if(!is_null($filters) && !$this->filter(pathinfo($file['name'], PATHINFO_BASENAME), $filters)) continue;
array_push($data, $path.'/'.$file['name']);
if(!is_null($filters) && !$this->filter(pathinfo($chunks[8], PATHINFO_BASENAME), $filters)) continue;
array_push($data, $path.'/'.$chunks[8]);
}
}
return $data;
}

public function get_files_meta(string $path, array|null $extensions = null, array|null $except = null, array|null $filters = null) : array {
$data = [];
$files = $this->ftp->mlsd($path);
$files = $this->ftp->rawlist($path);
foreach($files as $file){
if($file['name'] == '.' || $file['name'] == '..') continue;
if($file['type'] == 'dir'){
$data = array_merge($data, $this->get_files_meta($path.'/'.$file['name'], $extensions, $except));
} else if($file['type'] == 'file'){
$ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
$chunks = preg_split("/\s+/", $file);
if($chunks[8] == '.' || $chunks[8] == '..') continue;
if(substr($chunks[0], 0, 1) == 'd'){
$data = array_merge($data, $this->get_files_meta($path.'/'.$chunks[8], $extensions, $except));
} else {
$ext = strtolower(pathinfo($chunks[8], PATHINFO_EXTENSION));
if(!is_null($extensions) && !in_array($ext, $extensions)) continue;
if(!is_null($except) && in_array($ext, $except)) continue;
if(!is_null($filters) && !$this->filter(pathinfo($file['name'], PATHINFO_BASENAME), $filters)) continue;
if(!is_null($filters) && !$this->filter(pathinfo($chunks[8], PATHINFO_BASENAME), $filters)) continue;
array_push($data, [
'path' => $path.'/'.$file['name'],
'path' => $path.'/'.$chunks[8],
'directory' => $path,
'name' => $file['name'],
'date' => substr($file['modify'], 0, 4).'-'.substr($file['modify'], 4, 2).'-'.substr($file['modify'], 6, 2).' '.substr($file['modify'], 8, 2).':'.substr($file['modify'], 10, 2).':'.substr($file['modify'], 12, 2),
'permission' => $file['UNIX.mode'] ?? '',
'size' => $this->ftp->size($path.'/'.$file['name']),
'name' => $chunks[8],
'date' => date("Y-m-d H:i:s", $this->ftp->mdtm($path.'/'.$chunks[8])),
'permission' => $this->unix_permission(substr($chunks[0], 1)),
'size' => $this->ftp->size($path.'/'.$chunks[8]),
]);
}
}
Expand All @@ -60,22 +72,24 @@ public function get_files_meta(string $path, array|null $extensions = null, arra

public function get_folders(string $path) : array {
$data = [];
$files = $this->ftp->mlsd($path);
$files = $this->ftp->rawlist($path);
if($files === false) return [];
array_push($data, $path);
foreach($files as $file){
if($file['name'] == '.' || $file['name'] == '..') continue;
if($file['type'] == 'dir'){
$data = array_merge($data, $this->get_folders($path.'/'.$file['name']));
$chunks = preg_split("/\s+/", $file);
if($chunks[8] == '.' || $chunks[8] == '..') continue;
if(substr($chunks[0], 0, 1) == 'd'){
$data = array_merge($data, $this->get_folders($path.'/'.$chunks[8]));
}
}
return $data;
}

public function hasFiles(string $path) : bool {
$files = $this->ftp->mlsd($path);
$files = $this->ftp->rawlist($path);
foreach($files as $file){
if($file['name'] == '.' || $file['name'] == '..') continue;
$chunks = preg_split("/\s+/", $file);
if($chunks[8] == '.' || $chunks[8] == '..') continue;
return true;
}
return false;
Expand Down
8 changes: 5 additions & 3 deletions includes/tools/FileNamesEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,12 @@ public function ToolVideoGenerator() : bool {
$errors = 0;
$this->ave->set_errors($errors);
$video_extensions = explode(" ", $this->ave->config->get('AVE_EXTENSIONS_VIDEO'));
$audio_extensions = explode(" ", $this->ave->config->get('AVE_EXTENSIONS_AUDIO'));
$extensions = array_merge($video_extensions, $audio_extensions);
$media = new MediaFunctions($this->ave);
foreach($folders as $folder){
if(!file_exists($folder)) continue;
$files = $this->ave->get_files($folder, $video_extensions);
$files = $this->ave->get_files($folder, $extensions);
$items = 0;
$total = count($files);
foreach($files as $file){
Expand All @@ -386,7 +388,7 @@ public function ToolVideoGenerator() : bool {
} else {
$hash = null;
}
if($this->params['resolution']){
if($this->params['resolution'] && in_array($extension, $video_extensions)){
$resolution = $media->getVideoResolution($file);
if($resolution == '0x0'){
$this->ave->write_error("FAILED GET MEDIA RESOLUTION \"$file\"");
Expand All @@ -397,7 +399,7 @@ public function ToolVideoGenerator() : bool {
}
}
}
if($this->params['thumbnail']){
if($this->params['thumbnail'] && in_array($extension, $video_extensions)){
$thumbnail = $media->getVideoThumbnail($file, $directory, $this->ave->config->get('AVE_THUMBNAIL_WIDTH'), $this->ave->config->get('AVE_THUMBNAIL_ROWS'), $this->ave->config->get('AVE_THUMBNAIL_COLUMN'));
if($thumbnail){
$this->ave->write_log("GENERATE THUMBNAIL \"$file.webp\"");
Expand Down
7 changes: 6 additions & 1 deletion includes/tools/MediaTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,12 @@ public function ToolVideoFetchMediaInfo() : bool {
$errors = 0;
$this->ave->set_errors($errors);

$cache = new IniFile($this->ave->get_file_path("$input/AveMediaInfo.ini"), true);
$ini_old = $this->ave->get_file_path("$input/AveMediaInfo.ini");
$ini_new = $this->ave->get_file_path("$input/AveMediaInfo.gz-ini");
if(file_exists($ini_old) && !file_exists($ini_new)){
$this->ave->rename($ini_old, $ini_new);
}
$cache = new IniFile($ini_new, true, true);
$this->ave->echo(" Last update: ".$cache->get('.LAST_UPDATE', 'None'));

$csv_file = $this->ave->get_file_path("$input/AveMediaInfo.csv");
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.5
1.9.6

0 comments on commit 5b63be2

Please sign in to comment.