Jump to content

$_SERVER help


i8badhaggis

Recommended Posts

so this is really weird.  I can't quite figure out why it doesn't work.  I am doing the following:

 

$_SESSION['loginPage'] = $_SERVER['REQUEST_URI'];  // = /people-search

 

I then begin to output the page.

 

After a little bit of html tags outputted the variable changes to /page-not-found instead which is the name of my page that people are sent to on default and I can't figure out why it sends me there.

 

it works only if I remove anything like <td id="content">

 

it seems to work without those being outputted but of course I want / need to have those in there.  at this point I think I'm going to have to simply add divs inside those tds like <td><div id="content"> instead.

 

is there some reason it shouldn't like those to be outputted?

Link to comment
Share on other sites

//so here's where I set the variable
if($pageTitle != "login"){
		if(strpos($_SERVER['REQUEST_URI'], "/") == 0)
			$c_currentUri = substr($_SERVER['REQUEST_URI'], 1);
		else
			$c_currentUri = $_SERVER['REQUEST_URI'];

		$_SESSION["loginRedirectPage"] = $_SERVER['REQUEST_URI'];
	}

//a bunch of outputting
?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
		<?php if($this->getAttribute("title", $o_xml)){ ?>
			<title><?php echo $this->getAttribute("title", $o_xml); ?></title><?php
		}else{?>
			<title><?php echo "Grow and Create -";

				foreach($arTitle as $someTitles){
					echo " " . ucwords($someTitles);
				}?></title>
		<?php } ?>
		<script type="text/javascript" src="grow.js"></script>

		<?php
		/* if($b_isLoggedIn){ ?>
			<script type="text/javascript">
				lockAccount();
			</script>
		<?php }
		*/
		?>

		<script type="text/javascript">
			function doLoad(){
				clock();

				ho();

				validateStart();

				if(document.getElementById("anDate") !== null && document.getElementById("anDate") !== null){
					//annoucements();
				}
			}
		</script>

		<?php
echo '<table align="center" id="root">';
	if($_SERVER['REQUEST_URI'] == "/" || $_SERVER['REQUEST_URI'] == "/main"){
			echo '<tr><td id="head" colspan="3"><div style="padding: 4px; float: left;">';
			if($this->getAttribute("subTitle", $o_xml)){
				echo $this->getAttribute("subTitle", $o_xml);
			}elseif($this->getAttribute("title", $o_xml)){
				echo $this->getAttribute("title", $o_xml);
			}else{
				foreach($arTitle as $someTitles){
					echo " " . ucwords($someTitles);
				}
			}
			echo '</div><div style="padding: 4px; float: right;">';
			if(array_key_exists('loggedIn', $_SESSION) && $_SESSION['loggedIn'] && $_SESSION['user']){
				echo '<form name="logout" action="action" method="post"><input type="hidden" name="action" value="actions/logout.php"/>Welcome ';
				$ao_people = People::findByUsername($_SESSION['user']);
				echo $ao_people[0]->getFirstName() . " " . $ao_people[0]->getLastName()
					. '<input type="submit" class="buttonToLink" value="Logout"/> <a href="view-profile"/>View Profile</a></form>';
			}else{
				echo 'Welcome guest.  <a href="login">Login</a>';
			}
			echo '</div></td></tr>';
	}else{
		//die();
		//problems around here

		echo '<tr><td id="logo"><a href="';
		echo constant("baseUrl");
		echo '"><img src="';
		echo constant("baseUrl");
		echo 'images/grow-past.png" border="0"/></a></td>';
		?><td id="header"><div id="headRight"><?php

		if(array_key_exists('loggedIn', $_SESSION) && $_SESSION['loggedIn']){
			echo '<form name="logout" action="action" method="post"><input type="hidden" name="action" value="actions/logout.php"/>Welcome ';
			$ao_people = People::findByUsername($_SESSION['user']);
			echo $ao_people[0]->getFirstName() . " " . $ao_people[0]->getLastName()
				. '<input type="submit" class="buttonToLink" value="Logout"/> <a href="view-profile"/>View Profile</a></form>';
		}else{
			echo 'Welcome guest.  <a href="login">Login</a>';
		}

		echo '</div><h2 align="center" style="clear: right;">';

		if($this->getAttribute("subTitle", $o_xml)){
			echo $this->getAttribute("subTitle", $o_xml);
		}elseif($this->getAttribute("title", $o_xml)){
			echo $this->getAttribute("title", $o_xml);
		}else{
			foreach($arTitle as $someTitles){
				echo " " . ucwords($someTitles);
			}
		}
		echo '</h2></div></td></tr>';
	}
	echo '<tr><td id="m">';

	//die();

	$menu = new Menu($this);
	if(strlen($_SERVER['REQUEST_URI']) > 1){
		$uri = substr($_SERVER['REQUEST_URI'], 1);
	}else{
		$uri = "";
	}
	$menu->createMenu(simplexml_load_file("Content/grow.menu.xml"), $uri);
	echo '</td><td id="content">';

	die();

 

