VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/fcm/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/html/fcm/fcm_notification_cli.php
<?php
    class FCMNotificationCLI
    {
        static $servUrl = "https://absol.cf/fcm/fcm_notification_serv.php";
        static $secret = 'xJDDonkgbMOgIGtleSBiw60gbeG6rXQ=';
        public static function sendNotificationToTopic($params)  {
            $topic = $params['topic'];
            $title = $params['title'];
            $body = $params['body'];
            $moredata = isset($params['data']) ? $params['data'] : null;
            $image = isset($params['image']) ? $params['image'] : null;
            $badge = isset($params['badge']) ? (int)$params['badge'] : -1;
            if (isset($params['moredata'])) {
                $moredata = $params['moredata'];
            }

        $post_data = [
            'cmd' => 'sendNotificationToTopic',
            'secret' => self::$secret,
            'topic' => $topic,
            'title' => $title,
            'body' => $body
        ];
       
        if ($image !== null) {
            $post_data['image'] = $image;
        }
        if ($badge >= 0) {
            $post_data['badge'] = $badge;
        }
        if ($moredata !== null) {
                if (is_array($moredata)) {
                    $post_data['data'] = json_encode([
                        'moredata' => json_encode($moredata)
                    ]);
                }
                else if (is_string($moredata)) {
                    $post_data['data'] = json_encode([
                        'moredata' => $moredata
                    ]);
                } else {
                   $post_data['data'] =json_encode([
                        'moredata' => json_encode($moredata)
                    ]);
                }
            }
        
        $ch = curl_init(self::$servUrl);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $response = curl_exec($ch);
    

        if (curl_errno($ch)) {
            throw new Exception('Curl error: ' . curl_error($ch));
        }

        curl_close($ch);

        return json_decode($response);
        }

        static function sendNotificationToDevice($params) {
             $userFCMToken = $params['userFCMToken'];
            $title = $params['title'];
            $body = $params['body'];
            $moredata =  isset($params['data']) ? $params['data'] : null;
            if (isset($params['moredata'])) {
                $moredata = $params['moredata'];
            }

            $image = isset($params['image']) ? $params['image'] : null;
            $badge = isset($params['badge']) ? (int)$params['badge'] : -1;
            $post_data = [
                'cmd' => 'sendNotificationToDevice',
                'secret' => self::$secret,
                'userFCMToken' => $userFCMToken,
                'title' => $title,
                'body' => $body
            ];
            if ($image !== null) {
                $post_data['image'] = $image;
            }
            if ($badge >= 0) {
                $post_data['badge'] = $badge;
            }
           if ($moredata !== null) {
                if (is_array($moredata)) {
                    $post_data['data'] = json_encode([
                        'moredata' => json_encode($moredata)
                    ]);
                }
                else if (is_string($moredata)) {
                    $post_data['data'] = json_encode([
                        'moredata' => $moredata
                    ]);
                } else {
                   $post_data['data'] =json_encode([
                        'moredata' => json_encode($moredata)
                    ]);
                }
            }


            $ch = curl_init(self::$servUrl);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            $response = curl_exec($ch);

            if (curl_errno($ch)) {
                throw new Exception('Curl error: ' . curl_error($ch));
            }

            curl_close($ch);
            return json_decode($response);  
        } 
    }

VaKeR 2022