403Webshell
Server IP : 172.67.201.108  /  Your IP : 216.73.216.30
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/home2/domains/licampfair.com/wp-content/plugins/lcs-lff-data/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/home2/domains/licampfair.com/wp-content/plugins/lcs-lff-data/lcs_lff_data.php
<?php
/*
Plugin Name: LCS LFF Data
Plugin URI: http://www.latcomsystems.com/
Description: LI FamFest Data module.
Version: 1.0
Author: LatCom Systems
Author URI: http://www.latcomsystems.com/
Copyright 2016 LatCom Systems
*/

register_activation_hook(__FILE__, 'lcs_lff_data_activation');

function lcs_lff_data_activation() 
{
}

register_deactivation_hook(__FILE__, 'lcs_lff_data_deactivation');

function lcs_lff_data_deactivation() 
{
}

add_action('admin_menu', 'lcs_lff_data_menu');

function generate_random_string($length = 16)
                {
                        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
                        $random_string = '';
                        for ($i = 0; $i < $length; $i++) :
                                $random_string .= $characters[rand(0, strlen($characters) - 1)];
                        endfor;
                        return $random_string;
                }


function lcs_lff_data_menu() 
{
	add_menu_page(__('FamFest Data'), __('FamFest Data'), 'edit_themes', 'lcs_lff_data_admin', 'lcs_lff_data_exhibitor_submissions', 'dashicons-list-view', '26.5');
	add_submenu_page('lcs_lff_data_admin', __('Exhibitor Submissions'), __('Exhibitor Submissions'), 'edit_themes', 'lcs_lff_data_admin', 'lcs_lff_data_exhibitor_submissions');
	add_submenu_page('lcs_lff_data_admin', __('Customer Registrations'), __('Customer Registrations'), 'edit_themes', 'lcs_lff_data_registrations', 'lcs_lff_data_registrations');
	add_submenu_page('lcs_lff_data_admin', __('Coupon Codes'), __('Coupon Codes'), 'edit_themes', 'lcs_lff_data_coupon_codes', 'lcs_lff_data_coupon_codes');
	add_submenu_page('lcs_lff_data_admin', __('Exhibitors'), __('Exhibitors'), 'edit_themes', 'lcs_lff_data_exhibitors', 'lcs_lff_data_exhibitors');
	add_submenu_page('lcs_lff_data_admin', __('Reminder Emails'), __('Reminder Emails'), 'edit_themes', 'lcs_lff_data_reminders', 'lcs_lff_data_reminders');
}

