403Webshell
Server IP : 138.197.107.151  /  Your IP : 216.73.217.7
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux BloxBy-Builder 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64
User : wpbetasites_mrakzqskir ( 1022)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/silversharkdev/app/Console/Commands/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/silversharkdev/app/Console/Commands/CreateWebsiteArchiveCommand.php
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\Website;
use App\Models\WebsitesArchiveRequest;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Mail;

class CreateWebsiteArchiveCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:create-website-archive-command';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        //
        $archives = WebsitesArchiveRequest::where("status","pending")->limit(1)->get();

        $archives_inprogress = WebsitesArchiveRequest::where("status","inprogress")->count();

        if($archives_inprogress==0){
            foreach($archives as $archive){

                try{

                    $website = Website::where("id", $archive->website_id)->first();

                    if($website){
                        $archive->status = "inprogress";

                        $archive->save();

                        $server_meta = json_decode($website->server_meta,true);

                        $environment = env("ENVIRONMENT");
                        
                        $process = new Process([
                            'sudo',
                            '/var/bloxbycommands/create_zip.sh',
                            '--site-id='. $server_meta["site"],
                            '--wp-path='. "/var/www/". $server_meta["folder"]."/".$server_meta["slug_environment"]."_".$server_meta["site"]."/public_html",
                            '--backup-path='. "/var/www/website_zips",
                            '--environment='.$environment
                        ]);

                        $process->setTimeout(900); // Increase for long tasks

                        $process->run();

                       

                        if (!$process->isSuccessful()) {

                            $archive->status = "error";

                            $archive->error =  $process->getErrorOutput();

                            $archive->save();

                            
                        } else {

                            $backup = $process->getOutput(); 

                            $backup_array = explode("/",$backup);
                            
                            $archive->status = "completed";

                            $archive->backup_file = end($backup_array);

                            $archive->save();
                            
                            $archives_already_completed = WebsitesArchiveRequest::where("status","completed")->where("id","!=",$archive->id)->limit(1)->orderBy("id","desc")->get();

                            foreach($archives_already_completed as $ach){
                                @unlink("/var/www/website_zips/".$environment."/".$ach->backup_filename);
                            }
                            if($website->user){

                                Mail::send('emails.backup_generated', [
                                    'user' => $website->user,
                                    'website' => $website,
                                    "domain" => @$server_meta["domain"],
                                    "backup_link" => "https://backups.". \config('app.SITE_DOMAIN') ."/".$environment."/".end($backup_array)
                                ], function ($message) use ($website) {
                                    $message->to($website->user->email);
                                    $message->subject('Your Website archive is Ready - ' . env('APP_NAME'));
                                });
                            }

                        
                        }
                    } else {
                        $archive->status = "error";

                        $archive->error = "website not exist";

                        $archive->save();
                    }
                    
                    
                    

                } catch(Exception $e){
                    
                    //echo 9898; die;
                    
                    $archive->status = "error";

                    $archive->error = $e->getMessage();

                    $archive->save();
                }
            }
        }
        
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit