wip countries

This commit is contained in:
salam committed 2025-08-30 08:15:10 +02:00
1 parent 641b362752
commit 1b9a65b25a
23 files changed
+127755 -27137

No files matched your search

+34 -15
View File
@@ -6,27 +6,42 @@ use App\Utilities\Notice;
class Curl
{
public static $storage_file;
public static $file;
public static function load($url)
{
self::$storage_file = app_path().'/Utilities/TestFileStorage/latest.json';
$debug = NuhBash::$options['debug'] ?? 0;
$save_to_storage = NuhBash::$options['s'] ?? 0;
$load_form_storage = NuhBash::$options['l'] ?? 0;
self::$file = app_path().'/Console/TestFiles/'.strtolower(str_replace(' ', '_', NuhBash::$options['name'])).'.'.NuhBash::$options['filetype'];
$debug = NuhBash::$options['d'] ?? 0;
$save = NuhBash::$options['s'] ?? 0;
$read = NuhBash::$options['r'] ?? 0;
if ($debug) {
Notice::note($url, 'g');
Notice::note($url);
}
if ($load_form_storage) {
$file = file_get_contents(self::$storage_file);
if ($debug) {
Notice::note('data from storage', 'b');
if ($read) {
switch (NuhBash::$options['filetype']) {
case 'xml':
return simplexml_load_file(self::$file, null, LIBXML_NOCDATA);
break;
case 'json':
$file = file_get_contents(self::$file);
return json_decode($file, true);
break;
default:
Notice::note('filetype unknown', 'r', 1);
}
if ($debug) {
Notice::note('data read local', 'b');
}
return json_decode($file, true);
}
$ch = curl_init($url);
@@ -41,12 +56,16 @@ class Curl
}
curl_close($ch);
if ($save_to_storage) {
Notice::note('data saved to local storage', 'b');
file_put_contents(self::$storage_file, $data);
if ($save) {
Notice::note('data saved', 'b');
file_put_contents(self::$file, $data);
}
return json_decode($data, true);
if (NuhBash::$options['filetype'] == 'json') {
return json_decode($data, true);
} else {
return $data;
}
}
public static function curlerrorcode($id)