コード例 #1
0
ファイル: Out.class.php プロジェクト: axelhuizinga/gem
 static function init()
 {
     sys_io_File::saveContent("log.txt", "");
     me_cunity_debug_Out::$log = sys_io_File::write("log.txt", true);
     me_cunity_debug_Out::$log->flush();
     haxe_Log::$trace = isset(me_cunity_debug_Out::$_trace) ? me_cunity_debug_Out::$_trace : array("me_cunity_debug_Out", "_trace");
 }
コード例 #2
0
 public function log($context, $appMessages)
 {
     $logFile = _hx_string_or_null($context->get_contentDirectory()) . _hx_string_or_null($this->path);
     $req = $context->request;
     $res = $context->response;
     $userDetails = $req->get_clientIP();
     if ((null !== $context->session ? $context->session->get_id() : null) !== null) {
         $userDetails .= " " . _hx_string_or_null(null !== $context->session ? $context->session->get_id() : null);
     }
     if (($context->auth !== null && $context->auth->get_currentUser() !== null ? $context->auth->get_currentUser()->get_userID() : null) !== null) {
         $userDetails .= " " . _hx_string_or_null($context->auth !== null && $context->auth->get_currentUser() !== null ? $context->auth->get_currentUser()->get_userID() : null);
     }
     $content = "" . Std::string(Date::now()) . " [" . _hx_string_or_null($req->get_httpMethod()) . "] [" . _hx_string_or_null($req->get_uri()) . "] from [" . _hx_string_or_null($userDetails) . "], response: [" . _hx_string_rec($res->status, "") . " " . _hx_string_or_null($res->get_contentType()) . "]\n";
     $_g = 0;
     $_g1 = $context->messages;
     while ($_g < $_g1->length) {
         $msg = $_g1[$_g];
         ++$_g;
         $content .= "\t" . _hx_string_or_null(ufront_log_FileLogger::format($msg)) . "\n";
         unset($msg);
     }
     if ($appMessages !== null) {
         $_g2 = 0;
         while ($_g2 < $appMessages->length) {
             $msg1 = $appMessages[$_g2];
             ++$_g2;
             $content .= "\t" . _hx_string_or_null(ufront_log_FileLogger::format($msg1)) . "\n";
             unset($msg1);
         }
     }
     $path = haxe_io_Path::directory($logFile);
     $path1 = haxe_io_Path::addTrailingSlash($path);
     $_p = null;
     $parts = new _hx_array(array());
     while ($path1 !== ($_p = haxe_io_Path::directory($path1))) {
         $parts->unshift($path1);
         $path1 = $_p;
     }
     $_g3 = 0;
     while ($_g3 < $parts->length) {
         $part = $parts[$_g3];
         ++$_g3;
         if (_hx_char_code_at($part, strlen($part) - 1) !== 58 && !file_exists($part)) {
             @mkdir($part, 493);
         }
         unset($part);
     }
     $file = sys_io_File::append(_hx_string_or_null($context->get_contentDirectory()) . _hx_string_or_null($this->path), null);
     $file->writeString($content);
     $file->close();
     return ufront_core_SurpriseTools::success();
 }
コード例 #3
0
 public function getTemplateString($viewRelativePath)
 {
     $fullPath = _hx_string_or_null($this->get_viewDirectory()) . _hx_string_or_null($viewRelativePath);
     try {
         if (file_exists($fullPath)) {
             return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(haxe_ds_Option::Some(sys_io_File::getContent($fullPath))));
         } else {
             return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(haxe_ds_Option::$None));
         }
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         return $e->asSurpriseError("Failed to load template " . _hx_string_or_null($viewRelativePath));
     }
 }
