403Webshell
Server IP : 52.25.153.185  /  Your IP : 216.73.217.131
Web Server : Apache
System : Linux ip-172-26-6-158 5.10.0-35-cloud-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64
User : daemon ( 1)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /bitnami/wordpress/wp-content/plugins/testify/includes/integrations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /bitnami/wordpress/wp-content/plugins/testify/includes/integrations/WPCF7.class.php
<?php
/**
 * This file includes code based on and/or copied from WordPress
 * See license.txt for copyright and licensing details
 *
 * This file modified by Jonathan Hall, Dominika Rauk, Carl Wuensche and/or others; last modified 2020-08-28
 *
 */

if ( ! defined( 'ABSPATH' ) ) {
	die();
}

// phpcs:disable WordPress.Security.NonceVerification -- user input processing is triggered by Contact Form 7 so nonce verification is left up to that plugin

add_action( 'wpcf7_init', array( 'WPCF7Integration', 'wpcf7_contact_form_integration' ), 10, 0 );

class WPCF7Integration extends WPCF7_Service {
	const service_name = 'testify';
	private static $instance;

	public static function get_instance() {
		if ( empty( self::$instance ) ) {
			self::$instance = new self;
		}

		return self::$instance;
	}

	public static function init() {
		add_action( 'wpcf7_admin_init', array( 'WPCF7Integration', 'add_testimonial' ), 50 );
		add_action( 'wpcf7_init', array( 'WPCF7Integration', 'wpcf7_add_form_tag_testimonial' ) );
		add_filter( 'wpcf7_validate', array( 'WPCF7Integration', 'wpcf7_validate_testimonial' ), 10, 2 );

		add_action( 'wpcf7_before_send_mail', array( 'WPCF7Integration', 'wpcf7_before_send_mail' ) );
	}

	public static function add_testimonial() {
		$tag_generator = WPCF7_TagGenerator::get_instance();

		$tag_generator->add( 'testimonial', __( 'testimonial', 'contact-form-7' ), 'WPCF7_Testimonial' );
	}

	public function get_title() {
		return __( 'Testify', 'contact-form-7' );
	}

	// This will always be true because the only way we will see this integration message is if the plugin is active.
	public function is_active() {
		return true;
	}

	public static function wpcf7_contact_form_integration() {
		$integration = WPCF7_Integration::get_instance();

		$service = WPCF7Integration::get_instance();
		$integration->add_service( 'testify', $service );
	}

	public static function wpcf7_add_form_tag_testimonial() {
		wpcf7_add_form_tag( array( 'testimonial' ), 'WPCF7_testimonial_form_tag_handler', array( 'name-attr' => true ) );
	}

	public static function wpcf7_validate_testimonial( $result, $tags ) {
		if ( $tags[0]['type'] == 'testimonial' ) {
			//print_r($_POST);

			// phpcs:ignore ET.Sniffs.ValidatedSanitizedInput.InputNotSanitized -- assuming this function returns properly escaped HTML
			$author = isset( $_POST['author-name'] ) ? trim( wp_unslash( sanitize_text_field( strtr( (string) $_POST['author-name'], "\n", " " ) ) ) ) : '';

			$tag = new WPCF7_FormTag( array( 'type' => 'text*', 'basetype' => 'text', 'name' => 'author-name' ) );

			if ( $tag->is_required() && '' == $author ) {
				$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
			}

			$tag = new WPCF7_FormTag( array( 'type' => 'email*', 'basetype' => 'email', 'name' => 'author-email' ) );

			// phpcs:ignore ET.Sniffs.ValidatedSanitizedInput.InputNotSanitized -- assuming this function returns properly escaped HTML
			$email = isset( $_POST['author-email'] ) ? trim( wp_unslash( sanitize_text_field( strtr( (string) $_POST['author-email'], "\n", " " ) ) ) ) : '';

			if ( $tag->is_required() && '' == $email ) {
				$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
			} elseif ( '' != $email && ! wpcf7_is_email( $email ) ) {
				$result->invalidate( $tag, wpcf7_get_message( 'invalid_email' ) );
			}

			$testimonial = isset( $_POST['testimonial'] ) ? sanitize_textarea_field( (string) $_POST['testimonial'] ) : '';

			$tag = new WPCF7_FormTag( array( 'type'     => 'textarea*',
			                                 'basetype' => 'textarea',
			                                 'name'     => 'testimonial'
			) );

			if ( $tag->is_required() && '' == $testimonial ) {
				$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
			}

		}


		return $result;
	}

