shell bypass 403

GrazzMean Shell

: /www/wwwroot/koreanshop.lk/app/Helpers/ [ drwxr-xr-x ]
Uname: Linux peekpos.com 6.8.0-1060-aws #63~22.04.1-Ubuntu SMP Tue Jun 30 02:32:53 UTC 2026 x86_64
Software: Apache
PHP version: 8.3.25 [ PHP INFO ] PHP os: Linux
Server Ip: 47.130.192.226
Your Ip: 10.1.31.86
User: www (1001) | Group: www (1001)
Safe Mode: OFF
Disable Function:
passthru,putenv,chroot,chgrp,chown,shell_exec,popen,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,popepassthru,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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv

name : helper.php
<?php

namespace App\Helpers;

use App\Models\About;
use App\Models\Roles;
use App\Models\Cart;
use App\Models\Category;
use App\Models\User;
use App\Models\Payment;
use App\Models\Tax;
use App\Models\OTPConfiguration;
use App\Models\FooterFeatures;
use App\Models\Ratting;
use App\Models\Pixcel;
use App\Models\Time;
use App\Models\CustomStatus;
use App\Models\RoleManager;
use App\Models\RoleAccess;
use App\Models\TopDeals;
use App\Models\Variation;
use App\Models\Item;
use App\Models\WhatsappMessage;
use App\Models\SocialLinks;
use App\Models\Order;
use App\Models\AgeVerification;
use App\Models\Promocode;
use App\Models\Languages;
use App\Models\CurrencySettings;
use Illuminate\Support\Facades\Cookie;
use App\Models\SystemAddons;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Str;
use Twilio\Rest\Client;
use App;
use App\Models\OtherSettings;
use App\Models\TelegramMessage;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\URL;
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver;

class helper
{
    public static function push_notification($token, $title, $body, $type, $order_id)
    {
        $customdata = array(
            "type" => $type,
            'sub_type' => "",
            'category_id' => "",
            'category_name' => "",
            'item_id' => "",
            "order_id" => $order_id,
        );

        if ($title == "") {
            $title = @helper::appdata()->website_title;
        }
        $msg = array(
            'body' => $body,
            'title' => $title,
            'sound' => 1/*Default sound*/
        );
        $fields = array(
            'to'           => $token,
            'notification' => $msg,
            'data' => $customdata
        );
        $headers = array(
            'Authorization: key=' . @helper::appdata()->firebase,
            'Content-Type: application/json'
        );
        #Send Reponse To FireBase Server
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
    public static function image_path($image)
    {
        if ($image == "" && $image == null) {
            $path = asset('storage/app/public/admin-assets/images/about/defaultimages/item-placeholder.png');
        } else {
            $path = asset('storage/app/public/admin-assets/images/about/defaultimages/item-placeholder.png');
        }

        if (Str::contains($image, 'noaccess')) {
            if (file_exists(storage_path('app/public/admin-assets/images/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/' . $image);
            }
        }
        if (Str::contains($image, 'category')) {
            if (file_exists(storage_path('app/public/admin-assets/images/category/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/category/' . $image);
            }
        }
        if (Str::contains($image, 'profile-') || Str::contains($image, 'unknown') || Str::contains($image, 'identity')) {
            if (file_exists(storage_path('app/public/admin-assets/images/profile/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/profile/' . $image);
            }
        }
        if (Str::contains($image, 'item')) {
            if (file_exists(storage_path('app/public/admin-assets/images/item/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/item/' . $image);
            }
        }
        if (Str::contains($image, 'banner-')) {
            if (file_exists(storage_path('app/public/admin-assets/images/banner/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/banner/' . $image);
            }
        }
        if (Str::contains($image, 'slider')) {
            if (file_exists(storage_path('app/public/admin-assets/images/slider/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/slider/' . $image);
            }
        }
        if (Str::contains($image, 'card-image')) {
            if (file_exists(storage_path('app/public/admin-assets/images/card_image/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/card_image/' . $image);
            }
        }
        if (Str::contains($image, 'theme')) {
            if (file_exists(storage_path('app/public/admin-assets/images/theme/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/theme/' . $image);
            }
        }
        if (Str::contains($image, 'screenshot')) {
            if (file_exists(storage_path('app/public/admin-assets/images/screenshot/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/screenshot/' . $image);
            }
        }
        if (Str::contains($image, 'maintenance')) {
            if (file_exists(storage_path('app/public/admin-assets/images/index/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/index/' . $image);
            }
        }
        if (Str::contains($image, 'choose') || Str::contains($image, 'faq') ||  Str::contains($image, 'no_data_image')  || Str::contains($image, 'maintanance_image')) {
            if (file_exists(storage_path('app/public/admin-assets/images/index/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/index/' . $image);
            }
        }
        if (Str::contains($image, 'testimonial')) {
            if (file_exists(storage_path('app/public/admin-assets/images/testimonials/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/testimonials/' . $image);
            }
        }
        if (Str::contains($image, 'quick-')) {
            if (file_exists(storage_path('app/public/admin-assets/images/about/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/about/' . $image);
            }
        }
        if (Str::contains($image, 'trusted_badge')) {
            if (file_exists(storage_path('app/public/admin-assets/images/about/trusted_badge/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/about/trusted_badge/' . $image);
            }
        }
        if (Str::contains($image, 'trusted_badge')) {
            if (file_exists(storage_path('app/public/admin-assets/images/about/trusted_badge/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/about/trusted_badge/' . $image);
            }
        }
        if (
            Str::contains($image, 'auth_bg_image') || Str::contains($image, 'referral') || Str::contains($image, 'payment-') || Str::contains($image, 'app_bottom_image') || Str::contains($image, 'mobile_app_image') || Str::contains($image, 'blog') || Str::contains($image, 'veg') || Str::contains($image, 'gallery') || Str::contains($image, 'tutorial') || Str::contains($image, 'team') || Str::contains($image, 'default') || Str::contains($image, 'about') || Str::contains($image, 'footer') || Str::contains($image, 'logo') || Str::contains($image, 'favicon') || Str::contains($image, 'og_image')
        ) {

            if (file_exists(storage_path('app/public/admin-assets/images/about/' . $image))) {

                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/about/' . $image);
            }
        }
        if (Str::contains($image, 'flag')) {
            if (file_exists(storage_path('app/public/admin-assets/images/language/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/language/' . $image);
            }
        }

        if (Str::contains($image, 'nodata') || Str::contains($image, 'subscribe') || Str::contains($image, 'facebook') || Str::contains($image, 'google') || Str::contains($image, 'delivery') || Str::contains($image, 'cod') || Str::contains($image, 'wallet') || Str::contains($image, 'razorpay') || Str::contains($image, 'paystack') || Str::contains($image, 'stripe')  || Str::contains($image, 'flutterwave') || Str::contains($image, 'paytab') || Str::contains($image, 'phonepe')) {
            if (file_exists(storage_path('app/public/admin-assets/images/index/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'admin-assets/images/index/' . $image);
            }
        }

        if (Str::contains($image, 'playstore') || Str::contains($image, 'appstore')) {
            if (file_exists(storage_path('app/public/web-assets/images/index/' . $image))) {
                $path = url(env('ASSETSPATHURL') . 'web-assets/images/index/' . $image);
            }
        }
        return $path;
    }
    /*================================ All Mail Start ============================*/
    public static function verificationemail($email, $otp)
    {
        $var = ['{email}', "{otp}"];
        $newvar = [$email, $otp];
        $verificationemailmessage = str_replace($var, $newvar, nl2br(helper::appdata()->user_verification_email_message));
        $data = ['title' => trans('messages.email_code'), 'email' => $email, 'verificationemailmessage' => $verificationemailmessage, 'logo' => helper::image_path(@helper::appdata()->logo)];
        try {
            Mail::send('Email.emailverification', $data, function ($message) use ($data) {
                $message->to($data['email'])->subject($data['title']);
            });
            return 1;
        } catch (\Throwable $th) {
            return 1;
        }
    }
    public static function send_pass($email, $name, $password)
    {
        $var = ["{user}", '{email}', "{password}"];
        $newvar = [$name, $email, $password];
        $forgetpasswordmessage = str_replace($var, $newvar, nl2br(helper::appdata()->forget_password_email_message));
        $data = ['title' => trans('labels.new_password'), 'email' => $email, 'forgetpasswordmessage' => $forgetpasswordmessage, 'logo' => helper::image_path(@helper::appdata()->logo)];
        try {
            Mail::send('Email.email', $data, function ($message) use ($data) {
                $message->to($data['email'])->subject($data['title']);
            });
            return 1;
        } catch (\Throwable $th) {
            return 0;
        }
    }
    public static function referral($email, $referralmessage)
    {
        $data = ['title' => trans('labels.referral_earning'), 'email' => $email,  'referralmessage' => $referralmessage, 'logo' => helper::image_path(@helper::appdata()->logo), 'referralmessage' => $referralmessage];
        try {
            Mail::send('Email.referral', $data, function ($message) use ($data) {
                $message->to($data['email'])->subject($data['title']);
            });
            return 1;
        } catch (\Throwable $th) {
            return 0;
        }
    }
    public static function create_order_invoice($user_email, $user_name, $order_number, $orderdata)
    {
        $trackurl = URL::to('/orders-' . $order_number);
        $admininfo = User::where('id', '1')->first();
        $orderinvoicevar = ["{customername}", "{ordernumber}", "{orderdate}", "{grandtotal}", "{track_order_url}", "{adminname}"];
        $orderinvoicenewvar = [$user_name, $order_number, helper::date_format($orderdata->created_at), helper::currency_format($orderdata->grand_total), $trackurl, $admininfo->name];
        $neworderinvoicemessage = str_replace($orderinvoicevar, $orderinvoicenewvar, nl2br(helper::appdata()->new_order_invoice_email_message));
        $data = ['title' => trans('labels.order_placed'), 'email' => $user_email,  'neworderinvoicemessage' => $neworderinvoicemessage, 'logo' => helper::image_path(@helper::appdata()->logo)];
        try {
            Mail::send('Email.emailinvoice', $data, function ($message) use ($data) {
                $message->to($data['email'])->subject($data['title']);
            });
            return 1;
        } catch (\Throwable $th) {
            return 0;
        }
    }
    public static function order_status_email($email, $name, $title, $message_text)
    {
        $var = ["{customername}", "{status_message}"];
        $newvar = [$name, $message_text];
        $orderstatusmessage = str_replace($var, $newvar, nl2br(helper::appdata()->order_status_email_message));
        $data = ['email' => $email,  'title' => $title, 'orderstatusmessage' => $orderstatusmessage, 'logo' => helper::image_path(@helper::appdata()->logo)];
        try {
            Mail::send('Email.orderemail', $data, function ($message) use ($data) {
                $message->to($data['email'])->subject($data['title']);
            });
            return 1;
        } catch (\Throwable $th) {
            return 0;
        }
    }
    public static function send_mail_delete_account($vendor)
    {
        $var = ["{username}"];
        $newvar = [$vendor->name];
        $userdeletemessage = str_replace($var, $newvar, nl2br(helper::appdata()->delete_account_email_message));
        $data = ['title' => trans('labels.account_deleted'), 'userdeletemessage' => $userdeletemessage, 'email' => $vendor->email];
        try {
            Mail::send('Email.accountdeleted', $data, function ($message) use ($data) {
                $message->to($data['email'])->subject($data['title']);
            });
            return 1;
        } catch (\Throwable $th) {
            return 0;
        }
    }
    /*================================ All Mail End ============================*/
    public static function get_roles()
    {
        $data = Roles::select('modules')->where('id', Auth::user()->role_id)->first();
        return @$data->modules;
    }
    public static function get_user_cart()
    {
        $count = 0;
        if (Auth::user() && Auth::user()->type == 2) {
            $count = Cart::where('user_id', Auth::user()->id)->where('buynow', 0)->count();
        } else {
            $count = Cart::where('session_id', Session::getId())->where('buynow', 0)->count();
        }

        return $count;
    }
    public static function currency_format($price)
    {

        $price = floatval($price) * helper::currencyinfo()->exchange_rate;
        if (helper::currencyinfo()->currency_position == "1") {
            if (helper::currencyinfo()->decimal_separator == 1) {
                if (helper::currencyinfo()->currency_space == 1) {
                    return helper::currencyinfo()->currency . ' ' . number_format((float)$price, helper::currencyinfo()->currency_formate, '.', ',');
                } else {
                    return helper::currencyinfo()->currency . number_format((float)$price, helper::currencyinfo()->currency_formate, '.', ',');
                }
            } else {
                if (helper::currencyinfo()->currency_space == 1) {
                    return helper::currencyinfo()->currency . ' ' . number_format((float)$price, helper::currencyinfo()->currency_formate, ',', '.');
                } else {
                    return helper::currencyinfo()->currency . number_format((float)$price, helper::currencyinfo()->currency_formate, ',', '.');
                }
            }
        }
        if (helper::currencyinfo()->currency_position == "2") {
            if (helper::currencyinfo()->decimal_separator == 1) {
                if (helper::currencyinfo()->currency_space == 1) {
                    return number_format((float)$price, helper::currencyinfo()->currency_formate, '.', ',') . ' ' . helper::currencyinfo()->currency;
                } else {
                    return number_format((float)$price, helper::currencyinfo()->currency_formate, '.', ',') . helper::currencyinfo()->currency;
                }
            } else {
                if (helper::currencyinfo()->currency_space == 1) {
                    return number_format((float)$price, helper::currencyinfo()->currency_formate, ',', '.') . ' ' . helper::currencyinfo()->currency;
                } else {
                    return number_format((float)$price, helper::currencyinfo()->currency_formate, ',', '.') . helper::currencyinfo()->currency;
                }
                return number_format((float)$price, helper::currencyinfo()->currency_formate, ',', '.') . helper::currencyinfo()->currency;
            }
        }


        return $price;
    }
    public static function appdata()
    {
        $data = About::select('*', \DB::raw("CONCAT('" . url(env('ASSETSPATHURL') . 'admin-assets/images/about') . "/', app_bottom_image) AS app_bottom_image_url"), \DB::raw('(case when app_bottom_image is null then 0 else 1 end) as is_app_bottom_image'))->first();
        return $data;
    }
    public static function otherappdata()
    {
        $data = OtherSettings::first();
        return $data;
    }
    public static function telegramdata()
    {
        $data = TelegramMessage::first();
        return $data;
    }
    public static function stripe_data()
    {
        return Payment::select('environment', 'public_key', 'secret_key', 'currency')->where('id', '=', 4)->where('is_available', 1)->first();
    }
    public static function check_alert()
    {
        if (@helper::appdata()->max_order_qty != "" && @helper::appdata()->min_order_amount != "" && @helper::appdata()->max_order_amount != "" && @helper::appdata()->address != "" && @helper::appdata()->firebase != "" && @helper::appdata()->map != "") {
            return 1;
        } else {
            return 0;
        }
    }
    public static function check_restaurant_closed()
    {
        if (@helper::appdata()->timezone != "") {
            date_default_timezone_set(helper::appdata()->timezone);
        }
        $checkstatus = User::find(Auth::user()->id);
        return $checkstatus->is_online;
    }
    public static function date_format($date)
    {
        return date(helper::appdata()->date_format, strtotime($date));
    }
    public static function date_time_format($date)
    {
        if (helper::appdata()->time_format == 1) {
            return $date->format('H:i');
        } else {
            return $date->format('h:i A');
        }
    }
    public static function number_format($number)
    {
        // $number = (float)$number;
        // return number_format($number, 2, '.', '');
        return $number;
    }


    public static function is_in_polygon($points_polygon, $vertices_x, $vertices_y, $longitude_x, $latitude_y)
    {
        $i = $j = $c = 0;
        for ($i = 0, $j = $points_polygon - 1; $i < $points_polygon; $j = $i++) {
            if ((($vertices_y[$i] > $latitude_y != ($vertices_y[$j] > $latitude_y)) &&
                ($longitude_x < ($vertices_x[$j] - $vertices_x[$i]) * ($latitude_y - $vertices_y[$i]) / ($vertices_y[$j] - $vertices_y[$i]) + $vertices_x[$i])))
                $c = !$c;
        }

        if ($c == true) {
            return 1;
        } else {
            return 0;
        }
    }

    public static function verificationsms($mobile, $otp)
    {
        try {
            $getconfiguration = OTPConfiguration::where('status', 1)->first();
            if (!empty($getconfiguration)) {
                if ($getconfiguration->name == "twilio") {
                    $sid    = $getconfiguration->twilio_sid;
                    $token  = $getconfiguration->twilio_auth_token;
                    $twilio = new Client($sid, $token);
                    $message = $twilio->messages->create($mobile, array("from" => $getconfiguration->twilio_mobile_number, "body" => "Your Verification Code is : " . $otp));
                }
                if ($getconfiguration->name == "msg91") {
                    $curl = curl_init();
                    curl_setopt_array($curl, array(
                        CURLOPT_URL => "https://api.msg91.com/api/v5/otp?template_id=" . $getconfiguration->msg_template_id . "&mobile=" . $mobile . "&authkey=" . $getconfiguration->msg_authkey . "",
                        CURLOPT_RETURNTRANSFER => true,
                        CURLOPT_ENCODING => "",
                        CURLOPT_MAXREDIRS => 10,
                        CURLOPT_TIMEOUT => 30,
                        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                        CURLOPT_CUSTOMREQUEST => "GET",
                        CURLOPT_HTTPHEADER => array("content-type: application/json"),
                    ));
                    $response = curl_exec($curl);
                    $err = curl_error($curl);
                    curl_close($curl);
                }
                return 1;
            }
            return 0;
        } catch (\Throwable $th) {
            return 0;
        }
    }
    public static function check_review_exist($user_id)
    {
        $data = Ratting::where('user_id', $user_id)->first();
        if (!empty($data)) {
            return 1;
        }
        return 0;
    }
    public static function getavgreviews($item_id)
    {
        $testimonials = Ratting::with('user_info')->select(DB::raw('ROUND(AVG(testimonials.star),1) as ratings_average'))->where('item_id', $item_id)->where('status', 1)->first();
        return $testimonials;
    }
    public static function get_theme()
    {
        $setting = About::first();
        return $setting->theme;
    }

    // front
    public static function footer_features()
    {
        return FooterFeatures::select('id', 'icon', 'title', 'description')->orderByDesc('id')->get();
    }
    public static function get_categories()
    {
        return Category::select('id', 'category_name', 'slug', 'image')->where('is_available', '=', '1')->where('is_deleted', '2')->orderBy('reorder_id')->get();
    }
    public static function get_item_cart($item_id)
    {
        if (Auth::user()) {
            return Cart::where('item_id', $item_id)->where('user_id', Auth::user()->id)->sum('qty');
        } else {
            return Cart::where('item_id', $item_id)->where('session_id', Session::getId())->sum('qty');
        }
    }

    public static function language()
    {
        $lang = Languages::where('is_available', '1')->get();
        if (session()->get('locale') == null) {
            $layout = Languages::select('name', 'layout', 'image', 'is_default', 'code')->where('is_default', 1)->first();
            App::setLocale($layout->code);
            session()->put('locale', $layout->code);
            session()->put('language', $layout->name);
            session()->put('flag', $layout->image);
            session()->put('direction', $layout->layout);
        } else {
            $layout = Languages::select('name', 'layout', 'image', 'is_default', 'code')->where('code', session()->get('locale'))->first();
            App::setLocale(session()->get('locale'));
            session()->put('locale', @$layout->code);
            session()->put('language', @$layout->name);
            session()->put('flag', @$layout->image);
            session()->put('direction', @$layout->layout);
        }
        return $lang;
    }

    // display dynamic paymant name
    public static function getpayment($payment_type)
    {
        $payment = Payment::select('payment_name')->where('payment_type', $payment_type)->first();
        return $payment->payment_name;
    }
    public static function gettax($tax_id)
    {
        $taxArr = explode('|', $tax_id);
        $taxes = [];
        foreach ($taxArr as $tax) {
            $taxes[] = Tax::find($tax);
        }
        return $taxes;
    }

    public static function taxRate($taxRate, $price, $quantity, $tax_type)
    {
        if ($tax_type == 1) {
            return $taxRate * $quantity;
        }

        if ($tax_type == 2) {
            return ($taxRate / 100) * ($price * $quantity);
        }
    }
    // dynamic email configration
    public static function emailconfigration()
    {
        $mailsettings = About::first();
        $emaildata = [];
        if ($mailsettings) {
            $emaildata = [
                'driver' => $mailsettings->mail_driver,
                'host' => $mailsettings->mail_host,
                'port' => $mailsettings->mail_port,
                'encryption' => $mailsettings->mail_encryption,
                'username' => $mailsettings->mail_username,
                'password' => $mailsettings->mail_password,
                'from'     => ['address' => $mailsettings->mail_fromaddress, 'name' => $mailsettings->mail_fromname]
            ];
        }
        return $emaildata;
    }
    public static function getsociallinks()
    {
        $links = SocialLinks::get();
        return $links;
    }
    // diplay all paymane images in footer
    public static function getallpayment()
    {
        $payment = Payment::where('is_available', '1')->where('is_activate', 1)->orderBy('reorder_id')->get();
        return $payment;
    }
    public static function allpaymentcheckaddons()
    {
        $getpaymentmethods = Payment::where('is_available', '1')->where('is_activate', 1)->whereNot('payment_type', 16)->get();
        foreach ($getpaymentmethods as $pmdata) {
            $systemAddonActivated = false;
            $addon = App\Models\SystemAddons::where('unique_identifier', $pmdata->unique_identifier)->first();
            if ($addon != null && $addon->activated == 1) {
                $systemAddonActivated = true;
                break;
            }
        }
        return $systemAddonActivated;
    }

    public static function imagesize()
    {
        $imagesize  = (int)1024 * (int)helper::appdata('')->image_size;
        return $imagesize;
    }
    public static function imageext()
    {
        $imageext = 'mimes:jpeg,jpg,png,webp';
        return $imageext;
    }
    public static function gettype($status, $type, $order_type)
    {
        $status = CustomStatus::where('order_type', $order_type)->where('type', $type)->where('id', $status)->first();
        return $status;
    }
    public static function customstauts($order_type)
    {
        $status = CustomStatus::where('order_type', $order_type)->where('is_available', 1)->where('is_deleted', 2)->orderBy('reorder_id')->get();
        return $status;
    }
    public static function getpixelid()
    {
        $pixcel = Pixcel::first();
        return $pixcel;
    }
    public static function imageresize($file, $directory_name)
    {
        $reimage = 'item-' . uniqid() . "." . $file->getClientOriginalExtension();

        $new_width = 1000;

        // create image manager with desired driver      

        $manager = new ImageManager(new Driver());

        // read image from file system
        $image = $manager->read($file);


        // Get Height & Width
        list($width, $height) = getimagesize("$file");

        // Get Ratio
        $ratio = $width / $height;

        // Create new height & width
        $new_height = $new_width / $ratio;

        // resize image proportionally to 200px width
        $image->scale(width: $new_width, height: $new_height);

        $extension = File::extension($reimage);

        $exif = @exif_read_data("$file");

        $degrees = 0;
        if (isset($exif['Orientation'])) {
            switch ($exif['Orientation']) {
                case 8:
                    $degrees = 90;
                    break;
                case 3:
                    $degrees = 180;
                    break;
                case 6:
                    $degrees = -90;
                    break;
            }
        }

        // $image->rotate($degrees);
        $convert = $image;
        if (Str::endsWith($reimage, '.jpeg')) {
            $convert = $convert->toJpeg();
        } else if (Str::endsWith($reimage, '.jpg')) {
            $convert = $convert->toJpeg();
        } else if (Str::endsWith($reimage, '.webp')) {
            $convert = $convert->toWebp();
        } else if (Str::endsWith($reimage, '.gif')) {
            $convert = $convert->toGif();
        } else if (Str::endsWith($reimage, '.png')) {
            $convert = $convert->toPng();
        } else if (Str::endsWith($reimage, '.avif')) {
            $convert = $convert->toAvif();
        } else if (Str::endsWith($reimage, '.bmp')) {
            $convert = $convert->toBitmap();
        }
        if ($extension == "webp") {
            $convertimg = $reimage;
        } else {
            $convertimg = str_replace($extension, 'webp', $reimage);
        }


        $convert->save("$directory_name/$convertimg");

        return $convertimg;
    }
    public static function role($id)
    {
        $role = RoleManager::select('role')->where('id', $id)->first();
        return $role;
    }
    public static function check_menu($role_id, $slug)
    {
        if ($role_id == "" || $role_id == null || $role_id == 0) {
            return 1;
        } else {
            $module = RoleManager::where('id', $role_id)->first();
            $module = explode('|', $module->module);
            if (in_array($slug, $module)) {
                return 1;
            } else {

                return 0;
            }
        }
    }
    public static function check_access($module, $role_id, $action)
    {

        $module = RoleAccess::where('module_name', $module)->where('role_id', $role_id)->first();
        if (!empty($module) && $module != null) {
            if ($action == 'add' && $module->add == 1) {
                return 1;
            } elseif ($action == 'edit' && $module->edit == 1) {
                return 1;
            } elseif ($action == 'delete' && $module->delete == 1) {
                return 1;
            } elseif ($action == 'manage' && $module->manage == 1) {
                return 1;
            } else {
                return 0;
            }
        } else {
            return 0;
        }
    }
    public static function top_deals()
    {
        date_default_timezone_set(helper::appdata()->timezone);
        $current_date  = Carbon::now()->format('Y-m-d');
        $current_time  = Carbon::now()->format('H:i:s');
        $topdeal = TopDeals::first();
        $topdeals = null;
        if (SystemAddons::where('unique_identifier', 'top_deals')->first() != null && SystemAddons::where('unique_identifier', 'top_deals')->first()->activated == 1) {
            if (isset($topdeal) && $topdeal->top_deals_switch == 1) {
                $startDate = $topdeal['start_date'];
                $starttime = $topdeal['start_time'];
                $endDate = $topdeal['end_date'];
                $endtime = $topdeal['end_time'];
                // Checking validity of top deal offer
                if ($topdeal->deal_type == 1) {
                    if ($current_date > $startDate) {
                        if ($current_date < $endDate) {
                            $topdeals = TopDeals::first();
                        } elseif ($current_date == $endDate) {
                            if ($current_time < $endtime) {
                                $topdeals = TopDeals::first();
                            }
                        }
                    } elseif ($current_date == $startDate) {
                        if ($current_date < $endDate && $current_time >= $starttime) {
                            $topdeals = TopDeals::first();
                        } elseif ($current_date == $endDate) {
                            if ($current_time >= $starttime && $current_time <= $endtime) {
                                $topdeals = TopDeals::first();
                            }
                        }
                    }
                } else if ($topdeal->deal_type == 2) {
                    if ($current_time >= $starttime && $current_time <= $endtime) {
                        $topdeals = TopDeals::first();
                    }
                }
            }
        }
        return $topdeals;
    }

    public static function topdealitemlist()
    {
        $user_id = @Auth::user()->id;
        $session_id = Session::getId();
        if ($user_id != null) {
            $topdealsproducts = Item::with('category_info', 'subcategory_info', 'variation', 'item_image')->select('item.*', DB::raw('(case when favorite.item_id is null then 0 else 1 end) as is_favorite'), DB::raw('(case when item.price is null then 0 else item.price end) as item_price'), DB::raw('(case when cart.item_id is null then 0 else 1 end) as is_cart'))
                ->leftJoin('favorite', function ($query) use ($user_id) {
                    $query->on('favorite.item_id', '=', 'item.id')
                        ->where('favorite.user_id', '=', $user_id);
                })
                ->leftJoin('cart', function ($query) use ($user_id) {
                    $query->on('cart.item_id', '=', 'item.id')
                        ->where('cart.user_id', '=', $user_id);
                })
                ->where('item.top_deals', '1')
                ->groupBy('item.id', 'cart.item_id')
                ->inRandomOrder()
                ->where('item.item_status', '1')
                ->where('item.is_deleted', 2)->get();
        } else {
            $topdealsproducts = Item::with('category_info', 'subcategory_info', 'variation', 'item_image')->select('item.*', DB::raw('(case when item.price is null then 0 else item.price end) as item_price'), DB::raw('(case when cart.item_id is null then 0 else 1 end) as is_cart'))
                ->leftJoin('cart', function ($query) use ($session_id) {
                    $query->on('cart.item_id', '=', 'item.id')
                        ->where('cart.session_id', '=', $session_id);
                })
                ->where('item.top_deals', '1')
                ->groupBy('item.id', 'cart.item_id')
                ->inRandomOrder()
                ->where('item.item_status', '1')->where('item.is_deleted', 2)->get();
        }
        return $topdealsproducts;
    }

    public static function getcoupons()
    {
        $coupons = Promocode::where('is_available', 1)->where('start_date', '<=', date('Y-m-d'))->where('expire_date', '>=', date('Y-m-d'))->orderBy('reorder_id')->get();
        $data = array();
        foreach ($coupons as $prod) {
            $count = helper::getcouponcodecount($prod->offer_code);
            if ($prod->usage_type == 1) {
                if ($count < $prod->usage_limit) {
                    $data[] = $prod;
                }
            } else {
                $data[] = $prod;
            }
        }
        return $data;
    }
    public static function getcouponcodecount($coupon_code)
    {
        $count = Order::where('offer_code', $coupon_code)->count();
        return $count;
    }
    public static function gettiming()
    {
        $gettimings = Time::all();
        return $gettimings;
    }
    public static function checklowqty($item_id)
    {
        $item = Item::where('id', $item_id)->first();
        if ($item->has_variants == 1) {
            $qty = Variation::select('item_id', 'qty')->where('item_id', $item_id)->get();
            $array = [];

            foreach ($qty as $qty) {
                array_push($array, $qty->qty);
            }
            if (in_array(0, $array)) {
                return 2;
            }
            if (count(array_filter($array)) == 0) {
                return 3;
            }
            foreach ($array as $qty) {
                if ($qty != null && $qty != "") {
                    if ($qty <= $item->low_qty) {
                        return 1;
                    }
                }
            }
        } else {

            if ($item->qty == null && $item->qty == "") {
                return 3;
            }
            if ((string)$item->qty != null && (string)$item->qty != "") {
                if ((string)$item->qty == 0) {
                    return 2;
                }
                if ($item->qty <= $item->low_qty) {
                    return 1;
                }
            }
        }
    }

    public static function getagedetails()
    {
        $agedetails = AgeVerification::first();
        return $agedetails;
    }

    public static function checkaddons($addons)
    {
        if (str_contains(url()->current(), 'admin')) {
            if (session()->get('demo') == "free-addon") {
                $check = SystemAddons::where('unique_identifier', $addons)->where('activated', 1)->where('type', 1)->first();
            } elseif (session()->get('demo') == "all-addon") {
                $check = SystemAddons::where('unique_identifier', $addons)->where('activated', 1)->whereIn('type', ['1', '2'])->first();
            } else {
                $check = SystemAddons::where('unique_identifier', $addons)->where('activated', 1)->first();
            }
        } else {
            $check = SystemAddons::where('unique_identifier', $addons)->where('activated', 1)->first();
        }

        return $check;
    }

    public static function checkthemeaddons($addons)
    {
        if (session()->get('demo') == "free-addon") {
            $check = SystemAddons::where('unique_identifier', 'LIKE', '%' . $addons . '%')->where('activated', 1)->where('type', 1)->get();
        } elseif (session()->get('demo') == "all-addon") {
            $check = SystemAddons::where('unique_identifier', 'LIKE', '%' . $addons . '%')->where('activated', 1)->whereIn('type', ['1', '2', '3'])->get();
        } else {
            $check = SystemAddons::where('unique_identifier', 'LIKE', '%' . $addons . '%')->where('activated', 1)->get();
        }
        return $check;
    }


    // get currency list vendor side.
    public static function available_currency()
    {
        $listofcurrency = CurrencySettings::where('is_available', '1')->get();
        return $listofcurrency;
    }
    // get language list in athu pages.
    public static function currencyinfo()
    {
        if (Cookie::get('code') == null) {
            $currency = CurrencySettings::where('code', helper::appdata()->default_currency)->first();
            session()->put('currency', $currency->currency);
        } else {

            $currency = CurrencySettings::where('code', Cookie::get('code'))->first();
            if (empty($currency)) {
                $currency = CurrencySettings::where('code', helper::appdata()->default_currency)->first();
            }
            session()->put('currency', $currency->currency);
        }
        return $currency;
    }
}
© 2026 GrazzMean