コード例 #4
0
 public function doReadSessionFile($_)
 {
     if (ufront_web_session_FileSession_2($this, $_)) {
         $filename = "" . _hx_string_or_null($this->savePath) . _hx_string_or_null($this->sessionID) . ".sess";
         try {
             return ufront_core_SurpriseTools::asGoodSurprise(sys_io_File::getContent($filename));
         } catch (Exception $__hx__e) {
             $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
             $e = $_ex_;
             return ufront_core_SurpriseTools::asGoodSurprise(null);
         }
     } else {
         $this->context->messages->push(_hx_anonymous(array("msg" => "Session ID " . _hx_string_or_null($this->sessionID) . " was invalid, resetting session.", "pos" => _hx_anonymous(array("fileName" => "FileSession.hx", "lineNumber" => 243, "className" => "ufront.web.session.FileSession", "methodName" => "doReadSessionFile")), "type" => ufront_log_MessageType::$MWarning)));
         $this->sessionID = null;
         return ufront_core_SurpriseTools::asGoodSurprise(null);
     }
 }
コード例 #5
0
 public function process($onData, $partSize = null)
 {
     try {
         if ($partSize === null) {
             $partSize = 8192;
         }
         $doneTrigger = new tink_core_FutureTrigger();
         $fh = sys_io_File::read($this->tmpFileName, null);
         $pos = 0;
         $readNext = null;
         $readNext1 = null;
         $readNext1 = array(new _hx_lambda(array(&$doneTrigger, &$fh, &$onData, &$partSize, &$pos, &$readNext, &$readNext1), "ufront_web_upload_TmpFileUpload_0"), 'execute');
         $readNext = $readNext1;
         call_user_func($readNext);
         return $doneTrigger->future;
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e1 = $_ex_;
         $data = tink_core_Outcome::Failure(tink_core_TypedError::withData(null, "Error during TmpFileUpload.process()", $e1, _hx_anonymous(array("fileName" => "TmpFileUpload.hx", "lineNumber" => 148, "className" => "ufront.web.upload.TmpFileUpload", "methodName" => "process"))));
         return tink_core__Future_Future_Impl_::sync($data);
     }
 }
コード例 #6
0
 public function load_view_object($view, $vars = null)
 {
     $base = isset(system_base_Wet_base::$get_instance) ? system_base_Wet_base::$get_instance : array("system_base_Wet_base", "get_instance");
     $viewpath = _hx_string_or_null(system_base_Wet_base::$views_path) . _hx_string_or_null($view) . ".wtv";
     $view1 = null;
     $pos = 0;
     $left = null;
     $right = null;
     $uservar = null;
     $fieldname = null;
     try {
         $view1 = sys_io_File::getContent($viewpath);
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         throw new HException(new system_base_NoFileError(_hx_string_or_null($viewpath) . " does not exist or cannot be opened for reading"));
     }
     if ($vars !== null) {
         $fields = Reflect::fields($vars);
         $_g = 0;
         while ($_g < $fields->length) {
             $fieldname1 = $fields[$_g];
             ++$_g;
             $uservar = Std::string(Reflect::field($vars, $fieldname1));
             $pos = 0;
             while (($pos = _hx_index_of($view1, "::" . _hx_string_or_null($fieldname1) . "::", $pos)) !== -1) {
                 $left = _hx_substr($view1, 0, $pos);
                 $right = _hx_substr($view1, $pos + strlen($fieldname1) + 4, null);
                 $view1 = _hx_string_or_null($left) . _hx_string_or_null($uservar) . _hx_string_or_null($right);
                 $pos += 1;
             }
             unset($fieldname1);
         }
     }
     $this->cache->append($view1);
 }
コード例 #7
0
ファイル: File.class.php プロジェクト: marcdraco/Webrathea
 static function getBytes($path)
 {
     return haxe_io_Bytes::ofString(sys_io_File::getContent($path));
 }
