<?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();
$chain = "AWdrh78y892Djk*^523*%$#ghgHGHia&%$*)AsfdsLJnLaad";
include("validateLogin.php");
include("includeInformation.php");
include_once("functions/pointFunction.php");
include_once("functions/sendFunctions.php");
include("functions/insertMsg.php");
if(empty($_POST["numbers"]))
{
    header("location:sendMsg.php?error=rp");
}
$link="sendMsg.php";
$queryAccount = "SELECT * FROM $userLogin WHERE id=$_SESSION[userId]";
$resultAccount = mysqli_query($conn,$queryAccount);
$rowAccount = mysqli_fetch_array($resultAccount);
$numbers = $_POST["numbers"];
$arrayNumbers = clearArray(",", $numbers, 0, 1);
$countNumbers = count($arrayNumbers);
$userSender = $_POST["userSender"];
$msg = clearArabicNum($_POST['msg']);
$numMsgs = $_POST['numMsgs'];
$numbersNotAccepted = $_POST['numbersNotAccepted'];
$numbersNotAcceptedExplode = explode(',',$numbersNotAccepted);
$numbersNotAcceptedExplode = array_filter($numbersNotAcceptedExplode);
$countOfNotExpted = count($numbersNotAcceptedExplode);
$number966 = $numberOhers = '';
foreach($arrayNumbers as $value)
{
	if(!empty($value))
	{
		if(in_array(substr($value,0,5), array('96650','96657','96653','96654','96655','96656','96658','96659','96651')))
			$number966 .= $value.',';
		else
			$numberOhers .= $value.',';
	}
}
$points1 = $points2 = 0;
if(!empty($number966))
	$points1 = getPoints($number966, $msg);
$points = $points1;
$errMsg = "";
if ($rowAccount["account"] <= 0)
  $errMsg = $sendMsgLBL["balance0"];
if ($points > $rowAccount["account"])
   $errMsg = $sendMsgLBL["noBalance"];
if ($numbers)
{
	insertDBNumber($_SESSION["userId"],$userSender,$number966,$msg,1,$_SESSION["msgUnique"],$numbersNotAccepted,$countOfNotExpted);
	header("location: printMessage.php?res=221");
	exit();
}
else
{
    if ($errMsg)
    {
        echo "<table><tr><td>
							<fieldset width='100%'>
								<table border=0 cellpadding=2 cellspacing=2 align=center>
									<tr>
										<td align=center>&nbsp;</td>
										<td align=center nowrap><font class='warning2'>" . $errMsg . "</font></td>
									</tr>	
								</table>
							</fieldset>
						</td></tr></table>";
		exit();
    }
}
ob_end_flush();
?>
