| Server IP : 209.209.40.120 / Your IP : 216.73.217.112 Web Server : Microsoft-IIS/10.0 System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586 User : NEWWWW$ ( 0) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/HostingSpaces/admin/penpalamerica.com/wwwroot/penpal/backup/ |
Upload File : |
<?php
include "general.php";
include "connect.php";
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
header('Access-Control-Allow-Origin : *');
header('Access-Control-Allow-Methods : POST, GET, OPTIONS, PUT, DELETE');
header('Access-Control-Allow-Headers : *');
exit;
}
//$response = array();
$email_u =$_POST["email_u"];
$email_f =$_POST["email_f"];
$message =$_POST['message'];
$image_url =$_POST["image_url"];
$sentby =$_POST["sentby"];
$domain=$_POST["domain"];
date_default_timezone_set('africa/lagos');
//echo $sentby;
$message = str_replace("'","^",$message);
//check if friends already exists in friend lists
$query = "Select message_count_f from penpalfriends where (email_u ='$email_u' and email_f ='$email_f' and domain ='$domain') or (email_u ='$email_f' and email_f ='$email_u' and domain ='$domain') ";
$myresponse =getQuery1($query);
//echo $query;
//die();
//echo $myresponse;
if ($myresponse == "#"){
$query ="insert into penpalfriends (email_u,email_f,latest_message,message_count_f,datecreated,domain) VALUES
('$email_u','$email_f','$message','1',now(),'$domain')";
//echo $query;
$queryresponse = updateQuery($query);
//update penpalmatch table to remove the users from matchlist
$query = "update penpalfriendmatch set message ='1',datecreated=now() where (email_u ='$email_u' and email_f ='$email_f' and domain ='$domain') or (email_u ='$email_f' and email_f ='$email_u' and domain ='$domain')";
//echo $query;
$queryresponse = updateQuery($query);
//insert message to chat table
$query = "insert into penpalchat (email_u,email_f,message,image,sentby,datecreated,domain) values
( '$email_u','$email_f','$message','$image_url','$sentby',now(),'$domain')";
$queryresponse = updateQuery($query);
// update user status to online
$query = "update penpal set userStatus='online',lastseen=now() where email ='$sentby' and domain ='$domain'";
$queryresponse = updateQuery($query);
echo "0";
die();
}
else{
$query = "Select message_count_u,message_count_f from penpalfriends where email_u ='$email_u' and email_f ='$email_f' and domain ='$domain' order by sn desc";
$myresponse =getQuery2($query);
//echo $myresponse;
//echo $query;
if($myresponse !="#"){
$splitResponse = explode(",", $myresponse);
$message_count_u = $splitResponse[0]+1;
$message_count_f = $splitResponse[1]+1;
$query ="update penpalfriends set latest_message ='$message', message_count_f ='$message_count_f',datecreated =NOW() where email_u ='$email_u' and email_f ='$email_f' and domain ='$domain'";
//echo $query;
$queryresponse = updateQuery($query);
}else{
$query = "Select message_count_u from penpalfriends where email_u ='$email_f' and email_f ='$email_u' and domain ='$domain'";
$myresponse =getQuery1($query);
$message_count_u = $myresponse+1;
$query ="update penpalfriends set latest_message ='$message', message_count_u ='$message_count_u', datecreated =NOW() where email_u ='$email_f' and email_f ='$email_u' and domain ='$domain'";
//echo $query;
$queryresponse = updateQuery($query);
}
//insert message to chat table
$query = "insert into penpalchat (email_u,email_f,message,image,sentby,datecreated,domain) values
( '$email_u','$email_f','$message','$image_url','$sentby',now(),'$domain')";
//echo $query;
$queryresponse = updateQuery($query);
// update user status to online
$query = "update penpal set userStatus='online', lastseen=now() where email ='$sentby' and domain ='$domain'";
$queryresponse = updateQuery($query);
echo "1";
die();
}
?>