Changeset - 58eeb176287a
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 15 years ago 2010-10-09 20:56:31
ohnobinki@ohnopublishing.net
Prevent multiple calls to session_start() and use a named session to avoid colliding with other apps' sessions.
2 files changed with 29 insertions and 11 deletions:
0 comments (0 inline, 0 general)
inc/class.page.php
Show inline comments
 
@@ -63,7 +63,7 @@ class page
 
   $this->trackingcode = '<script type="text/javascript" src="' . $ga_www . 'google-analytics.com/ga.js" />' . "\n"
 
     . $this->trackingcode;
 

	
 
    session_start();
 
   page::session_start();
 
    if($immediate
 
       && $ntitle != "NOHEAD")
 
      $this->head();
 
@@ -265,6 +265,26 @@ class page
 

	
 
  /**
 
   * \brief
 
   *   Start the PHP session by calling session_start().
 
   *
 
   * Used to make sure that different areas of our code don't call
 
   * session_start() multiple times and to make it easier to ensure
 
   * that session_start() is called at least before it's needed.
 
   */
 
  public static function session_start()
 
  {
 
    static $session_started = FALSE;
 

	
 
    if (!$session_started)
 
      {
 
	session_name('slate_permutate');
 
	session_start();
 
	$session_started = TRUE;
 
      }
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Get the current school profile handle.
 
   */
 
  public function get_school()
process.php
Show inline comments
 
<?php
 

	
 
session_start();
 

	
 
require_once('inc/schedule_store.inc');
 
require_once('inc/class.page.php');
 
include_once 'class.schedule.php';
 
include_once 'class.class.php';
 
include_once 'class.section.php';
 

	
 
function sortInputs($post){
 
//	return array_filter($post['postData']); // Remove any null or unset items. Disabled as it kills day stuff, @FIXME and add day unset setting here (==0).
 
	return $post['postData'];
 
}
 

	
 

	
 
// Converts a 5-element array into a nice string.
 
// Supports multiple modes, prettiness, and searching for different indicators
 
function arrayToDays($array, $mode = 'num', $pretty = false, $key = 1) {
 
@@ -57,6 +49,11 @@ function prettyTime($time){
 
	return substr($time,0,strlen($time)-2) . ":" . substr($time,strlen($time)-2, strlen($time));
 
}
 

	
 
/*
 
 * The below code relies on sessions being started already.
 
 */
 
page::session_start();
 

	
 
$DEBUG = FALSE;
 
if (isset($_GET['debug']))
 
  $DEBUG = $_GET['debug'];
 
@@ -84,12 +81,13 @@ if(!$DEBUG)
 
	  }
 

	
 
	header('Location: input.php');
 
	exit;
 
      }
 
    else
 
      {
 
		$allClasses = new Schedule($_POST['postData']['name']);
 
	
 
		foreach(sortInputs($_POST) as $class)
 
		foreach($_POST['postData'] as $class)
 
		{
 
		  /*
 
		   * Only add classes if the user added at least one
 
@@ -127,7 +125,7 @@ if(!$DEBUG)
 
else
 
  {
 
	echo '<pre>DEBUG OUTPUT: <br /><br />';
 
	foreach(sortInputs($_POST) as $class) {
 
	foreach($_POST['postData'] as $class) {
 
		echo 'Class: ' . $class['name'] . '<br />';
 
		foreach($class as $section)
 
			if(is_array($section))
0 comments (0 inline, 0 general)