	public static function wpcf7_before_send_mail( $contact_form ) {

		$name = $contact_form->scan_form_tags( array( 'type' => 'testimonial' ) );

		if ( ! $name ) {
			return;
		}

        $author  = isset( $_POST['author-name'] ) ? sanitize_text_field( $_POST['author-name'] ) : '';
        $content = isset( $_POST['testimonial'] ) ? sanitize_textarea_field( $_POST['testimonial'] ) : '';
        $email   = isset( $_POST['author-email'] ) ? sanitize_email( $_POST['author-email'] ) : '';
        $tags    = isset( $_POST['tags'] ) ? $_POST['tags'] : '';         // phpcs:ignore ET.Sniffs.ValidatedSanitizedInput.InputNotSanitized -- to be processed by wp_set_post_terms below
        $cats    = isset( $_POST['category'] ) ? $_POST['category'] : ''; // phpcs:ignore ET.Sniffs.ValidatedSanitizedInput.InputNotSanitized -- used for term lookup below

        $testimonialId = wp_insert_post( array(
            'post_title'   => $author,
            'post_type'    => 'testify-testimonial',
            'post_status'  => 'pending',
            'post_content' => wp_strip_all_tags( $content ),
        ) );

        if ( ! empty( $testimonialId ) ) {
            update_post_meta( $testimonialId, 'testimonial-author', $author );
            update_post_meta( $testimonialId, 'testimonial-submit-time', current_time( 'timestamp' ) );
            update_post_meta( $testimonialId, 'testimonial-submit-email', $email );
            if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
                update_post_meta( $testimonialId, 'testimonial-submit-ip', sanitize_text_field( $_SERVER['REMOTE_ADDR'] ) );
            }

            $categories = array();

            foreach ( $cats as $value ) {
                $term = get_term_by( 'name', $value, 'testify-cat' );

                if ( $term && $term->term_id > 0 ) {
                    $categories[] = $term->term_id;
                }
            }

            if ( ! empty( $categories ) ) {
                wp_set_post_terms( $testimonialId, $categories, 'testify-cat', true );
            }

            if ( ! empty( $tags ) ) {
                wp_set_post_terms( $testimonialId, $tags, 'testify-tag', true );
            }

            if ( isset( $_FILES['photo']['name'] ) ) {
                $file_type_pattern = 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv';

                $file_type_pattern = trim( $file_type_pattern, '|' );
                $file_type_pattern = '(' . $file_type_pattern . ')';
                $file_type_pattern = '/\.' . $file_type_pattern . '$/i';

                // phpcs:ignore ET.Sniffs.ValidatedSanitizedInput.InputNotSanitized -- file name is just being used to check the file extension
                if ( preg_match( $file_type_pattern, $_FILES['photo']['name'] ) ) {
                    /*wpcf7_init_uploads(); // Confirm upload dir
                    $uploads_dir = wpcf7_upload_tmp_dir();
                    $uploads_dir = wpcf7_maybe_add_random_dir( $uploads_dir );

                    $filename = $file['name'];
                    $filename = wpcf7_canonicalize( $filename, 'as-is' );
                    $filename = sanitize_file_name( $filename );
                    $filename = wpcf7_antiscript_file_name( $filename );
                    $filename = wp_unique_filename( $uploads_dir, $filename );

                    $new_file = trailingslashit( $uploads_dir ) . $filename;

                    move_uploaded_file( $file['tmp_name'], $new_file );*/

                    require_once( ABSPATH . "wp-admin/includes/image.php" );
                    require_once( ABSPATH . "wp-admin/includes/media.php" );
                    require_once( ABSPATH . "wp-admin/includes/file.php" );

                    $attachmentId = media_handle_upload( 'photo', $testimonialId );

                    update_post_meta( $testimonialId, '_thumbnail_id', $attachmentId );
                }
            }

        }
	}

	public function display( $action = '' ) {
		echo '<p>' . sprintf(
				esc_html( __( 'Create beautiful responsive testimonials for your website in minutes.', 'testify-testify' ) ),
				// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- assuming this function returns properly escaped HTML
				wpcf7_link(
					'https://wpzone.co/product/testify/',
					__( 'Testify Integration', 'testify-testify' )
				)
			) . '</p>';


	}

}

