OverLord Shell
<?php
/*
@Purpose: add company job into database
@Author: Rajahree
@CreatedOn: 4 May 2016
@ModifiedOn: 4 May 2016
*/
error_reporting(0);
session_start();
include("db/conn.php");
//include_once("header.inc.php");
//include("sidebar.php");
if(!isset($_SESSION['company_id']) || !isset($_SESSION['company_name'])){session_destroy();echo "login.php";exit;}
if(!in_array($_SESSION['loggedin_user'],array('admin','company'))){echo "404.php";exit;}
if($_SERVER['REQUEST_METHOD']!='POST' || empty($_POST)){echo "404.php";exit;}
$testmonial = htmlentities(trim($_POST['testmonial']),ENT_QUOTES);
$fname1=$_FILES['photo']['name'];
$target_logo_file = "";
if(!empty($fname1)){
$ftype1=$_FILES['photo']['type'];
if($_FILES['photo']['error']==1){echo "Logo upload error.";exit;}
else{
if($_FILES['photo']['size'] < 2*1024*1024){
if($ftype1=="image/jpeg" || $ftype1=="image/pjpeg" || $ftype1=="image/gif" || $ftype1=="image/png"){
@$ext1=explode('.',basename($fname1));
@$ext1=end($ext1);
$file_name = date('YmdHis').".".$ext1;
}
else{echo "Logo type error. Only JPG, PNG and GIF allowed.";exit;}
}
else{echo "Logo size error. Max size is 2 MB.";exit;}
}
}
$patterns = array();
$patterns[0] = '/([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/';
$patterns[1] = '/([0-9]+[\- ]?[0-9]{9}+)/';
$patterns[2] = '/([0-9]{2,}-[0-9]{0,}-[0-9]{0,})/';
$patterns[3] = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
$replacements = array();
$replacements[0] = '';
$replacements[1] = '';
$replacements[2] = '';
$replacements[3] = '';
$string = preg_replace($patterns, $replacements, $testmonial);
$data = array(
'company_id' => $_SESSION['company_id'],
'news' => $string,
'photo' => $file_name,
'createdby' => $_SESSION['company_id'],
'createdon' => date('Y-m-d H:i:s')
);
$insertresult = dbRowInsert('busdir_mst_news', $data);
$insertresultarr = explode("-",$insertresult);
if($insertresultarr[0]){
@move_uploaded_file($_FILES['photo']['tmp_name'], "uploads/news/".$file_name);
$enq_from=null;
$comm_id=null;
$listq="SELECT token from busdir_mst_company where (token is not null AND token !='0' AND token !='') AND company_id !=".$_SESSION['company_id']."";
$listr=$connection->query($listq);
$info=array();
while($listrow=$listr->fetch_assoc()){
array_push($info,$listrow['token']);
}
$out=implode(",", $info);
$string='MACCIA : You have new news notification';
$registatoin_ids = (explode(",",$out));
$Title=$string;
$xyz='news';
$lastid=$lastid;
$json = $json . "{";
$json = $json . "\"title\":\"$Title\",";
$json = $json . "\"id\":\"$lastid\",";
$json = $json . "\"type\":\"$xyz\"";
$json = $json . "}";
//$out = implode(",",array_map(function($a) {return implode(",",$a);},$md));
$message_= $json;
$message1 = array("price" => $message_);
//splitting reg_ids in group of 1000, and sending notifications
$regids=array_chunk($registatoin_ids,1000);
foreach($regids as $regid){
$message = array(
'registration_ids' => $regid,
'data' => $message1
);
//@$result = $this->send_notification($message);
define( 'FIREBASE_API_KEY', 'AAAAZcBAFsU:APA91bFLGC9T5p571eX7lFORkZkNq5KwY9z38dv8pfko3Vm7dMkjsUJtXBXXVobU-bHzwpHPW5q0SrFR5odPUT_4etOY6hFdw9bZOsg6vrHSrzIYo9ko0KEyuzVZ_tuMpzXooEn_xf2gVqbd0YxzB4b_RKyrkst1JQ' );
//importing the constant files
//firebase server url to send the curl request
$url = 'https://fcm.googleapis.com/fcm/send';
//building headers for the request
$headers = array(
'Authorization: key=' . FIREBASE_API_KEY,
'Content-Type: application/json'
);
//Initializing curl to open a connection
$ch_new = curl_init();
//Setting the curl url
curl_setopt($ch_new, CURLOPT_URL, $url);
//setting the method as post
curl_setopt($ch_new, CURLOPT_POST, true);
//adding headers
curl_setopt($ch_new, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch_new, CURLOPT_RETURNTRANSFER, true);
// new line added
//curl_setopt($ch_new, CURLOPT_SSL_VERIFYHOST, 0);
//disabling ssl support
curl_setopt($ch_new, CURLOPT_SSL_VERIFYPEER, false);
//adding the fields in json format
curl_setopt($ch_new, CURLOPT_POSTFIELDS, json_encode($message));
//finally executing the curl request
$result = curl_exec($ch_new);
//print_r($result);exit;
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch_new));
}
//Now close the connection
curl_close($ch_new);
}
echo "success";
}
?>
xRyukZ - Copyright 2k19