function lcs_lff_data_reminders() 
{
	wp_enqueue_style( 'lcs-lff-admin-style', plugins_url().'/lcs-lff-data/lcs_lff_data_admin.css', array(), filemtime(dirname(__FILE__).'/lcs_lff_data_admin.css'));
	$_POST = stripslashes_deep($_POST);
	echo '<h1>Data Administration - Reminder Emails</h1>';
	global $db;
	global $wpdb;
	global $ar_err;
	global $err_flag;
	$ar_err = array();
	if ($_POST['lcs_lff_reminder_submitted'] == 1) :
		if (!set_time_limit(900)) :
			echo '<h2 class="form_error">Unable to set execution time limit!</h2>';
			exit();
		endif;
		$start_dt = $db->quote(get_option('lff_reminder_start_dt'));
		$end_dt = $db->quote(get_option('lff_reminder_end_dt'));
		$email_subject = get_option('lff_reminder_email_subject');
		$email_body = nl2br(get_option('lff_reminder_email_body'));
		$email_bcc = get_option('lff_reminder_email_bcc');
		$sql = "SELECT * FROM ".$wpdb->prefix."lcs_purchases WHERE purchase_date >= ".$start_dt." AND purchase_date <= ".$end_dt." ORDER BY id ASC";
		$result = $db->query($sql) or die('Database Error!');
		$email_err_count = 0;
		if ($result->rowCount() > 0) :
			while ($row = $result->fetch(PDO::FETCH_ASSOC)) :
				$mail_body = $email_body;
				foreach ($row as $key => $value) :
					$mail_body = str_replace('['.$key.']', htmlentities($value), $mail_body);
				endforeach;
				//***************** mail using PEAR *******************
				require_once "Mail.php";
				$mail_body = '<html><head><style>body {font-family:Arial, Helvetica, sans-serif; font-size:14px;} table {font-size:14px;}</style></head><body>'.
							$mail_body. 
							'</body></html>' ;

				$pmail_from = get_option('lff_email_from');
				$pmail_to["To"] = $row['email'];
				//$pmail_to["To"] = '[email protected]';
				if (!empty($email_bcc)) :
					$pmail_to["Bcc"] = get_option('woo_lcs_mb_bcc');
				endif;
				$pmail_subject = $email_subject;
				$pmail_body = $mail_body;
				$pmail_host = get_cfg_var('SMTP');
				$pmail_username = "";
				$pmail_password = "";
				
				$pmail_headers = array ('From' => $pmail_from,
										'To' => $pmail_to["To"],
										'Subject' => $pmail_subject,
										'MIME-Version' => '1.0',
										'Content-type' => 'text/html; charset=iso-8859-1');
				$smtp = Mail::factory('smtp',
										array ('host' => $pmail_host,
										 //'auth' => true,
										 'auth' => false,
										 'username' => $pmail_username,
										 'password' => $pmail_password
										 ));
				
				$pmail = $smtp->send($pmail_to, $pmail_headers, $pmail_body);
				
				if (PEAR::isError($pmail)) :
					echo '<p><span style="color:red;">Error!  Unable to send email to '.$row['email'].' Error: '.$pmail->getMessage().'.</span></p>';
					$email_err_count = $email_err_count + 1;
				endif;
				//**********************************************************
			endwhile;
			echo '<h2 class="form_ok">Emails selected: '.$result->rowCount().'.</h2>';
			echo '<h2 class="form_ok">Emails sent to '.($result->rowCount() - $email_err_count).' recipients.</h2>';
		else :
			echo '<h2 class="form_error">No records found!</h2>';
		endif;
	endif;
	if ($_POST['lcs_lff_reminder_options_submitted'] == 1) :
		form_validate('start_dt', 'string', true);
		form_validate('end_dt', 'string', true);
		form_validate('email_subject', 'string', true);
		form_validate('email_body', 'string', true);
		if (!$err_flag) :
			update_option('lff_reminder_start_dt', $_POST['start_dt']);
			update_option('lff_reminder_end_dt', $_POST['end_dt']);
			update_option('lff_reminder_email_subject', $_POST['email_subject']);
			update_option('lff_reminder_email_bcc', $_POST['email_bcc']);
			update_option('lff_reminder_email_body', $_POST['email_body']);
			echo '<h2 class="form_ok">Options saved successfully!</h2>';
		else :
			echo '<h2 class="form_error">Errors found!</h2>';
		endif;
	else :
		$_POST['email_subject'] = get_option('lff_reminder_email_subject');
		$_POST['email_bcc'] = get_option('lff_reminder_email_bcc');
		$_POST['email_body'] = get_option('lff_reminder_email_body');
		$_POST['start_dt'] = get_option('lff_reminder_start_dt');
		$_POST['end_dt'] = get_option('lff_reminder_end_dt');
	endif;
	/* ************ send email ********* */
	echo '<hr>';
	echo '<h2>Send Reminder Emails</h2>';
	echo '<p><b>If you change the options, be sure to save them first before sending email!</b></p>';
	echo '<p>Click Send to send emails.</p>';
	echo '<form method="post" action="">';
	echo '<input type="hidden" name="lcs_lff_reminder_submitted" value="1" />';
	echo '<div class="clear_div"></div>';
	echo '<input type="submit" name="submit" value="Send" />';
	echo '</form>';
	/* ************ options ********* */
	echo '<hr>';
	echo '<h2>Reminder Email Options</h2>';
	echo '<p>Enter start and end cutoff date/times and click Save.  <b>Note:</b> All date/times must be in the 24-hour format as follows: YYYY-MM-DD hh:mm:ss.</p>';
	echo '<form method="post" action="">';
	echo '<input type="hidden" name="lcs_lff_reminder_options_submitted" value="1" />';
	echo '<div class="input_column">';
	form_field('start_dt', 'text', 20, 0, true, false, false, '', '', 'start_dt', 'Registration Start Date/Time YYYY-MM-DD hh:mm:ss');
	form_field('end_dt', 'text', 20, 0, true, false, false, '', '', 'end_dt', 'Registration End Date/Time YYYY-MM-DD hh:mm:ss');
	form_field('email_subject', 'text', 100, 0, true, false, false, '', '', 'email_subject', 'Email Subject');
	form_field('email_bcc', 'text', 100, 0, false, false, false, '', '', 'email_bcc', 'Email BCC (comma spearated)');
	form_field('email_body', 'textarea', 100, 15, true, false, false, '', '', 'email_body', 'Email Body (with [special field] placeholders)');
	echo '</div>';
	echo '<div class="clear_div"></div>';
	echo '<input type="submit" name="submit" value="Save" />';
	echo '</form>';
	
}

function lcs_lff_data_exhibitor_submissions() 
{
	wp_enqueue_style( 'lcs-lff-admin-style', plugins_url().'/lcs-lff-data/lcs_lff_data_admin.css', array(), filemtime(dirname(__FILE__).'/lcs_lff_data_admin.css'));
	global $wpdb;
	$search_str = '';
	if (!empty($_POST['search'])) :
		$search_str_fields = 'exhibitor_name,business_name,email,email,phone,url,business_type,interests,assign_to,assign_comment';
		$search_int_fields = '';
		$search_str = lcs_search_tokenize($search_str_fields, $search_int_fields, $_POST['search']);
	endif;
	$sql = "SELECT * FROM ".$wpdb->prefix."lcs_exhibitor_contact_submissions ".$search_str." ORDER BY timestamp DESC";
	lcs_lff_data_panel('Data Administration - Exhibitor Submissions', $sql, array('exhibitor_name'=>'lcs_lff_exhibitor_submissions_sub', 'assign_to'=>'lcs_lff_exhibitor_submissions_sub'));
}