function WPCF7_testimonial_form_tag_handler() {
	$author   = new WPCF7_FormTag( array( 'type' => 'text*', 'basetype' => 'text', 'name' => 'author-name' ) );
	$email    = new WPCF7_FormTag( array( 'type' => 'email*', 'basetype' => 'email', 'name' => 'author-email' ) );
	$testi    = new WPCF7_FormTag( array( 'type' => 'textarea*', 'basetype' => 'textarea', 'name' => 'testimonial' ) );
	$tag      = new WPCF7_FormTag( array( 'type' => 'text*', 'basetype' => 'text', 'name' => 'tags' ) );
	$file     = new WPCF7_FormTag( array( 'type' => 'file*', 'basetype' => 'file', 'name' => 'photo' ) );
	$category = new WPCF7_FormTag( array( 'type'       => 'checkbox',
	                                      'basetype'   => 'checkbox',
	                                      'name'       => 'category',
	                                      'values'     => array(),
	                                      'raw_values' => array(),
	                                      'labels'     => array()
	) );
	$submit   = new WPCF7_FormTag( array( 'type'     => 'submit',
	                                      'basetype' => 'submit',
	                                      'name'     => 'submit',
	                                      'values'   => [ 'Submit' ]
	) );

	$html = "";

	$terms = get_terms( array(
		'taxonomy'   => 'testify-cat',
		'hide_empty' => false,
	) );

	if ( ! empty ( $terms ) ) {
		foreach ( $terms as $term ) {
			$category['values']     = array( $term->name );
			$category['raw_values'] = array( $term->name );
			$category['label']      = array( $term->name );
		}
	}
	$html .= sprintf( "<p><label>" . esc_html__( 'Author Name', 'testify-testify' ) . "<br />%s</label></p>", wpcf7_text_form_tag_handler( $author ) );
	$html .= sprintf( "<p><label>" . esc_html__( 'Author Email', 'testify-testify' ) . "<br />%s</label></p>", wpcf7_text_form_tag_handler( $email ) );
	$html .= sprintf( "<p><label>" . esc_html__( 'Testimonial', 'testify-testify' ) . "<br />%s</label></p>", wpcf7_textarea_form_tag_handler( $testi ) );
	$html .= sprintf( "<p><label>" . esc_html__( 'Tags', 'testify-testify' ) . "<br />%s</label></p>", wpcf7_text_form_tag_handler( $tag ) );
	$html .= sprintf( "<p><label>" . esc_html__( 'Photo', 'testify-testify' ) . "<br />%s</label></p>", wpcf7_file_form_tag_handler( $file ) );
	if ( ! empty ( $category ) ) {
		$html .= sprintf( "<p><label>" . esc_html__( 'Category', 'testify-testify' ) . "<br />%s</label></p>", wpcf7_checkbox_form_tag_handler( $category ) );
	}
	$html .= sprintf( "<p>%s</p>", wpcf7_submit_form_tag_handler( $submit ) );

	return $html;
}

function WPCF7_Testimonial( $contact_form, $args = '' ) {
	$args = wp_parse_args( $args, array() );

	$type        = $args['id'];
	$description = esc_html__( "Generate a form-tag for Testimonial.", 'testify-testify' );

	?>

    <div class="control-box">
        <fieldset>
            <legend><?php echo sprintf( esc_html( $description ) ); ?></legend>
        </fieldset>
    </div>

    <div class="testimonial-insert-box">
        <input type="text" name="<?php echo esc_attr( $type ); ?>" class="tag code" readonly="readonly"
               onfocus="this.select()"/>

        <div class="submitbox">
            <input type="button" class="button button-primary insert-tag"
                   value="<?php echo esc_attr( __( 'Insert Tag', 'testify-testify' ) ); ?>"/>
        </div>

        <br class="clear"/>

        <p class="description mail-tag">
            <label for="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>">
				<?php echo sprintf( esc_html( __( "To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'testify-testify' ) ), '<strong><span class="mail-tag"></span></strong>' ); ?>
                <input type="text" class="mail-tag code hidden" readonly="readonly"
                       id="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"/>
            </label>
        </p>
    </div>

<?php }

Youez - 2016 - github.com/yon3zu
LinuXploit