Linux spg1.cloudpowerdns.com 5.14.0-611.34.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 18 05:51:10 EST 2026 x86_64
LiteSpeed
Server IP : 176.9.63.151 & Your IP : 216.73.217.60
Domains :
Cant Read [ /etc/named.conf ]
User : fastear1
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
home /
fastear1 /
Game source /
core /
app /
Lib /
Delete
Unzip
Name
Size
Permission
Date
Action
Captcha.php
3.65
KB
-rw-r--r--
2024-05-09 05:39
ClientInfo.php
2.77
KB
-rw-r--r--
2024-05-09 05:39
CurlRequest.php
1.35
KB
-rw-r--r--
2024-09-25 09:17
FileManager.php
5.76
KB
-rw-r--r--
2025-06-22 13:41
FormProcessor.php
5.92
KB
-rw-r--r--
2025-03-02 11:07
GoogleAuthenticator.php
6.02
KB
-rw-r--r--
2025-05-05 11:06
Intended.php
2.11
KB
-rw-r--r--
2024-05-09 05:39
RequiredConfig.php
2.03
KB
-rw-r--r--
2025-04-22 10:58
Searchable.php
3.25
KB
-rw-r--r--
2024-05-09 05:39
SocialLogin.php
5.79
KB
-rw-r--r--
2024-05-20 14:46
UserNotificationSender.php
7.76
KB
-rw-r--r--
2025-03-02 11:23
Save
Rename
<?php namespace App\Lib; use App\Constants\Status; use App\Models\NotificationTemplate; use App\Models\User; /** * Class UserNotificationSender * * This class handles the sending of notifications to users based on specified criteria. * It supports multiple notification channels (e.g., email, push notifications) and manages * session data to track the notification sending process. */ class UserNotificationSender { private $isSingleNotification = false; /** * Send notifications to all or selected users based on the request parameters. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse */ public function notificationToAll($request) { if (!$this->isTemplateEnabled($request->via)) { return $this->redirectWithNotify('warning', 'Default notification template is not enabled'); } $handleSelectedUser = $this->handleSelectedUsers($request); if (!$handleSelectedUser) { return $this->redirectWithNotify('error', "Ensure that the user field is populated when sending an email to the designated user group"); } $userQuery = $this->getUserQuery($request); $totalUserCount = $this->getTotalUserCount($userQuery, $request); if ($totalUserCount <= 0) { return $this->redirectWithNotify('error', "Notification recipients were not found among the selected user base."); } $imageUrl = $this->handlePushNotificationImage($request); $users = $this->getUsers($userQuery, $request->start, $request->batch); $this->sendNotifications($users, $request, $imageUrl); return $this->manageSessionForNotification($totalUserCount, $request); } /** * Send a notification to a single user. * * @param \Illuminate\Http\Request $request * @param int $userId * @return \Illuminate\Http\RedirectResponse */ public function notificationToSingle($request, $userId) { if (!$this->isTemplateEnabled($request->via)) { return $this->redirectWithNotify('warning', 'Default notification template is not enabled'); } $this->isSingleNotification = true; $imageUrl = $this->handlePushNotificationImage($request); $user = User::findOrFail($userId); $this->sendNotifications($user, $request, $imageUrl, true); return $this->redirectWithNotify("success", "Notification sent successfully"); } /** * Check if the notification template is enabled for the specified channel. * * @param string $via * @return bool */ private function isTemplateEnabled($via) { return NotificationTemplate::where('act', 'DEFAULT')->where($via . '_status', Status::ENABLE)->exists(); } /** * Redirect with a notification message. * * @param string $type * @param string $message * @return \Illuminate\Http\RedirectResponse */ private function redirectWithNotify($type, $message) { $notify[] = [$type, $message]; return back()->withNotify($notify); } /** * Handle selected users logic, merging user data from session if necessary. * * @param \Illuminate\Http\Request $request * @return bol */ private function handleSelectedUsers($request) { if ($request->being_sent_to == 'selectedUsers') { if (session()->has("SEND_NOTIFICATION")) { $request->merge(['user' => session()->get('SEND_NOTIFICATION')['user']]); } elseif (!$request->user || !is_array($request->user) || empty($request->user)) { return false; } } return true; } /** * Get user query based on the scope. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Database\Eloquent\Builder */ private function getUserQuery($request) { $scope = $request->being_sent_to; return User::oldest()->active()->$scope(); } /** * Get the total user count for notification. * * @param \Illuminate\Database\Eloquent\Builder $userQuery * @param \Illuminate\Http\Request $request * @return int */ private function getTotalUserCount($userQuery, $request) { if (session()->has("SEND_NOTIFICATION")) { $totalUserCount = session('SEND_NOTIFICATION')['total_user']; } else { $totalUserCount = (clone $userQuery)->count() - ($request->start - 1); } return $totalUserCount; } /** * Handle image upload for push notifications. * * @param \Illuminate\Http\Request $request * @return string|null */ private function handlePushNotificationImage($request) { if ($request->via == 'push') { if ($request->hasFile('image')) { $imageUrl = fileUploader($request->image, getFilePath('push')); session()->put('PUSH_IMAGE_URL', $imageUrl); return $imageUrl; } return $this->isSingleNotification ? null : session()->get('PUSH_IMAGE_URL'); } return null; } /** * Get users for notification based on pagination. * * @param \Illuminate\Database\Eloquent\Builder $userQuery * @param int $start * @param int $batch * @return \Illuminate\Support\Collection */ private function getUsers($userQuery, $start, $batch) { return (clone $userQuery)->skip($start - 1)->limit($batch)->get(); } /** * Send notifications to users. * * @param \Illuminate\Support\Collection $users * @param \Illuminate\Http\Request $request * @param string|null $imageUrl * @param bol $isSingleNotification * @return void */ private function sendNotifications($users, $request, $imageUrl, $isSingleNotification = false) { if (!$isSingleNotification) { foreach ($users as $user) { notify($user, 'DEFAULT', [ 'subject' => $request->subject, 'message' => $request->message, ], [$request->via], pushImage: $imageUrl); } } else { notify($users, 'DEFAULT', [ 'subject' => $request->subject, 'message' => $request->message, ], [$request->via], pushImage: $imageUrl); } } /** * Manage session data for notification sending process. * * @param int $totalUserCount * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse */ private function manageSessionForNotification($totalUserCount, $request) { if (session()->has('SEND_NOTIFICATION')) { $sessionData = session("SEND_NOTIFICATION"); $sessionData['total_sent'] += $sessionData['batch']; } else { $sessionData = $request->except('_token', 'image'); $sessionData['total_sent'] = $request->batch; $sessionData['total_user'] = $totalUserCount; } $sessionData['start'] = $sessionData['total_sent'] + 1; if ($sessionData['total_sent'] >= $totalUserCount) { session()->forget("SEND_NOTIFICATION"); $message = ucfirst($request->via) . " notifications were sent successfully"; $url = route("admin.users.notification.all"); } else { session()->put('SEND_NOTIFICATION', $sessionData); $message = $sessionData['total_sent'] . " " . $sessionData['via'] . " notifications were sent successfully"; $url = route("admin.users.notification.all") . "?email_sent=yes"; } $notify[] = ['success', $message]; return redirect($url)->withNotify($notify); } }