GRAYBYTE WORDPRESS FILE MANAGER4795

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/trustyourlawyer.com/wp-content/plugins/backwpup/inc/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/trustyourlawyer.com/wp-content/plugins/backwpup/inc//class-wp-cli.php
<?php

use WP_CLI\Formatter;

/**
 * Class for WP-CLI commands.
 */
class BackWPup_WP_CLI extends WP_CLI_Command
{
    /**
     * Start a BackWPup job.
     *
     * # EXAMPLES
     *
     *   backwpup start 13
     *   backwpup start --jobid=13 (deprecated)
     *
     * @param $args
     * @param $assoc_args
     */
    public function start($args, $assoc_args)
    {
        $jobid = 0;

        if (file_exists(BackWPup::get_plugin_data('running_file'))) {
            WP_CLI::error(__('A job is already running.', 'backwpup'));
        }

        if (isset($assoc_args['jobid'])) {
            $jobid = (int) $assoc_args['jobid'];
        }

        if (!empty($args[0])) {
            $jobid = (int) $args[0];
        }

        if (empty($jobid)) {
            WP_CLI::error(__('No job ID specified!', 'backwpup'));
        }

        $jobids = BackWPup_Option::get_job_ids();
        if (!in_array($jobid, $jobids, true)) {
            WP_CLI::error(__('Job ID does not exist!', 'backwpup'));
        }

        BackWPup_Job::start_cli($jobid);
    }

    /**
     *  Abort a working BackWPup Job.
     */
    public function abort($args, $assoc_args)
    {
        if (!file_exists(BackWPup::get_plugin_data('running_file'))) {
            WP_CLI::error(__('Nothing to abort!', 'backwpup'));
        }

        //abort
        BackWPup_Job::user_abort();
        WP_CLI::success(__('Job will be terminated.', 'backwpup'));
    }

    /**
     * Display a List of Jobs.
     */
    public function jobs($args, $assoc_args)
    {
        $formatter_args = [
            'format' => 'table',
            'fields' => [
                'Job ID',
                'Name',
            ],
            'field' => null,
        ];

        $items = [];

        $formatter = new Formatter($formatter_args);

        $jobids = BackWPup_Option::get_job_ids();

        foreach ($jobids as $jobid) {
            $items[] = [
                'Job ID' => $jobid,
                'Name' => BackWPup_Option::get($jobid, 'name'),
            ];
        }

        $formatter->display_items($items);
    }

    /**
     * See Status of a working job.
     *
     * @param $args
     * @param $assoc_args
     */
    public function working($args, $assoc_args)
    {
        $job_object = BackWPup_Job::get_working_data();

        if (!is_object($job_object)) {
            WP_CLI::error(__('No job running', 'backwpup'));
        }

        $formatter_args = [
            'format' => 'table',
            'fields' => [
                'JobID',
                'Name',
                'Warnings',
                'Errors',
                'On Step',
                'Done',
            ],
            'field' => null,
        ];

        $formatter = new Formatter($formatter_args);

        $items = [];
        $items[] = [
            'JobID' => $job_object->job['jobid'],
            'Name' => $job_object->job['name'],
            'Warnings' => $job_object->warnings,
            'Errors' => $job_object->errors,
            'On Step' => $job_object->steps_data[$job_object->step_working]['NAME'],
            'Done' => $job_object->step_percent . ' / ' . $job_object->substep_percent,
            'Last message' => str_replace('&hellip;', '...', strip_tags((string) $job_object->lastmsg)),
        ];

        $formatter->display_items($items);

        WP_CLI::log('Last Message: ' . str_replace('&hellip;', '...', strip_tags((string) $job_object->lastmsg)));
    }

