示例#1
0
 /**
  * simple function for creating prg pattern. 
  * (Keep state when reloading browser and resends forms etc.) 
  * @param int $last
  */
 public static function prg($max_time = 0)
 {
     if (!html::csrfValidate()) {
         http::locationHeader('/error/accessdenied', 'Bad request');
         return;
     }
     // genrate a session var holding the _POST
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $uniqid = uniqid();
         $_SESSION['post'][$uniqid] = $_POST;
         $_SESSION['post'][$uniqid]['prg_time'] = time();
         $_SESSION['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
         header("HTTP/1.1 303 See Other");
         $location = self::getRedirect() . 'prg=1&uniqid=' . $uniqid;
         self::locationHeader($location);
     }
     if (!isset($_SESSION['REQUEST_URI'])) {
         $_SESSION['post'] = null;
     } else {
         if (isset($_GET['prg'])) {
             $uniqid = $_GET['uniqid'];
             if (isset($_SESSION['post'][$uniqid])) {
                 if ($max_time && $_SESSION['post'][$uniqid]['prg_time'] + $max_time < time()) {
                     unset($_SESSION['post'][$uniqid]);
                 } else {
                     $_POST = $_SESSION['post'][$uniqid];
                 }
             }
         } else {
             @($_SESSION['REQUEST_URI'] = null);
         }
     }
 }
示例#2
0
 /**
  * Simple pattern for creating PRG. 
  * (Keep state when reloading browser and resends forms etc.) 
  * @param int $last
  */
 public static function prg($max_time = 0)
 {
     if (!html::csrfValidate()) {
         http::locationHeader('/error/accessdenied', 'Bad request');
         return;
     }
     prg::prg($max_time);
 }