Location: PHPKode > projects > phpMyPrepaid > phpmyprepaid/www/include/ap/modify_ap.php
<?php
				
if(!isset($_SESSION['locID'])){ $error="Location is not set."; $count=$count+1;}
else
$ap=$oreon->database->getapconfiguration($_SESSION['locID']);	
$locationName=get_location_name($_SESSION['locID']);

if (isset($_POST['formsubmit']))
	{

//		if(!isset($_POST['location'])){ $error="Location not set<br>"; $count=$count+1;}
//		if($_POST['location'] == ""){ $error="$error Location not Filled in<br>"; $count=$count+1;}
		if(!isset($_POST['dnsname'])){ $error="DNS name not set.<br>"; $count=$count+1;}
		if($_POST['dnsname'] == ""){ $error="$error DNS name not filled in<br>"; $count=$count+1;}
		
		if(!isset($_POST['ipaddress'])){ $error="$error IP address not set.<br>"; $count=$count+1;}
		if($_POST['ipaddress'] == ""){ $error="$error IP Address not Filled in<br>"; $count=$count+1;}
	if($ap['req_userpass']==1){	
		if(!isset($_POST['user'])){ $error="$error UserName not set.<br>"; $count=$count+1;}
		if($_POST['user'] == ""){ $error="$error UserName not filled in<br>"; $count=$count+1;}
	
		if(!isset($_POST['pass'])){ $error="$error Password not set.<br>"; $count=$count+1;}
		if($_POST['pass'] == ""){ $error="$error Password not filled in<br>"; $count=$count+1;}
	}
	if($ap['req_snmp']==1){
		if(!isset($_POST['comunity'])){ $error="$error Community not set.<br>"; $count=$count+1;}
		if($_POST['comunity'] == ""){ $error="$error Community not filled in<br>"; $count=$count+1;}
		
		if(!isset($_POST['version'])){ $error="$error Version not set.<br>"; $count=$count+1;}
		if($_POST['version'] == ""){ $error="$error Version not filled in<br>"; $count=$count+1;}
		
	//	if(!isset($_POST['mib'])){ $error="$error MIB not set.<br>"; $count=$count+1;}
	//	if($_POST['mib'] == ""){ $error="$error MIB not filled in<br>"; $count=$count+1;}
	}	
				
				

	// check to make sure the location name does not have ilegal chars
	// NO SPACES as this will be a table name!!!
	// $LocID=($_POST['location']);
	// getLoc($LocID);
	$mib_len=strlen($_POST['mib']);
	$dnsname = $_POST['dnsname'];
	$ipaddress = $_POST['ipaddress'];
	$apid = $_POST['APID'];
	if(isset($_POST['user'])) { $user = $_POST['user']; }else{ $user=NULL;} 
	if(isset($_POST['pass'])) { $pass = $_POST['pass']; }else{ $pass=NULL;}
	if(isset($_POST['version'])) { $version = $_POST['version']; }else{ $version=NULL;}
	if(isset($_POST['comunity'])) { $comunity = $_POST['comunity']; }else{ $comunity=NULL;}
	if((isset($_POST['mib']))&& ($mib_len>=1)) { $mib = $_POST['mib']; 
	}elseif(isset($_POST['mib2'])) { $mib = $_POST['mib2']; 
	}else{	$mib=NULL;}
	$locID = $_SESSION['locID'];
        $mib_len=strlen($_POST['mib']);
	$dnsname = $_POST['dnsname'];
	$ipaddress = $_POST['ipaddress'];
	$secret = $_POST['secret'];
	$port = $_POST['port'];
	$description = $_POST['description'];
	$nastype = $_POST['nastype'];
	$nasid = $_POST['nasid'];
	$macaddress = $_POST['macaddress'];
	$latitude = $_POST['longitude'];
	$longitude = $_POST['latitude'];
	//$query="select LocationName from locations where LocationName = '$location'";
	//$numresults=$oreon->database->database->query($query);
	//$numrows=$oreon->database->database->result_num_rows($numresults);
	//if($numrows > 0){ $error="$error.This Location already exists<br>";}
	if(!isset($error)){
		//MODIFY AP TABLE
		$locID = $_SESSION['locID'];
		$query = "UPDATE AP SET dnsname='$dnsname', ipaddress='$ipaddress',macaddress='$macaddress',user='$user', pass='$pass', comunity='$comunity', version='$version', mib='$mib',latitude='$latitude',longitude='$longitude' WHERE ID='$apid' ";
	        $oreon->database->database->query ($query) or die("Query database error !");
		
		//MODIFY NAS TABLE
		$query = "UPDATE nas SET shortname='$dnsname', nasname='$ipaddress',type='$nastype',ports='$port',secret='$secret', community='$comunity', description='$description' WHERE ID='$nasid' ";
		$oreon->database->database->query ($query) or die("Query database error !");

		echo '<b><p class="information">NAS '.$dnsname.' successfully modified.</p><br><br>';
		}
	if(isset($error)){
		if($count>1){
			$msg="$count errors were encountered while processing the form.";
			$tailmsg="Please fix the above errors and resubmit.";}
		if($count==1){
			$msg="An error was encountered while processing the form.";
			$tailmsg="Please fix the above error and resubmit.";}
		echo("<p class=\"error\">$msg<br>$error $tailmsg</p>");
		include('include/ap/modify_ap_form.php');}
		
	}
	if($buttonID=="mod_ap"){
		if (!isset($_POST['formsubmit'])){
   		include('include/ap/modify_ap_form.php'); 
		}
	}else{
		echo "<hr><table border=\"0\" width=100%><tr><td  style=\"width: 400px;\">";
		printf('<form action="phpmyprepaid.php" method="post">');
		echo('<input type="hidden" name="buttonID" value="open_addAP">');
		echo("<input type=\"submit\" class=\"smallButton\" name=\"submit\" value=\"Add NAS\">");
		printf('</form></td><td style="text-align: right;">');
		printf('<form action="phpmyprepaid.php" method="post">');
		echo('<input type="hidden" name="buttonID" value="mod_loc">');
		echo("<input type=\"hidden\" name=\"location_name\" value=$locationName>");
		echo("<input type=\"submit\" class=\"smallButton\" name=\"submit\" value=\"Modify location\">");
		printf('</form></td><td style="text-align: right;">');
		echo '<script type="text/javascript">  
			function confirmDelete() { 
	        if(confirm("Are you sure, you want to delete this nas ?" )) document.location.href = phpmyprepaid.php;
	          return false; //pour ne pas revenir au début de la page
          	}  
	</script>  
	<form action="phpmyprepaid.php" method="post" onsubmit="return confirmDelete();">';  
	echo('<input type="hidden" name="buttonID" value="del_loc">');
	echo("<input type=\"hidden\" name=\"location_name\" value=\"$locationName\">");
	echo("<input type=\"submit\" class=\"smallButton\" name=\"submit\" value=\"Delete location\">");
	printf('</form></td></tr></table>');
	}
 
?>
Return current item: phpMyPrepaid