コード例 #8
0
ファイル: Index.class.php プロジェクト: marcdraco/Webrathea
function Index_0(&$base, &$cache, &$cl, &$params, &$profiler, &$route, &$user_class, &$user_method)
{
    $router = null;
    if (system_base_Router::$instance === null) {
        system_base_Router::$instance = new system_base_Router();
    }
    $router = system_base_Router::$instance;
    $hash = $router->query_hash;
    $fullpath = _hx_string_or_null(system_base_Wet_base::$cache_path) . _hx_string_or_null($hash) . ".htm";
    if (!file_exists($fullpath)) {
        return false;
    } else {
        $r_query = $router->query_string;
        $fin = sys_io_File::read($fullpath, false);
        $query = $fin->readLine();
        if ($r_query === $query) {
            $etag = null;
            if (file_exists($fullpath)) {
                $stats = sys_FileSystem::stat($fullpath);
                $etag = _hx_string_or_null(StringTools::hex($stats->size, null)) . "-" . _hx_string_or_null(StringTools::hex($stats->ino, null)) . "-" . _hx_string_or_null(_hx_string_call(_hx_string_call($stats->mtime, "toString", array()), "substr", array(17, 2)));
            } else {
                $etag = "";
            }
            if (php_Web::getClientHeader("If-none-match") === $etag) {
                php_Web::setReturnCode(304);
                $fin->close();
                return true;
            } else {
                while (!system_base_Cache::$cookie_buffer->isEmpty()) {
                    system_base_Wet_base::send_cookie(system_base_Cache::$cookie_buffer->pop());
                }
                header("X-Powered-By" . ": " . "Webrathea/0.4 (PHP)");
                $value = DateTools::format(Date::now(), "%a, %d %b %Y %X %Z");
                header("Date" . ": " . _hx_string_or_null($value));
                header("X-Frame-Options" . ": " . "sameorigin");
                header("X-XSS-Protection" . ": " . "1; mode=block");
                php_Web::setReturnCode(200);
                $value1 = Std::string(sys_FileSystem::stat($fullpath)->size);
                header("Content-Length" . ": " . _hx_string_or_null($value1));
                header("ETag" . ": " . _hx_string_or_null($etag));
                $m = null;
                $pos = strlen($query);
                $fin1 = sys_io_File::read($fullpath, false);
                $size = sys_FileSystem::stat($fullpath)->size;
                $fin1->seek($pos, sys_io_FileSeek::$SeekBegin);
                $output = $fin1->readString($size - $pos);
                $fin1->close();
                $m = $output;
                $message = null;
                $message = Std::string($m);
                haxe_Log::trace("DEPRECATED FUNCTION: " . _hx_string_or_null($message), _hx_anonymous(array("fileName" => "Base.hx", "lineNumber" => 449, "className" => "system.base.Wet_base", "methodName" => "echo")));
                $fin->close();
                return true;
            }
            unset($etag);
        } else {
            $fin->close();
            return false;
        }
        unset($r_query, $query, $fin);
    }
    unset($router, $hash, $fullpath);
}
コード例 #9
0
ファイル: Store.class.php プロジェクト: komcdo/winnow
 public function write($str)
 {
     sys_io_File::saveContent($this->file, $str);
 }