function lcs_lff_exhibitor_submissions_sub($value, $row, $field_name)
{
	global $db;
	global $wpdb;
	$retval = '';
	switch ($field_name) :
		case 'exhibitor_name' :
			if ($_POST['lcs_lff_exh_submitted'] == 2) :
				$sql = "DELETE FROM ".$wpdb->prefix."lcs_exhibitor_contact_submissions WHERE id = ".nz($_POST['id']);
				$db->query($sql) or die('Database Error!');
				echo '<script>';
				echo 'window.location.href = "'.$_SERVER['REQUEST_URI'].'"';
				echo '</script>';
				exit();
			endif;
			$retval .= $value.'<br />';
			$retval .= '<form action="" method="post" onsubmit="return confirm(\'Are you sure?\');">';
			$retval .= '<input type="hidden" name="lcs_lff_exh_submitted" value="2" />';
			$retval .= '<input type="hidden" name="id" value="'.$row->id.'" />';
			$retval .= '<input type="submit" name="submit" value="Delete" /><br />';
			$retval .= '</form>';
			break;
		case 'assign_to' :
			if ($_POST['lcs_lff_exh_submitted'] == 1 && !empty($_POST['assign_to'])) :
				$sql = "UPDATE ".$wpdb->prefix."lcs_exhibitor_contact_submissions SET ".
						"assign_to = ".$db->quote($_POST['assign_to']).", ".
						"assign_comment = ".$db->quote($_POST['assign_comment']).", ".
						"assign_timestamp = ".nzdatetime(date("Y-m-d H:i:s"))." ".
						"WHERE id = ".nz($_POST['id']);
				$db->query($sql) or die('Database Error!');
				$sql = "SELECT * FROM  ".$wpdb->prefix."lcs_exhibitor_contact_submissions WHERE id = ".nz($_POST['id']);
				$result = $db->query($sql) or die('Database Error!');
				$row = $result->fetch(PDO::FETCH_OBJ);
				//***************** mail using PEAR *******************
				require_once "Mail.php";
				$mail_body = '<html>'.
							'<style>body {font-family:Arial, Helvetica, sans-serif; font-size:14px;} table {font-size:14px;}</style>'.
							'You have been assigned the following exhibitor submission:<br><br>'. 
							'<b>Note:</b> '.$row->assign_comment.'<br>'.
							'<b>Assigned on:</b> '.$row->assign_timestamp.'<br><br>'.
							'<table style="border: 1px solid black;">'.
							'<tr><td><b>Name:</b> </td><td>'.$row->exhibitor_name.' </td></tr>'.
							'<tr><td><b>Business Name:</b> </td><td>'.$row->business_name.' </td></tr>'.
							'<tr><td><b>Email:</b> </td><td>'.$row->email.' </td></tr>'.
							'<tr><td><b>Phone:</b> </td><td>'.$row->phone.' </td></tr>'.
							'<tr><td><b>URL:</b> </td><td>'.$row->url.' </td></tr>'.
							'<tr><td><b>Type of Business:</b> </td><td>'.$row->business_type.' </td></tr>'.
							'<tr><td><b>Areas of Interest:</b> </td><td>'.$row->interests.' </td></tr>'.
							'<tr><td><b>Date:</b> </td><td>'.$row->timestamp.'</td></tr>'.
							'<tr><td><b>Submitted from IP address:</b> </td><td>'.$row->ip.'</td></tr>'.
							'</table><br>'.
							'Thank You, <br>'.
							'LI Fam Fest <br><br>'.
							'Admin link: <a href="'.str_ireplace('https://', 'http://', site_url()).'/wp-admin/admin.php?page=lcs_lff_data_admin">'.str_ireplace('https://', 'http://', site_url()).'/wp-admin/admin.php?page=lcs_lff_data_admin</a><br>'.
							'</html>' ;

				$pmail_from = get_option('lff_email_from');
				$pmail_to["To"] = $_POST['assign_to'];
				//$pmail_to["Bcc"] = get_option('woo_lcs_mb_bcc');
				$pmail_subject = 'LI Fam Fest - You have been assigned an exhibitor';
				$pmail_body = $mail_body;
				$pmail_host = get_cfg_var('SMTP');
				$pmail_username = "";
				$pmail_password = "";
				
				$pmail_headers = array ('From' => $pmail_from,
										'To' => $pmail_to["To"],
										'Subject' => $pmail_subject,
										'MIME-Version' => '1.0',
										'Content-type' => 'text/html; charset=iso-8859-1');
				$smtp = Mail::factory('smtp',
										array ('host' => $pmail_host,
										 //'auth' => true,
										 'auth' => false,
										 'username' => $pmail_username,
										 'password' => $pmail_password
										 ));
				
				$pmail = $smtp->send($pmail_to, $pmail_headers, $pmail_body);
				
				if (PEAR::isError($pmail)) :
					echo '<p><span style="color:red;">Error!  Unable to send email.</span></p>';
					exit();
				endif;
				//**********************************************************
				echo '<script>';
				echo 'window.location.href = "'.$_SERVER['REQUEST_URI'].'"';
				echo '</script>';
				exit();
			endif;
			if (empty($row->{$field_name})) :
				$retval .= '<form action="" method="post">';
				$retval .= '<input type="hidden" name="lcs_lff_exh_submitted" value="1" />';
				$retval .= '<input type="hidden" name="id" value="'.$row->id.'" />';
				$retval .= 'Assign to:<br />';
				//$retval .= '<input type="text" name="assign_to" /><br />';
				$retval .= '<select name="assign_to">';
				$retval .= '<option value=""></option>';
				$ar_assign = explode(',', get_option('lff_exhibitor_assign_to'));
				foreach ($ar_assign as $val) :
					$retval .= '<option value="'.trim($val).'" >'.trim($val).'</option>';
				endforeach;
				$retval .= '</select><br />';
				$retval .= 'Comment:<br />';
				$retval .= '<input type="text" name="assign_comment" /><br />';
				$retval .= '<input type="submit" name="submit" value="Assign" /><br />';
				$retval .= '</form>';
			else :
				$retval = $value;
			endif;
			break;
	endswitch;
	return $retval;
}

