public function init() { if (isset($_REQUEST['_process'])) { // fix up WordPress bork: // todo: don't overwrite default superglobals, run stripslashes every time before we use the content, because another plugin might be stripslashing already $_POST = stripslashes_deep($_POST); $_GET = stripslashes_deep($_GET); $_REQUEST = stripslashes_deep($_REQUEST); $process_action = $_REQUEST['_process']; $process_options = array(); $shub_message_id = false; if ($process_action == 'send_shub_message' && check_admin_referer('shub_send-message')) { // we are sending a social message! yay! $send_time = time(); // default: now if (isset($_POST['schedule_date']) && isset($_POST['schedule_time']) && !empty($_POST['schedule_date']) && !empty($_POST['schedule_time'])) { $date = $_POST['schedule_date']; $time_hack = $_POST['schedule_time']; $time_hack = str_ireplace('am', '', $time_hack); $time_hack = str_ireplace('pm', '', $time_hack); $bits = explode(':', $time_hack); if (strpos($_POST['schedule_time'], 'pm')) { $bits[0] += 12; } // add the time if it exists $date .= ' ' . implode(':', $bits) . ':00'; $send_time = strtotime($date); //echo $date."<br>".$send_time."<br>".shub_print_date($send_time,true);exit; } else { if (isset($_POST['schedule_date']) && !empty($_POST['schedule_date'])) { $send_time = strtotime($_POST['schedule_date']); } } // wack a new entry into the shub_message database table and pass that onto our message_managers below $shub_message_id = shub_update_insert('shub_message_id', false, 'shub_message', array('post_id' => isset($_POST['post_id']) ? $_POST['post_id'] : 0, 'sent_time' => $send_time)); if ($shub_message_id) { $process_options['shub_message_id'] = $shub_message_id; $process_options['send_time'] = $send_time; } else { die('Failed to create social message'); } /* @var $message_manager shub_facebook */ $message_count = 0; foreach ($this->message_managers as $name => $message_manager) { $message_count += $message_manager->handle_process($process_action, $process_options); } if ($shub_message_id && !$message_count) { // remove the gobal social message as nothing worked. shub_delete_from_db('shub_message', 'shub_message_id', $shub_message_id); } else { if ($shub_message_id) { shub_update_insert('shub_message_id', $shub_message_id, 'shub_message', array('message_count' => $message_count)); } } if (isset($_POST['debug']) && $_POST['debug']) { echo "<br><hr> Successfully sent {$message_count} messages <hr><br><pre>"; print_r($_POST); print_r($process_options); echo "</pre><hr><br>Completed"; exit; } header("Location: admin.php?page=support_hub_sent"); exit; } else { if ($process_action == 'save_general_settings') { if (check_admin_referer('save-general-settings')) { if (isset($_POST['possible_shub_manager_enabled'])) { foreach ($_POST['possible_shub_manager_enabled'] as $id => $tf) { if (isset($_POST['shub_manager_enabled'][$id]) && $_POST['shub_manager_enabled'][$id]) { update_option('shub_manager_enabled_' . $id, 1); } else { update_option('shub_manager_enabled_' . $id, 0); } } header("Location: admin.php?page=support_hub_settings"); exit; } } } else { if ($process_action == 'save_log_settings') { if (check_admin_referer('save-log-settings')) { if (!empty($_POST['enable_logging'])) { update_option('shub_logging_enabled', time() + 3600 * 24); } if (!empty($_POST['remove_logs'])) { global $wpdb; $wpdb->query($wpdb->prepare("DELETE FROM `" . _support_hub_DB_PREFIX . "shub_log` WHERE log_time <= %d", $_POST['remove_logs'])); } header("Location: admin.php?page=support_hub_settings&tab=logs"); exit; } } else { if ($process_action == 'save_encrypted_vault') { if (check_admin_referer('save-encrypted-vault') && !empty($_POST['public_key']) && !empty($_POST['private_key'])) { update_option('shub_encrypt_public_key', $_POST['public_key']); update_option('shub_encrypt_private_key', $_POST['private_key']); header("Location: admin.php?page=support_hub_settings&tab=extra"); exit; } } else { if ($process_action == 'save_extra_details') { $shub_extra_id = !empty($_REQUEST['shub_extra_id']) ? (int) $_REQUEST['shub_extra_id'] : 0; if (check_admin_referer('save-extra' . $shub_extra_id)) { $shub_extra = new SupportHubExtra($shub_extra_id); if (isset($_REQUEST['butt_delete'])) { $shub_extra->delete(); header("Location: admin.php?page=support_hub_settings&tab=extra"); exit; } if (!$shub_extra->get('shub_extra_id')) { $shub_extra->create_new(); } $shub_extra->update($_POST); $shub_extra_id = $shub_extra->get('shub_extra_id'); header("Location: admin.php?page=support_hub_settings&tab=extra"); //&shub_extra_id=" . $shub_extra_id ); exit; } } else { if ($process_action == 'save_product_details') { $shub_product_id = !empty($_REQUEST['shub_product_id']) ? (int) $_REQUEST['shub_product_id'] : 0; if (check_admin_referer('save-product' . $shub_product_id)) { $shub_product = new SupportHubProduct($shub_product_id); if (isset($_REQUEST['butt_delete'])) { $shub_product->delete(); header("Location: admin.php?page=support_hub_settings&tab=products"); exit; } if (!$shub_product->get('shub_product_id')) { $shub_product->create_new(); } $shub_product->update($_POST); $shub_product_id = $shub_product->get('shub_product_id'); header("Location: admin.php?page=support_hub_settings&tab=products"); //&shub_product_id=" . $shub_product_id ); exit; } } else { // just process each request normally: /* @var $message_manager shub_facebook */ foreach ($this->message_managers as $name => $message_manager) { $message_manager->handle_process($process_action, $process_options); } } } } } } } } }
$shub_extra = new SupportHubExtra(); if ($current_extra !== false) { $shub_extra->load($current_extra); ?> <div class="wrap"> <h2> <?php _e('Extra Details', 'support_hub'); ?> </h2> <form action="" method="post"> <input type="hidden" name="_process" value="save_extra_details"> <input type="hidden" name="shub_extra_id" value="<?php echo (int) $shub_extra->get('shub_extra_id'); ?> "> <?php wp_nonce_field('save-extra' . (int) $shub_extra->get('shub_extra_id')); ?> <table class="form-table"> <tbody> <tr> <th class="width1"> <?php _e('Extra Name', 'support_hub'); ?> </th> <td class="">