403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /laragon4/www/wa-gateway/app/Http/Controllers/Api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /laragon4/www/wa-gateway/app/Http/Controllers/Api/DeviceController.php
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Device;
use App\Services\Impl\WhatsappServiceImpl;
use App\Utils\CacheKey;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\File;

class DeviceController extends Controller
{



    public function logoutDevice(Request $request)
    {
        $device = Device::whereBody($request->sender)->first();
        if ($device->status != 'Connected') {
            return response()->json(['status' => true, 'message' => 'Connection closed. You are logged out.']);
        }

        $whatsappService = new WhatsappServiceImpl();
        try {
            //code...
            $respon = $whatsappService->logoutDevice($device->body);
            return $respon;
        } catch (\Throwable $th) {
            throw $th;
            return response()->json(['status' => false, 'message' => 'Whtsapp server unable to reach']);
        }
    }


    public function deleteDevice(Request $request)
    {
        $device = Device::whereBody($request->sender)->first();
        $isForce =  isset($request->force) && $request->force === true ? true : false;
        if ($device->status === 'Connected' && !$isForce) return backWithFlash('danger', 'Device is connected. Please disconnect first');
        try {
            if (!empty($device->body)) {
                $path = base_path('credentials/' . $device->body);
                if (file_exists($path))  File::deleteDirectory($path);
            }
            $device->delete();
            Cache::forget(CacheKey::DEVICE_BY_BODY . $device->body);
            Cache::forget(CacheKey::DEVICE_BY_ID . $device->id);
            Cache::forget(CacheKey::USER_BY_API_KEY . $device->api_key);
            return response()->json(['status' => true, 'message' => 'Device deleted']);
        } catch (\Throwable $th) {
            return backWithFlash('danger', 'Something went wrong');
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit