Max F 5 gadi atpakaļ
vecāks
revīzija
11d3a6ed3c
2 mainītis faili ar 0 papildinājumiem un 131 dzēšanām
  1. 0 85
      src/Http/ResponseFile.php
  2. 0 46
      src/Http/ResponseRedirect.php

+ 0 - 85
src/Http/ResponseFile.php

@@ -1,85 +0,0 @@
-<?php
-
-namespace KarmaFW\Http;
-
-use KarmaFW\App;
-
-
-throw new \Exception("DEPRECATED", 1);
-
-
-class ResponseFile extends Response
-{
-	protected $file_path;
-
-
-	public function __construct($file_path, $status=200)
-	{
-		parent::__construct($status);
-
-		$this->file_path = $file_path;
-	}
-
-
-	public function sendHeaders()
-	{
-		if (App::isCli()) {
-			return;
-		}
-
-		if ($this->headers_sent) {
-			// Warning: headers already sent
-			//error_log("Warning: headers already sent");
-			//return;
-		}
-
-		if (! is_file($this->file_path)) {
-			// File not found
-			$this->setStatus(404);
-			$this->setContentType('text/html'); // or application/json
-			//$this->headers['Content-Length'] = 0;
-			// TODO: return $this->fork( ResponseError404 );
-
-		} else {
-			$content_type = $this->getContentType();
-			if (empty($content_type)) {
-				$content_type = mime_content_type($this->file_path);
-			}
-			if (empty($content_type)) {
-				$content_type = "application/octet-stream";
-			}
-
-			$this->headers['Content-Length'] = filesize($this->file_path);
-			//$this->headers['Content-Type'] = $content_type;
-			$this->setContentType($content_type);
-			$this->headers['Content-Transfer-Encoding'] = "Binary";
-			$this->headers['Content-disposition'] = 'attachment; filename="' . basename($this->file_path) . '"';
-		}
-
-		parent::sendHeaders();
-	}
-
-
-	public function send()
-	{
-		if (! is_file($this->file_path)) {
-			// ERROR 404
-			$this->setStatus(404);
-		}
-
-		if ($this->headers_sent) {
-			// Warning: redirect may not work
-		}
-
-		$this->sendHeaders();
-
-		if (is_file($this->file_path)) {
-			readfile($this->file_path);
-
-		} else {
-			echo "File not found";
-		}
-	}
-
-
-}

+ 0 - 46
src/Http/ResponseRedirect.php

@@ -1,46 +0,0 @@
-<?php
-
-namespace KarmaFW\App;
-
-use KarmaFW\App;
-
-
-throw new \Exception("DEPRECATED", 1);
-
-
-class ResponseRedirect extends Response
-{
-	protected $redirect_url = null;
-	protected $status = 302;
-
-
-	public function __construct($url, $status=302)
-	{
-		parent::__construct($status);
-
-		$this->redirect_url = $url;
-	}
-
-
-	public function sendHeaders()
-	{
-		if (App::isCli()) {
-			echo "# HTTP REDIRECTION " . $this->status . " TO " . $this->redirect_url . PHP_EOL;
-			return;
-		}
-
-		if ($this->headers_sent || headers_sent()) {
-			//error_log("Warning: headers already sent");
-			$this->content = '<meta http-equiv="refresh" content="0;URL=' . htmlspecialchars($this->redirect_url) . '">';
-			//$this->content = '<script>window.location.href = "' . $this->redirect_url . '";</script>';
-			return;
-		}
-
-		$this->content = '';
-
-		$this->headers['Location'] = $this->redirect_url;
-
-		parent::sendHeaders();
-	}
-
-}