	/**
	 * Decrypt an BackWPup archive.
	 *
     * # EXAMPLES
	 *
	 *   backwpup decrypt archiv.zip
	 *   backwpup decrypt achriv.tar.gz --key="ABCDEFGHIJKLMNOPQRSTUVWXYZ123456"
	 *   backwpup decrypt archiv.zip --key="./id_rsa_backwpup.pri"
	 *
	 * @param $args
	 * @param $assocArgs
	 */
	public function decrypt( $args, $assocArgs ) {
		$key = '';
		if ( isset( $assocArgs['key'] ) ) {
			if ( is_file( $assocArgs['key'] ) ) {
				$key = file_get_contents( $assocArgs['key'], false );
			} else {
				$key = $assocArgs['key'];
			}
		} else {
			$decryptionType = get_site_option( 'backwpup_cfg_encryption' );
			if ( $decryptionType === 'symmetric' ) {
				$key = get_site_option( 'backwpup_cfg_encryptionkey' );
			}
		}

		if ( ! $key ) {
			WP_CLI::error( __( 'No Key provided or stored in settings for decryption!', 'backwpup' ) );
		}

		if ( $args[0] && is_file( $args[0] ) ) {
			$archiveFile = $args[0];
		} else {
			WP_CLI::error( __( 'Archive file that should be decrypted can\'t be found!', 'backwpup' ) );
		}

		/** @var \Inpsyde\Restore\Api\Module\Decryption\Decrypter $decrypter */
		$decrypter = Inpsyde\BackWPup\Infrastructure\Restore\restore_container( 'decrypter' );
		if ( ! $decrypter->isEncrypted( $archiveFile ) ) {
			WP_CLI::error( __( 'Archive not needs decryption.', 'backwpup' ) );
		}

		try {
			$decrypter->decrypt( $key, $archiveFile );
		} catch ( \Exception $e ) {
			WP_CLI::error( sprintf( __( 'Cannot decrypt: %s', 'backwpup' ), $e->getMessage() ) );
		}

		WP_CLI::success( __( 'Archive has been successfully decrypted.', 'backwpup' ) );
	}

