⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.36
Server IP:
15.204.235.159
Server:
Linux srv.techlup.co.ke 4.18.0-553.5.1.el8_10.x86_64 #1 SMP Wed Jun 5 09:12:13 EDT 2024 x86_64
Server Software:
Apache
PHP Version:
8.3.16
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
tech
/
call.techlup.co.ke
/
pbx
/
app
/
View File Name :
custom_helpers.php
<?php use Illuminate\Support\Facades\Http; function webrtc_token($phone=null, $new=false){ if(!auth()->user()) return ['token'=> ""]; $user = \App\Models\User::query()->find(auth()->user()->id); $metadata = json_decode($user->metadata); if($metadata){ if(property_exists($metadata,'selected_number')){ $phone = \App\Models\PhoneNumber::query()->where('name', $metadata->selected_number)->first()->number; } else{ if(isset($metadata->phone_numbers)) $phone = $metadata->phone_numbers[0]; else $phone = env('AFRICAS_TALKING_PHONE'); } } $apiEndpoint = 'https://webrtc.africastalking.com/capability-token/request'; $apiKey = env('AFRICAS_TALKING_API_KEY'); $jsonData = [ 'clientName' => auth()->user()->username, 'username' => env('AFRICAS_TALKING_USER_NAME'), 'phoneNumber' => $phone ?? env('AFRICAS_TALKING_PHONE'), ]; $response = Http::withHeaders([ 'apikey' => $apiKey, 'Content-Type' => 'application/json', 'Accept' => 'application/json', ])->post($apiEndpoint, $jsonData); session('rtc_token', $response['token']); return $response; } function get_agents(){ if(!auth()->user()) return []; return \App\Models\User::query()->where('id', '!=', auth()->user()->id)->get(); } function get_phone_numbers(){ if(!auth()->user()) return []; $numbers = \App\Models\PhoneNumber::query(); $metadata = json_decode(auth()->user()->metadata); $selected_numbers = $metadata?$metadata->phone_numbers : []; foreach ($selected_numbers as $n){ $numbers->orWhere('number', $n); } return $numbers->get(); } function get_selected_phone(){ if(!auth()->user()) return ''; $user = \App\Models\User::query()->find(auth()->user()->id); $metadata = json_decode($user->metadata); if($metadata){ if(property_exists($metadata,'selected_number')) return $metadata->selected_number; } if(count(get_phone_numbers())>0) return get_phone_numbers()[0]->name; return ''; }