improved output and headers

This commit is contained in:
Steffen Vogel 2010-06-08 15:42:00 +02:00
parent cc7d33eed6
commit 56b56dd93b
4 changed files with 16 additions and 5 deletions

View file

@ -21,7 +21,7 @@
abstract class HttpHandle {
public $code;
public $headers = array();
protected $headers = array();
protected static $codes = array(
100 => 'Continue',

View file

@ -29,6 +29,8 @@ class HttpRequest extends HttpHandle {
public $files;
public function __construct() {
$this->headers = apache_response_headers();
$this->server = $_SERVER;
$this->get = $_GET;
$this->post = $_POST;
@ -41,5 +43,8 @@ class HttpRequest extends HttpHandle {
unset($_COOKIE);
unset($_FILES);
}
public function getHeader($header) {
return $this->headers[$header];
}
}

View file

@ -24,6 +24,8 @@ class HttpResponse extends HttpHandle {
public $code = 200; // default code (OK)
public function __construct() {
$this->headers = apache_response_headers();
ob_start(array($this, 'obCallback'));
}
@ -41,5 +43,9 @@ class HttpResponse extends HttpHandle {
}
ob_end_flush();
}
public function setHeader($header, $value) {
$this->headers[$header] = $value;
}
}

View file

@ -23,11 +23,11 @@ include '../../backend/init.php';
$meter = current(Channel::getByFilter(array('id' => 1)));
$readings = $meter->getData(0, time()*1000, 'hour');
$readings = $meter->getData(0, time()*1000);
echo '<table>';
echo '<table border="1">';
foreach ($readings as $i => $reading) {
echo '<tr><td>' . ($i + 1) . '</td><td>' . date('l jS \of F Y h:i:s A', $reading['timestamp']/1000) . '</td><td>' . $reading['value'] . '</td><td>' . $reading['count'] . '</td></tr>';
echo '<tr><td>' . ($i + 1) . '</td><td>' . date('h:i:s', $reading['timestamp']/1000) . '</td><td>' . $reading['value'] . '</td><td>' . $reading['count'] . '</td></tr>';
}
echo '</table>';