after I run this I look at my session on another page... it should still say the correct page and doesn't always

 

<td id="header"> can not be <td id="head">  it won't work then

<td id="m"> can not be <td id="menu"> again it won't work then

 

I have no idea why it wouldn't like those

Link to comment
Share on other sites

ok so here is everything

 

first to be called even if the page is people-search

caller.php

<?php

ini_set('session.use_trans_sid', false); 
ini_set('session.use_only_cookies', true); 
ini_set('url_rewriter.tags', '');

/* Required Files */
require_once("ReqOnce.php");
$c_files[] = "business/domainInfo.php";
$c_files[] = "business/requestDispatcher/RequestDispatcher.php";
$c_files[] = "pageRequest.php";
$c_files[] = "page-machine.php";
ReqOnce::customReqOnce($c_files, null, "caller.php");

$ac_piecesDot = explode(".", str_replace("http://", "", constant("baseUrl")));
if($ac_piecesDot[0] == "growandcreate"){
header('location: http://www.' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
die("should never be reached");
}

/* Determine file name and get variables */
$pieces = explode("?", $_SERVER['REQUEST_URI']);
if(count($pieces) == 1){
$parts = explode("/", $pieces[0]);
$c_fileName = $parts[count($parts) - 1];
}else{
$parts = explode("/", $pieces[0]);
$c_fileName = $parts[count($parts) - 1];
$c_get = $pieces[1];
}

//no longer needed I think
/*
Process the get variables
if($c_get){
$ac_getVariables = explode("&", $c_get);
if($ac_getVariables && is_array($ac_getVariables)){
	foreach($ac_getVariables as $c_getVariable){
		$ac_pieces = explode("=", $c_getVariable);
		if($ac_pieces[0] && $ac_pieces[1])
			$ac_get[$ac_pieces[0]] = $ac_pieces[1];
	}
}
}
*/

/* Determine and require the action file */
if($_POST['formName'] || $_POST['action'] || $_GET['action']){
if($_POST['action']){
	$c_actionLoc = $_POST['action'];
}elseif($_GET['action']){
	$c_actionLoc = $_GET['action'];
}else{
	$c_actionLoc = "actions/actionDefault.php";
}

ReqOnce::customReqOnce($c_actionLoc, count($c_files) + 1, "caller.php");
}

/* calling an action */
if($c_fileName == "action" && $c_actionLoc){
/* Start the session */
session_start();
if (!isset($_SESSION['initiated']) || !$_SESSION['initiated'])
{
	session_regenerate_id();
	$_SESSION['initiated'] = true;
}

$o_requestDispatch = new RequestDispatcher();

$pieces = explode(".", basename($c_actionLoc));
if(class_exists($pieces[0])){
	if(method_exists($pieces[0], "execute")){
		call_user_func_array(array($pieces[0], "execute"), array($o_requestDispatch));
	}
}
die("hello here");
}

/* finds correct page file */
$c_file = PageRequest::processPageRequest($c_fileName);

/* finds and requires files that are need to properly start session with objects in it */
$o_xml = simplexml_load_file($c_file);
if($o_xml){
$results = $o_xml->xpath("//storage");
for($n = 0; $n < count($results); $n++){
	ReqOnce::customReqOnce($results[$n] . "", count($c_files) + $n + 2, "caller.php");
}
}

/* Start the session */
session_start();
if (!isset($_SESSION['initiated']) || !$_SESSION['initiated'])
{
session_regenerate_id();
$_SESSION['initiated'] = true;
}

/* creates the request dispatcher */
$o_request = new RequestDispatcher($ac_get);

/* set the page viewed */
//$_SESSION['request']['pageView'] = $c_fileName;

/****************************************/
/******calls for page to be created******/
/****************************************/

$newContent = new anXML($c_file, $c_contentTitle, $o_request);

?>

 

then pagemachine.php is called

<?php

$c_files[] = "Common/peopleSearch.php";
$c_files[] = "tagLibrary/menu.php";
$c_files[] = "business/backup.php";
$c_files[] = "tagLibrary/content.php";
$c_files[] = "tagLibrary/format.php";
$c_files[] = "tagLibrary/admin.php";
$c_files[] = "tagLibrary/table.php";
$c_files[] = "tagLibrary/Columns.php";
$c_files[] = "tagLibrary/newForms.php";
$c_files[] = "tagLibrary/LogIn/log.php";
$c_files[] = "tagLibrary/coinSlot.php";
$c_files[] = "business/Mail.php";
$c_files[] = "phpMailer/class.phpmailer.php";

if(class_exists("ReqOnce")){
ReqOnce::customReqOnce($c_files, null, "page-machine.php");
}else{
header('location: http://www.growandcreate.com/');
die('should never be reached');
}

class anXML{

private $request;
private $tables;
private $content;
private $format;
private $col;
private $log;
private $admin;
private $newForms;
private $slot;

public function __construct($c_filePath, $title, $myRequest){
	$this->request = $myRequest;
	$this->tables = new tables($this);
	$this->content = new content($this);
	$this->format = new format($this, $myRequest);
	$this->col = new Columns($this);
	$this->log = new Log($this);
	$this->admin = new Admin($this);
	$this->slot = new CoinSlot($this);
	$this->newForms = new newForms($this, $myRequest);

	libxml_use_internal_errors(true);
	$o_xml = simplexml_load_file($c_filePath);
	$b_errorOccured = false;
	if(libxml_get_errors()){
		$b_errorOccured = true;
		foreach(libxml_get_errors() as $ac_error){
			echo "<p>Error ";
			switch($ac_error->level){
				case LIBXML_ERR_WARNING: echo "<br/>Level: warning ";
					break;
				case LIBXML_ERR_ERROR: echo "<br/>Level: simple error ";
					break;
				case LIBXML_ERR_FATAL: echo "<br/>Level: fatal error ";
					break;
			}
			echo "<br/>code: " . $ac_error->code;
			echo "<br/>column: " . $ac_error->column;
			echo "<br/>message: " . $ac_error->message;
			echo "<br/>file: " . $ac_error->file;
			echo "<br/>line: " . $ac_error->line;
			echo "</p>";
		}
		libxml_clear_errors();
	}

	if($b_errorOccured)
		die();

	if($o_xml){

		$this->newHead(str_replace(".xml", "", str_replace("grow.", "", basename($c_filePath))), $o_xml);

		foreach($o_xml->children() as $i){
			$this->choice($i, 0);
		}

		$this->endFoot();
	}

}

private function emailMeSearchedPage($file){
	session_start();

	$o_mail = new Mail();
		$o_mail->setFrom("scoilnadtri-page-manager@scoilnadtri.com", "Page Manager");
		$o_mail->addAddress("i8badhaggis@yahoo.com", "James");
		$o_mail->setSubject("Page desired unfound by user.");

		$today = getdate();

		$c_message = null;
			$c_message = "<p>A user tried to load the following page " . constant("baseUrl") . $file . "</p>"
						."<p>on " . $today['weekday'] . ", " . $today['month'] . " " . $today['mday'] . " at " . $today['hours'] . ":" . $today['minutes'] . ":" . $today['seconds'] . "</p>";
			$c_message .= "<p>" . $_SESSION['user'] . "</p>";
		$o_mail->setBody($c_message);
		$c_altMessage = null;
			$c_altMessage = "A user tried to load the following page " . $file;
		$o_mail->setAlterBody($altMessage);
		$o_mail->mailSend();
}

private function newHead($pageTitle, $o_xml){
	/* determine if the page requires the user to be logged in */
	$c_login = $this->getAttribute("login", $o_xml);
	if($c_login == "true")
		$b_loginRequired = true;
	else
		$b_loginRequired = false;

	/* determine if the page is closed */
	$c_pageClosed = $this->getAttribute("closed", $o_xml);
	if($c_pageClosed == "true")
		$b_pageClosed = true;
	else
		$b_pageClosed = false;

	/* determine role requirements */
	$c_role = $this->getAttribute("role", $o_xml);
	if($c_role == "admin")
		$b_adminRequired = true;
	else
		$b_adminRequired = false;

	/* redirect to the page closed page */
	if($b_pageClosed){
		header("location: " . constant("baseUrl") . "page-closed");
		die("should never be reached");
	}

	/* redirect to the home page */
	if($pageTitle == "login" && array_key_exists('loggedIn', $_SESSION) && $_SESSION['loggedIn']){
		header( 'Location: ' . constant("baseUrl"));
		die("should not be reached ever");
	}

	if($pageTitle != "login"){
		if(strpos($_SERVER['REQUEST_URI'], "/") == 0)
			$c_currentUri = substr($_SERVER['REQUEST_URI'], 1);
		else
			$c_currentUri = $_SERVER['REQUEST_URI'];

		$_SESSION["loginRedirectPage"] = $_SERVER['REQUEST_URI'];
	}

	if($b_loginRequired){

		/* verify the user is logged in otherwise redirect to login */
		if(array_key_exists('loggedIn', $_SESSION)){
			if(!$_SESSION['loggedIn']){
				//user is not logged in
				header( 'Location: ' . constant("baseUrl") . 'login');
				die("should not be reached ever");
			}
		}else{
			session_write_close();
			header( 'Location: ' . constant("baseUrl") . 'login');	
			die("should not be reached ever");
		}

		/* make sure the session is secure */
		if (isset($_SESSION['HTTP_USER_AGENT'])){
			if ($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT'])){
				$_SESSION['loggedIn'] = false;
				header( 'Location: ' . constant("baseUrl") . 'login');
				die("should never be reached");
			}
		}else{
			$_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
		}

		if($b_adminRequired){
			$ao_people = People::findByUsername($_SESSION['user']);

			if($ao_people[0]->getRole() != "admin"){
				header('Location: ' . constant("baseUrl") . 'access-denied');
				die("should never be reached");
			}
		}
	}

	var_dump($_SESSION);

	$arTitle = explode("-", $pageTitle); 

	?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
		<?php if($this->getAttribute("title", $o_xml)){ ?>
			<title><?php echo $this->getAttribute("title", $o_xml); ?></title><?php
		}else{?>
			<title><?php echo "Grow and Create -";

				foreach($arTitle as $someTitles){
					echo " " . ucwords($someTitles);
				}?></title>
		<?php } ?>
		<script type="text/javascript" src="grow.js"></script>

		<?php
		/* if($b_isLoggedIn){ ?>
			<script type="text/javascript">
				lockAccount();
			</script>
		<?php }
		*/
		?>

		<script type="text/javascript">
			function doLoad(){
				clock();

				ho();

				validateStart();

				if(document.getElementById("anDate") !== null && document.getElementById("anDate") !== null){
					//annoucements();
				}
			}
		</script>

		<?php

	/*
	if (file_exists("images/favicon.ico")) {
        		echo "<link REL=\"shortcut icon\" HREF=\"http://www.scoilnadri.com/favicon.ico\" TYPE=\"image/x-icon\">\n";
    		}
    		*/

	echo '<link href="' . constant("baseUrl") . 'grow.css" rel="stylesheet" type="text/css"/></head><body onload="doLoad();">';
	if($_SERVER['REQUEST_URI'] == "/" || $_SERVER['REQUEST_URI'] == "/main"){
		echo '<p align="center"><img src="' . constant("baseUrl") . 'images/grow-past.png"/></p>';
	}

	echo '<table align="center" id="root">';
	if($_SERVER['REQUEST_URI'] == "/" || $_SERVER['REQUEST_URI'] == "/main"){
		echo '<tr><td id="head" colspan="3"><div style="padding: 4px; float: left;">';
		if($this->getAttribute("subTitle", $o_xml)){
			echo $this->getAttribute("subTitle", $o_xml);
		}elseif($this->getAttribute("title", $o_xml)){
			echo $this->getAttribute("title", $o_xml);
		}else{
			foreach($arTitle as $someTitles){
				echo " " . ucwords($someTitles);
			}
		}
		echo '</div><div style="padding: 4px; float: right;">';
		if(array_key_exists('loggedIn', $_SESSION) && $_SESSION['loggedIn'] && $_SESSION['user']){
			echo '<form name="logout" action="action" method="post"><input type="hidden" name="action" value="actions/logout.php"/>Welcome ';
			$ao_people = People::findByUsername($_SESSION['user']);
			echo $ao_people[0]->getFirstName() . " " . $ao_people[0]->getLastName()
				. '<input type="submit" class="buttonToLink" value="Logout"/> <a href="view-profile"/>View Profile</a></form>';
		}else{
			echo 'Welcome guest.  <a href="login">Login</a>';
		}
		echo '</div></td></tr>';
	}else{
		echo '<tr><td id="logo"><a href="';
		echo constant("baseUrl");
		echo '"><img src="';
		echo constant("baseUrl");
		echo 'images/grow-past.png" border="0"/></a></td>';
		?><!-- <td id="header"> --><div id="headRight"><?php

		if(array_key_exists('loggedIn', $_SESSION) && $_SESSION['loggedIn']){
			echo '<form name="logout" action="action" method="post"><input type="hidden" name="action" value="actions/logout.php"/>Welcome ';
			$ao_people = People::findByUsername($_SESSION['user']);
			echo $ao_people[0]->getFirstName() . " " . $ao_people[0]->getLastName()
				. '<input type="submit" class="buttonToLink" value="Logout"/> <a href="view-profile"/>View Profile</a></form>';
		}else{
			echo 'Welcome guest.  <a href="login">Login</a>';
		}

		echo '</div><h2 align="center" style="clear: right;">';

		if($this->getAttribute("subTitle", $o_xml)){
			echo $this->getAttribute("subTitle", $o_xml);
		}elseif($this->getAttribute("title", $o_xml)){
			echo $this->getAttribute("title", $o_xml);
		}else{
			foreach($arTitle as $someTitles){
				echo " " . ucwords($someTitles);
			}
		}
		echo '</h2></div></td></tr>';
	}
	echo '<tr><!--<td id="menu">-->';

	$menu = new Menu($this);
	if(strlen($_SERVER['REQUEST_URI']) > 1){
		$uri = substr($_SERVER['REQUEST_URI'], 1);
	}else{
		$uri = "";
	}
	$menu->createMenu(simplexml_load_file("Content/grow.menu.xml"), $uri);
	echo '</td><td id="content">';

	die();
}

private function division($xmlChoice){
		$divId = $this->getAttribute("id", $xmlChoice);
		$divClass = $this->getAttribute("class", $xmlChoice);
		if($divId){
			?><div id="<?php echo $divId;?>" <?php
			if($divClass){
				?>class="<?php echo $divClass; ?>"><?php
			}else{
				?>><?php
			}
		}else{
			?> <div <?php
			if($divClass){
				?>class="<?php echo $divClass; ?>"><?php
			}else{
				?>><?php
			}
		}
		foreach($xmlChoice->children() as $divChild){
			$this->choice($divChild, 1);
		}
		?> </div> 
<?php

}

private function endFoot(){
	?>
	<br/>
	<br/>
	<hr/>
	<br/>
		</td>
			</tr>
	<tr>
		<td colspan="2" id="foot">
			<hr/>
			<p align="center">Site design and content Copyright © 2008, 2009 Grow and Create, unless otherwise noted. All rights reserved.<br /><br />Any questions or comments about the website should be directed to <a href="mailto:i8badhaggis@yaoo.com">James Anderson</a>.</p>
		</td>
	</tr>
	</table></body></html><?php
}

public function choice($i){
	switch($i->getName()){
		//this class functions
		case "sect": $this->division($i);
			break;

		//content tag file
		case "aLink": $this->content->linking($i);
			break;
		case "bar": $this->content->bars($i);
			break;
		case "ampersand": $this->content->ampersand($i);
			break;
		case "centerH": $this->content->headers($i, "center");
			break;
		case "centerP": $this->content->paragraph($i, "center");
			break;
		case "clock": $this->content->clock();
			break;
		case "rightP": $this->content->paragraph($i, "right");
			break;
		case "centerS": $this->content->subHeaders($i, "center");
			break;
		case "centerT": $this->content->titles($i, "center");
			break;
		case "copyright": $this->content->copyright();
			break;
		case "fire": $this->content->urgency($i);
			break;
		case "head": $this->content->headers($i, "left");
			break;
		case "imgTest": $this->content->imgTest($i);
			break;
		case "include": $this->content->included($i, $this->request);
			break;
		case "list": $this->content->listing($i);
			break;
		case "par": $this->content->paragraph($i, "left");
			break;
		case "part": $this->content->part($i);
			break;
		case "pict": $this->content->picture($i);
			break;
		case "spe": $this->content->specialize($i);
			break;
		case "sub-head": $this->content->subHeaders($i, "left");
			break;
		case "title": $this->content->titles($i, "left");
			break;
		case "xmlError": $this->content->xmlError($i);
			break;
		case "findToReplace": $this->content->findToReplace($i);
			break;
		case "indent": $this->content->indent($i);
			break;
		case "justP": $this->content->paragraph($i, "justify");
			break;

		//coinSlot tag file
		case "coinSlot": $this->slot->coinSlot($i);
			break;
		case "slot": $this->slot->slot($i);
			break;

		//column tag file
		case "col-set": $this->col->column($i);
			break;

		//format tag file
		case "date": $this->format->date($i, "normal");
			break;
		case "fullDateTime": $this->format->fullDateTime($i);
			break;
		case "dateY": $this->format->date($i, "year");
			break;
		case "random": $this->format->random($i);
			break;
		case "screen": $this->format->screen($i);
			break;
		case "quote": $this->format->quote($i);
			break;
		case "split": $this->format->split($i);
			break;
		case "time": $this->format->time($i);
			break;
		case "key-text": $this->format->keyText($i);
			break;
		case "for": $this->format->forXml($i);
			break;
		case "variable": $this->format->variable($i);
			break;
		case "if": $this->format->xmlIf($i);
			break;

		//table tag file
		case "note": $this->tables->note($i);
			break;
		case "table": $this->tables->createTable($i);
			break;
		case "row": $this->tables->row($i);
			break;
		case "header": $this->tables->header($i);
			break;
		case "headers": $this->tables->headers($i);
			break;
		case "cell":$this->tables->cell($i);
			break;

		//log tag file
		case "admin": $this->log->admin($i);
			break;
		case "forgot": $this->log->forgotPass();
			break;
		case "logButtons": $this->log->logButtons();
			break;
		case "logError": $this->log->error();
			break;
		case "logIn": $this->log->logIn();
			break;
		case "seCure": $this->log->secure($i);  //for whatever reason it will not allow for secure as the tag name
			break;
		case "notLoggedIn": $this->log->notLoggedIn($i);
			break;
		case "stolen": $this->log->stolen();
			break;
		case "userNotExist": $this->log->userNotExist();
			break;
		case "welcomeMessage": $this->log->welcomeMessage();
			break;

		//info tag file
		case "allDirTable": $this->info->allTable();
			break;
		case "dirInput": $this->info->inputFields();
			break;
		case "dirResult": $this->info->searchResult();
			break;
		case "dirTable": $this->info->speTable($i);
			break;

		//photos tag file
		case "albums": $this->photos->albums();
			break;

		//admin tag file
		case "newPassword": $this->admin->newPass();
			break;

		case "newForm": $this->newForms->form($i);
			break;
		case "text": $this->newForms->text($i, "text");
			break;
		case "pass": $this->newForms->text($i, "password");
			break;
		case "textbox": $this->newForms->textbox($i);
			break;
		case "submit": $this->newForms->button($i);
			break;
		/*
		case "errors": $this->newForms->errors($i);
			break;
		case "subject": $this->newForms->formEmailSubject($i);
			break;
		case "formTitle": $this->newForms->formEmailTitle($i);
			break;
		*/
		case "radio": $this->newForms->radio($i);
			break;
		case "newFormNone": $this->newForms->formNone($i);
			break;
		case "textNone": $this->newForms->textNone($i, "text");
			break;
		case "passNone": $this->newForms->textNone($i, "password");
			break;
		case "textboxNone": $this->newForms->textboxNone($i);
			break;
		case "submitNone": $this->newForms->buttonNone($i);
			break;
		/*
		case "errors": $this->newForms->errors($i);
			break;
		case "subject": $this->newForms->formEmailSubject($i);
			break;
		case "formTitle": $this->newForms->formEmailTitle($i);
			break;
		*/
		case "radioNone": $this->newForms->radio($i);
			break;
		case "checkboxNone": $this->newForms->checkboxNone($i);
			break;
	}
}

public function getRequest(){
	return $this->request;
}

public function errorInvalid($message){
	?><div class="notice"><table><tr><td><?php echo $message; ?></td></tr></table><?php
}

	public function xmlError($choice){
		?>
		<table>
			<tr bgcolor="red"><td><?php echo $choice; ?></td></tr>
		</table>
		<?php
	}

//pass in a attribute name followed by the xml object it exists in
public function getAttribute($name, $node){
	foreach($node->attributes() as $key=>$val){
		if($key == $name){
			return (string)$val;
		}
	}
}

//returns true if the simplexml object has a child
public function hasChild($xmlChoice){
	$hasChild = FALSE;
	if($xmlChoice && $xmlChoice->xPath("child::*")){
		$hasChild = TRUE;
	}
	return $hasChild;
}

public function childNum($xmlChoice){
	$childNum = 0;
	foreach($xmlChoice->children() as $child){
		$childNum++;
	}
	return $childNum;
}

}//end of the class

?>

 

let me know if you need anything more.  I just don't understand how a variable in session can be modified simply by not outputting a <td> tag.

if I change it from <td id="head or header"> to <td> it works

 

I don't understand

Link to comment
Share on other sites

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"><head> 
						<title>Grow and Create - Login</title> 
					<script type="text/javascript" src="grow.js"></script> 


		<script type="text/javascript"> 
			function doLoad(){
				clock();

				ho();

				validateStart();

				if(document.getElementById("anDate") !== null && document.getElementById("anDate") !== null){
					//annoucements();
				}
			}
		</script> 

		<link href="http://www.growandcreate.com/grow.css" rel="stylesheet" type="text/css"/></head><body onload="doLoad();"><table align="center" id="root"><tr><td id="logo"><a href="http://www.growandcreate.com/"><img src="http://www.growandcreate.com/images/grow-past.png" border="0"/></a></td><!-- <td id="header"> --><div id="headRight">Welcome guest.  <a href="login">Login</a></div><h2 align="center" style="clear: right;"> Login</h2></div></td></tr><tr><!--<td id="menu">--><ul><li><a href='http://www.growandcreate.com/'>Home</a></li><li><a href='http://www.growandcreate.com/javascript'>Javascript</a><ul></ul></li><li><a href='http://www.growandcreate.com/staindslowty'>Staindslowty</a></li><li><a href='http://www.growandcreate.com/gains'>Gains</a></li></ul></td><td id="content"><p align="center" >To login please give your username and password</p><form action='http://www.growandcreate.com/action' id='mainForm' method='post'><input type='hidden' name='action' value='actions/login.php'/><input type='hidden' name='formName' value='login'/><table style='border: 0px;' align='center'><tr style='border: 0px;'><td style='border: 0px;'>Username</td><td style='border: 0px;'><input type='text' name='username' size='35' id='username' onblur='validate("username");' value=''/>  <span id='usernameValid'><!--<img src='images/eraseImage.png'/>--></span></td></tr><tr style='border: 0px;'><td style='border: 0px;'>Password</td><td style='border: 0px;'><input type='password' name='password' size='35' id='password' onblur='validate("password");' value=''/>  <span id='passwordValid'><!--<img src='images/eraseImage.png'/>--></span></td></tr><tr><td colspan='2' align='center'><input type='submit' value='submit'/></p></table></form>		<br/> 
	<br/> 
	<hr/> 
	<br/> 
		</td> 
			</tr> 
	<tr> 
		<td colspan="2" id="foot"> 
			<hr/> 
			<p align="center">Site design and content Copyright © 2008, 2009 Grow and Create, unless otherwise noted. All rights reserved.<br /><br />Any questions or comments about the website should be directed to <a href="mailto:i8badhaggis@yaoo.com">James Anderson</a>.</p> 
		</td> 
	</tr> 
	</table></body></html>

 

here's my page

now if I uncomment the td tags the variable is changed.  keep them commented and it works.

Link to comment
Share on other sites

No offense, but what a mess! :)

 

