2); $db =& DB::connect($dsn,$options); $db->setFetchMode(DB_FETCHMODE_ASSOC); if (DB::isError($db)) { /* * This is not what you would really want to do in * your program. It merely demonstrates what kinds * of data you can get back from error objects. */ echo 'Standard Message: ' . $db->getMessage() . "\n"; echo 'DBMS/User Message: ' . $db->getUserInfo() . "\n"; echo 'DBMS/Debug Message: ' . $db->getDebugInfo() . "\n"; exit; } define("MAXSEARCH",0); define("MAXPERPAGE",15); $time=date('Y-m-d H:i:s'); session_start(); #this section un-uncommented - Russell /* print_r($_POST); $SESS=$_POST["SESS"]; $host=$_POST["host"]; $port=$_POST["port"]; $URL=$_POST["URL"]; //$mode=$_POST["mode"]; $username=$_POST["username"]; $password=$_POST["password"]; */ while(list($k,$v)=each($_POST)){ $$k=$v; } while(list($k,$v)=each($_GET)){ $$k=$v; } while(list($k,$v)=each($_SERVER)){ $$k=$v; } #if ($SESS) # if ($SESS <> session_id() ) { # loginpage(''); # die(); #} if (!isset($_SESSION['sessionid'])) { $_SESSION['sessionid']=session_id(); } include "/usr2/sluldap/sluldap.inc"; if (!$mode == "authorizeguest") { #if (!preg_match("/147.174.92/",$REMOTE_ADDR)) { # echo "You are not on the Public Network"; # die(); # } if (checkip_debug($REMOTE_ADDR)) { echo "$REMOTE_ADDR already registered for Public Access"; die(); } $registered=check_registered(getmac($REMOTE_ADDR)); if ($registered == 1) // Card Registered and Access ok $mode='registered'; if ($registered == 2) // Card Registered but access = false $mode='noaccess'; #if ($registered == 1) { # if (checkip($REMOTE_ADDR)) { # echo "$REMOTE_ADDR already registered for Public Access"; # die(); # } # } } if ($port == 80) $redirect="http://$host$URL"; else if ($port == 443) $redirect="https://$host$URL"; else $redirect="http://$host:$port$URL"; if (!$host) $redirect="http://www2.selu.edu"; $redirect=urldecode($URL); switch ($mode) { case 'registered': if (check_guest(getmac($REMOTE_ADDR))) allowip_guest($REMOTE_ADDR); else if (!checkip($REMOTE_ADDR)) { if (check_facstaff(getmac($REMOTE_ADDR))) { allowip_facstaff($REMOTE_ADDR); } else { allowip($REMOTE_ADDR); } } redirect($redirect); die(); case 'noaccess': echo "Could not grant wireless access. Please call Computing Services at x5555.

sluwirelessaccess is N."; die(); case 'auth': //echo "Checking Login info for $username