function lcs_lff_data_registrations() 
{
	wp_enqueue_style( 'lcs-lff-admin-style', plugins_url().'/lcs-lff-data/lcs_lff_data_admin.css', array(), filemtime(dirname(__FILE__).'/lcs_lff_data_admin.css'));
	global $db;
	global $wpdb;
	$search_str = '';
	if (!empty($_POST['search'])) :
		$search_str_fields = 'first_name,last_name,email,street,street2,city,state,zip,phone,purchase_date';
		$search_int_fields = 'ticket_nbr';
		$search_str = lcs_search_tokenize($search_str_fields, $search_int_fields, $_POST['search']);
	endif;
	$sql = "SELECT * FROM ".$wpdb->prefix."lcs_purchases ".$search_str." ORDER BY id DESC";
	lcs_lff_data_panel('Data Administration - Customer Registrations', $sql);
}

function lcs_lff_data_exhibitors() 
{
	wp_enqueue_style( 'lcs-lff-admin-style', plugins_url().'/lcs-lff-data/lcs_lff_data_admin.css', array(), filemtime(dirname(__FILE__).'/lcs_lff_data_admin.css'));
	global $db;
	global $wpdb;
	if (empty($_GET['func'])) :
		echo '<p><button onclick="window.location.href=\''.admin_url().'admin.php?page='.$_GET['page'].'&func=edit\';">Add New</button></p>';
		$search_str = '';
		if (!empty($_POST['search'])) :
			$search_str_fields = 'exhibitor_name,business_name,street,street2,city,state,zip,email,phone,url,writeup,sales_rep,region,category';
			$search_int_fields = 'show_year';
			$search_str = lcs_search_tokenize($search_str_fields, $search_int_fields, $_POST['search']);
		endif;
		$sql = "SELECT * FROM ".$wpdb->prefix."lcs_exhibitors ".$search_str." ORDER BY business_name ASC";
		lcs_lff_data_panel('Data Administration - Exhibitors', $sql, array('exhibitor_name'=>'lcs_lff_exh_edit'));
	elseif ($_GET['func'] == 'edit') :
		$_POST  = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);	
		$_POST = stripslashes_deep($_POST);
		//$_POST = array_map("strip_tags", $_POST);
		$current_user = wp_get_current_user();
		if (empty($_REQUEST['id'])) :
			$action = 'add';
			echo '<h1>Exhibitor - Add New</h1>';
			if (empty($_POST['lcs_lff_submitted'])) :
				$_POST['active'] = '1' ;
				$_POST['show_year'] = get_option('lff_exhibitor_current_show_year');
				$_POST['region'] = get_option('lff_exhibitor_current_region');
			endif;
		else :
			$action = 'edit';
			$sql = "SELECT * FROM ".$wpdb->prefix."lcs_exhibitors WHERE id = ".nz($_REQUEST['id'], '0');
			$result = $db->query($sql) or die('Database Error!');
			if ($result->rowCount() > 0) :
				$row = $result->fetch(PDO::FETCH_OBJ);
				echo '<h1>Exhibitor - Edit - '.$row->business_name.'</h1>';
				if (empty($_POST['lcs_lff_submitted'])) :
					foreach ($row as $key => $value) :
						$_POST[$key] = $value;
					endforeach;
				endif;
			else :
				echo '<h1>Invalid Operation!</h1>';
				return;
			endif;
		endif;
		global $ar_err;
		global $err_flag;
		$ar_err = array();
		if ($_POST['lcs_lff_submitted'] == '1') :
			//var_dump_pre($_POST);
			form_validate('exhibitor_name', 'string', true);
			form_validate('business_name', 'string', true);
			//form_validate('street', 'string', true);
			//form_validate('city', 'string', true);
			//form_validate('state', 'string', true);
			//form_validate('zip', 'string', true);
			form_validate('phone', 'string', true);
			//form_validate('email', 'email', true);
			//form_validate('url', 'url', false);
			form_validate('show_year', 'int', true);
			//form_validate('region', 'string', true);
			if (!$err_flag) :
				$set = "exhibitor_name = ".$db->quote(trim($_POST['exhibitor_name'])).", ".
						"business_name = ".$db->quote(trim($_POST['business_name'])).", ".
						"street = ".$db->quote(trim($_POST['street'])).", ".
						"street2 = ".$db->quote(trim($_POST['street2'])).", ".
						"city = ".$db->quote(trim($_POST['city'])).", ".
						"state = ".$db->quote(trim($_POST['state'])).", ".
						"zip = ".$db->quote(trim($_POST['zip'])).", ".
						"multi_address = ".nz(trim($_POST['multi_address']), '0').", ".
						"phone = ".$db->quote(trim($_POST['phone'])).", ".
						"email = ".$db->quote(trim($_POST['email'])).", ".
						"url = ".$db->quote(trim($_POST['url'])).", ".
						"active = ".nz(trim($_POST['active']), '0').", ".
						"show_year = ".nz(trim($_POST['show_year']), '0').", ".
						"region = ".$db->quote(trim($_POST['region'])).", ".
						"category = ".$db->quote(trim($_POST['category'])).", ".
						"comment = ".$db->quote(trim($_POST['comment'])).", ".
						"sales_rep = ".$db->quote(trim($_POST['sales_rep'])).", ".
						"writeup = ".$db->quote(trim($_POST['writeup'])).", ".
						"update_timestamp = ".$db->quote(date('Y-m-d H:i:s')).", ".
						"update_by = ".$db->quote(trim($current_user->user_login))." ";
				if ($action == 'edit') :
					$sql = "UPDATE ".$wpdb->prefix."lcs_exhibitors SET ".$set.
						"WHERE id = ".nz($_REQUEST['id'], '0')." ";
					$db->query($sql) or die('Database Error!');
					//echo '==='.$sql.'===';
					$_POST['update_by'] = trim($current_user->user_login);
					$_POST['update_timestamp'] = date('m/d/Y h:i:s a');
				else :
					if ($action == 'add') :
						$sql = "INSERT INTO ".$wpdb->prefix."lcs_exhibitors SET ".
							"create_timestamp = ".$db->quote(date('Y-m-d H:i:s')).", ".
							"create_by = ".$db->quote(trim($current_user->user_login)).", ".
							$set;
						//echo '==='.$sql.'===';
						$db->query($sql) or die('Database Error!');
						$_POST['id'] = last_id();
						$_POST['create_by'] = trim($current_user->user_login);
						$_POST['create_timestamp'] = date('m/d/Y h:i:s a');
						$_POST['update_by'] = trim($current_user->user_login);
						$_POST['update_timestamp'] = date('m/d/Y h:i:s a');
					endif;
				endif;
				echo '<h2 class="form_ok">Saved Succesfully!</h2>';
				if ($_POST['submit'] == 'Save & New') :
					echo '<script>';
					echo 'window.location.href="'.site_url().'/wp-admin/admin.php?page=lcs_lff_data_exhibitors&func=edit";';
					echo '</script>';
					return;
				elseif ($_POST['submit'] == 'Save & Close') :
					echo '<script>';
					echo 'window.location.href="'.site_url().'/wp-admin/admin.php?page=lcs_lff_data_exhibitors";';
					echo '</script>';
					return;
				endif;
			else :
				echo '<h2 class="form_error">Errors found!</h2>';
			endif;
		else :
		endif;
		//var_dump_pre($current_user);
		echo '<form method="post" action="">';
		echo '<input type="hidden" name="lcs_lff_submitted" value="1" />';
		echo '<div class="input_column">';
		form_field('id', 'text', 10, 0, false, false, true, '', '', 'id', 'Exhibitor ID');
		form_field('exhibitor_name', 'text', 100, 0, true, false, false, '', '', 'exhibitor_name', 'Exhibitor Name');
		form_field('business_name', 'text', 100, 0, true, false, false, '', '', 'business_name', 'Business Name');
		form_field('street', 'text', 75, 0, false, false, false, '', '', 'street', 'Street Address');
		form_field('street2', 'text', 75, 0, false, false, false, '', '', 'street2', '');
		form_field('city', 'text', 50, 0, false, false, false, '', '', 'city', 'City');
		//form_field('state', 'text', 50, 0, true, false, false, '', '', 'state', 'State');
		$sql = "SELECT state, state_name FROM ".$wpdb->prefix."lcs_states WHERE country_sort_code = 1 ORDER BY state_name ";
		$result = $db->query($sql) or die('Database Error!');
		$ar_states = $result->fetchAll(PDO::FETCH_KEY_PAIR);
		form_field('state', 'select', 50, 0, false, false, false, '', '', 'state', 'State', $ar_states);
		form_field('zip', 'text', 15, 0, false, false, false, '', '', 'zip', 'Zip');
		form_field('phone', 'text', 50, 0, false, false, false, '', '', 'phone', 'Phone');
		form_field('email', 'text', 75, 0, false, false, false, '', '', 'email', 'Email');
		form_field('url', 'text', 75, 0, false, false, false, '', '', 'url', 'URL');
		form_field('multi_address', 'checkbox', 50, 0, false, false, false, '', '', 'multi_address', 'Multiple Addresses');
		form_field('active', 'checkbox', 50, 0, false, false, false, '', '', 'active', 'Active');
		echo '</div>';
		echo '<div class="input_column">';
		$ar_show_years = explode(',', get_option('lff_exhibitor_show_years'));
		$ar_show_years = array_map('trim', $ar_show_years);
		form_field('show_year', 'select', 50, 0, true, false, false, '', '', 'show_year', 'Show Year', $ar_show_years);
		$ar_regions = explode(',', get_option('lff_exhibitor_regions'));
		$ar_regions = array_map('trim', $ar_regions);
		//form_field('region', 'select', 50, 0, false, false, false, '', '', 'region', 'Region', $ar_regions);
		$ar_sales_reps = explode(',', get_option('lff_exhibitor_sales_reps'));
		$ar_sales_reps = array_map('trim', $ar_sales_reps);
		form_field('sales_rep', 'select', 50, 0, false, false, false, '', '', 'sales_rep', 'Sales Rep', $ar_sales_reps);
		$ar_categories = explode(',', get_option('lff_exhibitor_categories'));
		$ar_categories = array_map('trim', $ar_categories);
		form_field('category', 'select', 50, 0, false, false, false, '', '', 'category', 'Category', $ar_categories);
		form_field('writeup', 'textarea', 70, 10, false, false, false, '', '', 'writeup', 'Writeup');
		form_field('comment', 'textarea', 70, 5, false, false, false, '', '', 'comment', 'Comment');
		echo '</div>';
		echo '<div class="input_column">';
		form_field('create_timestamp', 'text', 50, 0, false, false, true, '', '', 'create_timestamp', 'Date Created');
		form_field('create_by', 'text', 50, 0, false, false, true, '', '', 'create_by', 'Created By');
		form_field('update_timestamp', 'text', 50, 0, false, false, true, '', '', 'update_timestamp', 'Date Updated');
		form_field('update_by', 'text', 50, 0, false, false, true, '', '', 'update_by', 'Updated By');
		echo '</div>';
		echo '<div class="clear_div"></div>';
		echo '<input type="submit" name="submit" value="Save" />';
		echo '&emsp;<input type="submit" name="submit" value="Save &amp; New" />';
		echo '&emsp;<input type="submit" name="submit" value="Save &amp; Close" />';
		echo '&emsp;<input type="button" value="Cancel" onclick="window.location.href=\''.site_url().'/wp-admin/admin.php?page=lcs_lff_data_exhibitors\';" />';
		echo '</form>';
	endif;
}

