Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560
[2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85
[3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50
[4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13
[5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
403WebShell
403Webshell
Server IP : 94.177.8.99  /  Your IP : 216.73.217.165
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/hopeinstoughton_www/wp-content/plugins/form-wizard/fielddefs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/hopeinstoughton_www/wp-content/plugins/form-wizard/fielddefs/fw_mailchimp.php
<?php

// Turn this form into a mailchimp subscribe form. Also requires a email address field on the form

	$defdir = dirname(__FILE__);
	include_once "$defdir/fw_checkbox.php";
	include_once "$defdir/../class.mailchimp.php";

class fw_mailchimp extends fw_checkbox {

	function __construct($aparent) {
	// these are the default values for settings used by this component
	// they will be used when displaying settings for this field type
		parent::__construct($aparent);
		$this->params['mc_apikey'] = array();
		$this->params['mc_list'] = array();
		$this->params['cb_style'] = array('list' => array(1 => 'first column', '2' => 'second column', '3' => 'hidden (always subscribes)'),
											'value' => 2);
	}
	
	public function FieldType() {
		return 'mailchimp';
	}
	
	public function FieldPriority() {
		return 99;	// should be processed last
	}

// doing the actual unsubscribe should only occur once all the other fields have been validated
	public function Validate($value) {
		$style = $this->params['cb_style']['value'];
		if ($style < 3 && empty($value)) return;		// we're not unsubscribing
		
		if ($this->parent->errorcount > 0) return;		// there are other errors - we cannot unsubscribe yet
// locate the email address field
		$email_field = NULL;
		foreach($this->parent->fields as $item) {
			if ($item->FieldType() == 'email') {
				$email_field = $item;
				break;
			}
		}
		if ($email_field === NULL) {
			return 'configuration error - no email field located';
		}
		
		$email_address = $email_field->params['value'];
		$mailing_list_id = $this->params['mc_list']['value'];
		
		$n = $this->SubscribeEmail($email_address, $mailing_list_id);
		$status = isset($n['status']) ? $n['status'] : '';
		if ($status == 'error') {
			$email_field->fielderror = $n['error'];
			$email_field->parent->errorcount++;
			return '';	// error is not with the subscribe field, but the email address being used
		}
		// subscribe was successful - a confirmation email will be sent from mailchimp
		return '';
	}
	
	private function _GetAPIkey() {
		return $this->params['mc_apikey']['value'];
	}
	
	private function getMailingLists() {
		$mailchimp = new MailChimp($this->_GetAPIkey());
		$items = $mailchimp->call('lists/list');
		$output = array();
		$output[''] = '(please select a mailing list)';
		foreach($items['data'] as $item) {
			$output[$item['id']] = $item['name'];
		}
		return $output;
	}

	private function SubscribeEmail($email_address, $mailing_list_id) {
		$param = array();
		$param['id'] = $mailing_list_id;
		$param['email']['email'] = $email_address;
		$mailchimp = new MailChimp($this->_GetAPIkey());
		$items = $mailchimp->call('/lists/subscribe', $param);
		return $items;
	}
	
	public function SettingsFields_AsHTML() {
		$fields = $this->AddWizardSubField('cb_hint', 'text', 'Hint').
				  $this->AddWizardSubField('cb_desc', 'text', 'Description').
				  $this->AddWizardSubField('mc_apikey', 'text', 'MailChimp API Key');
		$apikey = $this->_GetAPIkey();
		$param = array();
		if ($apikey == '') {
			$this->params['mc_list']['list'] = array('' => '(please enter and save the API key first)');
		} else {
			$this->params['mc_list']['list'] = $this->getMailingLists();
		}
		$fields.= $this->AddWizardSubField('mc_list', 'select', 'Mailing List').
				  $this->AddWizardSubField('cb_style', 'select', 'Checkbox Style');
		return $fields;
	}
	

}

Youez - 2016 - github.com/yon3zu
LinuXploit