403Webshell
Server IP : 104.21.38.3  /  Your IP : 162.158.190.75
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/wwwroot/coircraft.com/wp-content/plugins/caldera-forms/classes/email/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/coircraft.com/wp-content/plugins/caldera-forms/classes/email/previews.php
<?php

/**
 * Manages an email preview
 *
 * @package Caldera_Forms
 * @author    Josh Pollock <[email protected]>
 * @license   GPL-2.0+
 * @link
 * @copyright 2016 CalderaWP LLC
 */
class Caldera_Forms_Email_Previews {

	/**
	 * Form ID
	 *
	 * @since 1.4.0
	 *
	 * @var null|string
	 */
	protected  $id;

	/**
	 * Caldera_Forms_Email_Previews constructor.
	 *
	 * @param null|string $id Optional. Form ID
	 * @param bool $view Optional. Whether to view (true) or record (false) the preview. Default is false.
	 */
	public function __construct( $id = null, $view = false ) {
		if( $view && null != $id ){
			$this->id = $id;
			$this->view();
		}else{
			add_filter( 'caldera_forms_mailer', array( $this, 'maybe_create_preview' ), 99, 3 );
		}



	}

	/**
	 * Display email preview
	 *
	 * @since 1.4.0
	 */
	public function view(){
		if ( isset( $this->id ) ) {
			$preview = $this->get_saved( $this->id );
			if ( is_object( $preview ) && ! empty( $preview ) ) {
				$headers = $this->format_headers( $preview->headers );
				$message = $preview->message;
				include CFCORE_PATH . 'ui/emails/email-preview.php';
				exit;
			}else{
				wp_die( esc_html__( 'There is no saved email preview. Please submit this form with email previewing on and then try again.', 'caldera-forms' ) );
			}

		}

	}

	/**
	 * Format header view
	 *
	 * Create UL markup from array
	 *
	 * @since 1.4.0
	 *
	 * @param $headers
	 *
	 * @return string
	 */
	public function format_headers( $headers ){
		$view = array();
		$pattern = '<li><pre>%s</pre>: <span>%s</span></li>';
		foreach ( $headers as $header => $value ){
			if ( is_string( $value ) ){
				$view[ $header ] = sprintf( $pattern, ucwords( $header ), htmlentities( $value ) );
			}else{
				$view[ $header ] = sprintf( $pattern, ucwords( $header ), $this->format_headers( $value ) );
			}

		}

		return sprintf( '<ul>%s</ul>', implode( $view ) );
	}

	/**
	 * If preview should be recorded, record
	 *
	 * @since 1.4.0
	 *
	 * @uses "caldera_forms_mailer" filter
	 *
	 * @param array $mail
	 * @param array $data
	 * @param array $form
	 *
	 * @return array
	 */
	public function maybe_create_preview( $mail, $data, $form ){
		if( ! empty( $form[ 'mailer' ][ 'preview_email' ] ) ){
			$this->id = $form[ 'ID' ];
			$preview = new Caldera_Forms_Email_Preview( $mail  );
			$this->record( $preview );
		}

		return $mail;
	}

	/**
	 * Get saved preview as stdClass
	 * 
	 * @param null|string $id Optional. Form ID. By default $this->id is used. Pass ID here to reset that property.
	 *
	 * @return bool|object
	 */
	public function get_saved( $id = null ){
		if( is_string( $id ) ){
			$this->id = $id;
		}

		$_preview = get_option( $this->key() );
		if( ! empty( $_preview ) && is_object( $preview = json_decode( $_preview ) ) ){
			return $preview;
		}else{
			return false;
		}

	}

	/**
	 * Save preview
	 * 
	 * @since 1.4.0
	 * 
	 * @param Caldera_Forms_Email_Preview $preview Preview object
	 */
	protected function record( Caldera_Forms_Email_Preview $preview ){
		if ( false == get_option( $this->key( ) ) ){
			add_option( $this->key(), wp_json_encode( $preview ), false );
		}else{
			update_option( $this->key(), wp_json_encode( $preview ), false );
		}

	}

	/**
	 * Option key
	 * 
	 * @since 1.4.0
	 * 
	 * @return string
	 */
	protected function key( ){
		return '__cf_email_preview_' . $this->id;
		
	}
	
}

Youez - 2016 - github.com/yon3zu
LinuXploit