	/**
	 * Encrypt an BackWPup archive.
	 *
     * # EXAMPLES
	 *
	 *   backwpup encrypt achriv.tar.gz
	 *   backwpup encrypt achriv.tar.gz -key="ABCDEFGHIJKLMNOPQRSTUVWXYZ123456"
	 *   backwpup encrypt archiv.zip -keyfile="./id_rsa_backwpup.pub"
	 *
	 * @param $args
	 * @param $assocArgs
	 */
	public function encrypt( $args, $assocArgs ) {
		$aesIv     = \phpseclib3\Crypt\Random::string( 16 );
		$rsaPubKey = '';
		$type      = Inpsyde\BackWPup\Infrastructure\Security\EncryptionStream::TYPE_SYMMETRIC;
		if ( isset( $assocArgs['key'] ) ) {
			if ( is_file( $assocArgs['key'] ) ) {
				$key       = \phpseclib3\Crypt\Random::string( 32 );
				$rsaPubKey = file_get_contents( $assocArgs['key'], false );
				$type      = Inpsyde\BackWPup\Infrastructure\Security\EncryptionStream::TYPE_ASYMMETRIC;
			} else {
				$key = pack( 'H*', $assocArgs['key'] );
			}
		} else {
			$encryptionType = get_site_option( 'backwpup_cfg_encryption' );
			if ( $encryptionType !== 'symmetric' ) {
				$key       = \phpseclib3\Crypt\Random::string( 32 );
				$rsaPubKey = get_site_option( 'backwpup_cfg_publickey' );
				$type      = Inpsyde\BackWPup\Infrastructure\Security\EncryptionStream::TYPE_ASYMMETRIC;
			} else {
				$key = pack( 'H*', get_site_option( 'backwpup_cfg_encryptionkey' ) );
			}
		}

		if ( ! $key ) {
			WP_CLI::error( __( 'No Key provided or stored in settings for encryption!', 'backwpup' ) );
		}

		if ( $args[0] && is_file( $args[0] ) ) {
			$archiveFile = $args[0];
		} else {
			WP_CLI::error( __( 'Archive file that should be encrypted can\'t be found!', 'backwpup' ) );
		}

		if ( $type === Inpsyde\BackWPup\Infrastructure\Security\EncryptionStream::TYPE_SYMMETRIC ) {
			WP_CLI::log( __( 'Symmetric encryption will be used for the archive.', 'backwpup' ) );
		} else {
			WP_CLI::log( __( 'Asymmetric encryption will be used for the archive.', 'backwpup' ) );
		}

		try {
			$fileIn = GuzzleHttp\Psr7\Utils::streamFor( GuzzleHttp\Psr7\Utils::tryFopen( $archiveFile, 'r' ) );
		} catch ( \RuntimeException $e ) {
			WP_CLI::error( __( 'Cannot open the archive for reading. Aborting encryption.', 'backwpup' ) );
		}

		try {
			$fileOut = GuzzleHttp\Psr7\Utils::tryFopen( $archiveFile . '.encrypted', 'a+' );
		} catch ( \RuntimeException $e ) {
			WP_CLI::error( __( 'Cannot write the encrypted archive. Aborting encryption.', 'backwpup' ) );
		}

		$encryptor = new Inpsyde\BackWPup\Infrastructure\Security\EncryptionStream(
			$aesIv,
			$key,
			GuzzleHttp\Psr7\Utils::streamFor( $fileOut ),
			$rsaPubKey
		);

		if ( ! $encryptor ) {
			WP_CLI::error( __( 'Could not initialize encryptor.', 'backwpup' ) );
		}

		$blockSize = 128 * 1024;
		while ( ! $fileIn->eof() ) {
			$data = $fileIn->read( $blockSize );
			$encryptor->write( $data );
		}
		$fileIn->close();
		$encryptor->close();

		if ( ! unlink( $archiveFile ) ) {
			WP_CLI::error( __( 'Unable to delete unencrypted archive.', 'backwpup' ) );
		}
		if ( ! rename( $archiveFile . '.encrypted', $archiveFile ) ) {
			WP_CLI::error( __( 'Unable to rename encrypted archive.', 'backwpup' ) );
		}
		WP_CLI::success( __( 'Archive has been successfully encrypted.', 'backwpup' ) );
	}

	/**
	 * Activate Legacy Jobs; Filter by all or selected job IDs
	 *
	 * @subcommand activate-legacy-job
	 *
	 * @param array $args        Positional arguments passed to the command.
	 * @param array $assoc_args  Associative arguments passed to the command (e.g --type, --jobIds).
	 * @return void
	 */
	public function activate_legacy_job( array $args, array $assoc_args ): void {
		// Check if mandatory flag exist.
		if ( ! isset( $assoc_args['type'] ) ) {
			WP_CLI::error( __( 'The --type flag is mandatory and must be specified.', 'backwpup' ) );
		}

		// Check if provided type is valid (must be either wpcron or link).
		if ( ! in_array( $assoc_args['type'], [ 'wpcron', 'link' ], true ) ) {
			WP_CLI::error( __( 'Invalid value for --type flag.', 'backwpup' ) );
		}

		$job_ids = isset( $assoc_args['jobIds'] ) ? explode( ',', $assoc_args['jobIds'] ) : [];

		// Check that all job ids are numeric.
		if ( ! empty( $job_ids ) && count( $job_ids ) !== count( array_filter( $job_ids, 'is_numeric' ) ) ) {
			WP_CLI::error( __( 'Invalid value for --jobIds flag provided.', 'backwpup' ) );
		}

		// Convert string ids to proper integers.
		$job_ids = array_map( 'intval', $job_ids );

		// Sanitize type value.
		$type = sanitize_text_field( wp_unslash( $assoc_args['type'] ) );

		WP_CLI::log( __( 'Activating legacy jobs.', 'backwpup' ) );

		// Get all jobs.
		$jobs = get_site_option( 'backwpup_jobs', [] );

		[ $filtered_jobs, $total_filtered_jobs ] = $this->filter_jobs_to_be_activated( $jobs, $job_ids, $type );

		// Bail out early if number of jobs to be updated is still 0.
		if ( 0 === $total_filtered_jobs ) {
			WP_CLI::warning( 'No job was updated.', 'backwpup' );
			return;
		}

		// Update jobs.
		update_site_option( 'backwpup_jobs', $filtered_jobs );
		WP_CLI::success(
			sprintf(
				// translators: %1$d = Number of jobs, %2$s = Success message.
				_n( '%1$d job %2$s', '%1$d jobs %2$s', $total_filtered_jobs, 'backwpup' ),
				$total_filtered_jobs,
				esc_html__( 'successfully activated', 'backwpup' )
			)
			);
	}

