<?php

include_once('CAS.php');





phpCAS::setDebug();



// initialize phpCAS

phpCAS::client(SAML_VERSION_1_1,'login.tamucc.edu',443,'cas');

// no SSL validation for the CAS server

phpCAS::setNoCasServerValidation();



// force CAS authentication

phpCAS::forceAuthentication();



// at this step, the user has been authenticated by the CAS server

// and the user's login name can be read with phpCAS::getUser().

?>



<html>

  <head>

    <title>phpCAS simple client</title>

  </head>

  <body>

       

<?php

session_start
();



if(
$_SERVER['HTTPS'] == 'on')

{

$username=phpcas::getUser();



$i=0;





    foreach (
phpCAS::getAttributes() as $key => $value) {

        if (
is_array($value)) {

                foreach(
$value as $item) {

                       
$pieces explode('='$item);

                 
$nxtpiece explode(','$pieces[1]);

                 
$Data_array[$i]=$nxtpiece[0];

                
$i++;

            }

                

          } 

            else {

                
//echo '<li>', $key, ': <strong>', $value, '</strong></li>';

               
}

    }

$_SESSION['USERNAME'] = $username;

         

         }

                                         

if (isset(
$_REQUEST['logout'])) {

        
phpCAS::logout();

}



echo 
'<p><a href="?logout=">CAS Logout</a></p>';



}





?>

  </body>

</html>