<?php

/*/
	(c) 2001-2004 by Locke Enterprises (iLocke.com) - All rights reserved.
	License:  Authorized for use on the AutoGlassHosting.com website.
	File:  oLoginAuth.phi [v2.03]
	Purpose:  Nathan's standardized but extensible login/authorization check/enforcement/prompt handling module.
	Created:  10/10/2001 - Locke Enterprises (iLocke.com)
	Modification History:
		* 12/7/2004 - Nathan - legacy in-line code concepts � 2001-2004 molded into this new class object
		* 05/23/2019 - Nathan - adapted for responsive template
		* mm/dd/yyyy - [name] - [comment]
	Prerequisites:  NDB, PHP4 w/ register_globals=on / magic_quotes=off
	Notes:
		Still needs several additional callbacks - this version is specific to W2G customers.
		The plan is to have a simple and callback login method.
		Simple just gives it a template SQL string:
			(numerical) SELECT ID FROM {TABLE} WHERE {USER_FIELD}='{USER_KEY}' AND {PW_FIELD}='{PW_KEY}'
			(object) SELECT * ... / this method registers the array into the rInfo of the session object
		Complex runs a callback and logs the user in on its own.
/*/


	define( "NLA_DEFAULT_KEY", "LOGIN_INFO" );
	define( "NLA_NO_REDIRECT", "{NONE}" );
	define( "NLA_CB_LOGIN_SUCCESSFUL", "LoginSuccessful" );  // callbacks
	$dev_IP = "24.176.238.70";


//-------------------------------------------------------------------------
// LoginAuth:  Encapsulation of core login and authentication services.
//-------------------------------------------------------------------------
class LoginAuth {


