]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add init, last_modified to actions
authorEvan Prodromou <evan@controlyourself.ca>
Tue, 2 Dec 2008 03:47:36 +0000 (22:47 -0500)
committerEvan Prodromou <evan@controlyourself.ca>
Tue, 2 Dec 2008 03:47:36 +0000 (22:47 -0500)
darcs-hash:20081202034736-5ed1f-e096ab5e9a77d2bb74c949659966d400cbc9a149.gz

index.php
lib/action.php

index de39dd020c37aace898489c3194c49facac5c862..7d1eede46236a96c9665dd8d0de591e3fd4847b9 100644 (file)
--- a/index.php
+++ b/index.php
@@ -52,6 +52,7 @@ if (file_exists($actionfile)) {
                }
                $config['db']['database'] = $mirror;
        }
+    call_user_func(array($action_obj, 'init'), $_REQUEST);
     call_user_func(array($action_obj, 'handle'), $_REQUEST);
 } else {
     common_user_error(_('Unknown action'));
index c0229cf75ff14bc5c6640b74f8dbf817ca32ec69..ba4fc71fb667c71625873a64af43f56405c1899f 100644 (file)
@@ -26,6 +26,19 @@ class Action { // lawsuit
        function Action() {
        }
 
+       # For initializing members of the class
+       
+       function init($argarray) {
+               $this->args =& common_copy_args($argarray);
+       }
+
+       # For comparison with If-Last-Modified
+       # If not applicable, return NULL
+       
+       function last_modified() {
+               return NULL;
+       }
+       
        function is_readonly() {
                return false;
        }
@@ -43,8 +56,27 @@ class Action { // lawsuit
                return (is_string($arg)) ? trim($arg) : $arg;
        }
 
-       function handle($argarray) {
-               $this->args =& common_copy_args($argarray);
+       # Note: argarray ignored, since it's now passed in in init()
+       
+       function handle($argarray=NULL) {
+               
+               $lm = $this->last_modified();
+               
+               if ($lm) {
+                       header('Last-Modified: ' . date(DATE_RFC822, $dt));
+                       $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
+                       if ($if_modified_since) {
+                               $ims = strtotime($if_modified_since);
+                               if ($lm <= $ims) {
+                                       $if_none_match = $_SERVER['HTTP_IF_NONE_MATCH'];
+                                       if ($if_none_match) {
+                                               header('304 Not Modified');
+                                               # Better way to do this?
+                                               exit(0);
+                                       }
+                               }
+                       }
+               }
        }
 
        function boolean($key, $def=false) {