function lcs_lff_exh_edit($value, $row, $field_name)
{
	global $db;
	global $wpdb;
	$retval = '';
	switch ($field_name) :
		case 'exhibitor_name' :
			$retval .= '<a href="'.site_url().'/wp-admin/admin.php?page=lcs_lff_data_exhibitors&func=edit&id='.$row->id.'">'.$value.'</a>';
			break;
	endswitch;
	return $retval;
}

function lcs_lff_data_coupon_codes() 
{
	wp_enqueue_style( 'lcs-lff-admin-style', plugins_url().'/lcs-lff-data/lcs_lff_data_admin.css', array(), filemtime(dirname(__FILE__).'/lcs_lff_data_admin.css'));
	global $db;
	global $wpdb;
	if (empty($_GET['func'])) :
		echo '<p><button onclick="window.location.href=\''.admin_url().'admin.php?page='.$_GET['page'].'&func=edit\';">Add New</button></p>';
		$search_str = '';
		if (!empty($_POST['search'])) :
			$search_str_fields = 'sku,code,type';
			$search_int_fields = '';
			$search_str = lcs_search_tokenize($search_str_fields, $search_int_fields, $_POST['search']);
		endif;
		$sql = "SELECT * FROM ".$wpdb->prefix."lcs_promo_codes ".$search_str." ORDER BY code ASC";
		lcs_lff_data_panel('Data Administration - Coupon Codes', $sql, array('code'=>'lcs_lff_coupon_edit'));
	elseif ($_GET['func'] == 'edit') :
		$_POST  = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);	
		$_POST = stripslashes_deep($_POST);
		$current_user = wp_get_current_user();
		if (empty($_REQUEST['id'])) :
			$action = 'add';
			echo '<h1>Coupon Code - Add New</h1>';
			if (empty($_POST['lcs_lff_submitted'])) :
				/*
				$_POST['active'] = '1' ;
				$_POST['show_year'] = get_option('lff_exhibitor_current_show_year');
				$_POST['region'] = get_option('lff_exhibitor_current_region');
				*/
			endif;
		else :
			$action = 'edit';
			$sql = "SELECT * FROM ".$wpdb->prefix."lcs_promo_codes WHERE id = ".nz($_REQUEST['id'], '0');
			$result = $db->query($sql) or die('Database Error!');
			if ($result->rowCount() > 0) :
				$row = $result->fetch(PDO::FETCH_OBJ);
				echo '<h1>Coupon Code - Edit - '.$row->code.'</h1>';
				if (empty($_POST['lcs_lff_submitted'])) :
					foreach ($row as $key => $value) :
						$_POST[$key] = $value;
					endforeach;
				endif;
			else :
				echo '<h1>Invalid Operation!</h1>';
				return;
			endif;
		endif;
		global $ar_err;
		global $err_flag;
		$ar_err = array();
		if ($_POST['lcs_lff_submitted'] == '1') :
			//var_dump_pre($_POST);
			form_validate('code', 'string', true);
			form_validate('type', 'string', true);
			form_validate('value', 'float', true);
			form_validate('expires', 'date', true);
			form_validate('sku', 'string', true);
			form_validate('reg_price', 'float', true);
			form_validate('uses_left', 'int', false);
			if (!$err_flag) :
				$set = "code = ".$db->quote(trim($_POST['code'])).", ".
						"type = ".$db->quote(trim($_POST['type'])).", ".
						"sku = ".$db->quote(trim($_POST['sku'])).", ".
						"value = ".nzfloat($_POST['value'], '0').", ".
						"expires = ".nzdate($_POST['expires']).", ".
						"limited_use = ".nz($_POST['limited_use'], '0').", ".
						"uses_left = ".nz($_POST['uses_left'], '0').", ".
						"reg_price = ".nzfloat($_POST['reg_price'], '0').", ".
						"update_timestamp = ".$db->quote(date('Y-m-d H:i:s')).", ".
						"update_by = ".$db->quote(trim($current_user->user_login))." ";
				if ($action == 'edit') :
					$sql = "UPDATE ".$wpdb->prefix."lcs_promo_codes SET ".$set.
						"WHERE id = ".nz($_REQUEST['id'], '0')." ";
					$db->query($sql) or die('Database Error!');
					//echo '==='.$sql.'===';
					$_POST['update_by'] = trim($current_user->user_login);
					$_POST['update_timestamp'] = date('m/d/Y h:i:s a');
				else :
					if ($action == 'add') :
						$sql = "INSERT INTO ".$wpdb->prefix."lcs_promo_codes SET ".
							"create_timestamp = ".$db->quote(date('Y-m-d H:i:s')).", ".
							"create_by = ".$db->quote(trim($current_user->user_login)).", ".
							$set;
						//echo '==='.$sql.'===';
						$db->query($sql) or die('Database Error!');
						$_POST['id'] = last_id();
						$_POST['create_by'] = trim($current_user->user_login);
						$_POST['create_timestamp'] = date('m/d/Y h:i:s a');
						$_POST['update_by'] = trim($current_user->user_login);
						$_POST['update_timestamp'] = date('m/d/Y h:i:s a');
					endif;
				endif;
				echo '<h2 class="form_ok">Saved Succesfully!</h2>';
				if ($_POST['submit'] == 'Save & New') :
					echo '<script>';
					echo 'window.location.href="'.site_url().'/wp-admin/admin.php?page=lcs_lff_data_coupon_codes&func=edit";';
					echo '</script>';
					return;
				elseif ($_POST['submit'] == 'Save & Close') :
					echo '<script>';
					echo 'window.location.href="'.site_url().'/wp-admin/admin.php?page=lcs_lff_data_coupon_codes";';
					echo '</script>';
					return;
				endif;
			else :
				echo '<h2 class="form_error">Errors found!</h2>';
			endif;
		else :
		endif;
		//var_dump_pre($current_user);
		echo '<form method="post" action="">';
		echo '<input type="hidden" name="lcs_lff_submitted" value="1" />';
		echo '<div class="input_column">';
		form_field('id', 'text', 10, 0, false, false, true, '', '', 'id', 'Coupon Code ID');
		form_field('code', 'text', 25, 0, true, false, false, '', '', 'code', 'Coupon Code');
		form_field('type', 'radiogroup', 50, 0, true, false, false, '', '', 'type', 'Coupon Type', array('amt_off', 'amt_sale', 'pct_off'));
		form_field('value', 'text', 10, 0, true, false, false, '', '', 'value', 'Coupon Value');
		form_field('sku', 'text', 30, 0, true, false, false, '', '', 'sku', 'SKU');
		form_field('reg_price', 'text', 10, 0, true, false, false, '', '', 'reg_price', 'Regular Price');
		form_field('expires', 'text', 10, 0, true, false, false, '', '', 'expires', 'Expires (YYYY-MM-DD)');
		form_field('limited_use', 'checkbox', 50, 0, false, false, false, '', '', 'limited_use', 'Limited Use');
		form_field('uses_left', 'text', 10, 0, false, false, false, '', '', 'uses_left', 'Uses Left');
		echo '</div>';
		echo '<div class="input_column">';
		form_field('create_timestamp', 'text', 50, 0, false, false, true, '', '', 'create_timestamp', 'Date Created');
		form_field('create_by', 'text', 50, 0, false, false, true, '', '', 'create_by', 'Created By');
		form_field('update_timestamp', 'text', 50, 0, false, false, true, '', '', 'update_timestamp', 'Date Updated');
		form_field('update_by', 'text', 50, 0, false, false, true, '', '', 'update_by', 'Updated By');
		echo '</div>';
		echo '<div class="clear_div"></div>';
		echo '<input type="submit" name="submit" value="Save" />';
		echo '&emsp;<input type="submit" name="submit" value="Save &amp; New" />';
		echo '&emsp;<input type="submit" name="submit" value="Save &amp; Close" />';
		echo '&emsp;<input type="button" value="Cancel" onclick="window.location.href=\''.site_url().'/wp-admin/admin.php?page=lcs_lff_data_coupon_codes\';" />';
		echo '</form>';
	endif;
}

