本文整理汇总了PHP中redirect_browser函数的典型用法代码示例。如果您正苦于以下问题:PHP redirect_browser函数的具体用法?PHP redirect_browser怎么用?PHP redirect_browser使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了redirect_browser函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$this->module_name = "pin";
$this->module_position = 0;
module_config::register_css('pin', 'pin.css');
module_config::register_js('pin', 'pin.js');
$this->version = 2.11;
//2.11 css tweak
if (isset($_REQUEST['pin_process']) && module_security::is_logged_in() && module_pin::can_i('edit', 'Header Pin')) {
switch ($_REQUEST['pin_process']) {
case 'pin_save':
switch ($_REQUEST['pin_action']) {
case 'modify':
if ($_REQUEST['pin_id'] && $_REQUEST['current_title']) {
$this->update_pin($_REQUEST['pin_id'], false, $_REQUEST['current_title']);
set_message('Pin modified successfully');
redirect_browser($_REQUEST['current_url']);
}
break;
case 'delete':
if ($_REQUEST['pin_id']) {
$this->delete_pin($_REQUEST['pin_id']);
set_message('Pin deleted successfully');
redirect_browser($_REQUEST['current_url']);
}
break;
case 'add':
if ($_REQUEST['current_url'] && $_REQUEST['current_title']) {
$pin_id = $this->add_pin($_REQUEST['current_url'], $_REQUEST['current_title']);
if ($pin_id) {
set_message('Pin added successfully');
} else {
set_message('Pin already exists');
}
redirect_browser($_REQUEST['current_url']);
}
break;
}
break;
}
}
}
示例2: htmlspecialchars
$template->assign_values($data);
echo $template->render('pretty_html');
exit;
}
}
} else {
// show normal unsubscribe form. asking for their email address.
if (isset($_REQUEST['email']) && trim($_REQUEST['email'])) {
$email = htmlspecialchars(strtolower(trim($_REQUEST['email'])));
if (!module_newsletter::unsubscribe_member_via_email($email)) {
echo 'Unsubscribe failed... Please enter a valid email address.';
exit;
}
// is the newsletter module giving us a subscription redirection?
if (module_config::c('newsletter_unsubscribe_redirect', '')) {
redirect_browser(module_config::c('newsletter_unsubscribe_redirect', ''));
}
// or display a message.
$template = module_template::get_template_by_key('newsletter_unsubscribe_done');
$data['email'] = $email;
$template->page_title = htmlspecialchars(_l('Unsubscribe'));
$template->assign_values($data);
echo $template->render('pretty_html');
exit;
}
$template = module_template::get_template_by_key('newsletter_unsubscribe');
$data['email'] = '';
// to be sure to be sure
$template->page_title = htmlspecialchars(_l('Unsubscribe'));
$template->assign_values($data);
echo $template->render('pretty_html');
示例3: die
<?php
/**
* Copyright: dtbaker 2012
* Licence: Please check CodeCanyon.net for licence details.
* More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/
* Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
* Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
* Package Date: 2015-11-25 02:55:20
* IP Address: 67.79.165.254
*/
if (!module_change_request::can_i('delete', 'Change Requests')) {
die('no perms');
}
$change_request_id = (int) $_REQUEST['change_request_id'];
$change_request = module_change_request::get_change_request($change_request_id);
if (!$change_request['website_id']) {
die('no linked website');
}
$website_data = module_website::get_website($change_request['website_id']);
if (module_form::confirm_delete('change_request_id', "Really delete Change Request?", module_website::link_open($change_request['website_id']))) {
module_change_request::delete_change_request($_REQUEST['change_request_id']);
set_message("Change request deleted successfully");
redirect_browser(module_website::link_open($change_request['website_id']));
}
示例4: redirect_browser
<?php
/**
* Copyright: dtbaker 2012
* Licence: Please check CodeCanyon.net for licence details.
* More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/
* Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
* Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
* Package Date: 2015-11-25 02:55:20
* IP Address: 67.79.165.254
*/
if (!module_config::can_i('view', 'Settings') || !module_template::can_i('edit', 'Templates')) {
redirect_browser(_BASE_HREF);
}
$template_id = $_REQUEST['template_id'];
$template = array();
if ((int) $template_id && $template_id != 'new') {
$template = module_template::get_template($template_id);
}
if (!$template) {
$template_id = 'new';
$template = array('template_id' => 'new', 'template_key' => '', 'description' => '', 'content' => '', 'name' => '', 'default_text' => '', 'wysiwyg' => 1);
module_security::sanatise_data('template', $template);
}
?>
<form action="<?php
echo module_template::link_open(false);
?>
" method="post" id="template_form">
示例5: save_report
public function save_report($report_id, $data)
{
if ((int) $report_id > 0) {
$original_report_data = $this->get_report($report_id);
if (!$original_report_data || $original_report_data['report_id'] != $report_id) {
$original_report_data = array();
$report_id = false;
}
} else {
$original_report_data = array();
$report_id = false;
}
// check create permissions.
if (!$report_id && !self::can_i('create', 'reports')) {
// user not allowed to create reports.
set_error('Unable to create new reports');
redirect_browser(self::link_open(false));
}
$report_id = update_insert("report_id", $report_id, "report", $data);
module_extra::save_extras('report', 'report_id', $report_id);
return $report_id;
}
示例6: redirect_browser
$schedule->save($type);
}
}
// Redirect back to the page again, but without the query string, so reloads are cleaner
if ($db->query_col('SELECT COUNT(*) FROM program WHERE chanid = ? and starttime = FROM_UNIXTIME(?) LIMIT 1', $program->chanid, $program->starttime) == 0) {
redirect_browser(root . 'tv/detail?recordid=' . $schedule->recordid);
}
redirect_browser(root_url . 'tv/detail/' . $program->chanid . '/' . $program->starttime);
} elseif ($_REQUEST['forget_old']) {
$program->rec_forget_old();
// Redirect back to the page again, but without the query string, so reloads are cleaner
redirect_browser(root_url . 'tv/detail/' . $program->chanid . '/' . $program->starttime);
} elseif (isset($_GET['never_record']) || isset($_POST['never_record'])) {
$program->rec_never_record();
// Redirect back to the page again, but without the query string, so reloads are cleaner
redirect_browser(root_url . 'tv/detail/' . $program->chanid . '/' . $program->starttime);
} else {
// auto-metadata-lookup
if (!isset($schedule->autometadata)) {
$schedule->autometadata = setting('AutoMetadataLookup');
}
// auto-commercial-flag
if (!isset($schedule->autocommflag)) {
$schedule->autocommflag = setting('AutoCommercialFlag');
}
// auto-user-jobs
if (!isset($schedule->autouserjob1)) {
$schedule->autouserjob1 = setting('AutoRunUserJob1');
}
if (!isset($schedule->autouserjob2)) {
$schedule->autouserjob2 = setting('AutoRunUserJob2');
示例7: NOW
// Update the play count
$db->query('UPDATE music_songs
SET numplays = numplays + 1, lastplay = NOW()
WHERE song_id = ?', $_GET['i']);
// Set the XML transfer command
$xml_command = 'Content/GetMusic';
// Set the XML transfer file id
$xml_id = $_GET['i'];
}
// Unknown request or empty file?
if (empty($fname)) {
exit;
}
// HTTP stream?
if (preg_match('#^\\w+://#', $fname)) {
redirect_browser($fname);
}
// Mime type
switch (substr($fname, -3)) {
case 'jpg':
$mime = 'image/jpeg';
break;
case 'gif':
$mime = 'image/gif';
break;
case 'png':
$mime = 'image/png';
break;
case 'mp3':
$mime = 'audio/mpeg';
break;
示例8: handle_link_transactions
public static function handle_link_transactions()
{
$link_invoice_payment_ids = isset($_REQUEST['link_invoice_payment_ids']) && is_array($_REQUEST['link_invoice_payment_ids']) ? $_REQUEST['link_invoice_payment_ids'] : array();
$link_finance_ids = isset($_REQUEST['link_finance_ids']) && is_array($_REQUEST['link_finance_ids']) ? $_REQUEST['link_finance_ids'] : array();
if (count($link_invoice_payment_ids) || count($link_finance_ids)) {
// success we can link!
if (!count($link_finance_ids)) {
set_error('Please select at least one transaction that is not an invoice payment.');
redirect_browser(self::link_open(false));
}
$parent_finance_id = (int) key($link_finance_ids);
if ($parent_finance_id > 0) {
// we have a parent! woo!
unset($link_finance_ids[$parent_finance_id]);
foreach ($link_finance_ids as $link_finance_id => $tf) {
$link_finance_id = (int) $link_finance_id;
if (strlen($tf) && $link_finance_id > 0) {
// create this link.
$sql = "UPDATE `" . _DB_PREFIX . "finance` SET parent_finance_id = {$parent_finance_id} WHERE finance_id = {$link_finance_id} LIMIT 1";
query($sql);
}
}
foreach ($link_invoice_payment_ids as $link_invoice_payment_id => $tf) {
$link_invoice_payment_id = (int) $link_invoice_payment_id;
if (strlen($tf) && $link_invoice_payment_id > 0) {
// create this link.
$sql = "UPDATE `" . _DB_PREFIX . "invoice_payment` SET parent_finance_id = {$parent_finance_id} WHERE invoice_payment_id = {$link_invoice_payment_id} LIMIT 1";
query($sql);
}
}
}
}
set_message('Linking success');
redirect_browser(self::link_open(false));
}
示例9: save_data_record
function save_data_record()
{
$data = $_POST;
$data_record_id = isset($data['data_record_id']) ? $data['data_record_id'] : false;
$data_type_id = (int) $data['data_type_id'];
if (!$data_type_id) {
set_error(_l('Sorry no data type set'));
return false;
}
$data_type = $this->get_data_type($data_type_id);
if ((!$data_record_id || $data_record_id == 'new') && !$this->can_i('create', $data_type['data_type_name'])) {
set_error('No permissions to create data');
return false;
} else {
if ((int) $data_record_id > 0 && !$this->can_i('edit', $data_type['data_type_name'])) {
set_error('No permissions to edit data');
return false;
} else {
if ((int) $data_record_id > 0 && !$this->can_i('delete', $data_type['data_type_name']) && isset($_POST['butt_del'])) {
set_error('No permissions to delete data');
return false;
} else {
if ((int) $data_record_id > 0 && $this->can_i('delete', $data_type['data_type_name']) && isset($_POST['butt_del'])) {
if (module_form::confirm_delete('data_record_id', "Really delete this entire data record?", $this->link('', array("data_record_id" => $data_record_id)))) {
$this->delete_data_record($data_record_id);
set_error(_l("Data deleted successfully"));
redirect_browser($this->link());
}
}
}
}
}
if (!isset($data['save_data_group']) || !is_array($data['save_data_group'])) {
// no information to save?? error
set_error(_l('Sorry no group found to save'));
return false;
}
if ((!isset($data['data_field']) || !is_array($data['data_field']) || !count($data['data_field'])) && !isset($_FILES['data_field']['tmp_name'])) {
set_error(_l('Sorry, no data found to save'));
return false;
}
if (isset($_REQUEST['form_id']) && $_REQUEST['form_id']) {
$form_id = $_REQUEST['form_id'];
} else {
$form_id = 'default';
}
$_SESSION['_form_highlight'][$form_id] = array();
//unset($data['data_type_id']);
// first we check for required fields missing in the data field array.
// return false on error, and set the error fields in session so they can be highligted on re-render
$data_field_groups = $this->get_data_field_groups($data_type_id);
$allowed_to_save = array();
// an array of fields we are allowed to save in this save call.
$missing_required_fields = array();
$missing_required_fields_names = array();
$all_data_fields = array();
// for history cache.
foreach ($data_field_groups as $data_field_group) {
// check if the user is posting data for this field.
$data_field_group_id = $data_field_group['data_field_group_id'];
if (isset($data['save_data_group'][$data_field_group_id]) && $data['save_data_group'][$data_field_group_id]) {
$data_fields = $this->get_data_fields($data_field_group_id);
$all_data_fields[$data_field_group_id] = $data_fields;
// loop over all fields, and ensure the ones that are required are present.
foreach ($data_fields as $data_field) {
$data_field_id = $data_field['data_field_id'];
if ($data_field['required']) {
// depending on the type of field, there are different ways to
// check if the required field has been inserted.
switch ($data_field['field_type']) {
case 'radio':
case 'checkbox_list':
if (isset($data['data_field'][$data_field_id]) && strtolower($data['data_field'][$data_field_id]) == 'other' && (!isset($data['other_data_field'][$data_field_id]) || !$data['other_data_field'][$data_field_id])) {
$missing_required_fields[$data_field_id] = 'other';
$missing_required_fields_names[$data_field_id] = $data_field['title'];
} else {
if (!isset($data['data_field'][$data_field_id]) || !$data['data_field'][$data_field_id]) {
$missing_required_fields[$data_field_id] = true;
}
}
break;
case 'file':
if (!is_uploaded_file($_FILES['data_field']['tmp_name'][$data_field_id])) {
$missing_required_fields[$data_field_id] = true;
$missing_required_fields_names[$data_field_id] = $data_field['title'];
}
break;
case 'created_date_time':
case 'created_date':
case 'created_time':
case 'updated_date_time':
case 'updated_date':
case 'updated_time':
case 'created_by':
case 'updated_by':
break;
default:
// normal text field etc..
if (!isset($data['data_field'][$data_field_id]) || !$data['data_field'][$data_field_id]) {
$missing_required_fields[$data_field_id] = true;
//.........这里部分代码省略.........
示例10: bulk_handle_delete
public static function bulk_handle_delete()
{
if (isset($_REQUEST['bulk_action']) && isset($_REQUEST['bulk_action']['delete']) && $_REQUEST['bulk_action']['delete'] == 'yes') {
// confirm deletion of these tickets:
$product_ids = isset($_REQUEST['bulk_operation']) && is_array($_REQUEST['bulk_operation']) ? $_REQUEST['bulk_operation'] : array();
foreach ($product_ids as $product_id => $k) {
if ($k != 'yes') {
unset($product_ids[$product_id]);
} else {
$product_ids[$product_id] = self::link_open($product_id, true);
}
}
if (count($product_ids) > 0) {
if (module_form::confirm_delete('product_id', "Really delete products: " . implode(', ', $product_ids), self::link_open(false))) {
foreach ($product_ids as $product_id => $product_number) {
self::delete_product($product_id);
}
set_message(_l("%s products deleted successfully", count($product_ids)));
redirect_browser(self::link_open(false));
}
}
}
}
示例11: external_hook
//.........这里部分代码省略.........
// this is a normal once off payment.
self::add_payment_data($invoice_payment_id, 'log', "API IP is " . $_SERVER['REMOTE_ADDR']);
self::add_payment_data($invoice_payment_id, 'log', "Received BTC: " . $event_json->order->total_btc->cents / 10000000);
self::add_payment_data($invoice_payment_id, 'log', "Received " . $event_json->order->total_native->currency_iso . ': ' . $event_json->order->total_native->cents / 100);
self::add_payment_data($invoice_payment_id, 'log', "Destination Address: " . $event_json->order->receive_address);
if ($currency['code'] == $event_json->order->total_native->currency_iso) {
self::add_payment_data($invoice_payment_id, 'log', "Currency code matches, marking invoice as paid.");
update_insert("invoice_payment_id", $invoice_payment_id, "invoice_payment", array('date_paid' => date('Y-m-d'), 'amount' => $event_json->order->total_native->cents / 100));
module_invoice::save_invoice($invoice_id, array());
echo "Successful Payment!";
$success = true;
} else {
self::add_payment_data($invoice_payment_id, 'log', "Currency code missmatch, please check settings!");
}
self::add_payment_data($invoice_payment_id, 'log', "Raw Event Data: \n" . json_encode($event_json));
}
}
}
}
$debug = ob_get_clean();
if (module_config::c('coinbase_payment_debug', 0)) {
send_error("Coinbase Debug: {$debug}");
}
exit;
break;
case 'pay_subscription':
$invoice_id = isset($_REQUEST['invoice_id']) ? $_REQUEST['invoice_id'] : false;
$invoice_payment_id = isset($_REQUEST['invoice_payment_id']) ? $_REQUEST['invoice_payment_id'] : false;
$invoice_payment_subscription_id = isset($_REQUEST['invoice_payment_subscription_id']) ? $_REQUEST['invoice_payment_subscription_id'] : false;
$coinbase_plan_id = isset($_REQUEST['coinbase_plan_id']) ? $_REQUEST['coinbase_plan_id'] : false;
$user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : false;
if ($invoice_id && $invoice_payment_id && $coinbase_plan_id && $invoice_payment_subscription_id && $user_id && isset($_POST['coinbaseToken'])) {
$user_data = module_user::get_user($user_id);
$email = isset($_REQUEST['coinbaseEmail']) && strlen($_REQUEST['coinbaseEmail']) ? $_REQUEST['coinbaseEmail'] : $user_data['email'];
if (!$email || !strpos($email, '@')) {
die('Please ensure your user account has a valid email address before paying with coinbase');
}
$invoice_payment = get_single('invoice_payment', 'invoice_payment_id', $invoice_payment_id);
$invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
if (!$invoice_payment || !$invoice_payment_subscription || $invoice_payment['invoice_id'] != $invoice_id || $invoice_payment['invoice_payment_subscription_id'] != $invoice_payment_subscription_id) {
die('Invalid invoice payment subscription id');
}
$invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id);
$invoice_data = module_invoice::get_invoice($invoice_id);
if ($invoice_payment_data && $invoice_data && $invoice_id == $invoice_data['invoice_id'] && $invoice_payment_data['invoice_id'] == $invoice_data['invoice_id']) {
$currency = module_config::get_currency($invoice_payment_data['currency_id']);
$currency_code = $currency['code'];
$description = isset($_REQUEST['description']) ? $_REQUEST['description'] : 'N/A';
$template = new module_template();
ob_start();
require_once 'includes/plugin_paymethod_coinbase/coinbase-php/lib/coinbase.php';
$coinbase = array("secret_key" => module_config::c('payment_method_coinbase_api_key'), "publishable_key" => module_config::c('payment_method_coinbase_secret_key'));
coinbase::setApiKey($coinbase['secret_key']);
try {
// todo- search for existing customer based on email address???
// todo: check if adding new plan to existing customer work??
$coinbase_customer = coinbase_Customer::create(array("card" => $_POST['coinbaseToken'], "email" => $email, 'metadata' => array('user_id' => $user_id)));
if ($coinbase_customer && $coinbase_customer->id) {
//} && $coinbase_customer->subscriptions){
$coinbase_subscription = $coinbase_customer->subscriptions->create(array('plan' => $coinbase_plan_id));
if ($coinbase_subscription && $coinbase_subscription->id) {
update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_ACTIVE, 'date_start' => date('Y-m-d'), 'coinbase_customer' => $coinbase_customer->id, 'coinbase_subscription' => $coinbase_subscription->id));
module_paymethod_coinbase::add_payment_data($invoice_payment_id, 'log', "Started coinbase Subscription: " . var_export(array('customer.id' => $coinbase_customer->id, 'plan.id' => $coinbase_plan_id, 'subscription.id' => $coinbase_subscription->id), true));
// success!
// redirect to receipt page.
redirect_browser(module_invoice::link_public_payment_complete($invoice_id));
} else {
echo 'Failed to create subscription with coinbase';
}
}
$error = "Something went wrong during coinbase payment. Please confirm invoice payment went through: " . htmlspecialchars($description);
send_error($error);
echo $error;
} catch (coinbase_CardError $e) {
// The card has been declined
$body = $e->getJsonBody();
$err = $body['error'];
$error = "Sorry: Payment failed. <br><br>\n\n" . htmlspecialchars($description) . ". <br><br>\n\n";
$error .= $err['message'];
echo $error;
$error .= "\n\n\n" . var_export($err, true);
send_error($error);
} catch (Exception $e) {
$body = $e->getJsonBody();
$err = $body['error'];
$error = "Sorry: Payment failed. <br><br>\n\n" . htmlspecialchars($description) . ". <br><br>\n\n";
$error .= $err['message'];
echo $error;
$error .= "\n\n\n" . var_export($err, true);
send_error($error);
}
$template->content = ob_get_clean();
echo $template->render('pretty_html');
exit;
}
}
echo 'Error paying via coinbase';
exit;
}
}
示例12: _handle_save_template
private function _handle_save_template()
{
// handle post back for save template template.
$template_id = (int) $_REQUEST['template_id'];
// delete.
if (isset($_REQUEST['butt_del']) && self::can_i('delete', 'Templates')) {
$template_data = self::get_template($template_id);
if (module_form::confirm_delete('template_id', _l("Really delete template: %s", $template_data['template_key']), self::link_open($template_id))) {
$this->delete($template_id);
// todo: delete company template as well if exists.
set_message("Template deleted successfully");
redirect_browser(self::link_open(false));
}
}
$data = $_POST;
$already_saved = false;
if ((int) $template_id > 0 && class_exists('module_company', false)) {
module_company::template_handle_save($template_id, $data);
// we have to redirect to a company specific version of this template
// each company template must have a matching parent template id/key. cannot change keys in company unique config.
}
// write header/footer html based on uploaded images.
// pass uploaded images to the file manager plugin.
$template_id = update_insert('template_id', $template_id, 'template', $data);
// redirect upon save.
set_message('Template saved successfully!');
if (isset($_REQUEST['return']) && $_REQUEST['return']) {
redirect_browser($_REQUEST['return']);
}
redirect_browser($this->link_open($template_id));
exit;
}
示例13: process
public function process()
{
$errors = array();
if ("save_from_popup" == $_REQUEST['_process']) {
// dont use the normal hook to save, its gay way of saving.
// look at post data.
if (isset($_POST['address']) && is_array($_POST['address'])) {
foreach ($_POST['address'] as $address_hash => $address_data) {
if (isset($address_data['address_id']) && (int) $address_data['address_id']) {
$this->save_address($address_data['address_id'], $address_data);
}
}
}
}
if (!count($errors)) {
redirect_browser($_REQUEST['_redirect']);
exit;
}
print_error($errors, true);
}
示例14: process
public function process()
{
if ("save_facebook" == $_REQUEST['_process']) {
$social_facebook_id = isset($_REQUEST['social_facebook_id']) ? (int) $_REQUEST['social_facebook_id'] : 0;
$facebook = new ucm_facebook_account($social_facebook_id);
if (isset($_POST['butt_del']) && module_social::can_i('delete', 'Facebook', 'Social', 'social')) {
if (module_form::confirm_delete('social_facebook_id', "Really delete this Facebook account from the system? All messages will be lost.", self::link_open($_REQUEST['social_facebook_id']))) {
$facebook->delete();
set_message("Facebook account deleted successfully");
redirect_browser(self::link_open(false));
}
}
$facebook->save_data($_POST);
$social_facebook_id = $facebook->get('social_facebook_id');
if (isset($_POST['butt_save_connect'])) {
$redirect = $this->link_open($social_facebook_id, false, false, 'facebook_account_connect');
} else {
set_message('Facebook account saved successfully');
$redirect = $this->link_open($social_facebook_id);
}
redirect_browser($redirect);
exit;
} else {
if ("send_facebook_message" == $_REQUEST['_process']) {
if (module_form::check_secure_key()) {
$social_facebook_id = isset($_REQUEST['social_facebook_id']) ? (int) $_REQUEST['social_facebook_id'] : 0;
$facebook = new ucm_facebook_account($social_facebook_id);
if ($social_facebook_id && $facebook->get('social_facebook_id') == $social_facebook_id) {
// queue the message into the facebook_message table
// if there's a scheduled date in the past we send it in the past, no date we send straight away, date in the future we leave it in the db table for the cron job to pick up.
//print_r($_POST);exit;
$send_time = false;
// 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(input_date($date, true));
} else {
if (isset($_POST['schedule_date']) && !empty($_POST['schedule_date'])) {
$send_time = strtotime(input_date($_POST['schedule_date'], true));
}
}
//echo print_date($send_time,true);
//echo '<br>';
//echo date('c',$send_time);
//exit;
/* @var $available_pages ucm_facebook_page[] */
$available_pages = $facebook->get('pages');
$send_pages = isset($_POST['compose_page_id']) && is_array($_POST['compose_page_id']) ? $_POST['compose_page_id'] : array();
$page_count = 0;
if ($send_pages) {
foreach ($send_pages as $facebook_page_id => $tf) {
if (!$tf) {
continue;
}
// see if this is an available page.
if (isset($available_pages[$facebook_page_id])) {
// push to db! then send.
$facebook_message = new ucm_facebook_message($facebook, $available_pages[$facebook_page_id], false);
$facebook_message->create_new();
$facebook_message->update('social_facebook_page_id', $available_pages[$facebook_page_id]->get('social_facebook_page_id'));
$facebook_message->update('social_facebook_id', $facebook->get('social_facebook_id'));
$facebook_message->update('summary', isset($_POST['message']) ? $_POST['message'] : '');
$facebook_message->update('type', 'pending');
$facebook_message->update('link', isset($_POST['link']) ? $_POST['link'] : '');
$facebook_message->update('data', json_encode($_POST));
$facebook_message->update('user_id', module_security::get_loggedin_id());
// do we send this one now? or schedule it later.
$facebook_message->update('status', _SOCIAL_MESSAGE_STATUS_PENDINGSEND);
if ($send_time) {
// schedule for sending at a different time (now or in the past)
$facebook_message->update('last_active', $send_time);
} else {
// send it now.
$facebook_message->update('last_active', 0);
}
if (isset($_FILES['picture']['tmp_name']) && is_uploaded_file($_FILES['picture']['tmp_name'])) {
$facebook_message->add_attachment($_FILES['picture']['tmp_name']);
}
$facebook_message->send_queued(isset($_POST['debug']));
$page_count++;
} else {
// log error?
}
}
}
set_message(_l('Message delivered successfully to %s Facebook pages', $page_count));
$redirect = $this->link_open_message_view($social_facebook_id);
redirect_browser($redirect);
}
}
} else {
//.........这里部分代码省略.........
示例15: template_handle_save
public static function template_handle_save($template_id, $data)
{
// check if we're savniga company id and that this user has access to this company, and permissions to edit templates.
$company_id = isset($_REQUEST['company_id']) ? (int) $_REQUEST['company_id'] : false;
if ($company_id) {
$company = self::get_company($company_id);
if ($company) {
$existing_template = module_template::get_template($template_id);
if ($existing_template && $existing_template['template_id'] == $template_id) {
// we're saving a template for this particular company.
// if it's an empty template content then we remove this company template so it reverts to the system default.
if (isset($data['content']) && !strlen(trim($data['content']))) {
delete_from_db('company_template', array('company_id', 'template_id'), array($company_id, $template_id));
set_message('Company template successfully reset to default');
redirect_browser(module_template::link_open($template_id));
} else {
$sql = 'REPLACE INTO `' . _DB_PREFIX . "company_template` SET company_id = " . (int) $company_id . ", `template_id` = " . (int) $template_id . ", `description` = '" . mysql_real_escape_string(isset($data['description']) ? $data['description'] : '') . "', `content` = '" . mysql_real_escape_string(isset($data['content']) ? $data['content'] : '') . "', `wysiwyg` = '" . mysql_real_escape_string(isset($data['wysiwyg']) ? $data['wysiwyg'] : '') . "'";
query($sql);
set_message('Unique company template successfully updated');
redirect_browser(module_template::link_open($template_id) . '&company_id=' . $company_id);
}
}
}
}
}