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 :  D:/laragon4/www/wa-gateway/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

namespace App\Http\Controllers;

use App\Http\Requests\StoreAutoreplyRequest;
use Illuminate\Http\Request;
use App\Models\Autoreply;
use App\Services\MessageService;
use Illuminate\Support\Facades\DB;

class AutoreplyController extends Controller
{
   
    protected $msgservice;
    public function __construct(MessageService $msgservice)
    {
        $this->msgservice = $msgservice;
    }

    public function index(Request $request)
    {
        $autoreplies = $request->user()->autoreplies()->whereHas('device', function ($q) {
            $q->where('id', session()->has('selectedDevice') ? session()->get('selectedDevice')['device_id']  : '');
        });

        $autoreplies->when($request->keyword != null, function ($query) use ($request) {
            return $query->where('keyword', 'like', '%' . $request->keyword . '%');
        });
        $autoreplies = $autoreplies->latest()->paginate(15);

        return view('pages.autoreply', compact('autoreplies'));
    }

    public function store(StoreAutoreplyRequest $request)
    {

        $type = $request->type;
        try {
            //code...
            $reply = $this->msgservice->format($type, (object) $request->all());
        } catch (\Throwable $th) {
            return back()->with(['alert' => ['type' => 'danger', 'msg' => $th->getMessage()]]);
        }
        $data = $request->all();
        $data['reply'] = json_encode($reply);
        $data['device_id'] = $request->device;
        $request->user()->autoreplies()->create($data);
        return redirect(route('autoreply'))->with('alert', ['type' => 'success', 'msg' => 'Your auto reply was added!']);
    }





    public function destroy(Request $request)
    {
        Autoreply::whereId($request->id)->delete();
        return redirect(route('autoreply'))->with('alert', ['type' => 'success', 'msg' => 'Deleted',]);
    }


    public function update(Request $request, Autoreply $autoreply)
    {
        try {
            // if $request->keyword and exists in $autoreply with same device_id
            if ($request->keyword && $request->keyword != $autoreply->keyword) {
                $keyword = $request->keyword;
                $device_id = $autoreply->device_id;
                $check = Autoreply::where('keyword', $keyword)->where('device_id', $device_id)->first();
                if ($check) {
                    return response()->json(['status' => 'error', 'msg' => __('Keyword already exists')]);
                }
            }
            $autoreply->update([
                'keyword' => $request->keyword ?? $autoreply->keyword,
                'status' => $request->status ?? $autoreply->status,
                'is_quoted' => $request->quoted ?? $autoreply->is_quoted,
                'is_read' => $request->read ?? $autoreply->is_read,
                'is_typing' => $request->typing ?? $autoreply->is_typing,
                'delay' => $request->delay ?? $autoreply->delay,
            ]);
            return response()->json(['error' => false, 'msg' => 'Updated']);
        } catch (\Throwable $th) {
            //throw $th;
        }
    }

    public function edit(Request $request)
    {
        $autoreply = DB::table('autoreplies')->where('id', $request->id)->first();
        return view('pages.autoreply-edit', compact('autoreply'));
        //return redirect(route('autoreply'))->with('alert', ['type' => 'success', 'msg' => 'Your auto reply was edited!']);
    }

    public function editUpdate(Request $request)
    {
        $type = $request->type;
        try {
            $reply = $this->msgservice->format($type, (object) $request->all());
        } catch (\Throwable $th) {
            return back()->with(['alert' => ['type' => 'danger', 'msg' => $th->getMessage()]]);
        }
        $check = Autoreply::where('id', $request->edit_id)->first();
        if (!$check) {
            return redirect(route('pages.autoreply-edit'))->with('alert', ['type' => 'error', 'msg' => __('There is problem')]);
        }
        $data = $request->all();
        $data['reply'] = json_encode($reply);
        $data['device_id'] = $request->device;
        $check->update($data);
        return redirect(route('autoreply'))->with('alert', ['type' => 'success', 'msg' => __('Your auto reply was edited!')]);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit