Changeset - 864e30313107
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 15 years ago 2010-10-09 23:39:00
ohnobinki@ohnopublishing.net
Consolidate all redirect-ish code into page::redirect().
2 files changed with 55 insertions and 9 deletions:
0 comments (0 inline, 0 general)
inc/class.page.php
Show inline comments
 
@@ -301,6 +301,58 @@ class page
 

	
 
  /**
 
   * \brief
 
   *   Perform a redirect.
 
   *
 
   * By consolidating all redirects here, we're hopefully able to do
 
   * it in a somewhat compliant and portablish way ;-).
 
   *
 
   * This function does not return. It calls exit().
 
   *
 
   * \param $dest
 
   *   A URL relative to the slate_permutate root. For example,
 
   *   'input.php' or '44' (for clean urls, for example).
 
   * \param $http_code
 
   *   The redirection code to use, if any. For example, this can be
 
   *   used to implement ``permanent'' redirects if necessary.
 
   */
 
  public static function redirect($dest, $http_code = NULL)
 
  {
 
    if ($http_code)
 
      header('HTTP/1.1 ' . $http_code);
 

	
 
    $uri = '';
 

	
 
    $host = '';
 
    if (isset($_SERVER['SERVER_NAME']))
 
      $host = $_SERVER['SERVER_NAME'];
 
    if (isset($_SERvER['HTTP_HOST']))
 
      $host = $_SERVER['HTTP_HOST'];
 

	
 
    if (strlen($host))
 
      {
 
	$proto = 'http';
 
	$port = NULL;
 
	if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80)
 
	  {
 
	    if ($_SERVER['SERVER_PORT'] == 443 || !empty($_SERVER['HTTPS']))
 
	      $proto .= 's';
 
	    if ($_SERVER['SERVER_PORT'] != 433)
 
	      $port = $_SERVER['SERVER_PORT'];
 
	  }
 

	
 
	$uri = $proto . '://' . $host;
 
	if ($port !== NULL)
 
	  $uri .= ':' . $port;
 
	$uri .= dirname($_SERVER['REQUEST_URI']) . '/';
 
      }
 

	
 
    header('Location: ' . $uri . $dest);
 

	
 
    exit();
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Get the current school profile handle.
 
   */
 
  public function get_school()
process.php
Show inline comments
 
@@ -84,12 +84,12 @@ if(!$DEBUG)
 
	    unset($_SESSION['saved'][(int)$_GET['del']]);
 
	  }
 

	
 
	header('Location: input.php');
 
	page::redirect('input.php');
 
	exit;
 
      }
 
    elseif (!isset($_POST['postData']))
 
      {
 
	header('Location: input.php');
 
	page::redirect('input.php');
 
	exit;
 
      }
 
    else
 
@@ -131,14 +131,8 @@ if(!$DEBUG)
 
		$process_php_s = '';
 
		if (!$clean_urls)
 
		  $process_php_s = 'process.php?s=';
 
		header('Location: ' . $process_php_s . $schedule_id);
 
		page::redirect($process_php_s . $schedule_id);
 
		exit;
 
		/*
 
		 * writeoutTables() needs to know $schedule_id, so it
 
		 * has to be called after we save the schedule. See
 
		 * schedule_store_store().
 
		 */
 
		$allClasses->writeoutTables();
 
      }
 
  }
 
else
0 comments (0 inline, 0 general)