public function __construct(string $error, int $level = 0) { $this->error = $error; $this->level = $level; $this->reference = Etc::getRandomId(); $this->tryDebugBacktrace(); $this->handle(); }
public static function upload(string $path, string $postName = "images", $thumbWidth = 300, $thumbHeight = 300) { $path = FileSystem::getRealPath($path); $response = []; if (isset($_FILES[$postName])) { foreach ($_FILES[$postName]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES[$postName]["tmp_name"][$key]; $name = Etc::sanitize($_FILES[$postName]["name"][$key]); if (move_uploaded_file($tmp_name, "{$path}/{$name}")) { $image = new Image("{$path}/{$name}"); $response[] = ["thumb" => $image->src($thumbWidth, $thumbHeight), "file" => $name]; } } } } return $response; }
public static function log($log, $level = 1) { $ref = Etc::getRandomId(); $now = new \DateTime('now'); $file = "log/" . $now->format("Y-m-d") . ".txt"; try { $logs = FileSystem::get($file); $logs .= "Ref# : " . $ref . " || \t"; $logs .= "Level : " . $level . "\n"; $logs .= $now->format("Y-m-d h:i:s A") . " || \t"; $logs .= "IP: " . GeoLocation::getIP() . " || \t"; $logs .= "Country: " . GeoLocation::getCountry() . "\n"; $logs .= GeoLocation::userAgent() . "\n"; $logs .= "Log: " . $log . "\n"; $logs .= "--------------------------------------------------------------------------------------------------------------------------\n"; FileSystem::put($file, $logs); } catch (\Exception $e) { throw new \Exception($e->getMessage()); } return $ref; }
public function collect(array $fields, bool $required = true) { $data = Etc::parseFields($fields, $required); return $this->fill($data); }