예제 #1
0
 /**
  * Handles redirects to other pages. If page argument "ref" has a value,
  * that will be used as the url for the redirect, overriding the $sURI argument passed to the script.
  * @param string $target_uri URI to redirect to.
  * @param string $msg (Optional) message to pass along to the next page.
  * @throws ConfigurationUndefinedException
  */
 public static function doRedirect($target_uri = '', $msg = null)
 {
     if (!defined('P_MESSAGE')) {
         throw new ConfigurationUndefinedException("P_MESSAGE not defined in app settings.");
     }
     if (!defined('P_REFERER')) {
         throw new ConfigurationUndefinedException("P_REFERER not defined in app settings.");
     }
     $_SESSION[P_MESSAGE] = $msg;
     $uri = Validation::collectStringInput(P_REFERER, FILTER_SANITIZE_URL);
     if (!$uri) {
         $uri = $target_uri;
     }
     $iPos = strpos($uri, "/");
     if (is_numeric($iPos) && $iPos == 0) {
         /* NB INPUT_SERVER is unreliable with filter_input() */
         $uri = 'http://' . $_SERVER['HTTP_HOST'] . $uri;
     }
     if (function_exists('cleanup')) {
         cleanup();
     }
     header("Location: {$uri}\n\n");
     exit;
 }
예제 #2
0
 /**
  * Collects page status value as defined in request variables (e.g. GET, POST, session)
  * @throws ConfigurationUndefinedException
  */
 public static function collectPageStatus()
 {
     if (!defined('P_MESSAGE')) {
         throw new ConfigurationUndefinedException("P_MESSAGE not defined in app settings.");
     }
     self::$status = Validation::collectStringInput(P_MESSAGE);
     if (isset($_SESSION[P_MESSAGE])) {
         unset($_SESSION[P_MESSAGE]);
     }
 }