GRAYBYTE WORDPRESS FILE MANAGER3052

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/chahida.co.in/wp-content/plugins/wp-optimize/includes/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/chahida.co.in/wp-content/plugins/wp-optimize/includes//class-re-smush-it-task.php
<?php
/**
 *  A sample implementation using the Resmush.it API and our tasks library
 */

if (!defined('ABSPATH')) die('Access denied.');

if (!class_exists('Re_Smush_It_Task')) :

class Re_Smush_It_Task extends Updraft_Smush_Task {

	public $label = 're-smush-it';

	const MAX_FILESIZE = 5242880;

	const API_URL = 'http://api.resmush.it/';

	/**
	 * Checks if the server is online
	 *
	 * @return boolean - true if yes, false otherwise
	 */
	public static function is_server_online() {
		
		global $wp_version;
		$test_image = WPO_PLUGIN_MAIN_PATH . 'images/icon/wpo.png';
		$boundary = wp_generate_password(12);
		$file_name = basename($test_image);

		$body = "--$boundary";
		$body .= "\r\n";
		$body .= "Content-Disposition: form-data; name=\"files\"; filename=\"$file_name\"\r\n";
		$body .= "\r\n";
		$body .= file_get_contents($test_image);
		$body .= "\r\n";
		$body .= "--$boundary";

		$request = array(
			'headers' => array( "content-type" => "multipart/form-data; boundary=$boundary" ),
			'user-agent' => "WordPress $wp_version/WP-Optimize ".WPO_VERSION.' - anonymous', // Anonymous until Resmushit has a clear privacy statement that we can link to
			'timeout' => 10,
			'body' => $body,
		);

		$response = wp_remote_post(self::API_URL, $request);

		if (is_wp_error($response)) {
			update_option(__CLASS__, $response->get_error_message());
			return false;
		}

		$data = json_decode(wp_remote_retrieve_body($response));


		if (empty($data)) {
			update_option(__CLASS__, "Empty data returned by server");
			return false;
		}

		if (isset($data->error)) {
			update_option(__CLASS__, $data->error_long);
			return false;
		}

		return true;
	}
	
	/**
	 * Prepares the image as part of the post data for the specific implementation
	 *
	 * @param String $local_file - The image to e optimised
	 * @param array  $options    - Eventual options
	 */
	public function prepare_post_request($local_file, $options) {
		global $wp_version;
		
		$boundary = wp_generate_password(12);
		$headers  = array( "content-type" => "multipart/form-data; boundary=$boundary" );

		$lossy = $this->get_option('lossy_compression');

		if ($lossy) {
			$quality = $this->get_option('image_quality');
		} else {
			$quality = 92;
		}

		if (isset($options['quality']) && is_int($options['quality']) && 0 < $options['quality']) $quality = $options['quality'];

		$post_fields = array(
			'qlty' => $quality,
			'exif' => $this->get_option('preserve_exif', false)
		);
		$payload = '';
		$file_name = basename($local_file);

		foreach ($post_fields as $name => $value) {
			$payload .= "--$boundary";
			$payload .= "\r\n";
			$payload .= "Content-Disposition: form-data; name='$name' \r\n\r\n $value";
			$payload .= "\r\n";
		}

		$payload .= "--$boundary";
		$payload .= "\r\n";
		$payload .= "Content-Disposition: form-data; name=\"files\"; filename=\"$file_name\"\r\n";
		$payload .= "\r\n";
		$payload .= file_get_contents($local_file);
		$payload .= "\r\n";
		$payload .= "--$boundary";

		return array(
			'headers' => $headers,
			'timeout' => $this->get_option('request_timeout'),
			'user-agent' => "WordPress $wp_version/WP-Optimize ".WPO_VERSION.' - anonymous', // Anonymous until Resmushit has a clear privacy statement that we can link to
			'body' => $payload,
		);
	}

	/**
	 * Processes the response received from the remote server
	 *
	 * @param String $response - The response object
	 */
	public function process_server_response($response) {
		global $http_response_header;

		$response = parent::process_server_response($response);
		$data = json_decode(wp_remote_retrieve_body($response));

		if (!$data) {
			$this->log("Cannot establish connection with reSmush.it webservice. Please try later");
			return false;
		}

		if (isset($data->error)) {
			$this->fail($data->error, $data->error_long);
			return false;
		}

		if (!property_exists($data, 'dest')) {
			$this->fail("invalid_response", "The response does not contain the compressed file URL");
			$this->log("data: ".wp_json_encode($data));
			return false;
		}

		$compressed_image_response = wp_remote_get($data->dest);

		if (!is_wp_error($compressed_image_response)) {
			$image_contents = wp_remote_retrieve_body($compressed_image_response);
			if ($this->is_downloaded_image_buffer_mime_type_valid($image_contents)) {
				return $image_contents;
			} else {
				$this->log("The downloaded resource does not have a matching mime type.");
				return false;
			}
		} else {
			$this->fail("invalid_response", "The compression apparently succeeded, but WP-Optimize could not retrieve the compressed image from the remote server.");
			$this->log("data: ".wp_json_encode($data));
			if (!empty($http_response_header) && is_array($http_response_header)) {
				$this->log("headers: ".implode("\n", $http_response_header));
			}
			return false;
		}
	}

	/**
	 * Retrieve features for this service
	 *
	 * @return Array - an array of options
	 */
	public static function get_features() {
		return array(
			'max_filesize' => self::MAX_FILESIZE,
			'lossy_compression' => false,
			'preserve_exif' => true,
		);
	}