PHP does not care about the HTML you output, but there are limitations for things such as headers and sessions.

One such limitation is that you may not have any output before sending a header or starting a session. (There is a workaround for this, but out of scope of the thread.)

 

Without being able to actually run your code, I can't say for sure whether that is the problem or not. Its either that, or a flaw in your logic. Like I said, PHP does not care whether you have <td> or <td id="header">.

 

All I can say is,

1. Verify $_SESSION["loginRedirectPage"] has the correct value directly after setting it.

2. Verify it has the correct value at other key points on the same page that it is set to ensure you are not unintentionally modifying it.

3. Verify it has the correct value at the very beginning of the login page.

4. Verify it has the correct value at key points of the login page, again to make sure you are not unintentionally modifying it.

Link to comment
Share on other sites

ok here's the weird part.  you can see where I set it.

 

if I var_dump it at the very end.  the absolutely last thing to be called is that dump.  it's the correct value.  if I open up the following file right afterwards

<?php

session_start();

var_dump($_SESSION);

?>

 

it's different.  why?

 

Link to comment
Share on other sites

actually here

 

here is a straight page

<?php

session_start();

$_SESSION["loginRedirectPage"] = $_SERVER['REQUEST_URI'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
	<head> 
		<title>Grow and Create - Login</title> 
		<script type="text/javascript" src="grow.js"></script> 
		<script type="text/javascript"> 
			function doLoad(){
				//clock();

				//ho();

				//validateStart();

				if(document.getElementById("anDate") !== null && document.getElementById("anDate") !== null){
					//annoucements();
				}
			}
		</script> 

		<link href="http://www.growandcreate.com/grow.css" rel="stylesheet" type="text/css"/>
	</head>
	<body onload="doLoad();">
		<table align="center" id="root">
			<tr>
				<td id="logo">
					<a href="http://www.growandcreate.com/">
						<img src="http://www.growandcreate.com/images/grow-past.png" border="0"/>
					</a>
				</td>
				<td><!-- <td id="header"> -->
					<div id="headRight">Welcome guest.  <a href="login">Login</a></div>
					<!-- <h2 align="center" style="clear: right;"> Login</h2></div> -->
				</td>
			</tr>
			<tr>
				<td><!-- <td id="menu"> -->
					<ul>
						<li><a href='http://www.growandcreate.com/'>Home</a></li>
						<li><a href='http://www.growandcreate.com/javascript'>Javascript</a>
							<ul></ul>
						</li>
						<li><a href='http://www.growandcreate.com/staindslowty'>Staindslowty</a></li>
						<li><a href='http://www.growandcreate.com/gains'>Gains</a></li>
					</ul>
				</td>
				<td id="content">
					<p align="center" >To login please give your username and password</p>
					<form action='http://www.growandcreate.com/action' id='mainForm' method='post'>
						<input type='hidden' name='action' value='actions/login.php'/>
						<input type='hidden' name='formName' value='login'/>
						<table style='border: 0px;' align='center'>
							<tr style='border: 0px;'>
								<td style='border: 0px;'>Username</td>
								<td style='border: 0px;'>
									<input type='text' name='username' size='35' id='username' onblur='validate("username");' value=''/>  
									<span id='usernameValid'><!--<img src='images/eraseImage.png'/>--></span>
								</td>
							</tr>
							<tr style='border: 0px;'>
								<td style='border: 0px;'>Password</td>
								<td style='border: 0px;'>
									<input type='password' name='password' size='35' id='password' onblur='validate("password");' value=''/>  
									<span id='passwordValid'><!--<img src='images/eraseImage.png'/>--></span>
								</td>
							</tr>
							<tr>
								<td colspan='2' align='center'>
									<input type='submit' value='submit'/><!-- </p> -->
								</td><!-- was missing -->
							</tr><!-- was missing -->
						</table>
					</form>
					<br/> 
					<br/> 
					<hr/> 
					<br/> 
				</td> 
			</tr> 
			<tr> 
				<td colspan="2" id="foot"> 
					<hr/> 
					<p align="center">Site design and content Copyright © 2008, 2009 Grow and Create, unless otherwise noted. All rights reserved.<br /><br />Any questions or comments about the website should be directed to <a href="mailto:i8badhaggis@yaoo.com">James Anderson</a>.</p> 
				</td> 
			</tr> 
		</table>
	</body>
</html>

<?php 

var_dump($_SESSION);

?>

 

I open it in that simple page above

 

it's all based on those two td tags still

set them to simply normal <td> and it all works fine

set them to anything else and it breaks

Link to comment
Share on other sites

result directly after running it

array(2) { ["initiated"]=> bool(true) ["loginRedirectPage"]=> string(6) "/z.php" }

 

result at the end of the page

array(2) { ["initiated"]=> bool(true) ["loginRedirectPage"]=> string(6) "/z.php" }

 

result on the next page with the following code

<?php

session_start();

var_dump($_SESSION);

?>

 

array(4) { ["initiated"]=> bool(true) ["loginRedirectPage"]=> string(15) "/page-not-found" ["application"]=> NULL ["request"]=> NULL }

Link to comment
Share on other sites

I use the following .htaccess

RewriteEngine on

Options All -Indexes

#RewriteRule ^maintenance$ ErrorHandling/redirectPages/maintenance.php
#RewriteRule ^dev/complicate/the/url/maintenance$ dev/complicate/the/url/ErrorHandling/redirectPages/maintenance.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^caller.php$
RewriteCond %{REQUEST_FILENAME} !^page-machine.php$
RewriteRule ^(.*)$ caller.php [L]

 

to get to the file caller.php

 

if put a die("t"); or even just a var_dump("t"); at the beginning of caller.php that test page and display page work properly however t is never displayed

 

Link to comment
Share on other sites

Do this then,

 

Create two new pages:

 

testinit.php

<?php
session_start();
$_SESSION['redirectTo'] = $_SERVER['REQUEST_URI'];

header('Location: testview.php');
exit;

 

testview.php

<?php
session_start();
var_dump($_SESSION);

 

Run testinit.php and see if it displays "testinit.php" as expected.

Link to comment
Share on other sites

array(2) { ["initiated"]=> bool(true) ["redirectTo"]=> string(13) "/testinit.php" }

 

yep that's what it should be.

I have another page

that does the following to destroy my session

which set the initiated index

<?php

session_start();

$_SESSION = array();

$_SESSION['initiated'] = true;

var_dump($_SESSION);

echo "Session destroyed";

?>

 

so. it worked properly

this leaves the question of what does my html do to it.  cause I do not think that it could do that.  what would an auto_append look like?  cause I don't think I have anything like that

Link to comment
Share on other sites

Ok so its definitely something to do with your logic in either the caller.php or pagemachine.php.

 

I've got to run out of the office, but in the meantime try spreading

echo 'short desc of where this line is at in your code: '. var_dump($_SESSION);

throughout those two files and find out where the session var is being changed to an unexpected value.

Link to comment
Share on other sites

the problem with that idea is that I know that the variable survives the trip through my code in both of those files.  at the very very absolute end it is still correct.  but if I go to that session_display page it's different.

 

one thought I have is that perhaps $_SERVER['REQUEST_URI'] is changing... and maybe when I set my variable with it I'm simply giving it a pointer by mistake.

Link to comment
Share on other sites

  • 4 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.