<?php
/**
 * Processing Forget password form data:
 * check data then generate new password and send it through SMPT Email
 *
 * PHP version 7.3
 *
 * @package        SMS
 * @version        Release 1.0.0
 * @create_by      Mohammad aljaouni
 * @create_date    10-08-2020
 * @edited_by      Mohammad aljaouni
 * @last_edit_date 10-08-2020
 * @todo           Nothing
 */
ob_start();
session_start();

$ConnectionName = $Host = $Port = $UserName = $Password = $AddressTON = $AddressNPI = $SystemType = $SubmitMode = $SrcTON = $SrcNPI = $DestTON = $DestNPI = $DataCoding = $SubmitCount = $SubmitCountPend = $EnquireInterval = $AutoReconnect = $SaveLogFile = 0;
if(isset($_POST["ConnectionName"]))
	$ConnectionName = $_POST["ConnectionName"];
if(isset($_POST["Host"]))
	$Host = $_POST["Host"];
if(isset($_POST["Port"]))
	$Port = $_POST["Port"];
if(isset($_POST["UserName"]))
	$UserName = $_POST["UserName"];
if(isset($_POST["Password"]))
	$Password = $_POST["Password"];
if(isset($_POST["AddressTON"]))
	$AddressTON = $_POST["AddressTON"];
if(isset($_POST["AddressNPI"]))
	$AddressNPI = $_POST["AddressNPI"];
if(isset($_POST["SystemType"]))
	$SystemType = $_POST["SystemType"];
if(isset($_POST["SubmitMode"]))
	$SubmitMode = $_POST["SubmitMode"];
if(isset($_POST["SrcTON"]))
	$SrcTON = $_POST["SrcTON"];
if(isset($_POST["SrcNPI"]))
	$SrcNPI = $_POST["SrcNPI"];
if(isset($_POST["DestTON"]))
	$DestTON = $_POST["DestTON"];
if(isset($_POST["DestNPI"]))
	$DestNPI = $_POST["DestNPI"];
if(isset($_POST["DataCoding"]))
	$DataCoding = $_POST["DataCoding"];
if(isset($_POST["SubmitCount"]))
	$SubmitCount = $_POST["SubmitCount"];
if(isset($_POST["SubmitCountPend"]))
	$SubmitCountPend = $_POST["SubmitCountPend"];
if(isset($_POST["EnquireInterval"]))
	$EnquireInterval = $_POST["EnquireInterval"];
if(isset($_POST["AutoReconnect"]))
	$AutoReconnect = 1;
else
	$AutoReconnect = 0;
if(isset($_POST["SaveLogFile"]))
	$SaveLogFile = 1;
else
	$SaveLogFile = 0;

$id = $_POST["connId"];
$chain = "AWdrh78y892Djk*^523*%$#ghgHGHia&%$*)AsfdsLJnLaad";
include("validateLogin.php");
include("includeInformation.php");

$query = "UPDATE `connections` SET  ";
$query.= "ConnectionName='".$ConnectionName."',";
$query.= "Host='".$Host."',";
$query.= "Port='".$Port."',";
$query.= "UserName='".$UserName."',";
$query.= "Password='".$Password."',";
$query.= "AddressTON='".$AddressTON."',";
$query.= "AddressNPI='".$AddressNPI."',";
$query.= "SystemType='".$SystemType."',";
$query.= "SubmitMode='".$SubmitMode."',";
$query.= "SrcTON='".$SrcTON."',";
$query.= "SrcNPI='".$SrcNPI."',";
$query.= "DestTON='".$DestTON."',";
$query.= "DestNPI='".$DestNPI."',";
$query.= "DataCoding='".$DataCoding."',";
$query.= "SubmitCount='".$SubmitCount."',";
$query.= "SubmitCountPend='".$SubmitCountPend."',";
$query.= "EnquireInterval='".$EnquireInterval."',";
$query.= "AutoReconnect='".$AutoReconnect."',";
$query.= "SaveLogFile='".$SaveLogFile."'";
$query .=" WHERE id='".$id."'";
$result = mysqli_query($conn, $query);
if($result) {
	if(isset($_POST["defSender"])){
		$defSender = trim($_POST["defSender"]);
		$set = "";
		if($id == 1)
			$set = "short_code_stc";
		if($id == 2)
			$set = "short_code_mobily";
		if($id == 3)
			$set = "short_code_zain";
		$queryUpdate  = "UPDATE `settings` SET `$set`='".mysqli_real_escape_string($conn, $defSender)."'";
		$resultUpdate = mysqli_query($conn, $queryUpdate);
		if($resultUpdate) {
			header("location:connectionsList.php?res=1");
			exit;
		} else {
			header("location:connectionsList.php?res=2");
			exit;
		}
	}
	header("location:connectionsList.php?res=1");
	exit;
} else {
	header("location:connectionsList.php?res=2");
	exit;
}
		
		
?>
