Location: PHPKode > projects > phpMyOrdering > phpMyOrdering-0.1.7-alpha/phpMyPurchasing-0.1.2-alpha/scripts/classes/class.errors.php
<?PHP
/*
 * errors.inc.php
 *
 * Handle generation of error messages
 *
 * Copyright Jason Gerfen <hide@address.com>
 *
 */

class GenerateErrors
{
 var $help;
 var $section;
 var $image;
 var $message;

 function GenerateErrorLink( $help, $section, $image, $message, $width, $height )
 {
	 if( empty( $width ) ) { $width = "800"; }
		if( empty( $height ) ) { $height = "800"; }
  return "<a href=\"javascript:popUp('$help$section', '$width', '$height')\"><img src=\"$image\" border=\"0\">&nbsp;&nbsp;$message</a>";
 }

 function GenerateErrorMsg( $image, $message )
 {
  return "<img src=\"$image\" border=\"0\">&nbsp;&nbsp;$message</a>";
 }

 function GenerateErrorImg( $image, $link, $width, $height )
 {
  return "<a href=\"javascript:popUp('$link$section', '$width', '$height')\"><img src=\"$image\" border=\"0\"></a>";
 }

 function detLoginErr($code)
	{
  global $defined;
  global $errors;
  switch( $code ) {
   case 0:
    // user credentials and/or authentication token is valid
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#valid_auth", $defined['good'], "You have been authenticated.", NULL, NULL );
    break;
   case 1:
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#default_login", $defined['good'], "Welcome to the " . $defined['title'] . " application, please log in...", NULL, NULL );
    // user not authenticated (no posted authentication credentials found)
    if( $_SESSION['count']++ > 1 ) {
     $ERROR = $this->GenerateErrorLink( "help/help.html", "#no_credentials", $defined['error'], $errors['val_missing'], NULL, NULL );
    }
    break;
   case 2:
    // invalid data found with username / password combination (xss, sql checks)
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#invalid_charset", $defined['error'], $errors['val_par'], NULL, NULL );
    break;
   case 3:
    // not a valid database user found with supplied credentials
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#invalid_charset", $defined['error'], $errors['val_par'], NULL, NULL );
    break;
   case 4:
    // double check user results by count in array of returned variables
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#invalid_user", $defined['error'], $errors['auth_n'], NULL, NULL );
    break;
   case 5:
    // a problem was found when updating user table with private key and other
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#invalid_user_update", $defined['error'], $errors['db_edit_err'], NULL, NULL );
    break;
   case 6:
    // a problem occured when attempting to create an authenticated session token
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#invalid_token_create", $defined['error'], $errors['sess_tok_cr'], NULL, NULL );
    break;
   case 7:
    // unable to decode authentication token (invalid session token, possible csrf, session
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#invalid_token_create", $defined['error'], $errors['sess_tok_empty'], NULL, NULL );
    break;
   case 8:
    // a problem occured when querying username from database during re-authentication
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#invalid_token_decode", $defined['error'], $errors['sess_tok_dc'], NULL, NULL );
    break;
   case 9:
    // no valid user found with decoded username from authenticated session token
    // possible session spoof or session hijack attempt
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#invalid_user", $defined['error'], $errors['db_search_err'], NULL, NULL );
    break;
   case 10:
    // decoded public key does not match md5 hash of private key registered during primary
    // authentication process (csrf, session fixation attack)
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#token_inv_user", $defined['error'], $errors['sess_tok_un'], NULL, NULL );
    break;
   case 11:
    // the ip, browser agent or referring address does not match initial data (csrf, session fixation attack)
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#token_inv_pub_priv", $defined['error'], $errors['sess_tok_pub'], NULL, NULL );
    break;
   case 12:
    // timestamp is greater then defined timeout (user has exceeded session time requirements)
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#token_inv_chks", $defined['error'], $errors['sess_tok_3'], NULL, NULL );
    break;
   case 13:
    // an error occured when using decoded user credentials to reauthenticate the user
    unset( $_SESSION['token'] );
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#timeout", $defined['error'], $errors['auth_to'], NULL, NULL );
    break;
   case 14:
    // no valid user found with decoded token credentials (possible csrf, session fixation attack)
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#token_inv_token", $defined['error'], $errors['sess_tok_readb'], NULL, NULL );
    break;
   case 15:
    // no valid user found with decoded token credentials (possible csrf, session fixation attack)
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#token_inv_user", $defined['error'], $errors['sess_tok_rea'], NULL, NULL );
    break;
   default:
    // give the user a login page
    $ERROR = $this->GenerateErrorLink( "help/help.html", "#default_login", $defined['good'], "Welcome to the phpMyAuth SSO application, please log in...", NULL, NULL );
    break;
   }
 		return $ERROR;
 	}

}

?>
Return current item: phpMyOrdering