Location: PHPKode > projects > Skat Statistics > skatstat-1.7.1/skatstat/inc/authentication.php
<?
require_once("smfunc.php");
require_once( "smconfig.php" );

function check_auth()
{
//try 
//{
//  $cookie = new Cookie();
//  $cookie->validate();
//}
//catch( AuthException $e )
//{
  global $SKAT_SESSION;
  ss_session_read();
  if( ! isset( $SKAT_SESSION[userid] ) )
  {
    ss_session_destroy();
    header("Location: ".BASEHREF."/login.php?originating_uri=".$_SERVER['REQUEST_URI']);
    exit;
  }
  ss_session_write();
//}
}

# #$ret = $cookie->validate();
# #if( !$ret )
# if( !isset($_SESSION['UserId']) OR !isset($_SESSION['GroupId']) )
# {
#   $_SESSION = array();
#   session_destroy();
#   # }
#   # catch( AuthException $e ) {
#   if( !headers_sent( $fn, $ln ) )
#   {
#     header("Location: ".BASEHREF."/login.php?originating_uri=".$_SERVER['REQUEST_URI']);
#     exit;
#   }
#   else
#   {
#     echo "Header sent already<br>";
#     echo "Filename: $fn, Linenumber: $ln<br> ";
#     echo "<a href=".BASEHREF."/login>Go to the login page</a>";
#   }
#  }
#  }
#}

class Authentication
{
  function check_credentials( $uid, $pwd )
  {
    global $CONF;
    $sql = "SELECT t1.id, t1.uid, t1.GroupId, t2.name, t1.type FROM ".$CONF['tbl_user']." AS t1, ".$CONF['tbl_grp']." as t2 WHERE t1.GroupId=t2.Id AND t1.uid='$uid' AND t1.pwd='$pwd' ";
    $sqlExec = processSQL( $sql );
    if( $re = mysql_fetch_array( $sqlExec ) )
    {
      if( 1 == $re['type'] )
      {
        $admin =  1;
      }
      else
      {
        $admin =  0;
      }
      # UserID, UserName, GroupId, GroupName, AdminMode
      $return = array( $re[0], $re[1], $re[2], $re[3], $admin);
    }
    else
    {
//      throw new AuthException( "Benutzer ist nicht authorisiert!" );
      $return = 0;
    }
    return $return;
  }
}

Return current item: Skat Statistics