function lcs_lff_coupon_edit($value, $row, $field_name)
{
	global $db;
	global $wpdb;
	$retval = '';
	switch ($field_name) :
		case 'code' :
			$retval .= '<a href="'.site_url().'/wp-admin/admin.php?page=lcs_lff_data_coupon_codes&func=edit&id='.$row->id.'">'.$value.'</a>';
			break;
	endswitch;
	return $retval;
}

function lcs_search_tokenize($str_fields, $int_fields, $search) 
{
	global $db;
	$result = '';
	$ar_result = array();
	if (!empty($str_fields)) :
		$search_str = $db->quote('%'.$search.'%');
		$ar_str = explode(',', $str_fields);
		foreach ($ar_str as $field) :
			$ar_result[] = " ".$field." LIKE ".$search_str." ";
		endforeach;
	endif;
	if (!empty($int_fields)) :
		$search_int = nz($search, '0');
		$ar_int = explode(',', $int_fields);
		foreach ($ar_int as $field) :
			$ar_result[] = " ".$field." = ".$search_int." ";
		endforeach;
	endif;
	$result = implode(" OR ", $ar_result);
	if (!empty($result)) :
		$result = " WHERE ".$result;
	endif;
	return $result;
}

function lcs_lff_data_panel($title, $sql, $ar_funcs = array()) 
{
	global $db;
	global $wpdb;
	$excel_url = site_url() . '/wp-content/plugins/' . "lcs-lff-data" . '/export_excel.php';
	if (empty($_SESSION['lcs_rand_key'])) :
		$_SESSION['lcs_rand_key'] = generate_random_string(32);
	endif;
	echo '<h1>'.$title.'</h1>';
	//echo '<p>SQL: '.$sql.'</p>';
	$result = $db->query($sql) or die('Database Error!');
	if ($result->rowCount() > 0) :
		//echo '<p>';
		echo '<style>';
		echo 'form {display:inline-block;}';
		echo 'table.lcs_data_table td {vertical-align:top;}';
		echo '</style>';
		echo '<div>';
		echo $result->rowCount().' records found.&emsp;';
		echo '<button onclick="exportExcel(\''.urlencode(lcs_lff_sys_encrypt(gzcompress($sql,6), $_SESSION['lcs_rand_key'])).'\')">Export to Excel&reg;</button>';
		//echo '<p>SQL: '.$sql.'</p>';
		echo '&emsp;Search: <form method="post" action="">';
		echo '<input type="text" class="search" name="search" value="'.stripslashes_deep($_POST['search']).'" />';
		echo '<input type="submit" name="submit" value="Find" />';
		echo '</form>';
		echo '&emsp;<button onclick="window.location.href=window.location.href">List All</button>';
		echo '</div>';
		echo '<br /><br />';
		//echo '</p>';
		echo '<table class="lcs_data_table" style="border-collapse:collapse; border:1px solid #000000;">';
		echo '<thead><tr>';
		$ar_field_types = array();
		$ar_field_names = array();
		$i = 0;
		while ($i < $result->columnCount()) :
			$meta = $result->getColumnMeta($i);
			if (!$meta) :
				$ar_field_types[$i] = 'string';
				$column_name = 'column_'.$i;
			else :
				$ar_field_types[$i] = strtolower($meta['native_type']);
				$column_name = $meta['name'];
			endif;
			$ar_field_names[$i] = $column_name;
			echo '<th style="border:1px solid #000000; padding:5px;">'.$column_name.'</th>';
			$i++;
		endwhile;
		echo '</tr></thead>';
		while ($row = $result->fetch(PDO::FETCH_OBJ)) :
			echo '<tr>';
			$curr_col = 0;
			foreach($row as $row_field) :
				$row_field = utf8_encode($row_field);
				$value = '';
				if ($ar_field_types[$curr_col] == 'long' || $ar_field_types[$curr_col] == 'longlong') :
					$align = 'right';
					$value = intval(html_entity_decode($row_field, ENT_QUOTES));
				elseif ($ar_field_types[$curr_col] == 'newdecimal' || $ar_field_types[$curr_col] == 'float') :
					$align = 'right';
					$value = number_format(floatval(html_entity_decode($row_field, ENT_QUOTES)), 2, '.', ',');
				else :
					$align = 'left';
					$value = trim(html_entity_decode($row_field, ENT_QUOTES));
					if (strtolower(substr($row_field,0,7)) == 'http://' || strtolower(substr($row_field,0,8)) == 'https://') :
						$value = '<a target="_blank" href="'.$value.'">'.$value.'</a>';
					endif;
				endif;
				if (!empty($ar_funcs[$ar_field_names[$curr_col]])) :
					$value = $ar_funcs[$ar_field_names[$curr_col]]($value, $row, $ar_field_names[$curr_col]);
				endif;
				echo '<td style="border:1px solid #000000; padding:5px;" align="'.$align.'">'.$value.'</td>';
				$curr_col = $curr_col + 1;
			endforeach;
			echo '</tr>';
		endwhile;
		echo '</table>';
?>
		<script>
			exportExcel = function(xls_sql)
			{
				window.location.href = "<?php echo $excel_url; ?>?sql=" + xls_sql;
				//rptWindowName = this.open("<?php echo $excel_url; ?>?sql=" + xls_sql, "rptWindowName", "scrollbars=yes, resizable=yes, location=no, toolbar=no, menubar=no");
				//rptWindowName.focus();
			}
		</script>

<?php		
	else :
		echo '<p>No records found.</p>';
		echo '<button onclick="window.location.href=window.location.href">List All</button>';
	endif;
}

function lcs_lff_sys_encrypt($string, $key) {
	return @openssl_encrypt($string, 'AES-128-CFB', $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
}

function lcs_lff_sys_decrypt($string, $key) {
	return @openssl_decrypt($string, 'AES-128-CFB', $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
}


Youez - 2016 - github.com/yon3zu
LinuXploit