"; if (!checklogin($username,$password)) { $userinfo=get_user_info($username); if (wirelessaccess($userinfo)) { if (wirelesscards($userinfo) < 4) { //only allow 4 macs //if (wirelesscards($userinfo)) //removemac(wirelesscard($userinfo)); // remove old card form firewall syslog(LOG_WARNING, "wireless: calling setwirelesscard dn: $dn, mac: $mac, result: $result"); setwirelesscard(get_dn_only($username),$password,getmac($REMOTE_ADDR)); if (!checkip($REMOTE_ADDR)) { if (check_facstaff(getmac($REMOTE_ADDR))) { allowip_facstaff($REMOTE_ADDR); } else { allowip($REMOTE_ADDR); } } registeredpage($redirect); } else { //if they have more than one card registered Contact computing services echo "You have exceeded the number of wireless devices allowed on your account. In order to register another, please contact Computing Services at x 5555."; die(); } } else { echo "Could not grant wireless access. Please call Computing Services at x5555. Error Code 69"; die(); } } else loginpage('Login Failed'); die(); break; case 'guest': guest_info(""); break; case 'authorizeguest': authorizeguest($idkey); break; default: loginpage(''); break; } function allowip($ip) { #$connection = fsockopen('147.174.1.66', 169, &$errno, &$errstr, 1); $connection = fsockopen('147.174.1.66', 169, $errno, $errstr, 1); $res=fgets($connection,256); if (substr($res,0,3) != "100") { echo "Error connecting"; } fputs($connection, "allowip $ip\r\n"); $status=fgets($connection,256); } function allowip_facstaff($ip) { #$connection = fsockopen('147.174.1.66', 169, &$errno, &$errstr, 1); $connection = fsockopen('147.174.1.66', 169, $errno, $errstr, 1); $res=fgets($connection,256); if (substr($res,0,3) != "100") { echo "Error connecting"; } fputs($connection, "allowipfacstaff $ip\r\n"); $status=fgets($connection,256); } function allowip_guest($ip) { #$connection = fsockopen('147.174.1.66', 169, &$errno, &$errstr, 1); $connection = fsockopen('147.174.1.66', 169, $errno, $errstr, 1); $res=fgets($connection,256); if (substr($res,0,3) != "100") { echo "Error connecting"; } fputs($connection, "allowipguest $ip\r\n"); $status=fgets($connection,256); } function checkip($ip) { #$connection = fsockopen('147.174.1.66', 169, &$errno, &$errstr, 1); $connection = fsockopen('147.174.1.66', 169, $errno, $errstr, 1); $res=fgets($connection,256); if (substr($res,0,3) != "100") { echo "Error connecting"; } fputs($connection, "checkip $ip\r\n"); $status=fgets($connection,256); if (strstr($status,'Enabled')) return 1; else return 0; } function checkip_debug($ip) { # added 2/17/2011 to see why people keep getting 'already registered' message --ray #$connection = fsockopen('147.174.1.66', 169, &$errno, &$errstr, 1); $connection = fsockopen('147.174.1.66', 169, $errno, $errstr, 1); $res=fgets($connection,256); if (substr($res,0,3) != "100") { echo "Error connecting"; } fputs($connection, "checkip_debug $ip\r\n"); $status=fgets($connection,256); if (strstr($status,'Enabled')) return 1; else return 0; } function getmac($ip) { #$connection = fsockopen('147.174.1.66', 169, &$errno, &$errstr, 1); $connection = fsockopen('147.174.1.66', 169, $errno, $errstr, 1); $res=fgets($connection,256); if (substr($res,0,3) != "100") { echo "Error connecting"; } fputs($connection, "getmac $ip\r\n"); $result=fgets($connection,256); $elements = explode (" ",$result); $mac=$elements[1]; $mac=preg_replace("/:/","",$mac); $mac=substr($mac,0,6)."-".substr($mac,6,6); return $mac; } function removemac($mac) { $mac=preg_replace("/-/","",strtoupper($mac)); for ($i=0;$i<12;$i+=2){ $newmac .= substr($mac,$i,2); if ($i < 10) $newmac.=":"; } $mac=$newmac; #$connection = fsockopen('147.174.1.66', 169, &$errno, &$errstr, 1); $connection = fsockopen('147.174.1.66', 169, $errno, $errstr, 1); $res=fgets($connection,256); if (substr($res,0,3) != "100") { echo "Error connecting"; } fputs($connection, "removemac $mac\r\n"); $result=fgets($connection,256); } function check_registered($mac) { $lowmac=strtolower($mac); $foundlowmac=search("(sluwirelesscard=$lowmac)"); if ($foundlowmac["count"]) $result=search("(sluwirelesscard=$lowmac)"); else $result=search("(sluwirelesscard=$mac)"); print ($result[0]["sluwirelessaccess"][0]); if ($result["count"]) { // if card was found if ((strtolower($result[0]["sluwirelessaccess"][0]) == "true") || (strtolower($result[0]["sluwirelessaccess"][0]) == "y")) return 1; else return 2; } else return 0; } function check_guest($mac) { $result=search("(&(uid=802.11-guest)(sluwirelesscard=$mac))"); if ($result["count"]) { // if card was found if ((strtolower($result[0]["sluwirelessaccess"][0]) == "true") || (strtolower($result[0]["sluwirelessaccess"][0]) == "y")) return 1; else return 2; } else return 0; } function check_facstaff($mac) { $result=search("sluwirelesscard=$mac"); if ($result["count"]) { // if card was found if (is_faculty($result) || is_staff($result)) return 1; } else return 0; } function registeredpage($redirect) { ?>

