<?php
    ini_set('zlib.output_compression_level', 1);
    ob_start("ob_gzhandler");    /* gzip the content */
require_once("includes/.htconfig.php");
	$server_protocol = $_SERVER["SERVER_PROTOCOL"];
  	$server_software = $_SERVER["SERVER_SOFTWARE"];
	$_method = $_SERVER['REQUEST_METHOD'];
	if($_method == "GET")
  {
    $_request = $_GET;
  }
	else if($_method == "POST")
  {
    $_request = $_POST;
  }
	else
  {
 	  header("Server: ".$server_software);			
 	  header($server_protocol." 405 Method Not Allowed");					
   	  header("Status: 400 Bad Request");
   	  header("Allow: GET, POST, HEAD");
	  exit(0);					
	}
	while(list($_key,$_value)=each($_request))
  {
		${trim(htmlentities($_key, ENT_QUOTES, "UTF-8"))} = trim(htmlentities($_value, ENT_QUOTES, "UTF-8"));
  progress(__FILE__,__LINE__,"<BR>$_key is now ".$$_key);
	}
	reset($_request);

	if((isset($action)) && ($action == "verify"))
  {
  progress(__FILE__,__LINE__,"Trying try.inc");
		require_once(OPENIDDIRECTORY."/try.inc");
	}

	if(isset($openid_claimed_id))
  {
  progress(__FILE__,__LINE__,"Trying auth.inc");
		require_once(OPENIDDIRECTORY."/auth.inc");
    $subjectid=deslash($_SESSION['userIdentity']);
    $_SESSION['subjectid']=$subjectid;
    advancePage($newby);
    buggywuggy("$openid advanced to page $newby.");
    exit();
  }

	// if needs login 
	if($_SESSION['isSession'] == "true")
  {
		if($_SESSION['sessionTime'] >= (time()-3600))
    {
			$_SESSION['sessionTime'] = time();
		}
    else
    {			
			unset($_SESSION['isSession']);
			unset($_SESSION['sessionTime']);
			unset($_SESSION['userIdentity']);
			$_SESSION = array();
			session_destroy();
			$app = "session_timeout";
	  } // End check session time 
		if(intval($_SESSION['userIdentity']) < 1)
    {
      $app = "login";	// Login
		}
	}
  else
  { 
	  $app = "login";
	} // End check isSession
  include ("includes/headstart.php");
?>
<title>Provisional Authentication</title>
</head>
<body>

<?php
    progress(__FILE__,__LINE__,print_r($Auth_OpenID_sreg_data_fields,TRUE));
									$has_result = false;
									if(file_exists(OPENIDDIRECTORY."/$app.inc")) {
                  
  progress(__FILE__,__LINE__,"Chose to run $app.inc");
										require(OPENIDDIRECTORY."/$app.inc");	
										$has_result = true;
									}
									if(!$has_result){
  progress(__FILE__,__LINE__,"Running default.inc");
											require(OPENIDDIRECTORY."/default.inc");	// Your own default includes...
									}
    progress(__FILE__,__LINE__,print_r($Auth_OpenID_sreg_data_fields,TRUE));
?>

</body>
</html>