	/**
	 * Filters jobs to be activated based on job IDs and activation type.
	 *
	 * @param array  $jobs     Array of jobs to filter.
	 * @param array  $job_ids  Array of job IDs to activate. If empty, all legacy jobs will be activated.
	 * @param string $type     The activation type ('wpcron' or 'link').
	 *
	 * @return array An array containing the filtered jobs and the count of updated jobs.
	 */
	private function filter_jobs_to_be_activated( array $jobs, array $job_ids, string $type ) {
		$jobs_updated = 0;

		// Go over jobs and update only those with empty activeType and legacy set to 1.
		$jobs = array_map(
			function ( $job ) use ( $job_ids, $type, &$jobs_updated ) {
				// Filter out jobs that already have activetype set and not empty either legacy or not.
				if ( isset( $job['activetype'] ) && '' !== $job['activetype'] ) {
					return $job;
				}

				// Filter out non-legacy jobs.
				if ( ! isset( $job['legacy'] ) || ! $job['legacy'] ) {
						return $job;
				}

				// Activate legacy jobs with specified job ids.
				if ( ! empty( $job_ids ) && in_array( $job['jobid'], $job_ids, true ) ) {
					$job['activetype'] = $type;

					// Schedule next run for type of wpcron.
					if ( 'wpcron' === $type ) {
						wp_schedule_single_event( BackWPup_Cron::cron_next( $job['cron'] ), 'backwpup_cron', [ 'arg' => $job['jobid'] ] );
					}

					$jobs_updated++;
					return $job;
				}

				// Activate all legacy jobs.
				if ( empty( $job_ids ) ) {
					$job['activetype'] = $type;

					// Schedule next run for type of wpcron.
					if ( 'wpcron' === $type ) {
						wp_schedule_single_event( BackWPup_Cron::cron_next( $job['cron'] ), 'backwpup_cron', [ 'arg' => $job['jobid'] ] );
					}

					$jobs_updated++;
					return $job;
				}

				return $job;
			},
		$jobs
		);

		return [
			$jobs,
			$jobs_updated,
		];
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:29
giriqfky / giriqfky
0755
Notice
--
July 10 2025 04:32:37
giriqfky / giriqfky
0755
Settings
--
July 10 2025 04:32:37
giriqfky / giriqfky
0755
ThirdParty
--
July 10 2025 04:32:37
giriqfky / giriqfky
0755
Utils
--
July 10 2025 04:32:37
giriqfky / giriqfky
0755
dependencies
--
July 10 2025 04:32:37
giriqfky / giriqfky
0755
.htaccess
0.41 KB
July 10 2025 04:32:37
giriqfky / giriqfky
0644
BackWPup.php
11.618 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-admin.php
44.521 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-adminbar.php
2.676 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-create-archive-exception.php
0.148 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-create-archive.php
27.247 KB
March 10 2025 14:47:06
giriqfky / giriqfky
0644
class-cron.php
18.585 KB
April 29 2025 17:34:12
giriqfky / giriqfky
0644
class-destination-connect-exception.php
0.218 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-connect-interface.php
0.647 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-download-exception.php
0.202 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-downloader-data.php
1.223 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-downloader-factory.php
1.629 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-downloader-interface.php
0.52 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-downloader.php
5.126 KB
June 04 2024 10:51:14
giriqfky / giriqfky
0644
class-destination-dropbox-api-exception.php
0.129 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-dropbox-api-request-exception.php
0.595 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-dropbox-api.php
40.892 KB
February 13 2025 20:02:44
giriqfky / giriqfky
0644
class-destination-dropbox-downloader.php
2.907 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-destination-dropbox.php
21.399 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-destination-email.php
19.876 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-destination-folder-downloader.php
3.488 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-folder.php
10.113 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-destination-ftp-connect.php
5.373 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-ftp-downloader.php
3.351 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-ftp.php
29.519 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-destination-msazure-downloader.php
3.369 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-msazure.php
26.319 KB
February 04 2025 14:50:44
giriqfky / giriqfky
0644
class-destination-rsc.php
22.318 KB
March 21 2025 15:27:30
giriqfky / giriqfky
0644
class-destination-s3-downloader.php
3.298 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-s3.php
48.635 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-destination-sugarsync.php
38.054 KB
February 04 2025 14:50:44
giriqfky / giriqfky
0644
class-destinations.php
6.154 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-directory.php
6.025 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-download-file-interface.php
0.609 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-download-file.php
3.406 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-download-handler.php
1.956 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-easycron.php
8.057 KB
October 01 2024 16:10:48
giriqfky / giriqfky
0644
class-encryption-fallback.php
2.875 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-encryption-mcrypt.php
4.014 KB
March 03 2025 19:19:24
giriqfky / giriqfky
0644
class-encryption-openssl.php
3.925 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-encryption.php
6.265 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-factory-exception.php
0.191 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-file.php
10.787 KB
March 13 2025 16:05:40
giriqfky / giriqfky
0644
class-help.php
1.745 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-install.php
18.464 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-job.php
105.758 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-jobtype-dbcheck.php
6.386 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-jobtype-dbdump.php
11.304 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-jobtype-file.php
24.155 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-jobtype-wpexp.php
34.94 KB
March 13 2025 16:05:40
giriqfky / giriqfky
0644
class-jobtype-wpplugin.php
6.864 KB
March 03 2025 19:19:24
giriqfky / giriqfky
0644
class-jobtypes.php
2.25 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-message-box.php
3.464 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-migrate.php
10.691 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-msazure-destination-configuration.php
1.597 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-mysqldump.php
34.067 KB
June 19 2024 12:40:40
giriqfky / giriqfky
0644
class-option.php
18.498 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-page-about.php
27.481 KB
June 19 2024 12:40:40
giriqfky / giriqfky
0644
class-page-backups.php
20.81 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-page-backwpup.php
21.946 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-page-editjob.php
47.442 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-page-firstbackup.php
0.556 KB
February 04 2025 14:50:44
giriqfky / giriqfky
0644
class-page-jobs.php
44.727 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-page-logs.php
13.824 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-page-onboarding.php
6.948 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-page-restore.php
5.368 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-page-settings.php
45.41 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-path-fixer.php
0.815 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-recursive-directory.php
0.573 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-s3-destination.php
11.986 KB
March 13 2025 16:05:40
giriqfky / giriqfky
0644
class-sanitize-path.php
1.547 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-system-requirements.php
1.231 KB
October 01 2024 16:10:48
giriqfky / giriqfky
0644
class-system-tests-runner.php
9.5 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-system-tests.php
3.469 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-thirdparties.php
1.023 KB
June 19 2024 12:40:40
giriqfky / giriqfky
0644
class-wp-api.php
43.999 KB
April 29 2025 17:34:12
giriqfky / giriqfky
0644
class-wp-cli.php
11.83 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
functions.php
5.883 KB
April 30 2025 17:12:56
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF