0byt3m1n1
Path:
/
home1
/
aserty
/
public_html
/
appartsoft.info
/
wp-content
/
plugins
/
wp-assistant
/
appoint
/
[
Home
]
File: class.php
<?php global $app_plugin_dir, $app_plugin_url; $app_plugin_dir = plugin_dir_path(__FILE__); $app_plugin_url = WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)) . '/'; include_once $app_plugin_dir . 'classes/db.class.php'; class appAppointment extends appointmentDb { public $plugin_name; public static $app_setting_key = "__appointment_setting"; public static $app_defaultsetting_key = "__defaultsetting_key"; public $generalsetting; public $defaultformsetting; public function __construct() { global $pluginname; $this->plugin_name = $pluginname; $this->generalsetting = get_option(self::$app_setting_key); $this->defaultformsetting = get_option(self::$app_defaultsetting_key); add_action('admin_menu', array(&$this, 'admin_menu')); add_action('init', array(&$this, 'init')); add_shortcode('appointment-form', array(&$this, 'appointmentShort')); add_filter('mce_external_plugins', array($this, "app_tinyregister")); add_filter('mce_buttons', array($this, 'app_tinybutton'), 0); } public function app_tinybutton($buttons) { array_push($buttons, "separator", "appointmentplugin"); return $buttons; } public function app_tinyregister($plugin_array) { global $app_plugin_url; $url = $app_plugin_url . "js/tinty.js"; $plugin_array["appointmentplugin"] = $url; return $plugin_array; } public function init() { global $app_plugin_url; wp_enqueue_script('jquery'); wp_enqueue_script('app-script', $app_plugin_url . 'js/script.js'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_style('jquery-ui-all', $app_plugin_url . 'css/jquery.ui.all.css'); wp_enqueue_style('app-style', $app_plugin_url . 'css/style.css'); wp_enqueue_script('jquery-datepicker', $app_plugin_url . 'js/jquery.datepicker.js'); wp_enqueue_script('jquery-validateapp', $app_plugin_url . "js/jquery.validate.js"); if (isset($_GET['activate']) && $_GET['activate'] == 'true') { $this->createTable(); } } public function admin_menu() { global $app_plugin_url; add_menu_page(__($this->plugin_name), __($this->plugin_name), 8, 'appoint-setting', array(&$this, 'appSetting')); add_submenu_page('appoint-setting', 'Response Settings', 'Response Settings', 8, 'appoint-setting', array(&$this, 'appSetting')); add_submenu_page('appoint-setting', 'Appointment List', 'Appointment List', 6, 'appoint-list', array(&$this, 'appList')); add_submenu_page('appoint-setting', 'Form Settings', 'Form Settings', 6, 'form-setting', array(&$this, 'frmSetting')); } public function appSetting() { global $app_plugin_dir; if (isset($_POST['save'])) { unset($_POST['save']); $this->generalsetting = (object) $_POST; update_option(self::$app_setting_key, $this->generalsetting); } include_once $app_plugin_dir . 'pages/general-setting.php'; } public function appList() { global $app_plugin_dir, $app_plugin_url; if (isset($_GET['mode']) && $_GET['mode'] == "delete" && isset($_GET['aid'])) { if ($this->deleteAppointmentbyid($_GET['aid'])) { $this->redirect('admin.php?page=appoint-list&msg=deleted'); } } if (isset($_POST['submit'])) { unset($_POST['submit']); foreach ($_POST as $key => $value) { $arrayId = explode("_", $key); if (isset($arrayId[0]) && isset($arrayId[1]) && $arrayId[0] == "status") { $this->updateAppointmentstatus($value, $arrayId[1]); } } } include_once $app_plugin_dir . 'pages/list-appointment.php'; } public function frmSetting() { global $app_plugin_dir, $wpdb; if (isset($_POST['savedefaultsetting'])) { unset($_POST['savedefaultsetting']); $this->defaultformsetting = (object) $_POST; update_option(self::$app_defaultsetting_key, $this->defaultformsetting); } if (isset($_POST['save'])) { $id = $_POST['id']; $_POST['required'] = isset($_POST['required']) ? 1 : 0; $arrRemove = array('save', 'id'); $arrSave = array(); foreach ($_POST as $key => $value) { if (in_array($key, $arrRemove)) continue; $arrSave[$key] = $value; } $message = $this->saveFormSetting($arrSave, $id); if ($message) $this->redirect('admin.php?page=form-setting&msg=' . $message); } if (isset($_GET['mode']) && $_GET['mode'] == "edit") { $result = $this->get_formdata_by_id($_GET['id']); } if (isset($_GET['action']) && $_GET['action'] == "active") { $this->get_formdata_active($_GET['id']); $this->redirect('admin.php?page=form-setting&msg=active'); } if (isset($_GET['action']) && $_GET['action'] == "deactive") { $this->get_formdata_deactive($_GET['id']); $this->redirect('admin.php?page=form-setting&msg=deactive'); } if (isset($_GET['action']) && $_GET['action'] == "delete") { $this->deleteFormdata($_GET['frmid']); $this->redirect('admin.php?page=form-setting&msg=Delete'); } include_once $app_plugin_dir . 'pages/form-setting.php'; } public function redirect($location) { echo '<SCRIPT type="text/javascript">window.location="' . $location . '";</SCRIPT>'; } public function appointmentShort() { global $app_plugin_dir, $app_plugin_url; if (isset($_POST['aposubmit'])) { $arrError = array(); if (!isset($this->defaultformsetting->alldefault) && !isset($this->defaultformsetting->verificationdefault)) $arrError = $this->validAppoinmentfrm(); if (count($arrError) == 0) { $arrAppoemail = array(); $saveArray=array(); $subject = 'Appointment Request:' . stripcslashes($_POST['txtapname']); $body = ""; if (!isset($this->defaultformsetting->alldefault)) { if (!isset($this->defaultformsetting->namedefault)){ $saveArray['name']=$_POST['txtapname']; $body.='Name:' . stripcslashes($_POST['txtapname']) . '<br/>'; } if (!isset($this->defaultformsetting->emaildefault)){ $saveArray['email'] = $_POST['txtapemail']; $body.='Email:' . stripcslashes($_POST['txtapemail']) . '<br/>'; } if (!isset($this->defaultformsetting->phonedefault)){ $saveArray['phone'] = $_POST['txtapphone']; $body.='Phone Number:' . stripcslashes($_POST['txtapphone']) . '<br/>'; } if (!isset($this->defaultformsetting->datedefault)){ $saveArray['date'] = $_POST['txtapdate']; $body.='Appointment Date:' . stripcslashes($_POST['txtapdate']) . '<br/>'; } if (!isset($this->defaultformsetting->timedefault)){ $saveArray['aptime'] = $_POST['aptime']; $body.='Appointment Time:' . $_POST['aptime'] . '<br/>'; } if (!isset($this->defaultformsetting->messagedefault)){ $saveArray['message'] = $_POST['txtapcomments']; $body.='Comments: ' . stripcslashes($_POST['txtapcomments']) . '<br/>'; } if (!isset($this->defaultformsetting->appointmentdefault)){ $userdata = get_user_by('id', $_POST['memid']); $arrAppoemail[] = $userdata->data->user_email; $saveArray['memid'] = $_POST['memid']; $body.='Member Name: ' . stripslashes(ucfirst($userdata->data->display_name)) . '<br/>'; } } $cusmailbody= $this->generalsetting->msgbody; $activeField=$this->getactiveFormfield(); if($activeField && count($activeField)>0){ foreach($activeField as $field){ $body.=$field->lblname.' : ' . stripslashes($_POST['appid'.$field->columnstored]). '<br/>'; $saveArray['appid'.$field->columnstored]=stripslashes($_POST['appid'.$field->columnstored]); $cusmailbody = str_replace('['.$field->fldid.']', stripslashes($_POST['appid'.$field->columnstored]), $cusmailbody); } } $arrAppoemail[] = $this->generalsetting->appemail; if ($this->sendMail($arrAppoemail, $subject, $body, stripcslashes($_POST['txtapname']), $_POST['txtapemail'])) { $this->saveAppointment($saveArray); $cusmailbody = str_replace(array('[name]', '[email]', '[phone]', '[date]', '[time]', '[member]'), array(stripcslashes($_POST['txtapname']), $_POST['txtapemail'], $_POST['txtapphone'], $_POST['txtapdate'], $_POST['aptime'], stripslashes(ucfirst($userdata->data->display_name))), $cusmailbody); $this->sendMail($_POST['txtapemail'], "Appointment Request", $cusmailbody, stripslashes($this->generalsetting->appname), $this->generalsetting->appemail); $sucmessage = "<p>Your email has been sent successfully!!!</p>"; if (isset($_POST)) unset($_POST); } else { $sucmessage = ""; } } } include $app_plugin_dir . 'pages/appoinment-form.php'; } public function getUsersofspecificroll($role) { $wp_user_search = new WP_User_Query(array('role' => $role)); return $wp_user_search->get_results(); } public function sendMail($email, $subject, $mailbody, $fromname="", $fromemail="") { $emailbody = "<html><head><title>" . $subject . "</title></head><body>"; $emailbody .=stripcslashes($mailbody); $emailbody .="</body></html> "; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; if ($fromemail != "") { $headers .= "From:" . $fromname . " <" . $fromemail . "> "; } return wp_mail($email, $subject, $emailbody, $headers); } public function validAppoinmentfrm() { if (md5($_POST['apverif_box']) . 'a4xn' != $_COOKIE['appoinment_verification_image']) { $arrError['apcode'] = 'Wrong verification code.'; } return $arrError; } } new appAppointment(); ?>