	/**
	 * Retrieve default options for this task type.
	 *
	 * @return Array - an array of options
	 */
	public function get_default_options() {
		return array(
			'allowed_file_types' => array('gif', 'png', 'jpg', 'tif', 'jpeg'),
			'request_timeout' => 30,
			'keep_original' => true,
			'preserve_exif' => false,
			'image_quality' => 92,
			'api_endpoint' => self::API_URL,
			'max_filesize' => self::MAX_FILESIZE,
			'version' => '0.1.13',
			'backup_prefix' => '-updraft-pre-smush-original.'
		);
	}
}
endif;

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:24
giriqfky / giriqfky
0755
blockui
--
July 10 2025 04:32:24
giriqfky / giriqfky
0755
list-tables
--
July 10 2025 04:32:24
giriqfky / giriqfky
0755
tables
--
July 10 2025 04:32:24
giriqfky / giriqfky
0755
.htaccess
0.41 KB
July 10 2025 04:32:24
giriqfky / giriqfky
0644
backward-compatibility-functions.php
3.233 KB
December 18 2020 22:52:22
giriqfky / giriqfky
0644
class-re-smush-it-task.php
5.475 KB
February 17 2025 16:50:28
giriqfky / giriqfky
0644
class-updraft-abstract-logger.php
3.428 KB
September 24 2019 18:25:36
giriqfky / giriqfky
0644
class-updraft-email-logger.php
4.11 KB
November 30 2021 19:57:30
giriqfky / giriqfky
0644
class-updraft-file-logger.php
4.26 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-updraft-log-levels.php
0.89 KB
February 20 2018 16:52:16
giriqfky / giriqfky
0644
class-updraft-logger-interface.php
2.784 KB
November 30 2021 19:57:30
giriqfky / giriqfky
0644
class-updraft-logger.php
4.844 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-updraft-php-logger.php
2.808 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-updraft-ring-logger.php
4.051 KB
February 10 2025 16:14:44
giriqfky / giriqfky
0644
class-updraft-smush-manager-commands.php
26.522 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-updraft-smush-manager.php
57.373 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-updraft-smush-task.php
13.243 KB
February 17 2025 16:50:28
giriqfky / giriqfky
0644
class-updraftcentral-wp-optimize-commands.php
1.165 KB
June 03 2022 22:20:18
giriqfky / giriqfky
0644
class-wp-optimization.php
12.773 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-wp-optimize-404-detector-cron.php
1.033 KB
December 09 2024 17:24:26
giriqfky / giriqfky
0644
class-wp-optimize-404-detector.php
10.995 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-wp-optimize-admin.php
31.859 KB
March 03 2025 22:03:20
giriqfky / giriqfky
0644
class-wp-optimize-browser-cache.php
9.208 KB
February 10 2025 16:14:44
giriqfky / giriqfky
0644
class-wp-optimize-commands.php
36.47 KB
February 17 2025 16:50:28
giriqfky / giriqfky
0644
class-wp-optimize-database-information.php
16.731 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-wp-optimize-delay-js.php
10.952 KB
March 06 2025 16:33:06
giriqfky / giriqfky
0644
class-wp-optimize-gzip-compression.php
10.777 KB
February 10 2025 16:14:44
giriqfky / giriqfky
0644
class-wp-optimize-heartbeat.php
3.949 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-wp-optimize-htaccess.php
8.801 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-wp-optimize-http-error-codes-trait.php
8.833 KB
March 03 2025 22:03:20
giriqfky / giriqfky
0644
class-wp-optimize-install-or-update-notice.php
3.266 KB
April 16 2024 00:42:52
giriqfky / giriqfky
0644
class-wp-optimize-notices.php
18.152 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-wp-optimize-options.php
16.045 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-wp-optimize-performance.php
3.472 KB
December 09 2024 17:24:26
giriqfky / giriqfky
0644
class-wp-optimize-preloader.php
18.108 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-wp-optimize-server-information.php
4.825 KB
February 17 2025 16:50:28
giriqfky / giriqfky
0644
class-wp-optimize-system-status-report.php
10.927 KB
February 10 2025 16:14:44
giriqfky / giriqfky
0644
class-wp-optimize-table-management.php
3.674 KB
February 10 2025 16:14:44
giriqfky / giriqfky
0644
class-wp-optimize-transients-cache.php
3.354 KB
January 30 2020 16:28:26
giriqfky / giriqfky
0644
class-wp-optimize-updates.php
11.009 KB
February 17 2025 16:50:28
giriqfky / giriqfky
0644
class-wp-optimize-utils.php
6.789 KB
February 17 2025 16:50:28
giriqfky / giriqfky
0644
class-wp-optimizer.php
20.442 KB
February 10 2025 16:14:44
giriqfky / giriqfky
0644
class-wpo-activation.php
2.684 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-wpo-ajax.php
12.127 KB
March 03 2025 22:03:20
giriqfky / giriqfky
0644
class-wpo-deactivation.php
0.521 KB
March 06 2024 21:29:48
giriqfky / giriqfky
0644
class-wpo-image-utils.php
1.698 KB
July 06 2023 16:18:20
giriqfky / giriqfky
0644
class-wpo-page-optimizer.php
1.59 KB
June 02 2025 17:15:44
giriqfky / giriqfky
0644
class-wpo-uninstall.php
2.592 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
updraftcentral.php
1.664 KB
December 18 2020 22:52:22
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF