",$_REQUEST['WifiTargetBssidMac']))))); } if(isset($_REQUEST['WifiSsid'])){ $json['WifiSsid'] = str_replace("&","&",str_replace(""",'"',str_replace("'","'",str_replace("<","<",str_replace(">",">",$_REQUEST['WifiSsid']))))); } if(isset($_REQUEST['WifiPassword'])){ $json['WifiPassword'] = str_replace("&","&",str_replace(""",'"',str_replace("'","'",str_replace("<","<",str_replace(">",">",$_REQUEST['WifiPassword']))))); } if(isset($_REQUEST['WifiDhcpServer'])){ $json['WifiDhcpServer'] = $_REQUEST['WifiDhcpServer']; } if(isset($_REQUEST['WifiDhcpClient'])){ $json['WifiDhcpClient'] = $_REQUEST['WifiDhcpClient']; } if(isset($_REQUEST['WifiIpAddress'])){ $json['WifiIpAddress'] = $_REQUEST['WifiIpAddress']; } if(isset($_REQUEST['WifiSubmaskAddress'])){ $json['WifiSubmaskAddress'] = $_REQUEST['WifiSubmaskAddress']; } if(isset($_REQUEST['WifiGatewayAddress'])){ $json['WifiGatewayAddress'] = $_REQUEST['WifiGatewayAddress']; } if(isset($_REQUEST['TelcomApn'])){ $json['TelcomApn'] = str_replace("&","&",str_replace(""",'"',str_replace("'","'",str_replace("<","<",str_replace(">",">",$_REQUEST['TelcomApn']))))); } if(isset($_REQUEST['TelcomChapPapId'])){ $json['TelcomChapPapId'] = str_replace("&","&",str_replace(""",'"',str_replace("'","'",str_replace("<","<",str_replace(">",">",$_REQUEST['TelcomChapPapId']))))); } if(isset($_REQUEST['TelcomChapPapPwd'])){ $json['TelcomChapPapPwd'] = str_replace("&","&",str_replace(""",'"',str_replace("'","'",str_replace("<","<",str_replace(">",">",$_REQUEST['TelcomChapPapPwd']))))); } if(isset($_REQUEST['TelcomIpAddress'])){ $json['TelcomIpAddress'] = $_REQUEST['TelcomIpAddress']; } if(isset($_REQUEST['TelcomEnabled'])){ $json['TelcomEnabled'] = $_REQUEST['TelcomEnabled']; } if(isset($_REQUEST['TelcomNetworkType'])){ $json['TelcomNetworkType'] = $_REQUEST['TelcomNetworkType']; } if(isset($_REQUEST['isEnalbleFirewall'])){ $json['isEnalbleFirewall'] = $_REQUEST['isEnalbleFirewall']; } if(isset($_REQUEST['FirewallAcceptAddr0'])){ checkip2("FirewallAcceptAddr0"); $json['FirewallAcceptAddr0'] = $_REQUEST['FirewallAcceptAddr0']; } if(isset($_REQUEST['FirewallAcceptAddr1'])){ checkip2("FirewallAcceptAddr1"); $json['FirewallAcceptAddr1'] = $_REQUEST['FirewallAcceptAddr1']; } if(isset($_REQUEST['FirewallAcceptAddr2'])){ checkip2("FirewallAcceptAddr2"); $json['FirewallAcceptAddr2'] = $_REQUEST['FirewallAcceptAddr2']; } if(isset($_REQUEST['FirewallAcceptAddr3'])){ checkip2("FirewallAcceptAddr3"); $json['FirewallAcceptAddr3'] = $_REQUEST['FirewallAcceptAddr3']; } if(isset($_REQUEST['FirewallAcceptAddr4'])){ checkip2("FirewallAcceptAddr4"); $json['FirewallAcceptAddr4'] = $_REQUEST['FirewallAcceptAddr4']; } if(isset($_REQUEST['FirewallAcceptAddr5'])){ checkip2("FirewallAcceptAddr5"); $json['FirewallAcceptAddr5'] = $_REQUEST['FirewallAcceptAddr5']; } if(isset($_REQUEST['FirewallAcceptAddr6'])){ checkip2("FirewallAcceptAddr6"); $json['FirewallAcceptAddr6'] = $_REQUEST['FirewallAcceptAddr6']; } if(isset($_REQUEST['FirewallAcceptAddr7'])){ checkip2("FirewallAcceptAddr7"); $json['FirewallAcceptAddr7'] = $_REQUEST['FirewallAcceptAddr7']; } if(isset($_REQUEST['FirewallAcceptAddr8'])){ checkip2("FirewallAcceptAddr8"); $json['FirewallAcceptAddr8'] = $_REQUEST['FirewallAcceptAddr8']; } if(isset($_REQUEST['FirewallAcceptAddr9'])){ checkip2("FirewallAcceptAddr9"); $json['FirewallAcceptAddr9'] = $_REQUEST['FirewallAcceptAddr9']; } // ob_start(); shell_exec('sync;sync;sync'); chdir("/root"); $str_json=json_encode($json); exec("'./WebService' '3' '".$str_json."'",$output,$return_var); if(count($output)!=0){ $jsone['result'] = "Success"; $jsone['message'] = $json; echo json_encode($jsone); exit; } else{ // $jsone['result'] = "Error"; $jsone['result'] = $str_json; $jsone['message'] = "Something went wrong on machine"; echo json_encode($jsone); return false; exit; } // ob_end_clean(); } function checkip($id){ $ip=$_REQUEST[$id]; if($_REQUEST[$id] != ""){ if(ip2long($ip)){ } else{ $jsone['result'] = "Fail"; $jsone['message'] = "You have entered an invalid IP address on " . $id; echo json_encode($jsone); exit; } } } function checkip2($id){ $ip=$_REQUEST[$id]; if($_REQUEST[$id] != ""){ if(ip2long($ip)){ } else if(preg_match('/^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/', $ip)){ } else{ $jsone['result'] = "Fail"; $jsone['message'] = "You have entered an invalid IP address or domain name on " . $id; echo json_encode($jsone); exit; } } } function checkValue($id){ if($_REQUEST[$id] != ""){ if(strlen($_REQUEST[$id])!=1){ $jsone['result'] = "Fail"; $jsone['message'] = "You have entered a wrong value on " . $id . ", it should be numeric"; echo json_encode($jsone); exit; } if(!is_numeric($_REQUEST[$id])){ $jsone['result'] = "Fail"; $jsone['message'] = "You have entered a wrong value on " . $id . ", it should be numeric"; echo json_encode($jsone); exit; } } } function WifiMode_changed(){ if($_REQUEST['WifiMode']=="0"){ // $_REQUEST['WifiDhcpServer']=1; // $_REQUEST['WifiDhcpClient']=1; $_REQUEST['WifiSsid']=""; $_REQUEST['WifiPassword']=""; } if($_REQUEST['WifiMode']=="1"){ // $_REQUEST['WifiDhcpServer']=1; // $_REQUEST['WifiDhcpClient']=0; } if($_REQUEST['WifiMode']=="2"){ // $_REQUEST['WifiDhcpServer']=0; // $_REQUEST['WifiDhcpClient']=1; $_REQUEST['WifiSsid']=""; $_REQUEST['WifiPassword']=""; } } ?>