Uname:Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64

Base Dir : /var/www/machinox.in

User : root


403WebShell
403Webshell
Server IP : 13.235.167.51  /  Your IP : 216.73.217.116
Web Server : Apache
System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64
User : root ( 0)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/app.machinox.in/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/app.machinox.in/app/Http/Controllers/CommonController.php
<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Models\AppVersion;
use App\Models\Country;
use App\Models\DropdownList;
use App\Models\State;
use App\Models\StaticContent;
use App\Models\UserDevice;
use App\Traits\UploadTrait;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use stdClass;

class CommonController extends Controller
{
    use UploadTrait;

    public function getStatic(Request $request, $code)
    {
        $codeInfo = StaticContent::where("code", strtoupper($code))
            ->first();
        if ($codeInfo) {
            return view('static-page', ['info' => $codeInfo]);
        } else {
            return view('no-view');
        }
    }
    public function RegisterDevice(Request $request)
    {
        if ($request->has('token') && $request->has('type')) {
            UserDevice::where('type', $request->input('type'))
                ->where('token', $request->input('token'))
                ->delete();

            UserDevice::where("user_id", USER_ID())->delete();

            $device = new UserDevice();
            $device->user_id = USER_ID();
            $device->token = $request->input('token');
            $device->type = $request->input('type');
            $device->save();
        }

        return $this->sendSuccess(trans('messages.DEVICE_REGISTERED_SUCCESSFULLY'));
    }


    public function UnregisterDevice(Request $request)
    {
        if ($request->has('token') && $request->has('type')) {
            $device = UserDevice::where('type', $request->input('type'))
                ->where('token', $request->token)->first();
            if ($device) {
                $device->delete();
            }
        }
        return $this->sendSuccess(trans('messages.DEVICE_UNREGISTERED_SUCCESSFULLY'));
    }

    public function GetCountries(Request $request)
    {
        $keyword = $request->input('keyword');
        try {
            $list = Country::where('status', 'ACTIVE')
                ->when($keyword, function ($qu) use ($keyword) {
                    return $qu->where('title', 'like', "%$keyword%");
                })->orderBy('title', 'ASC')->limit(5)->select("id", "title");
            $data['list'] = $list->get();
            $data['count'] = $list->count();
            return $this->sendSuccess("success", $data);
        } catch (Exception $th) {
            return $this->sendError($th->getMessage());
        }
    }

    public function GetStates(Request $request)
    {
        $keyword = $request->input('keyword');
        try {
            $list = State::when($keyword, function ($qu) use ($keyword) {
                return $qu->where('name', 'like', "%$keyword%");
            })->orderBy('name', 'ASC')->select("name");
            $data['list'] = $list->get();
            $data['count'] = $list->count();
            return $this->sendSuccess("success", $data);
        } catch (Exception $th) {
            return $this->sendError($th->getMessage());
        }
    }

    public function GetYears(Request $request)
    {
        try {
            $startYear = 2000;
            $currentYear = date('Y');
            $years = [];

            for ($year = $startYear; $year <= $currentYear; $year++) {
                $years[] = [
                    'name' => (string) $year,
                    'value' => (string) $year,
                ];
            }
            $data['list'] = $years;
            return $this->sendSuccess("success", $data);
        } catch (Exception $th) {
            return $this->sendError($th->getMessage());
        }
    }

    public function GetServerLogs()
    {
        $logPath = storage_path('logs/laravel.log');

        if (!File::exists($logPath)) {
            return response()->json(['message' => 'Log file not found.'], 404);
        }

        // Read the last N lines (optional: set limit)
        $logContent = File::get($logPath);

        return response()->json([
            'log' => $logContent
        ]);
    }

    public function setServerLogs()
    {
        $logPath = storage_path('logs/laravel.log');

        if (!File::exists($logPath)) {
            return response()->json(['message' => 'Log file not found.'], 404);
        }

        $logContent = File::put($logPath, '');

        return response()->json([
            'log' => $logContent
        ]);
    }

    public function GetBoostLogs()
    {
        $logPath = storage_path('logs/boost_ads_notification.log');

        // If file does not exist, create it with empty content
        if (!File::exists($logPath)) {
            File::put($logPath, ''); // creates empty file
        }

        // Read the log file contents
        $logContent = File::get($logPath);

        return response()->json([
            'log' => $logContent
        ]);
    }

    public function CheckAppVersion(Request $request)

    {

        $device = $request->input("device_type");
        Log::info("Device: $device");
        $version = $request->input("version");
        Log::info("Payload version: $version");
        $info = new stdClass;

        $versionInfo = AppVersion::where(DB::raw("LOWER(device_type)"), strtolower($device))

            ->first();

        $androidVersion = config('services.app_versions.android') ?? "1.1";
        
        $iosVersion = config('services.app_versions.ios') ?? "1.1";
        Log::info("Android version threshold: $androidVersion");

        Log::info("iOS version threshold: $iosVersion");



        if ($versionInfo) {

            if (version_compare($version, $versionInfo->version) >= 0) {

                $versionInfo->has_update_available = false;
            }

            if (version_compare($version, $versionInfo->version) < 0) {

                $versionInfo->has_update_available = true;

                $versionInfo->has_review = 0;
            }


            Log::info("Version compare result (iOS): " . version_compare($version, $iosVersion));
            Log::info("Version compare result (Android): " . version_compare($version, $androidVersion));
            if (strtolower($device) == 'ios' && version_compare($version, $iosVersion) >= 0) {

                $versionInfo->has_review = 1; // For hiding Subscrition Flow.

            } else  if (strtolower($device) == 'android' && version_compare($version, $androidVersion) >= 0) {

                $versionInfo->has_review = 1; // For hiding Subscrition Flow.

            } else {

                $versionInfo->has_review = 0; // For hiding Subscrition Flow.

            }



            $info->message = 'Okay';

            $info->data = $versionInfo;

            return response()->json($info);
        }



        $info->message = "Sorry, something went wrong!";

        return response()->json($info, 400);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit