wip
This commit is contained in:
1 parent
1890b1fcc2
commit
bf48caa395
22 files changed
+510
-123
No files matched your search
@@ -4,18 +4,27 @@ namespace App\Utilities;
|
||||
|
||||
class Notice
|
||||
{
|
||||
// note
|
||||
/**
|
||||
* \e[1;30m Black
|
||||
* \e[1;31m Red
|
||||
* \e[1;32m Green
|
||||
* \e[1;33m Yellow
|
||||
* \e[1;34m Blue
|
||||
* \e[1;35m Purple
|
||||
* \e[1;36m Cyan
|
||||
* \e[1;37m White
|
||||
*/
|
||||
|
||||
public static function db($message, $exit = false)
|
||||
{
|
||||
echo "\e[0;35m";
|
||||
echo PHP_EOL.'-----------------------------------------------------------'.PHP_EOL;
|
||||
echo PHP_EOL . '-----------------------------------------------------------' . PHP_EOL;
|
||||
if (is_array($message)) {
|
||||
print_r($message);
|
||||
} else {
|
||||
echo $message.PHP_EOL;
|
||||
echo $message . PHP_EOL;
|
||||
}
|
||||
echo '-----------------------------------------------------------'.PHP_EOL;
|
||||
echo '-----------------------------------------------------------' . PHP_EOL;
|
||||
echo "\e[0;39m";
|
||||
if ($exit) {
|
||||
exit();
|
||||
@@ -72,13 +81,13 @@ class Notice
|
||||
break;
|
||||
}
|
||||
|
||||
echo PHP_EOL.'-----------------------------------------------------------'.PHP_EOL;
|
||||
echo PHP_EOL . '-----------------------------------------------------------' . PHP_EOL;
|
||||
if (is_array($message)) {
|
||||
print_r($message);
|
||||
} else {
|
||||
echo $message.PHP_EOL;
|
||||
echo $message . PHP_EOL;
|
||||
}
|
||||
echo '-----------------------------------------------------------'.PHP_EOL;
|
||||
echo '-----------------------------------------------------------' . PHP_EOL;
|
||||
echo "\e[0;39m";
|
||||
if ($exit) {
|
||||
exit();
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use ZipArchive;
|
||||
|
||||
class ZipFolder
|
||||
{
|
||||
public static function create(string $path)
|
||||
{
|
||||
|
||||
$zipFilePath = $path . '/archive.zip';
|
||||
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
|
||||
|
||||
if (is_dir($path)) {
|
||||
|
||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (!$file->isDir()) {
|
||||
$filePath = $file->getRealPath();
|
||||
$relativePath = substr($filePath, strlen($path) + 1);
|
||||
$zip->addFile($filePath, $relativePath);
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
}
|
||||
} else {
|
||||
return response()->json(['error' => 'Failed to create ZIP archive'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_tree(string $dir, &$results = array())
|
||||
{
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $value) {
|
||||
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
|
||||
if (!is_dir($path)) {
|
||||
$results[] = $path;
|
||||
} else if ($value != "." && $value != "..") {
|
||||
self::get_tree($path, $results);
|
||||
$results[] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user