MINI Sh3ll
<?php
use Illuminate\Support\Facades\Hash;
// This is helper function to send otp to phone number
if (!function_exists('send_otp')) {
function send_otp($phone, $otp) {
$status = false;
$smsUrl = App\Models\SmsSetting::first();
if(isset($smsUrl) && (!empty($smsUrl))){
$message = "Your Login code for the solar application is ". $otp .". Please do not share";
$message = rawurlencode($message);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_PORT => "8008",
CURLOPT_URL => $smsUrl->url."?".$smsUrl->mobile_number_parameter."=".$phone."&".$smsUrl->message_parameter."=". $message."&".$smsUrl->username_parameter."=".$smsUrl->username_key_value."&".$smsUrl->password_parameter."=".$smsUrl->password_key_value."&".$smsUrl->senderid_parameter."=".$smsUrl->senderid_key_value,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"postman-token: c819ccb0-bb68-e7fb-18de-dbe4aa9e98a5"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$status = true;
$message = '';
$response = json_decode($response, true);
if ($response['code'] == -1) {
$status = false;
$message = 'Error while Processing the request';
}
}
}
$response = array('status' => $status,'message'=> $message);
return $response;
}
}
//generate random string
if (!function_exists('generateRandomString')) {
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
}
//MenuList from database
if (!function_exists('menuList')) {
function menuList() {
$id = Auth::id();
$menulist = App\Models\ModulePermission::where('user_id', $id)->pluck('module_id')->toArray();
return $menulist;
}
}
//breadcrumb function
if (!function_exists('breadCrumb')) {
function breadCrumb($module, $url, $currentPage) {
$breadcrumb = array("module" => $module, "url" => $url, "currentPage" => $currentPage);
return $breadcrumb;
}
}
//Get Module by module code
if(!function_exists('getModule')){
function getModule($module_code) {
return App\Models\Module::where('module_code', $module_code)->pluck('id')->first();
}
}
//Create plant on treepye
if(!function_exists('createPlant')){
function createPlant($plant, $apiResponse) {
return App\Models\TreepyePlantDetails::create([
'plant_id' => $plant->id,
'company_id' => $plant->company_id,
'treepye_plant_id' => $apiResponse['details']['plant_id'],
'host_name' => $apiResponse['details']['host_name'],
'port' => $apiResponse['details']['port'],
'ftp_username' => $apiResponse['details']['ftp_username'],
'ftp_password' => $apiResponse['details']['ftp_password'],
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
]);
}
}
// Generate password automatically
if (!function_exists('generate_password')) {
function generate_password() {
$randomPassword = str_random(8);
return $randomPassword;
}
}
OHA YOOOO