Example #1
0
 public function __construct(string $error, int $level = 0)
 {
     $this->error = $error;
     $this->level = $level;
     $this->reference = Etc::getRandomId();
     $this->tryDebugBacktrace();
     $this->handle();
 }
Example #2
0
 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;
 }
Example #3
0
 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;
 }
Example #4
0
 public function collect(array $fields, bool $required = true)
 {
     $data = Etc::parseFields($fields, $required);
     return $this->fill($data);
 }