Exemplo n.º 1
0
    public function redirect($target_url, $status = 301)
    {
        if (fx::env('ajax')) {
            ob_start();
            ?>
            <script type="text/javascript">
            document.location.href = '<?php 
            echo $target_url;
            ?>
';    
            </script>
            <?php 
            echo trim(ob_get_clean());
            fx::complete();
            die;
        }
        $this->status($status);
        header("Location: " . $target_url);
        fx::complete();
        die;
    }
Exemplo n.º 2
0
<?php

ini_set('display_errors', 'off');
try {
    require_once 'boot.php';
    $result = fx::router()->route();
    if (fx::env('ajax')) {
        $result = fx::page()->ajaxResponse($result);
    }
    echo $result;
    fx::complete();
} catch (\Exception $e) {
    fx::log($e, $e->getTraceAsString());
    if (!fx::env('ajax') || fx::env('console')) {
        fx::debug($e, $e->getTraceAsString());
    }
}
Exemplo n.º 3
0
 public function sendDownloadFile($path, $name, $size = null)
 {
     if (file_exists($path) and $file = fopen($path, "r")) {
         for ($i = 0; $i < ob_get_level(); $i++) {
             ob_end_clean();
         }
         header("Content-Type: application/octet-stream");
         header("Content-Disposition: attachment; filename=" . urlencode($name) . ";");
         header("Content-Transfer-Encoding: binary");
         if ($size) {
             header("Content-Length: " . $size);
         }
         while (!feof($file)) {
             $content = fread($file, 1024 * 100);
             echo $content;
         }
         fx::complete();
     }
     return false;
 }