コード例 #1
0
ファイル: Error.php プロジェクト: akitech/hooks-src
 public function errorLog()
 {
     $now = new \DateTime('now');
     $file = "log/" . $now->format("Y-m-d") . ".txt";
     try {
         $logs = FileSystem::get($file);
         $logs .= "Ref# : " . $this->reference . " || \t";
         $logs .= "Level : " . $this->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 .= "Error: " . $this->error . "\n";
         $logs .= "Debug Errors: " . $this->debugErrors . "\n";
         $logs .= "Error Location: " . $this->file . " in line " . $this->line . "\n";
         $logs .= "--------------------------------------------------------------------------------------------------------------------------\n";
         FileSystem::put($file, $logs);
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage());
     }
 }
コード例 #2
0
ファイル: HooksApp.php プロジェクト: akitech/hooks-src
 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;
 }
コード例 #3
0
ファイル: DBHelpers.php プロジェクト: akitech/hooks-src
 public static function getColumns($table)
 {
     $file = "Models/.model-cache/" . $table . ".cols";
     if (FileSystem::exists($file)) {
         $data = FileSystem::get($file);
         try {
             return json_decode($data);
         } catch (\Exception $e) {
             new Error($e->getMessage(), 0);
         }
     }
     $sql = "SHOW COLUMNS FROM " . $table;
     $query = new SQLQuery($sql);
     $results = $query->getResults();
     try {
         FileSystem::put($file, json_encode($results));
     } catch (\Exception $e) {
         new Error($e->getMessage(), 0);
     }
     return $results;
 }
コード例 #4
0
ファイル: ModelBuilder.php プロジェクト: akitech/hooks-src
 public static function DeriveRelations($tables, $tableName, $columns)
 {
     $data = [];
     foreach ($columns as $col) {
         if ($col->Type == "timestamp") {
             $data[$col->Field] = "DateTime";
         } else {
             if ($col->Type == "date") {
                 $data[$col->Field] = "DateTime";
             } else {
                 if ($col->Type == "time") {
                     $data[$col->Field] = "DateTime";
                 } else {
                     if ($col->Field == "image") {
                         $data[$col->Field] = "hooks\\Media\\Image";
                     } else {
                         if (in_array($col->Field, $tables)) {
                             $data[$col->Field] = self::$namespace . "\\" . self::generateModelName($col->Field);
                         } else {
                             if (in_array($col->Field . "s", $tables)) {
                                 $data[$col->Field] = self::$namespace . "\\" . self::generateModelName($col->Field);
                             } else {
                                 if (in_array(rtrim($col->Field, "id"), $tables)) {
                                     $data[$col->Field] = self::$namespace . "\\" . self::generateModelName($col->Field);
                                 } else {
                                     if (in_array(rtrim($col->Field, "Id"), $tables)) {
                                         $data[$col->Field] = self::$namespace . "\\" . self::generateModelName($col->Field);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     echo count($data) . " relations defined.";
     FileSystem::put("Models/.model-cache/" . $tableName . ".rln", json_encode($data, JSON_PRETTY_PRINT));
 }
コード例 #5
0
ファイル: FileSystem.php プロジェクト: akitech/hooks-src
 public static function add($path, $data, $glue = "")
 {
     $data = FileSystem::get($path) . $glue . $data;
     return FileSystem::put($path, $data);
 }
コード例 #6
0
ファイル: File.php プロジェクト: akitech/hooks-src
 public function put($data)
 {
     return FileSystem::put($this->path, $data);
 }