	var $config = null;  // will be one main info array


//-------------------------------------------------------------------------
// LoginAuth:  Constructor.
//-------------------------------------------------------------------------
function LoginAuth( $sessionKey=null, $headerFile=null, $footerFile=null, $msg=null, $action="", $userkey="UserName", $passkey="PassKey", $showLocke=true ) {

	$this->config = array();
	
	/// main setup...
	$this->config['sessionkey'] = empty($sessionKey) ? NLA_DEFAULT_KEY : $sessionKey;  // where we keep the login object
	$this->config['as_object'] = false;  // when true, the session's [key]=ID becomes [key]->ID = ID
	$this->config['header'] = empty($headerFile) ? "" : $headerFile;
	$this->config['footer'] = empty($footerFile) ? "" : $footerFile;
	$this->config['msg'] = empty($msg) ? "" : $msg;
	$this->config['fields'] = array();
	
	/// login form specifics...
	$this->config['target'] = "";  // "_top";
	$this->config['prompt'] = "Please enter your login information.";  //
	$this->config['action'] = empty($action) ? ereg_replace("/index\\.php$", "/", $_SERVER['PHP_SELF']) : $action;
        if (isset($_GET['acct'])) {
            $this->config['action'] .= '?acct=' . $_GET['acct'];
            $this->config['action'] = 'https://account.autoglasshosting.com' . $this->config['action'];
        }

	$this->config['style'] = "";  // " style=\"border: #808080 1px dotted; background: #F0F0F0;\"";
	$this->config['stylesheet'] = "";
	$this->config['favicon'] = "";
	
	/// standard login fields...
	$this->config['user'] = empty($userkey) ? "UserName" : $userkey;  // standard login field 1
	$this->config['password'] = empty($passkey) ? "PassKey" : $passkey;  // standard login field 2
	$this->config['logout'] = "You have been logged out.";
	$this->config['invalid'] = "";

	/// system info items...
	$this->config['LOCKE'] = empty($showLocke) ? true : $showLocke===true;  // show the Locke header/title info
	$this->config['LOCKE_info'] = "PHP[LoginAuth] by Locke Enterprises | www.iLocke.com";
	$this->config['license'] = "Windshields To Go USA - AutoGlassHosting.com";
	$this->config['title'] = "Login - Web Content Management System | by iLocke.com";
	$this->config['heading'] = "Web Content Management System Login";

	/// override extras...
	$this->config['bUseResponsiveHTML'] = false;
	
	/// callbacks...
	$this->config['callbacks'] = array();

} // LoginAuth()


//-------------------------------------------------------------------------
// LoginForm:  A stock form that provides entry boxes to log the user in.
//-------------------------------------------------------------------------
function LoginForm( $specialPage=false ) {
	
	//echo "LoginAuth_LoginForm<br><br>";

	/// do this for the header/footer include files which usually won't be expecting to be included within a function (they'll want $g_Config, etc)...
	//foreach( $GLOBALS as $key => $value ) @eval( "global \$".$key.";" );  // manually is bound to be slower
	extract($GLOBALS); // fastest method!
	/*
	$to_extract = array();
	foreach( $GLOBALS as $key => $value ) {
		if( !ereg("_SERVER|_ENV|_SESSION|_COOKIE|_GET|_POST|_REQUEST|_FILES", $key) ) {
			$to_extract[] = $key;
			echo $key;
		}
	}
	extract($to_extract);
	/**/
	
	/* INIT() the $this->config hash with default (i.e., "") for all values to be used */
	/* should be:
		$oLogin = new LoginAuth( $InfoArrayString="", $Header="", $Footer="" ); // automatically does a first-pass check for a LogIn() action
		// properties/settings
		if( !$oLogin->authenticated() ) {
			$oLogin->LoginForm();  // exit()'s
		}
		// else $oLogin->register(); ?
		// falls through to remaining code
		- or -
		$oLogin->LogOut();
	*/

	/// initz...
	if( trim($this->config['msg'])=="" && isset($_GET['re']) && $_GET['re']=="LO" ) $this->config['msg'] = $this->config['logout'];
	
	/// page header...
	if( !empty($this->config['header']) ) {
		@include($this->config['header']);
		if( $this->config['LOCKE'] ) {
			echo "\n\n<!-- (start) ".$this->config['LOCKE_info']." -->\n";
		}
	} else {  // provide a stock header
		?>
		<html>
			<head>
				<title><?= htmlspecialchars($this->config['title']) ?></title>
				<? if( $this->config['LOCKE'] ) { ?>
				<meta name="Owner" content="Locke Enterprises (iLocke.com)">
				<meta name="Copyright" content="Copyright (c) 2002-2003 Locke Enterprises (iLocke.com) - All rights reserved.">
				<meta name="Author" content="Locke Enterprises (iLocke.com)">
				<meta name="Creator" content="Locke Enterprises (iLocke.com)">
				<meta name="Maintaned-By" content="Locke Enterprises (iLocke.com)">
				<? } ?>
				<meta name="License" content="<?= $this->config['license'] ?>">
				<?
					if( isset($this->config['script']) ) {
						echo "<script language=\"JavaScript\" src=\"".$this->config['script']."\"></script>";
					} elseif( isset($this->config['scripts']) && is_array($this->config['scripts']) ) {
						foreach( $this->config['scripts'] as $script ) {
							echo "<script language=\"JavaScript\" src=\"".$script."\"></script>";
						}
					}
					if( !empty($this->config['stylesheet']) ) {
						?><link rel="stylesheet" type="text/css" href="<?= $this->config['stylesheet'] ?>"><?
					} else {
						?>
							<style<!--
								/* (c) iLocke.com - as taken from m� master CSS templates */
								BODY, TD{ color: #000000; font-family: Arial, Helvetica; font-size: 12px; }
								A, A:link, A:visited { color: #2828B8; text-decoration: none; }
								A:hover, A:active { color: #88A0D8; text-decoration: underline; }
								A, A:link, A:visited, A:hover, A:active { font-weight: normal; }
								P.action{ color: #00A000; background: none; text-decoration: none; font-weight: bold; font-size: 16px; }
								P.error{ color: #E00000; background: none; text-decoration: none; font-weight: bold; font-size: 18px; }
								.normal {
									color: #000060; background: #F4F4F4; vertical-align: middle;
									font-size: 11px; font-weight: normal; border-color: #C0C0C0; text-decoration: none;
									font-family: "Arial", "Helvetica", "Sans-Serif"; /* N6?! */
									scrollbar-face-color: #A0A0A0; scrollbar-shadow-color: #808080; scrollbar-highlight-color: #E8E8E8;
									scrollbar-3dlight-color: #C0C0C0; scrollbar-darkshadow-color: #000000; scrollbar-track-color: #E0E0E0;
									scrollbar-arrow-color: #FFFFFF;
								}
								.button{ color: #FFFFFF; background: #8080B0; vertical-align: middle; font-size: 14px; border-color: 0040D0;  }
								-->
							</style>
						<?
					}
				?>
			</head>
			<? if( !empty($this->config['favicon']) ) { ?>
			<link rel="shortcut icon" href="<?= $this->config['favicon'] ?>">
			<? } ?>
		<body bgcolor=#E0E0E0>
			<br><br>
		<?php
	}

	/// set defaults if we were'nt setup right...
	$this->EstablishFields();
	//DumpInfo( $this->config['fields'] );

	// html5 bootstrap update
	if( $this->config['bUseResponsiveHTML'] ) {
	
		/// display the form...
		$target = !empty($this->config['target']) ? "target=\"".$this->config['target']."\"" : "";
		?>
			<form <?= $target ?> action="<?= $this->config['action'] ?>" method=POST>
				<input type="hidden" name="LoginAuth_FormFlag" value="Y">
				<input type="hidden" name="LoginAuth_FormRedirect" value="<?= $specialPage ? "Y" : "N" ?>">
				<? 
					if( $specialPage ) { 
						?><input type="hidden" name="LoginAuth_QueryString" value="<? echo htmlspecialchars($_SERVER['QUERY_STRING']); ?>"><? 
					}
					if( trim($this->config['msg']) != "" ) {
						echo "<p class=action>&gt;&gt; ".$this->config['msg']."</p>";
					}
			?>
			<div id="row-outer" class="row">
				<div class="col-sm-1 col-md-2 col-xl-3"></div>
				<div class="col-12 col-sm-10 col-md-8 col-xl-6 text-center p-2">

					<h3 class="pt-4" style="border-bottom: #000 1px solid; font-weight: bold;"><?= $this->config['heading'] ?></h3>
					<div class="pt-1 pb-1 pr-4 pl-4 mt-3 mb-2"><?= $this->config['prompt'] ?><div>
					
					<div class="row shadow-sm mt-2 pt-2" style="border: #C8C8C8 1px solid; border-radius: 12px; background: #EAEAEA;">
						<div class="col-1"></div>
						<div class="col-10">
							<?
								
								/// display each field...
								foreach( $this->config['fields'] as $fieldName => $fieldConfig ) {
									/// hidden fields...
									if( $fieldConfig['type']=="hidden" ) {
										echo "<input type=\"hidden\" name=\"".$fieldConfig['name']."\" value=\"".$fieldConfig['value']."\" ".$fieldConfig['parameters'].">";
										continue;
									}
									/// regular; visible fields...
									echo "\t<div class=\"row pt-4 no-gutters\">\n";
									echo "\t\t<div class=\"col-0 col-md-1 col-lg-2\"></div>\n";
									echo "\t\t<div class=\"col-12 col-sm-4 col-lg-3 label text-secondary text-right xs-left text-norwap pt-2\">".$fieldConfig['label']."</div>\n";
									echo "\t\t<div class=\"col-12 col-sm-7 col-md-6 col-lg-5 text-left ml-2 pl-2\">\n";
									echo "\t\t\t<input type=\"".$fieldConfig['type']
										."\" name=\"".$fieldConfig['name']
										."\" value=\"".$fieldConfig['value']
										."\" size=\"".$fieldConfig['size']
										."\" maxlength=\"".$fieldConfig['maxlength']
										."\" class=\"form-control ".$fieldConfig['class']
										."\" style=\"".$fieldConfig['style']
										."\" ".$fieldConfig['parameters'].">\n"
									;
									echo "\t\t\t &nbsp;<small><span style=\"color: #AAA;\">".$fieldConfig['hint']."</small></span>";
									echo "\t\t</div>\n";
									echo "\t\t<div class=\"col-0 col-sm-1 col-lg-2\"></div>\n";
									echo "\t</div>\n";
								}
								
							?>
							<div class="row pb-4">
								<div class="col-3"></div>
								<div class="col-6 mt-4">
									<input type="submit" class="form-control btn btn-primary" value="Log In">
								</div>
								<div class="col-3"></div>
							</div>
						
						</div>
						<div class="col-1"></div>
					</div>
					
				</div>
				<div class="col-sm-1 col-md-2 col-xl-3"></div>
			</div>
			</form>
		<?

	// legacy html4 version
	} else {
	
		/// display the form...
		$target = !empty($this->config['target']) ? "target=\"".$this->config['target']."\"" : "";
		?>
			<blockquote>
			<table width=100% cellpadding=0 cellspacing=0 border=0>
				<!-- ?? why not use the "_top" target !! -->
				<form <?= $target ?> action="<?= $this->config['action'] ?>" method=POST>
					<input type="hidden" name="LoginAuth_FormFlag" value="Y">
					<input type="hidden" name="LoginAuth_FormRedirect" value="<?= $specialPage ? "Y" : "N" ?>">
					<? if( $specialPage ) { ?>
					<input type="hidden" name="LoginAuth_QueryString" value="<? echo htmlspecialchars($_SERVER['QUERY_STRING']); ?>">
					<? } ?>
				<tr><td style='text-align: left;'>
				<?if( trim($this->config['msg']) != "" ) echo "<p class=action>&gt;&gt; ".$this->config['msg']."</p><br>"; ?>
				<font size=4><u><?= $this->config['heading'] ?></u></font>
				<blockquote>
						<? /* someday I should get a HiddenFields() working here for any form as well */ ?>
						<table cellpadding=5 cellspacing=0 border=0 <?= $this->config['style'] ?>>
							<tr>
								<td colspan=3><br><h4><?= $this->config['prompt'] ?></h4></td>
							</tr>
							<?
							
								/// display each field...
								foreach( $this->config['fields'] as $fieldName => $fieldConfig ) {
									//echo "<!-- LoginAuth: '$fieldName' == '".$fieldConfig['name']."' -->";
									/// hidden fields...
									if( $fieldConfig['type']=="hidden" ) {
										echo "<input type=\"hidden\" name=\"".$fieldConfig['name']."\" value=\"".$fieldConfig['value']."\" ".$fieldConfig['parameters'].">";
										continue;
									}
									/// regular; visible fields...
									echo "<tr><td style='text-align: left;' nowrap>&nbsp; ".$fieldConfig['label']." &nbsp;</td>";
									echo "<td align=left nowrap>";
									echo "<input type=\"".$fieldConfig['type']."\" name=\"".$fieldConfig['name']."\" value=\"".$fieldConfig['value']."\" size=\"".$fieldConfig['size']."\" maxlength=\"".$fieldConfig['maxlength']."\" class=\"".$fieldConfig['class']."\" style=\"".$fieldConfig['style']."\" ".$fieldConfig['parameters']."> &nbsp;";
									echo "<font size=2 color=#808080>".$fieldConfig['hint']."</font>";
									echo "</td><td width=50%>&nbsp;</td></tr>\n";
								}
								
							?>
						</table><br><br>
						<input type="submit" class=button value="Log In">
					</form>
				</blockquote>
			</td></tr></table>
			</blockquote><br><br>&nbsp;
		<?php
	}

	/// page footer...
	if( !empty($this->config['footer']) ) {
		if( $this->config['LOCKE'] ) {
			echo "\n<!-- (end) ".$this->config['LOCKE_info']." -->\n\n";
		}
		@include($this->config['footer']);
	} else {  // provide a stock footer
		echo "</body></html>\n\n<!-- ".$this->config['LOCKE_info']." -->";
	}

} // LoginForm()


//-------------------------------------------------------------------------
// LogOut:  Abandon the session; redirect either back to self or to another page.
//-------------------------------------------------------------------------
function LogIn() {

	global $g_oNDB;
	
	/// first in case setup wasn't explicit...
	$this->EstablishFields();
	
	/*/ -- Attempt to authenticate their login info now. -- /*/
	$this->config['msg'] = "";
	// $SQL = "SELECT ID FROM invoice WHERE affiliateID=".$g_oNDB->escape($this->config['fields']['affiliateID']['value'])." AND ";
	$SQL = "SELECT ID FROM invoice WHERE ";
	$SQL .= " orderNum=".$g_oNDB->escape(FV($this->config['fields'][$this->config['user']]['name']))." ";
	$SQL .= " AND customerKey=".$g_oNDB->escape(FV($this->config['fields'][$this->config['password']]['name'])); // echo "<p>$SQL</p>";
	$LoginAuthID = intval($g_oNDB->getField($SQL));
	if( $LoginAuthID<1 ) {
		if( !isset($_REQUEST['LoginAuth_FormFlag']) || $_REQUEST['LoginAuth_FormFlag'] != "Y" ) {
			$this->config['msg'] = "   ";  // this will not display a message, but *does* go to the login form ("" logs them in)
		} else {
			if( intval($g_oNDB->getField($SQL)) > 0 ) {
				$this->config['msg'] = "We apologize, but your account is currently deactivated.<p class=error style='font: normal;'>Please contact technical support for more information. Thank you.";
			} else {
				$this->config['msg'] = "Unable to authenticate your login information.<!--\n".$g_oNDB->message()."\n\n".$SQL."\n\n-->";
			}
		}
		//echo "<!--\n\n$SQL\n\n-->";
		global $g_Config;
		//if( $g_Config->isDev ) DumpInfo($SQL);
	}

	/*/ -- Successful login; register their info into the session. -- /*/
	if( $this->config['msg']=="" ) {
		/// we found them so log them in...
		if( $this->config['as_object'] ) {
			$_SESSION[$this->config['sessionkey']] = new object;
			$_SESSION[$this->config['sessionkey']]->ID = $LoginAuthID;
			$_SESSION[$this->config['sessionkey']]->rInfo = array();
		} else {
			$_SESSION[$this->config['sessionkey']] = $LoginAuthID;
		}
		@session_write_close();  // we are mandatorily redirecting, so go ahead and do this

		$this->RunCallback( NLA_CB_LOGIN_SUCCESSFUL, $LoginAuthID );
		
		/* EXTRA - let this be implemented in a CALLBACK...
		/// record the login / track their loginID...
		mysql_query( "UPDATE member SET logins=logins+1 WHERE ID='".$this->ID."'" );
		$sessionID = intval(getField(0,"SELECT ID FROM session WHERE name='".str_replace("'","''",session_id())."'",0));
		mysql_query( "INSERT INTO memberLogins SET memberID='".$this->ID."', stamp=Now(), sessionID='$sessionID'" );
		$this->loginID = mysql_insert_id();
		// - OR -
		$g_oNDB->getField( "INSERT INTO customerLogins SET stamp=Now(), invoiceID='".$LoginAuthID."'" );
		/**/

		/// since we just logged in, redirect to get the framed site...
		$url = "https://";
		$url .= $_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
		$url = ereg_replace( "/[^/]*\\.php\$", "/", $url );
		if( isset($_REQUEST['LoginAuth_FormRedirect']) && $_REQUEST['LoginAuth_FormRedirect']=="Y" ) {
			$url .= "?page=".urlencode($_SERVER['SCRIPT_NAME']);
			if( $LoginAuth_QueryString!="" ) $url .= urlencode("?".$LoginAuth_QueryString);
		}
                
                if (isset($_GET['acct'])) {
                    $url .= '?acct=' . $_GET['acct'];
                }
                
		header( "Location: ".$url );
		exit; // don't pass thru to priveleged features

	/*/ -- Display the form to let them login. This code is inline because it tends to break when imported within. -- /*/
	} else {
		/// special when anything but a default; keep only a querystring, not a form...
		$specialPage = !((isset($A) && $A=="LO") || basename($_SERVER['PHP_SELF'])=="login.php" || basename($_SERVER['PHP_SELF'])=="index.php");
		/// display the login form...
		$this->LoginForm( $specialPage );
		exit;  // don't pass thru to priveleged features
	}

} // LogIn()


//-------------------------------------------------------------------------
// LogOut:  Abandon the session; redirect either back to self or to another page.
//-------------------------------------------------------------------------
function LogOut( $url="" ) {

	/// log them out
	$_SESSION[$this->config['sessionkey']] = null;
	//session_unregister($this->config['sessionkey']); // [NL:2019-05-29] deprecated php 5.3 removed php 5.4
	unset( $_SESSION[$this->config['sessionkey']] );  // php 5.4 adjustment
	
	/// really shouldn't to do this so that we can log into more than one independent section at a time...
	if( $this->config['logoff_unset_all'] ) {
		@session_unset();  // unset all variables
		@session_destroy();  // actually destroy the session data
	}
	@session_write_close();

	/// redirect...
	if( $url==NLA_NO_REDIRECT ) return;
	if( !isset($url) || trim($url)=="" ) {
		$url = isset($_SERVER['HTTPS']) && strtoupper(trim($_SERVER['HTTPS']))=="ON" ? "https://" : "http://";
		$url .= $_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
		$url = ereg_replace( "/[^/]*\\.php".'$', "/", $url );
		$url .= "?re=LO";
	}
	header( "Location: ".$url );
	exit;
	
} // LogOut()


//-------------------------------------------------------------------------
// AddField:  Returns a reference to an array with parameters correctly named as the LoginForm.
//-------------------------------------------------------------------------
function & AddField( $name, $label="", $size="", $maxlength="", $hint="", $type="", $parameters="", $css_class="", $css_style="", $value="" ) {

	/// set up a new subarray for this field's information...
	$FieldInfo = array();
	$FieldInfo['name'] = "LoginAuth_".$name;  // automatically prepend this to avoid passthru form/querystring conflicts
	$FieldInfo['label'] = isset($label) && $label!="" ? (ereg("[:space:]\$",$label) ? $label : $label.":") : $name.":";  // a space at the end of the label name overrides the automatically appended ":"
	$FieldInfo['size'] = isset($size) && intval($size)!=0 ? $size : "25";
	$FieldInfo['maxlength'] = isset($maxlength) && intval($maxlength)!=0 ? $maxlength : "50";
	$FieldInfo['hint'] = isset($hint) && $hint!="" ? $hint : "";
	$FieldInfo['type'] = isset($type) && $type!="" ? $type : (eregi("pass", $name) ? "password" : "text");  // fields named with "pass" are automatically password types
	$FieldInfo['parameters'] = isset($parameters) && $parameters!="" ? $parameters : "";
	$FieldInfo['class'] = isset($css_class) && $css_class!="" ? $css_class : "normal";
	$FieldInfo['style'] = isset($css_style) && $css_style!="" ? $css_class : "";
	$FieldInfo['value'] = isset($value) && $value!="" ? $value : ($FieldInfo['type']=="password" ? "" : FV('LoginAuth_'.$name));  // assumes prepended "LoginAuth_" and no carryover value for passwords
	//DumpInfo($FieldInfo);
	
	/// all done...
	$this->config['fields'][$name] = $FieldInfo;
	return $this->config['fields'][$name];

} // AddField()


//-------------------------------------------------------------------------
// EstablishFields:  Ensure that the fields are loaded; provide defaults if necessary.
//-------------------------------------------------------------------------
function EstablishFields() {

	if( count($this->config['fields']) < 1 ) {
		//echo "EstablishFields: DEFAULTS<br>";
		$this->AddField( $this->config['user'], "Username", 20, 50 );
		$this->AddField( $this->config['password'], "Password", 20, 50 );
		$this->AddField( 'affiliateID', "", 0, 0, "hidden", "", "", "", 0/*=W2G*/ );
	}

} // EstablishFields()


//-------------------------------------------------------------------------
// RegisterCallback:  Sets the function name of one of the callback codes.
//-------------------------------------------------------------------------
function RegisterCallback( $code, $name ) {

	$this->config['callbacks'][$code] = $name;
	
} // RegisterCallback()


//-------------------------------------------------------------------------
// RunCallback:  Runs the function name of one of the callback codes with the specified passthru parameters. (modified from the DMgr)
// Note:  Returns TRUE by default. Convention is to say 'YES, go ahead' to the caller's query unless there is a reason not to proceed.
//-------------------------------------------------------------------------
function & RunCallback( $CODE, $param1=null, $param2=null, $param3=null, $param4=null, $param5=null ) {

	/// if there isn't one defined, just return true...
	if( !isset($this->config['callbacks'][$CODE]) || $this->config['callbacks'][$CODE]=="" ) return true;
	
	/// get the callback function's name...
	$callbackFunction = $this->config['callbacks'][$CODE];
	
	/// send out ONLY the specified arguments...
	$returned = null;
	if( isset($param5) ) {  /// max numPassthrus is 5
		$returned = $callbackFunction( $param1, $param2, $param3, $param4, $param5 );
	} elseif( isset($param4) ) {
		$returned = $callbackFunction( $param1, $param2, $param3, $param4 );
	} elseif( isset($param3) ) {
		$returned = $callbackFunction( $param1, $param2, $param3 );
	} elseif( isset($param2) ) {
		$returned = $callbackFunction( $param1, $param2 );
	} elseif( isset($param1) ) {
		$returned = $callbackFunction( $param1 );
	} else {
		$returned = $callbackFunction();
	}
	return $returned;
	
} // RunCallback()


//-------------------------------------------------------------------------
// IsLoggedIn:  Legacy idea - to assist with manual handling.
//-------------------------------------------------------------------------
function IsLoggedIn() {

	return false;

} // IsLoggedIn()


} // LoginAuth class


