Example #1
0
 public static function get()
 {
     if (!isset(self::$_instance) || get_class(self::$_instance) != __CLASS__) {
         if (isset($_SESSION) && is_array($_SESSION) && array_key_exists('PostHandler', $_SESSION) && !empty($_SESSION['PostHandler'])) {
             self::$_instance = unserialize($_SESSION['PostHandler']);
             unset($_SESSION['PostHandler']);
         } else {
             $c = __CLASS__;
             self::$_instance = new $c();
         }
     }
     if (self::$_instance->_postHandling) {
         return false;
     }
     if (is_array($_POST) && count($_POST) > 0) {
         self::$_instance->_postHandling = true;
         self::$_instance->save();
         $_SESSION['PostHandler'] = serialize(self::$_instance);
         $req = $_SERVER['REQUEST_URI'];
         if (!PVars::get()->cookiesAccepted) {
             $req = parse_url($req);
             $query = array();
             if (isset($request['query'])) {
                 parse_str($request['query'], $query);
             }
             if (is_array($query) && !array_key_exists(session_name(), $query)) {
                 $query[session_name()] = session_id();
                 $queries = array();
                 foreach ($query as $k => $q) {
                     $queries[] = $k . '=' . $q;
                 }
                 $req['query'] = implode('&', $queries);
             }
             $req = PFunctions::glueParsedUrl($req);
         }
         session_write_close();
         header('Location: ' . $req);
         PPHP::PExit();
     } else {
         $_SESSION['PostHandler'] = serialize(self::$_instance);
         self::$_instance->_postHandling = false;
     }
     return self::$_instance;
 }