| 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/register/ |
Upload File : |
<?PHP
include "general.php";
include "connect.php";
function sendMessage($message){
$content = array(
"en" => $message
);
$title = array(
"en" => 'PenpalAfrica'
);
$fields = array(
'app_id' => "3ddfb68d-b5e8-4630-90ea-494229489c52",
'included_segments' => array('All'),
'headings' => $title,
'contents' => $content
);
$fields = json_encode($fields);
print("\nJSON sent:\n");
print($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Authorization: Basic ZGY2MGIyNWUtOTJkMy00MDBlLWI5NDctYWVlZTU5M2NmNzA1'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
// End of function
//$query = "Select sn, nickname, age, sex, country from penpalsubscriber where pushh ='1' order by sn desc limit 1";
//database constants
define('DB_HOST', 'localhost');
define('DB_USER', 'smsEngine');
define('DB_PASS', 'guEnaR28T');
define('DB_NAME', 'smartsmsrouter');
//connecting to database and getting the connection object
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$conn2 = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
//Checking if any error occured while connecting
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
die();
}
$query = "Select sn, nickname, age, sex, country from penpalsubscriber where push ='1' and nickname != '' order by sn desc limit 1";
//creating a query
$stmt = $conn->prepare($query);
//executing the query
$stmt->execute();
//binding results to the query
$stmt->bind_result($sn,$nickname,$age,$sex,$country );
while($stmt->fetch()){
if($sex =="F"){
$mess = $nickname .', '. $country . ', ' . $sex . ', ' .$age . ', Chat with her';
}else
{
$mess = $nickname .', '. $country . ', ' . $sex . ', ' .$age . ', Chat with him';
}
$response = sendMessage($mess);
$return["allresponses"] = $response;
$return = json_encode( $return);
print("\n\nJSON received:\n");
print($return);
print("\n");
$query = "update penpalsubscriber set push='2' where sn =$sn";
//echo $query;
//creating a query
$stmt2 = $conn2->prepare($query);
//executing the query
$stmt2->execute();
}
$stmt->close();
//$stmt2->close();
?>