晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/rainic/public_html/wp-contentTZh/plugins/contact-form-7/modules/turnstile/ |
Upload File : |
<?php
/**
* Turnstile module main file
*/
include_once path_join( __DIR__, 'service.php' );
add_action( 'wpcf7_init', 'wpcf7_turnstile_register_service', 35, 0 );
/**
* Registers the Turnstile service.
*/
function wpcf7_turnstile_register_service() {
$integration = WPCF7_Integration::get_instance();
$integration->add_service( 'turnstile',
WPCF7_Turnstile::get_instance()
);
}
add_action( 'wp_enqueue_scripts', 'wpcf7_turnstile_enqueue_scripts', 10, 0 );
/**
* Enqueues the Turnstile script.
*/
function wpcf7_turnstile_enqueue_scripts() {
$service = WPCF7_Turnstile::get_instance();
if ( ! $service->is_active() ) {
return;
}
wp_enqueue_script(
'cloudflare-turnstile',
'https://challenges.cloudflare.com/turnstile/v0/api.js',
array(),
null,
array(
'strategy' => 'async',
)
);
wp_add_inline_script(
'cloudflare-turnstile',
"document.addEventListener( 'wpcf7submit', e => turnstile.reset() );"
);
}
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_turnstile', 10, 0 );
/**
* Registers the Turnstile form-tag type.
*/
function wpcf7_add_form_tag_turnstile() {
$service = WPCF7_Turnstile::get_instance();
if ( ! $service->is_active() ) {
wpcf7_add_form_tag(
'turnstile',
'__return_empty_string',
array(
'display-block' => true,
)
);
return;
}
wpcf7_add_form_tag(
'turnstile',
'wpcf7_turnstile_form_tag_handler',
array(
'display-block' => true,
'singular' => true,
)
);
}
/**
* The Turnstile form-tag handler.
*/
function wpcf7_turnstile_form_tag_handler( $tag ) {
$service = WPCF7_Turnstile::get_instance();
if ( ! $service->is_active() ) {
return;
}
return sprintf(
'<div %s></div>',
wpcf7_format_atts( array(
'class' => 'wpcf7-turnstile cf-turnstile',
'data-sitekey' => $service->get_sitekey(),
'data-response-field-name' => '_wpcf7_turnstile_response',
'data-action' => $tag->get_option(
'action', '[-0-9a-zA-Z_]{1,32}', true
),
'data-appearance' => $tag->get_option(
'appearance', '(always|execute|interaction-only)', true
),
'data-size' => $tag->get_option(
'size', '(normal|flexible|compact)', true
),
'data-theme' => $tag->get_option( 'theme', '(light|dark|auto)', true ),
'data-language' => $tag->get_option( 'language', '[a-z-]{2,5}', true ),
'data-tabindex' => $tag->get_option( 'tabindex', 'signed_int', true ),
) )
);
}
add_filter( 'wpcf7_form_elements', 'wpcf7_turnstile_prepend_widget', 10, 1 );
/**
* Prepends a Turnstile widget to the form content if the form template
* does not include a Turnstile form-tag.
*/
function wpcf7_turnstile_prepend_widget( $content ) {
$service = WPCF7_Turnstile::get_instance();
if ( ! $service->is_active() ) {
return $content;
}
$contact_form = WPCF7_ContactForm::get_current();
$manager = WPCF7_FormTagsManager::get_instance();
$tags = $contact_form->scan_form_tags( array(
'type' => 'turnstile',
) );
if ( empty( $tags ) ) {
$content = $manager->replace_all( '[turnstile]' ) . "\n\n" . $content;
}
return $content;
}
add_filter( 'wpcf7_spam', 'wpcf7_turnstile_verify_response', 9, 2 );
/**
* Verifies the Turnstile response token.
*
* @param bool $spam The spam/ham status inherited from preceding callbacks.
* @param WPCF7_Submission $submission The submission object.
* @return bool True if the submitter is a bot, false if a human.
*/
function wpcf7_turnstile_verify_response( $spam, $submission ) {
if ( $spam ) {
return $spam;
}
$service = WPCF7_Turnstile::get_instance();
if ( ! $service->is_active() ) {
return $spam;
}
$token = wpcf7_superglobal_post( '_wpcf7_turnstile_response' );
if ( $service->verify( $token ) ) { // Human
$spam = false;
} else { // Bot
$spam = true;
if ( '' === $token ) {
$submission->add_spam_log( array(
'agent' => 'turnstile',
'reason' => __( 'Turnstile token is empty.', 'contact-form-7' ),
) );
} else {
$submission->add_spam_log( array(
'agent' => 'turnstile',
'reason' => __( 'Turnstile validation failed.', 'contact-form-7' ),
) );
}
}
return $spam;
}
add_filter(
'wpcf7_flamingo_inbound_message_parameters',
'wpcf7_flamingo_inbound_message_parameters_turnstile',
10, 1
);
/**
* Passes response data from Turnstile siteverify API to Flamingo.
*/
function wpcf7_flamingo_inbound_message_parameters_turnstile( $params ) {
$meta = null;
if ( $submission = WPCF7_Submission::get_instance() ) {
$meta = $submission->pull( 'turnstile' );
}
if ( isset( $meta ) ) {
$params['meta']['turnstile'] = wp_json_encode( $meta );
}
return $params;
}