MINI Sh3ll
<?php
function mysql_escape($con, $parameter){
return mysqli_escape_string($con, $parameter);
}
function encrypt_decrypt($action, $string) {
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = 'Warranty';
$secret_iv = 'DrFixit';
// hash
$key = hash('sha256', $secret_key);
// iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
}
else if( $action == 'decrypt' ){
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}
function make_pageurl($title){
if($title == '') return '';
$finaltitle = str_replace(' ','-',strtolower($title));
$finaltitle = preg_replace("/[^a-zA-Z0-9.]/", "-", $finaltitle);
$pageurl = $finaltitle;
while(strpos($pageurl, '--')!== false){
$pageurl = str_replace('--', '-', $pageurl);
}
return $pageurl;
}
function getWarrantyCode($length_of_string = 10)
{
// String of all alphanumeric character
$str_result = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
// Shufle the $str_result and returns substring
// of specified length
return substr(str_shuffle($str_result),
0, $length_of_string);
}
function x($array = []){
print '<pre>';
print_r($array);
print '</pre>';
die;
}
function y($array = []){
print '<pre>';
print_r($array);
print '</pre>';
}
function generateNumericOTP($n) {
$generator = "1357902468";
$result = "";
for ($i = 1; $i <= $n; $i++) {
$result .= substr($generator, (rand()%(strlen($generator))), 1);
}
//$result = '123456';
return $result;
}
function correctImageOrientation($filename) {
if (function_exists('exif_read_data')) {
$exif = exif_read_data($filename);
//print_r($exif); die;
if($exif && isset($exif['Orientation'])) {
$orientation = $exif['Orientation'];
if($orientation != 1){
$img = imagecreatefromjpeg($filename);
$deg = 0;
switch ($orientation) {
case 3:
$deg = 180;
break;
case 6:
$deg = 270;
break;
case 8:
$deg = 90;
break;
}
if ($deg) {
$img = imagerotate($img, $deg, 0);
}
// then rewrite the rotated image back to the disk as $filename
imagejpeg($img, $filename, 95);
} // if there is some rotation necessary
} // if have the exif orientation info
} // if function exists
}
function saveCompressedImage($source, $destination, $quality = 60) {
if(!file_exists(dirname($destination))){
mkdir(dirname($destination), 0777, true);
}
try{
$info = getimagesize($source);
if (in_array($info['mime'], ['image/jpeg', 'image/gif', 'image/png'])){
correctImageOrientation($source);
}
if ($info['mime'] == 'image/jpeg')
$image = imagecreatefromjpeg($source);
elseif ($info['mime'] == 'image/gif')
$image = imagecreatefromgif($source);
elseif ($info['mime'] == 'image/png')
$image = imagecreatefrompng($source);
if($image)
imagejpeg($image, $destination, $quality);
else
move_uploaded_file($source, $destination);
}
catch(Exception $ex){
// $destination = false;
}
return basename($destination);
}
function getInspectionStatus($inspection_type){
$inspection_status = 0;
switch($inspection_type){
case "kickoff-meeting": $inspection_status = 2; break;
case "pre-inspection": $inspection_status = 3; break;
case "during-inspection": $inspection_status = 4; break;
case "post-inspection": $inspection_status = 5; break;
}
return $inspection_status;
}
function startsWith($string, $startString)
{
$len = strlen($startString);
return (substr($string, 0, $len) === $startString);
}
function callURL($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
//curl_setopt($ch, CURLOPT_POST, is_array($paramstring) ? count($paramstring) : 0);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $paramstring);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozila Firefox'); //$_SERVER['HTTP_USER_AGENT']
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
if($output === false)
{
echo "Error Number:".curl_errno($ch)."<br>";
echo "Error String:".curl_error($ch);
}
curl_close($ch);
$json_output = trim($output);
//x($json_output);
$data = json_decode($output, true);
return $data;
}
function callURL1($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
//curl_setopt($ch, CURLOPT_POST, is_array($paramstring) ? count($paramstring) : 0);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $paramstring);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozila Firefox'); //$_SERVER['HTTP_USER_AGENT']
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
if($output === false)
{
echo "Error Number:".curl_errno($ch)."<br>";
echo "Error String:".curl_error($ch);
}
curl_close($ch);
$json_output = trim($output);
//x($json_output);
//$data = json_decode($output, true);
return $json_output;
}
function sendWAAlert($mobileno = '', $template_id = '', $parameters){
$mobileno = trim($mobileno);
//$mobileno = '9619609308';
if($mobileno == '') return false;
$smsurl = 'https://saathi.pushandpull.in/actions/comm/send-warranty-alert?mobileno=@mobileno&template=@templateid';
$params = [];
$index = 1;
foreach($parameters as $p){
$params['param'.$index] = $p;
$index++;
}
$smsurl .="&".http_build_query($params);
$smsurl = str_replace("@mobileno", $mobileno, $smsurl);
$smsurl = str_replace("@templateid", $template_id, $smsurl);
$smsresponse = callURL($smsurl); //'sent'; //
$waresponse = [];
$waresponse['type'] = 'Whatsapp';
$waresponse['mobileno'] = $mobileno;
$waresponse['template'] = $template_id;
$waresponse['smsurl'] = $smsurl;
$waresponse['status_message'] = $smsresponse;
$waresponse = json_encode($waresponse, JSON_UNESCAPED_SLASHES);
//$waresponse = PHP_EOL.'========================WRITE RECORD========================'.PHP_EOL.$waresponse;
$logpath = SITE_ROOT_PATH."logger/alerts/";
if(!file_exists($logpath)){
mkdir($logpath, 0777, true);
}
file_put_contents($logpath.'whatsapp-'.date("Y-m-d").".log", $waresponse.PHP_EOL, FILE_APPEND | LOCK_EX);
return $smsresponse;
}
function sendMessage($mobileno = '', $message = '', $type = 'Information', $dlt_template_id = ''){
$mobileno = trim($mobileno);
$message = trim($message);
//$mobileno = '9619609308';
$smsurl = 'http://sms.pushandpull.in/submitsms.jsp?user=Mpower&key=9fc6681eb4XX&mobile='.$mobileno.'&message='.urlencode($message).'&senderid=DrFIXT&accusage=1&tempid='.$dlt_template_id.'&entityid=1201158073307569826';
$response = callURL1($smsurl); //'sent'; //
$json_data = [];
$json_data['datetime'] = date('Y-m-d H:i:s');
$json_data['type'] = strtoupper($type);
$json_data['mobileno'] = $mobileno;
$json_data['template'] = $dlt_template_id;
$json_data['message'] = $message;
$json_data['smsurl'] = $smsurl;
$json_data['response'] = $response;
$json_request = json_encode($json_data, JSON_UNESCAPED_SLASHES);
$logpath = SITE_ROOT_PATH."logger/alerts/";
if(!file_exists($logpath)){
mkdir($logpath, 0777, true);
}
file_put_contents($logpath.'sms-'.date("Y-m-d").".log", $json_request.PHP_EOL, FILE_APPEND | LOCK_EX);
return $response;
}
function export_csv($array, $filename = "export.csv", $delimiter=",") {
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="'.$filename.'";');
// open the "output" stream
// see http://www.php.net/manual/en/wrappers.php.php#refsect2-wrappers.php-unknown-unknown-unknown-descriptioq
$f = fopen('php://output', 'w');
$headers = array_keys($array[0]);
fputcsv($f, $headers, $delimiter);
foreach ($array as $line) {
fputcsv($f, $line, $delimiter);
}
}
?>
OHA YOOOO