check_Radius_Account.php

阅读更多

			
			
			';

			$URL = "http://".$cap_ip.":80/xmlrq";

			$headers = array();
			array_push($headers, "Content-Type: text/xml");
			array_push($headers, "Accept: text/xml");
				$ch = curl_init($URL);
				curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
				curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
				curl_setopt($ch, CURLOPT_POSTFIELDS, $login_xml_data);
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
				$login_output = curl_exec($ch);
				curl_close($ch);

			$login_xml = simplexml_load_string($login_output);
			if(strpos($login_xml->reason, 'XML messaging protocol mismatch.') === false){
				$proto = '4.0';
			}else{
				$proto = '3.0';
			}
//				echo $cap_ip . "|";
//				echo $proto . "
"; /////////Test login attempt//////// /////////Login with correct protocol//////// $login_xml_data =' '; $URL = "http://".$cap_ip.":80/xmlrq"; $headers = array(); array_push($headers, "Content-Type: text/xml"); array_push($headers, "Accept: text/xml"); $ch = curl_init($URL); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $login_xml_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $login_output = curl_exec($ch); curl_close($ch); $login_xml2 = simplexml_load_string($login_output); $session_id = $login_xml2->session['sid']; $xml_sid = $login_xml2->session['sid']; $manager_id=$login_xml2->session['manager-id']; //echo "
"; //print_r($login_xml2); //echo "
"; // echo $manager_id . "\n"; // echo "----------\n"; //////////////////////////////////*End of login*////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////// $update_xml_config_data = ' '; $headers = array(); array_push($headers, "Content-Type: text/xml"); array_push($headers, "Accept: text/xml"); $ch = curl_init($URL); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $update_xml_config_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $config_output = curl_exec($ch); curl_close($ch); $get_xml_config = simplexml_load_string($config_output); if ($get_xml_config->reason != ''){ echo "" . $cap_ip . " Failed " . $date . "\n"; $insert_offline=pg_query($con2, "INSERT INTO lb_failed_login (cap_ip, proto, account, checked) VALUES ('$cap_ip', '$proto', 'radius', '0')"); mail('[email protected]', 'CAP Admin account failed', "\n\r" . $cap_ip . "\nRadius login failed. Proto = " .$proto , null, '[email protected]'); }else{ echo $cap_ip . " Passed " . $date . "\n"; } ////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////*Beginning of logout*/////////////////////////// $logout_xml_data =' '; // print $logout_xml_data; $URL = "http://".$cap_ip.":80/xmlrq"; $headers = array(); array_push($headers, "Content-Type: text/xml"); array_push($headers, "Accept: text/xml"); $ch = curl_init($URL); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $logout_xml_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $logout_output = curl_exec($ch); curl_close($ch); /*End of logout*/ } } ?>

你可能感兴趣的:(php)