OverLord Shell
<?php
class utils
{
function generateCode($length = 10)
{
$password="";
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
srand((double)microtime()*1000000);
for ($i=0; $i<$length; $i++)
{
$password .= substr ($chars, rand() % strlen($chars), 1);
}
return $password;
}
// un
// Not in use following function
function WS_MEM_CNT ($group_id)
{
global $row;
$sql=" SELECT COUNT(1)
FROM user_group,users
WHERE group_id='".$group_id."'
AND user_group.user_id=users.user_id";
$db_query=$row->query($sql);
$total = mysql_fetch_array($db_query);
return $total[0];
}
// function for event all member count
function WS_MEM_CNT_EVT ($group_id)
{
global $row;
$sql=" SELECT COUNT(1)
FROM user_group,users
WHERE group_id='".$group_id."'
AND user_group.user_id=users.user_id";
$db_query=$row->query($sql);
$total = mysql_fetch_array($db_query);
return $total[0];
}
// function for event all participants member list
function WS_MEM_PARTICIPANTS ($group_id,$event_id)
{
global $row;
$sql=" SELECT COUNT(1)
FROM event_subscription
WHERE group_id='".$group_id."'
AND event_id='".$event_id."'
AND e_status!=1";
$db_query=$row->query($sql);
$total = mysql_fetch_array($db_query);
return $total[0];
}
function WS_GET_USR_DATA_FOR_SINGLE_USER($user_id)
{
global $row;
$teacher_names=array();
$sql = "SELECT user_id,
user_name,
user_password,
first_name,
middle_name,
last_name,
birth_date,
cell,phone,
address1,
address2,
address3,
city,
state,
country,
expert_area,
device_id,
device_type,
image_location,
pincode,
email,
push_notification_id,
access_code,
last_seen,
(SELECT COUNT(1)
FROM users
WHERE USER_ID = '".$this->no_injection($user_id)."') as usr_count
FROM users
WHERE USER_ID = '".$this->no_injection($user_id)."'";
$db_query=$row->query($sql);
while($client_result=$row->next_record())
{
$record = array();
foreach(array_keys($client_result) as $key){
if(gettype($key)=="string")
{
$record[$key] = stripslashes(stripslashes($client_result[$key]));
}
}
$teacher_names[]=$record;
}
return $teacher_names;
}
// this function user by member web services
function WS_GET_MEMBER_DETAILS($group_id)
{
global $row;
$teacher_names=array();
$sql=" SELECT *
FROM user_group,users
WHERE group_id='".$group_id."'
AND user_group.user_id=users.user_id";
$db_query=$row->query($sql);
while($client_result=$row->next_record())
{
$record = array();
foreach(array_keys($client_result) as $key){
if(gettype($key)=="string")
{
$record[$key] = stripslashes(stripslashes($client_result[$key]));
}
}
$teacher_names[]=$record;
}
return $teacher_names;
}
//Function for get records user from users table created by Chandrakant Bhamare on date 13/03/2015 10.00 am
function WS_GET_USER_DT($user_name,$access_code,$device_id)
{
global $row;
$teacher_names=array();
$sql=" SELECT user_id,
user_name,
access_code,
device_id,
push_notification_id,
device_id,
(SELECT COUNT(1)
FROM users
WHERE user_name = '".$user_name."'
AND (device_id = '".$device_id."' || device_id = '')) as dev_cnt
FROM users
WHERE user_name='".$user_name."'
AND access_code='".$access_code."'";
$db_query=$row->query($sql);
while($client_result=$row->next_record())
{
$record = array();
foreach(array_keys($client_result) as $key){
if(gettype($key)=="string")
{
$record[$key] = stripslashes(stripslashes($client_result[$key]));
}
}
$teacher_names[]=$record;
}
return $teacher_names;
}
function send_notification_ios($regId, $message,$msg)
{
/*$q6 = mysql_query("insert into test(id,text,device_id,device_type,push_notification_id) values(10,'in I funct','in','in','in')");*/
$passphrase = 'asdf';
$ctx = stream_context_create();
$err = NULL;
$errstr = NULL;
stream_context_set_option($ctx, 'ssl', 'local_cert', 'MMGck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
{
/*$q11 = mysql_query("insert into test(id,text,device_id,device_type,push_notification_id) values(10,'F','".$fp."','".$errstr."','".$regId."')");*/
}
$body['aps'] = array(
'alert' => $msg,
'MMG' => $message
);
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
$msg1 = chr(0) . pack('n', 32) . pack('H*', $regId) . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg1, strlen($msg1));
if (!$result)
{
/*$q11 = mysql_query("insert into test(id,text,device_id,device_type,push_notification_id) values(10,'FR','".$result."','".$errstr."','".$regId."')"); */
return 0;
}
else
{
/*$q11 = mysql_query("insert into test(id,text,device_id,device_type,push_notification_id) values(10,'FS','".$result."','".$errstr."','".$regId."')"); */
return 1;
}
// Close the connection to the server
fclose($fp);
}
function 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);
//and return the result
return $result;
}
public function send_notification_android($push_noti_id, $message) {
$url = 'https://android.googleapis.com/gcm/send'; // Set POST variables
//field with registration id and data
$fields = array(
'registration_ids' => $push_noti_id,
'data' => $message,
);
//field with Authorization and Content-Type
$headers = array(
'Authorization: key=' . GOOGLE_API_KEY,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();//
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields, true));
// Execute post
$result = curl_exec($ch);
//echo $result;
if ($result === FALSE) {
//die('Curl failed: ' . curl_error($ch));
return 0;
}
// Close connection
curl_close($ch);
return 1;
}
function upload_image($field,$directory,$filename='',$width,$height)
{
global $resizer;
$_FILES[$field]['name']=$filename;
if(move_uploaded_file($_FILES[$field]['tmp_name'],'../'.$directory.$_FILES[$field]['name']))
{
$this->createThumb('../'.$directory.$_FILES[$field]['name'],'../'.$directory.$_FILES[$field]['name'],$width,$height);
return $_FILES[$field]['name'];
}
return false;
}
// *********************** comman function
function no_injection($string)
{
//$string = htmlspecialchars($string); // convert html special char into url encode
$string = trim($string); // remove spaces from start and end
//$string = stripslashes($string); // will remove slashes
$string = mysql_escape_string($string); // Escape a string for query
//$string = addslashes($string); // add slashes to cotted string
return $string;
}
}
?>
xRyukZ - Copyright 2k19