コード例 #10
0
 static function cached_query($sql_cmd, $args = null, $dirty_pages = null)
 {
     $s_args = $args->join(":");
     $header = _hx_string_or_null($sql_cmd) . _hx_string_or_null($s_args);
     $filename = _hx_string_or_null(system_base_Wet_base::$cache_path) . _hx_string_rec(system_base_Hashes::do_hash($header), "");
     $resultset = null;
     $cached_results = null;
     $rows = new HList();
     $data = null;
     $total_rows = null;
     $results = null;
     $return_data = _hx_anonymous(array("rows" => $rows, "total_rows" => 0));
     if (strtoupper(_hx_substr(ltrim($sql_cmd), 0, 6)) !== "SELECT") {
         system_base_Database::get_instance(null, null, null, null, null, null, null, null);
         $resultset = system_base_Database::query($sql_cmd, $args, null);
         return _hx_anonymous(array("rows" => $resultset->results(), "total_rows" => $resultset->get_length()));
     }
     if (file_exists($filename)) {
         $fin = sys_io_File::read($filename, false);
         $results = $fin->readLine();
         if ($results === $header) {
             $cached_results = $fin->readLine();
             $return_data = haxe_Unserializer::run($cached_results);
         } else {
             $m = "Database cache collision running query: " . _hx_string_or_null($sql_cmd) . "\n";
             $m = Std::string(Date::now()) . ": " . _hx_string_or_null($m);
             system_base_Database::get_instance(null, null, null, null, null, null, null, null);
             $resultset = system_base_Database::query($sql_cmd, $args, null);
             return _hx_anonymous(array("rows" => $resultset->results(), "total_rows" => $resultset->get_length()));
         }
     } else {
         system_base_Database::get_instance(null, null, null, null, null, null, null, null);
         $resultset = system_base_Database::query($sql_cmd, $args, null);
         $data = haxe_Serializer::run(_hx_anonymous(array("rows" => $resultset->results(), "total_rows" => $resultset->get_length())));
         $fout = sys_io_File::write($filename, false);
         $fout->writeString(_hx_string_or_null($header) . "\n");
         $fout->writeString(_hx_string_or_null($data) . "\n");
         $fout->close();
     }
     return $return_data;
 }
コード例 #11
0
 public function writeBinary($bs)
 {
     $bytes = haxe_io_Bytes::ofData($bs);
     $fo = sys_io_File::write($this->location, true);
     $fo->writeBytes($bytes, 0, $bytes->length);
 }
コード例 #12
0
 public function saveContent($name, $txt)
 {
     sys_io_File::saveContent($name, $txt);
     return true;
 }
コード例 #13
0
 static function get_write_handle($fullpath, $binary = null)
 {
     if ($binary === null) {
         $binary = false;
     }
     return sys_io_File::write($fullpath, $binary);
 }
コード例 #14
0
function ufront_web_upload_TmpFileUploadMiddleware_0(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$origFileName, &$postName, &$size, &$tmpFilePath, $pName, $fName)
{
    $postName = $pName;
    $origFileName = $fName;
    $size = 0;
    while ($file === null) {
        $tmpFilePath = _hx_string_or_null($dir) . _hx_string_or_null($dateStr) . "-" . _hx_string_or_null(ufront_core_Uuid::create()) . ".tmp";
        if (!file_exists($tmpFilePath)) {
            $file = sys_io_File::write($tmpFilePath, null);
        }
    }
    return ufront_core_SurpriseTools::success();
}
コード例 #15
0
ファイル: Cache.class.php プロジェクト: marcdraco/Webrathea
 static function cache_to_disk()
 {
     $router = null;
     if (system_base_Router::$instance === null) {
         system_base_Router::$instance = new system_base_Router();
     }
     $router = system_base_Router::$instance;
     $hash = $router->query_hash;
     $query = $router->query_string;
     $fout = sys_io_File::write(_hx_string_or_null(system_base_Wet_base::$cache_path) . _hx_string_or_null($hash) . ".htm", false);
     $fout->writeString(_hx_string_or_null($query) . "\n" . _hx_string_or_null(system_base_Cache::$output_buffer->toString()));
     $fout->close();
     $fullpath = _hx_string_or_null(system_base_Wet_base::$cache_path) . _hx_string_or_null($hash) . ".htm";
     if (file_exists($fullpath)) {
         $stats = sys_FileSystem::stat($fullpath);
         return _hx_string_or_null(StringTools::hex($stats->size, null)) . "-" . _hx_string_or_null(StringTools::hex($stats->ino, null)) . "-" . _hx_string_or_null(_hx_string_call(_hx_string_call($stats->mtime, "toString", array()), "substr", array(17, 2)));
     } else {
         return "";
     }
 }
コード例 #16
0
 static function saveBytes($path, $bytes)
 {
     $f = sys_io_File::write($path, null);
     $f->write($bytes);
     $f->close();
 }