wip
This commit is contained in:
1 parent
7abcc5c56c
commit
90bba45c0a
26 files changed
+3448
-32353
No files matched your search
@@ -8,11 +8,8 @@ class Curl
|
||||
{
|
||||
public static $file;
|
||||
|
||||
public static function load($url, $filetype = 'json')
|
||||
public static function load($url)
|
||||
{
|
||||
|
||||
self::$file = app_path().'/Console/TestFiles/'.strtolower(str_replace(' ', '_', NuhBash::$options['name'])).'.'.$filetype;
|
||||
|
||||
$debug = NuhBash::$options['d'] ?? 0;
|
||||
$save = NuhBash::$options['s'] ?? 0;
|
||||
$read = NuhBash::$options['r'] ?? 0;
|
||||
@@ -23,22 +20,13 @@ class Curl
|
||||
|
||||
if ($read) {
|
||||
if ($debug) {
|
||||
Notice::note('data read local', 'r');
|
||||
Notice::note('READ LOCAL', 'r');
|
||||
}
|
||||
switch ($filetype) {
|
||||
case 'xml':
|
||||
return simplexml_load_file(self::$file, null, LIBXML_NOCDATA);
|
||||
break;
|
||||
$filename = app_path().'/Console/TestFiles/'.strtolower(str_replace(' ', '_', NuhBash::$options['name'])).'.json';
|
||||
|
||||
case 'json':
|
||||
$file = file_get_contents(self::$file);
|
||||
$file = file_get_contents($filename);
|
||||
|
||||
return json_decode($file, true);
|
||||
break;
|
||||
default:
|
||||
Notice::note('filetype unknown', 'r', 1);
|
||||
|
||||
}
|
||||
return json_decode($file, true);
|
||||
}
|
||||
|
||||
$ch = curl_init($url);
|
||||
@@ -57,15 +45,12 @@ class Curl
|
||||
}
|
||||
|
||||
if ($save) {
|
||||
Notice::note('data saved', 'b');
|
||||
Notice::note('SAVED LOCAL', 'b');
|
||||
self::$file = app_path().'/Console/TestFiles/'.strtolower(str_replace(' ', '_', NuhBash::$options['name'])).'.json';
|
||||
file_put_contents(self::$file, $data);
|
||||
}
|
||||
|
||||
if ($filetype == 'json') {
|
||||
return json_decode($data, true);
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
return json_decode($data, true);
|
||||
}
|
||||
|
||||
public static function curlerrorcode($id)
|
||||
|
||||
Reference in new issue
Block a user