Your network card is now registered.

You now have access to the Southeastern Public Network.

You will be redirected to in 10 seconds. Southeastern Public Network Login

 

 

 

addElement('hidden','mode','auth'); $form->addElement('hidden','SESS',$_SESSION['sessionid']); $form->addElement('hidden','host',$host); $form->addElement('hidden','port',$port); $form->addElement('hidden','URL',$URL); $form->addElement('header','header','Southeastern Public Network Login'); $form->addElement('static','','',"$status "); $form->addElement('text','username','Username:'); $form->addElement('password','password','Password:'); $form->addElement('submit','submit','Login'); $form->display(); ?>

Guest access
 
'; $_POST['facstaff']['email']=preg_replace('/\@selu\.edu/','',$_POST['facstaff']['email']); $form= new HTML_QuickForm('guestform','post',null,null,array('onSubmit'=>'doit();')); $form->addElement('hidden','mode','guest'); $form->addElement('hidden','SESS',$_SESSION['sessionid']); $form->addElement('hidden','host',$host); $form->addElement('hidden','port',$port); $form->addElement('hidden','URL',$URL); $form->addElement('hidden','lookup',''); $form->addElement('hidden','pageID',''); $form->addElement('header','header','Southeastern Public Network Guest Access Request'); $form->addElement('text','guestname','Name:'); $form->addElement('text','company','Company:'); $form->addElement('text','email','Your email:'); $t[]= &HTML_QuickForm::createElement('text','email',"Faculty/Staff email:"); $t[]= &HTML_QuickForm::createElement('static','suffix','suffix','@selu.edu '); # $t[]= &HTML_QuickForm::createElement('submit','lookup','Search',array('onClick'=>'document.guestform.lookup.value=1;')); $t[]= &HTML_QuickForm::createElement('link',null,null,'javascript:lookup();','Lookup Address'); $form->addGroup($t,'facstaff','Faculty/Staff email:',''); $form->addRule('guestname','Your name is required.','required','','server'); $form->addRule('email','Your email address is required','required','','server'); $form->addRule('email','Please enter valid email address.','email','','server'); // check if user clicked Lookup and if Name and Email address are entered if ($form->getElementValue('lookup') && $form->validate()) { $form->addElement('header','header',"Faculty/Staff Email Search:"); $form->addElement('text','searchfirstname','First Name:'); $form->addElement('text','searchlastname','Last Name:'); $form->addElement('submit','submit','Submit'); echo $body; $form->display(); $test=facstaffemail_lookup($searchfirstname,$searchlastname,$form->getElementValue('pageID')); echo $test['links']['all']; echo $test['table']; } else { // if not lookup, verify fac/staff email address if(!$form->getElementValue('lookup')) { $form->addGroupRule('facstaff',array( 'email'=>array( array('Email address required','required'), array('Invalid address','callback','validate_facstaffemail') ))); } // facstaff is required if not using lookup $form->addRule('facstaff',null,'required','server'); $form->addElement('submit','submit','Submit'); if ($form->validate()) { // $form->freeze(); $form->process('guest_register'); // $form->display(); } else { echo $body; $form->display(); } } ?>
"(&(sluemailflag=Y)(|(edupersonaffiliation=STAFF)(edupersonaffiliation=FACUTLY)))", "first" => $firstname, "last" => $lastname,); if ((strcmp($_SESSION['search_firstname'],$firstname)) || (strcmp($_SESSION['search_lastname'],$lastname))) { $_SESSION['searchresult']=do_email_search($srch); $_SESSION['search_firstname']=$firstname; $_SESSION['search_lastname']=$lastname; $_GET['pageID']=1; } else { $_GET['pageID']=$pageID; } $_SESSION['emailsearch_perpage']=15; return emailsearch_table($_SESSION['searchresult']); } function guest_register($data) { $REMOTE_ADDR = $_SERVER["REMOTE_ADDR"]; $PHP_SELF = $_SERVER["PHP_SELF"]; $host = $_POST["host"]; $URL= $_POST["URL"]; $port = $_POST["port"]; $guestname = $_POST["guestname"]; $company = $_POST["company"]; $authemail = $_POST["authemail"]; $email = $_POST["email"]; $time = $_POST["time"]; $db = $_POST["db"]; global $REMOTE_ADDR,$PHP_SELF,$host,$URL,$port,$guestname,$company,$authemail,$email,$time,$db; $mac=getmac($REMOTE_ADDR); $idkey=md5("$time$mac"); $access=array('name'=>$data['guestname'], 'macaddr'=>$mac, 'authorizor'=>email_to_cn($data['facstaff']['email']), 'company'=>$data['company'], 'email'=>$data['email'], 'idkey'=>$idkey, 'request_datetime'=>$time); #print_r($access); $db->autoExecute('access',$access,DB_AUTOQUERY_INSERT); $row = $db->getRow("select * from access where macaddr='$mac' and request_datetime='$time'"); $id=$row['id']; #print_r($row); email_authorization($id); setcookie(session_name(),'',time() - 36000,"/"); session_unset(); session_destroy(); ?>

  Your request for wireless internet access has been sent. getRow("select * from access where id=$id"); $authemail=$row['authorizor']; $email=$row['email']; $name=$row['name']; $company=$row['company']; $requestdatetime=$row['request_datetime']; $idkey=$row['idkey']; /* To send HTML mail, you can set the Content-type header. */ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=us-ascii;\r\n"; /* additional headers */ $headers .= "To: $authemail@selu.edu\r\n"; $headers .= "From: $email\r\n"; $to=$authemail."@selu.edu"; $subject="Guest Wireless Access Request"; $message="The following person has requested access to Southeastern's Public Network.\r\n\r\n"; $message.="Name: $name\r\n"; $message.="Company: $company\r\n"; $message.="Email: $email\r\n"; $message.="Request Submited: $requestdatetime\r\n"; $message.="\r\n\r\n Click the following link to Authorize this person for Wireless Internet access.\r\n"; $message.="https://www2.selu.edu/wireless/login.php?mode=authorizeguest&idkey=$idkey\r\n"; #echo "

";
#print_r($headers);
#print_r($message);
#print_r($to);
mail ($to,$subject,$message,$headers);

}

function authorizeguest($idkey) {

 $time = $_POST["time"];
 $db = $_POST["db"];
 
 global $db,$time;

 $row=$db->getRow("select * from access where idkey='$idkey'");

 if(!$row['idkey']==$idkey) {
    echo "There was an error processing your request.";
    die();
 }

 if ($row['approved_datetime']) {
   echo 	"This request is already approved!";
        die(); 
  }
 
  addguestwirelesscard($row['macaddr']);  
  
  $updaterow['approved_datetime']=$time;
  $updaterow['expire_datetime']=date('Y-m-d H:i:s',time()+259200);  //3 days..
  $db->autoExecute('access',$updaterow,DB_AUTOQUERY_UPDATE,"idkey = '$idkey'");

  echo "User will have 3 days of wireless internet access.";
  





}


?>