Location: PHPKode > projects > phpMyOrdering > phpMyOrdering-0.1.7-alpha/phpMyPurchasing-0.1.2-alpha/scripts/classes/class.pages.default.php
<?PHP

/*
 * phpMyAuth
 * Jason Gerfen [hide@address.com]
 *
 * class.pages.default.php - Generate page content class
 */

class GeneratePageContent
{

 function LoadPageContent( $page, $flag )
	{
		global $handles;

		switch( $page ) {
			case "default":
				return $this->GenDefPage( $_SESSION, $_GET, $_POST, $flag );
   case "applications":
    return $handles['applications']->GenMngApplications( $_SESSION['token'], $_GET, $_POST, $flag );
			case "groups":
				return $handles['groups']->GenMngGrpsPage( $_SESSION['token'], $_GET, $_POST, $flag );
			case "users":
				return $handles['users']->GenMngUsrsPage( $_SESSION['token'], $_GET, $_POST, $flag );
			default:
			 return;
		}
	}

 function GenDefPage( $token, $get, $post, $flag )
 {
  global $defined;
  global $handles;
		global $errors;

  // perform a check on the users access level information
  if(($handles['level']->ChkLevel($_SESSION['token']) === "root") || ($handles['level']->ChkLevel($_SESSION['token'] === "user"))) {

 		// define some variables for the template etc.
			$FILE = "loggedin.tpl";
   $JS = NULL;
   $FORM = NULL;
   $page = "admin.manage.users.php";

   // decode the auth token for our username data
   $user_details = $handles['encrypt']->DecodeAuthTokenHeavy( $_SESSION['token'] );
			$username = $user_details[0];

   // initialize a db connection handle
   $dbconn = $handles['db']->dbConnect( $defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname'] );

			// provide count of online users
			$online = "SELECT * FROM `sessions`";
			$ret = $handles['db']->dbQuery( $handles['val']->ValidateSQL( $online, $dbconn ), $dbconn );
			$usersoline = $handles['db']->dbNumRows( $ret );

   // Check to see if user has a the 'reset' flag for their password
   $query = "SELECT * FROM `users` WHERE `username` = \"" . $username . "\" LIMIT 1";

   if( ( $value = $handles['db']->dbQuery( $handles['val']->ValidateSQL( $query, $dbconn ), $dbconn ) ) === -1 ) {
    $error = $handles['err']->GenerateErrorLink( "help/help.html", "#loggin", $defined['error'], $errors['db_select'], NULL, NULL );
   } else {
    $data = $handles['db']->dbArrayResultsAssoc( $value );
    if( $data[0]['reset'] === "TRUE" ) { $FORM = "reset.tpl"; }
    if( $data[0]['level'] !== "admin" ) { $page = "user.preferences.php"; }
    $username = $data[0]['username'];
    $level = $data[0]['level'];
    $group = $data[0]['group'];
    $dept = $data[0]['dept'];
    $create = $data[0]['create_date'] . " @ " . $data[0]['create_time'];
    $access = $data[0]['access_date'] . " @ " . $data[0]['access_time'];
    $session = $data[0]['session'];
   }

   // nice message
   $string = "Welcome '" . $username . "'! Your last login was '" . $access . "'.";

   // give a message on authentication regarding various parameters
   $message = $handles['err']->GenerateErrorLink( "help/help.html", "#auth", $defined['good'], $string, '600', '600' );

   $handles['tpl']->assign( 'page', $page, NULL, NULL );
   $handles['tpl']->assign( 'message', $message, NULL, NULL );
   $handles['tpl']->assign( 'user_pw_1_err', NULL, NULL, NULL );
   $handles['tpl']->assign( 'user_pw_2_err', NULL, NULL, NULL );
   $handles['tpl']->assign( 'FORM', $handles['tpl']->assign( NULL, NULL, $FORM, $flag ), NULL, NULL );
  }
  return $FILE;
 }

}
Return current item: phpMyOrdering