File manager - Edit - /home/premiey/www/wp-includes/images/media/connect.tar
Back
manager.php 0000666 00000001113 15165320510 0006665 0 ustar 00 <?php namespace ElementorPro\Core\Connect; use ElementorPro\Core\Connect\Apps\Activate; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } class Manager { /** * @param \Elementor\Core\Common\Modules\Connect\Module $apps_manager */ public function register_apps( $apps_manager ) { $apps = [ 'activate' => Activate::get_class_name(), ]; foreach ( $apps as $slug => $class ) { $apps_manager->register_app( $slug, $class ); } } public function __construct() { add_action( 'elementor/connect/apps/register', [ $this, 'register_apps' ] ); } } apps/activate.php 0000666 00000007275 15165320510 0010035 0 ustar 00 <?php namespace ElementorPro\Core\Connect\Apps; use Elementor\Core\Common\Modules\Connect\Apps\Common_App; use ElementorPro\License; use ElementorPro\License\API; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } class Activate extends Common_App { public function get_title() { return esc_html__( 'Activate', 'elementor-pro' ); } public function get_slug() { return 'activate'; } protected function after_connect() { $this->action_activate_license(); } /** * @since 2.3.0 * @access public */ public function action_authorize() { // In case the first connect was not from Activate App - require a new authorization. if ( $this->is_connected() && ! License\Admin::get_license_key() ) { $this->disconnect(); } parent::action_authorize(); } public function action_activate_pro() { $this->action_activate_license(); } public function action_switch_license() { $this->disconnect(); $this->action_authorize(); } public function action_deactivate() { License\Admin::deactivate(); $this->disconnect(); wp_safe_redirect( License\Admin::get_url() ); die; } public function action_activate_license() { if ( ! $this->is_connected() ) { $this->add_notice( esc_html__( 'Please connect to Elementor in order to activate license.', 'elementor-pro' ), 'error' ); $this->redirect_to_admin_page(); } $license = $this->request( 'get_connected_license' ); if ( empty( $license ) ) { // TODO: add suggestions how to check/resolve. wp_die( 'License not found for user ' . esc_attr( $this->get( 'user' )->email ), esc_html__( 'Elementor Pro', 'elementor-pro' ), [ 'back_link' => true, ] ); } if ( is_wp_error( $license ) ) { wp_die( $license, esc_html__( 'Elementor Pro', 'elementor-pro' ), [ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 'back_link' => true, ] ); } $license_key = trim( $license->key ); if ( empty( $license_key ) ) { wp_die( esc_html__( 'License key is missing.', 'elementor-pro' ), esc_html__( 'Elementor Pro', 'elementor-pro' ), [ 'back_link' => true, ] ); } $data = License\API::activate_license( $license_key ); if ( is_wp_error( $data ) ) { wp_die( sprintf( '%s (%s) ', $data->get_error_message(), $data->get_error_code() ), esc_html__( 'Elementor Pro', 'elementor-pro' ), [ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 'back_link' => true, ] ); } if ( empty( $data['success'] ) ) { $error_msg = License\API::get_error_message( $data['error'] ); // get_error_message() escapes html wp_die( $error_msg, esc_html__( 'Elementor Pro', 'elementor-pro' ), [ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 'back_link' => true, ] ); } License\Admin::set_license_key( $license_key ); License\API::set_license_data( $data ); $this->add_notice( esc_html__( 'License has been activated successfully.', 'elementor-pro' ) ); $this->redirect_to_admin_page( License\Admin::get_url() ); die; } public function action_reset() { if ( current_user_can( 'manage_options' ) ) { delete_option( 'elementor_pro_license_key' ); delete_transient( 'elementor_pro_license_data' ); } $this->redirect_to_admin_page(); } protected function get_popup_success_event_data() { return [ 'templates_access_level' => API::get_library_access_level( 'template' ), 'kits_access_level' => API::get_library_access_level( 'kit' ), ]; } protected function get_app_info() { return [ 'license_data' => [ 'label' => 'License Data', 'value' => get_option( '_elementor_pro_license_data' ), ], 'license_key' => [ 'label' => 'License Key', 'value' => get_option( 'elementor_pro_license_key' ), ], ]; } } ai.php 0000666 00000023535 15165351314 0005666 0 ustar 00 <?php namespace Elementor\Modules\Ai\Connect; use Elementor\Core\Common\Modules\Connect\Apps\Library; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } class Ai extends Library { const API_URL = 'https://my.elementor.com/api/v2/ai/'; const STYLE_PRESET = 'style_preset'; const IMAGE_TYPE = 'image_type'; const IMAGE_STRENGTH = 'image_strength'; const ASPECT_RATIO = 'ratio'; const IMAGE_RESOLUTION = 'image_resolution'; const PROMPT = 'prompt'; public function get_title() { return esc_html__( 'AI', 'elementor' ); } protected function get_api_url() { return static::API_URL . '/'; } public function get_usage() { return $this->ai_request( 'POST', 'status/check', [ 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ] ); } /** * get_file_payload * @param $filename * @param $file_type * @param $file_path * @param $boundary * * @return string */ private function get_file_payload( $filename, $file_type, $file_path, $boundary ) { $name = $filename ?? basename( $file_path ); $mine_type = 'image' === $file_type ? image_type_to_mime_type( exif_imagetype( $file_path ) ) : $file_type; $payload = ''; // Upload the file $payload .= '--' . $boundary; $payload .= "\r\n"; $payload .= 'Content-Disposition: form-data; name="' . esc_attr( $name ) . '"; filename="' . esc_attr( $name ) . '"' . "\r\n"; $payload .= 'Content-Type: ' . $mine_type . "\r\n"; $payload .= "\r\n"; $payload .= file_get_contents( $file_path ); $payload .= "\r\n"; return $payload; } private function get_upload_request_body( $body, $file, $boundary, $file_name = '' ) { $payload = ''; // add all body fields as standard POST fields: foreach ( $body as $name => $value ) { $payload .= '--' . $boundary; $payload .= "\r\n"; $payload .= 'Content-Disposition: form-data; name="' . esc_attr( $name ) . '"' . "\r\n\r\n"; $payload .= $value; $payload .= "\r\n"; } if ( is_array( $file ) ) { foreach ( $file as $key => $file_data ) { $payload .= $this->get_file_payload( $file_data['name'], $file_data['type'], $file_data['path'], $boundary ); } } else { $image_mime = image_type_to_mime_type( exif_imagetype( $file ) ); // @todo: add validation for supported image types if ( empty( $file_name ) ) { $file_name = basename( $file ); } $payload .= $this->get_file_payload( $file_name, $image_mime, $file, $boundary ); } $payload .= '--' . $boundary . '--'; return $payload; } private function ai_request( $method, $endpoint, $body, $file = false, $file_name = '' ) { $headers = [ 'x-elementor-ai-version' => '2', ]; if ( $file ) { $boundary = wp_generate_password( 24, false ); $body = $this->get_upload_request_body( $body, $file, $boundary, $file_name ); // add content type header $headers['Content-Type'] = 'multipart/form-data; boundary=' . $boundary; } return $this->http_request( $method, $endpoint, [ 'timeout' => 50, 'headers' => $headers, 'body' => $body, ], [ 'return_type' => static::HTTP_RETURN_TYPE_ARRAY, ] ); } public function set_get_started() { return $this->ai_request( 'POST', 'status/get-started', [ 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ] ); } public function set_status_feedback( $response_id ) { return $this->ai_request( 'POST', 'status/feedback/' . $response_id, [ 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ] ); } public function set_used_gallery_image( $image_id ) { return $this->ai_request( 'POST', 'status/used-gallery-image/' . $image_id, [ 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ] ); } public function get_completion_text( $prompt ) { return $this->ai_request( 'POST', 'text/completion', [ 'prompt' => $prompt, 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ] ); } /** * get_image_prompt_enhanced * @param $prompt * * @return mixed|\WP_Error */ public function get_image_prompt_enhanced( $prompt ) { return $this->ai_request( 'POST', 'text/enhance-image-prompt', [ 'prompt' => $prompt, 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ] ); } public function get_edit_text( $input, $instruction ) { return $this->ai_request( 'POST', 'text/edit', [ 'input' => $input, 'instruction' => $instruction, 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ] ); } public function get_custom_code( $prompt, $language ) { return $this->ai_request( 'POST', 'text/custom-code', [ 'prompt' => $prompt, 'language' => $language, 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ] ); } public function get_custom_css( $prompt, $html_markup, $element_id ) { return $this->ai_request( 'POST', 'text/custom-css', [ 'prompt' => $prompt, 'html_markup' => $html_markup, 'element_id' => $element_id, 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ] ); } /** * get_text_to_image * @param $prompt * @param $prompt_settings * * @return mixed|\WP_Error */ public function get_text_to_image( $prompt, $prompt_settings ) { return $this->ai_request( 'POST', 'image/text-to-image', [ self::PROMPT => $prompt, self::IMAGE_TYPE => $prompt_settings[ self::IMAGE_TYPE ] . '/' . $prompt_settings[ self::STYLE_PRESET ], self::ASPECT_RATIO => $prompt_settings[ self::ASPECT_RATIO ], 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ] ); } /** * get_image_to_image * @param $image_data * * @return mixed|\WP_Error * @throws \Exception */ public function get_image_to_image( $image_data ) { $image_file = get_attached_file( $image_data['attachment_id'] ); if ( ! $image_file ) { throw new \Exception( 'Image file not found' ); } $result = $this->ai_request( 'POST', 'image/image-to-image', [ self::PROMPT => $image_data[ self::PROMPT ], self::IMAGE_TYPE => $image_data['promptSettings'][ self::IMAGE_TYPE ] . '/' . $image_data['promptSettings'][ self::STYLE_PRESET ], self::IMAGE_STRENGTH => $image_data['promptSettings'][ self::IMAGE_STRENGTH ], self::ASPECT_RATIO => $image_data['promptSettings'][ self::ASPECT_RATIO ], 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ], $image_file, 'image' ); return $result; } /** * get_image_to_image_upscale * @param $image_data * * @return mixed|\WP_Error * @throws \Exception */ public function get_image_to_image_upscale( $image_data ) { $image_file = get_attached_file( $image_data['attachment_id'] ); if ( ! $image_file ) { throw new \Exception( 'Image file not found' ); } $result = $this->ai_request( 'POST', 'image/image-to-image/upscale', [ self::IMAGE_RESOLUTION => $image_data['promptSettings']['upscale_to'], 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ], $image_file, 'image' ); return $result; } /** * store_temp_file * used to store a temp file for the AI request and deletes it once the request is done * @param $file_content * @param $file_ext * * @return string */ private function store_temp_file( $file_content, $file_ext = '' ) { $temp_file = str_replace( '.tmp', '', wp_tempnam() . $file_ext ); file_put_contents( $temp_file, $file_content ); // make sure the temp file is deleted on shutdown register_shutdown_function( function () use ( $temp_file ) { if ( file_exists( $temp_file ) ) { unlink( $temp_file ); } } ); return $temp_file; } /** * get_image_to_image_out_painting * @param $image_data * * @return mixed|\WP_Error * @throws \Exception */ public function get_image_to_image_out_painting( $image_data ) { $img_content = str_replace( ' ', '+', $image_data['mask'] ); $img_content = substr( $img_content, strpos( $img_content, ',' ) + 1 ); $img_content = base64_decode( $img_content ); $mask_file = $this->store_temp_file( $img_content, '.png' ); if ( ! $mask_file ) { throw new \Exception( 'Expended Image file not found' ); } $result = $this->ai_request( 'POST', 'image/image-to-image/outpainting', [ self::PROMPT => $image_data[ self::PROMPT ], self::IMAGE_TYPE => '', 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ], [ [ 'name' => 'image', 'type' => 'image', 'path' => $mask_file, ], ] ); return $result; } /** * get_image_to_image_mask * @param $image_data * * @return mixed|\WP_Error * @throws \Exception */ public function get_image_to_image_mask( $image_data ) { $image_file = get_attached_file( $image_data['attachment_id'] ); $mask_file = $this->store_temp_file( $image_data['mask'], '.svg' ); if ( ! $image_file ) { throw new \Exception( 'Image file not found' ); } if ( ! $mask_file ) { throw new \Exception( 'Mask file not found' ); } $result = $this->ai_request( 'POST', 'image/image-to-image/inpainting', [ self::PROMPT => $image_data[ self::PROMPT ], self::IMAGE_TYPE => $image_data['promptSettings'][ self::IMAGE_TYPE ] . '/' . $image_data['promptSettings'][ self::STYLE_PRESET ], self::IMAGE_STRENGTH => $image_data['promptSettings'][ self::IMAGE_STRENGTH ], 'api_version' => ELEMENTOR_VERSION, 'site_lang' => get_bloginfo( 'language' ), ], [ [ 'name' => 'image', 'type' => 'image', 'path' => $image_file, ], [ 'name' => 'mask_image', 'type' => 'image/svg+xml', 'path' => $mask_file, ], ] ); return $result; } protected function init() {} }
| ver. 1.4 |
Github
|
.
| PHP 5.4.45 | Generation time: 0 |
proxy
|
phpinfo
|
Settings