当前位置: 首页>>代码示例>>PHP>>正文


PHP update_insert函数代码示例

本文整理汇总了PHP中update_insert函数的典型用法代码示例。如果您正苦于以下问题:PHP update_insert函数的具体用法?PHP update_insert怎么用?PHP update_insert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了update_insert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 public function process()
 {
     if (isset($_REQUEST['_process']) && $_REQUEST['_process'] == 'ajax_save_map_coords') {
         $address_id = (int) $_REQUEST['address_id'];
         if ($address_id && !empty($_REQUEST['address_hash']) && !empty($_REQUEST['lat']) && !empty($_REQUEST['lng'])) {
             // existing?
             $existing = get_single('map', 'address_id', $address_id);
             update_insert('map_id', $existing ? $existing['map_id'] : false, 'map', array('address_hash' => $_REQUEST['address_hash'], 'address_id' => $_REQUEST['address_id'], 'lat' => $_REQUEST['lat'], 'lng' => $_REQUEST['lng']));
         }
         echo 'Done';
         exit;
     }
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:13,代码来源:map.php

示例2: run_cron

 public function run_cron($debug = false)
 {
     // check for payments.
     $sql = "SELECT * FROM `" . _DB_PREFIX . "invoice_payment` ip WHERE 1 ";
     $sql .= " AND  `method` = 'paynl' ";
     $sql .= " AND  `date_paid` = '0000-00-00' ";
     $sql .= " AND  `other_id` != '' ";
     foreach (qa($sql) as $payment) {
         // check api status:
         $strUrl = 'https://token:' . module_config::c('payment_method_paynl_token', '') . '@rest-api.pay.nl/v5/Transaction/info/json?';
         $arrArguments = array();
         $arrArguments['transactionId'] = $payment['other_id'];
         # Prepare and call API URL
         $strUrl .= http_build_query($arrArguments);
         if ($debug) {
             echo "Checking URL {$strUrl} <br>\n";
             $jsonResult = file_get_contents($strUrl);
         } else {
             $jsonResult = @file_get_contents($strUrl);
         }
         $json = @json_decode($jsonResult, true);
         if ($debug) {
             echo "Got result: <br>\n";
             print_r($json);
         }
         if ($json && isset($json['paymentDetails']) && isset($json['paymentDetails']['stateName']) && isset($json['paymentDetails']['amount'])) {
             module_paymethod_paynl::add_payment_data($payment['invoice_payment_id'], 'log', "PayNL Status " . $json['paymentDetails']['stateName'] . ": \n " . var_export($json, true));
             switch ($json['paymentDetails']['stateName']) {
                 case 'PENDING':
                     // defauly, still waiting for payment.
                     break;
                 case 'PAID':
                     update_insert("invoice_payment_id", $payment['invoice_payment_id'], "invoice_payment", array('date_paid' => date('Y-m-d'), 'amount' => $json['paymentDetails']['amount'] / 100, 'other_id' => ''));
                     module_invoice::save_invoice($payment['invoice_id'], array());
                     break;
                 case 'CANCEL':
                     update_insert("invoice_payment_id", $payment['invoice_payment_id'], "invoice_payment", array('other_id' => ''));
                     module_invoice::save_invoice($payment['invoice_id'], array());
                     send_error('PayNL payment cancelled for invoice: ' . module_invoice::link_open($payment['invoice_id'], true));
                     break;
             }
         } else {
             module_paymethod_paynl::add_payment_data($payment['invoice_payment_id'], 'log', "PayNL Status ERROR: \n " . $jsonResult);
         }
     }
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:46,代码来源:paymethod_paynl.php

示例3: isset

echo $n->toHex();
echo ' <br><br> ';
*/
// are we creating a new encrypution value or trying to decrypt an existing one?
$encrypt_field_id = isset($_REQUEST['encrypt_field_id']) ? (int) $_REQUEST['encrypt_field_id'] : false;
if (!$encrypt_field_id && module_encrypt::can_i('create', 'Encrypts')) {
    // are we creating a new encryption for this field??
    // ooooooooooooooooo.
    $encrypt_field_name = isset($_REQUEST['encrypt_field_name']) ? $_REQUEST['encrypt_field_name'] : false;
    $page_name = isset($_REQUEST['page_name']) ? $_REQUEST['page_name'] : false;
    if (!$encrypt_field_name || !$page_name) {
        die('Unable to encrypt this field. Sorry');
    }
    // ready to create our field!
    // for now we just create an entry in the db ready to go.
    $encrypt_field_id = update_insert('encrypt_field_id', 0, 'encrypt_field', array('page_name' => $page_name, 'field_name' => $encrypt_field_name, 'encrypt_key_id' => 0));
}
if (!$encrypt_field_id) {
    die('no encrypt field id');
}
$encrypt_field = module_encrypt::get_encrypt_field($encrypt_field_id);
//if(!$encrypt_field||$encrypt_field['encrypt_field_id']!=$encrypt_field_id)die('invalid field specified');
$callback_id = isset($_REQUEST['callback_id']) ? $_REQUEST['callback_id'] : '';
$encrypt_id = isset($_REQUEST['encrypt_id']) ? (int) $_REQUEST['encrypt_id'] : 0;
$existing_value = isset($_REQUEST['value']) ? html_entity_decode(@base64_decode($_REQUEST['value'])) : '';
$encrypt = module_encrypt::get_encrypt($encrypt_id);
$encryption_keys = module_encrypt::get_encrypt_keys();
if ($encrypt && $encrypt['encrypt_key_id'] && isset($encryption_keys[$encrypt['encrypt_key_id']])) {
    $encryption_key = $encryption_keys[$encrypt['encrypt_key_id']];
} else {
    $encryption_key = isset($encryption_keys[$encrypt_field['encrypt_key_id']]) ? $encryption_keys[$encrypt_field['encrypt_key_id']] : false;
开发者ID:sgh1986915,项目名称:php-crm,代码行数:31,代码来源:encrypt_popup.php

示例4: calculate_recurring_date

 public static function calculate_recurring_date($finance_recurring_id, $force = false, $update_db = true)
 {
     $recurring = self::get_recurring($finance_recurring_id);
     if ($recurring['next_due_date_custom'] && !$force) {
         return $recurring['next_due_date'];
     }
     $data = array();
     $data['next_due_date'] = '';
     $data['next_due_date_custom'] = '0';
     // work out next due date from the start date or from last transaction date.
     $last_transaction = $recurring['last_transaction_date'];
     if (!$last_transaction || $last_transaction == '0000-00-00' || $last_transaction == '0000-00-00 00:00:00') {
         // no last transaction date!
         // use the start date?
         $last_transaction = $recurring['start_date'];
         if (!$last_transaction || $last_transaction == '0000-00-00') {
             // default to todays date.
             $last_transaction = date('Y-m-d');
         }
         $next_time = strtotime($last_transaction);
     } else {
         // check if the start date has increased past the last transaction date.
         $start_time = strtotime($recurring['start_date']);
         $last_transaction_time = strtotime($last_transaction);
         if (isset($_REQUEST['reset_start']) && $start_time > $last_transaction_time) {
             // todo - set this as a flag - a button they click to reset the counter from "this date" onwards
             // without doing this then recording a paymetn early will not set the correct recurring date from that time.
             $next_time = $start_time;
         } else {
             // there was a previous one - base our time off that.
             // only if it's not a once off..
             if (!$recurring['days'] && !$recurring['months'] && !$recurring['years']) {
                 // it's a once off..
                 $next_time = 9999999999;
                 $recurring['end_date'] = '1970-01-02';
             } else {
                 // work out when the next one will be.
                 $next_time = strtotime($last_transaction);
                 $next_time = strtotime('+' . abs((int) $recurring['days']) . ' days', $next_time);
                 $next_time = strtotime('+' . abs((int) $recurring['months']) . ' months', $next_time);
                 $next_time = strtotime('+' . abs((int) $recurring['years']) . ' years', $next_time);
             }
         }
     }
     $end_time = $recurring['end_date'] && $recurring['end_date'] != '0000-00-00' ? strtotime($recurring['end_date']) : 0;
     if ($end_time > 0 && $next_time > $end_time) {
         $data['next_due_date'] = '0000-00-00';
     } else {
         $data['next_due_date'] = date('Y-m-d', $next_time);
     }
     if ($update_db) {
         update_insert('finance_recurring_id', $finance_recurring_id, 'finance_recurring', $data);
     }
     return $data['next_due_date'];
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:55,代码来源:finance.php

示例5: create_new_invoice_for_subscription_payment

 public static function create_new_invoice_for_subscription_payment($invoice_id, $invoice_payment_id, $invoice_payment_subscription_id)
 {
     // we have an inbound subscription payment for an invoice.
     // we have to generate a new invoice (or find the generated invoice if one exists)
     // first we have to check if this payment is for this invoice (ie: the first subscription payment)
     $invoice_data = self::get_invoice($invoice_id);
     if ($invoice_data['total_amount_due'] > 0) {
         // this invoice is unpaid, we apply this subscription payment against thsi invoice
         return array('invoice_id' => $invoice_id, 'invoice_payment_id' => $invoice_payment_id);
     }
     // first we look for a generated invoice, this is easiest.
     if (class_exists('module_subscription', false)) {
         // check if this invoice is part of a subscription.
         // if it is we hunt through the subscription history until we find a recent unpaid invoice
         // THIS CODE IS SIMILAR TO module_invoice::is_automatic_paying_invoice($invoice_id)
         $subscription_history_item = get_single('subscription_history', 'invoice_id', $invoice_id);
         if ($subscription_history_item && $subscription_history_item['subscription_owner_id']) {
             // we have an invoice that is on a subscription!
             $subscription_owner = module_subscription::get_subscription_owner($subscription_history_item['subscription_owner_id']);
             // check if there are unpaid invoices that were generated after this invoice.
             if ($subscription_owner['subscription_owner_id'] == $subscription_history_item['subscription_owner_id']) {
                 $subscription_history = get_multiple('subscription_history', array('subscription_owner_id' => $subscription_owner['subscription_owner_id']));
                 foreach ($subscription_history as $h) {
                     if ($h['invoice_id'] > $invoice_id && $h['paid_date'] == '0000-00-00') {
                         // found an invoice for this subscription that was generated after the initial invoice that is unpaid.
                         // apply subscription payment to this one.
                         $invoice_data = module_invoice::get_invoice($h['invoice_id']);
                         if ($invoice_data['total_amount_due'] > 0) {
                             $invoice_payment_id = update_insert('invoice_payment_id', false, 'invoice_payment', array('invoice_id' => $h['invoice_id'], 'payment_type' => _INVOICE_PAYMENT_TYPE_NORMAL, 'method' => _l('Pending Subscription'), 'currency_id' => $invoice_data['currency_id'], 'invoice_payment_subscription_id' => $invoice_payment_subscription_id));
                             return array('invoice_id' => $h['invoice_id'], 'invoice_payment_id' => $invoice_payment_id);
                         }
                     }
                 }
                 // if we get here it means we have a subscription invoice that hasn't been renewed yet.
                 $subscription = module_subscription::get_subscription($subscription_owner['subscription_id']);
                 // we force the renewal of the next invoice in this subscription lot and mark it as paid.
                 $invoice_id = module_subscription::generate_subscription_invoice($subscription_owner['subscription_id'], $subscription_owner['owner_table'], $subscription_owner['owner_id'], date('Y-m-d'), $subscription['amount']);
                 if ($invoice_id) {
                     $invoice_data = module_invoice::get_invoice($invoice_id);
                     $invoice_payment_id = update_insert('invoice_payment_id', false, 'invoice_payment', array('invoice_id' => $invoice_id, 'payment_type' => _INVOICE_PAYMENT_TYPE_NORMAL, 'method' => _l('Pending Subscription'), 'currency_id' => $invoice_data['currency_id'], 'invoice_payment_subscription_id' => $invoice_payment_subscription_id));
                     if ($subscription['automatic_email'] && module_config::c('invoice_subscription_send_due_email_before_payment', 1)) {
                         if (module_invoice::email_invoice_to_customer($invoice_id)) {
                         } else {
                             echo " - failed to send subscription invoice " . module_invoice::link_open($invoice_id, true) . " to customer <br>\n";
                         }
                         exit;
                     }
                     return array('invoice_id' => $invoice_id, 'invoice_payment_id' => $invoice_payment_id);
                 }
             }
         }
     }
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:53,代码来源:invoice.php

示例6: array

$ip = $json_data->ip;
$datetime = $json_data->datetime;
$trackingnum = $json_data->trackingnum;
$customer_import = array('customer_name' => $callername, 'customer_extra' => array('Medium' => $referrermedium, 'Source' => $callsource, 'Campaign' => $utm_campaign, 'Content' => $utm_content, 'Term' => $utm_term, 'Query' => $keywords, 'Conversion URL' => $last_requested_url, 'IP Address' => $ip, 'Called In' => $datetime), 'address' => array('line_1' => '123 Test Street', 'line_2' => '', 'suburb' => $callercity, 'state' => $callerstate, 'post_code' => $callerzip), 'contact' => array('name' => $callername, 'last_name' => $callername, 'email' => $trackingnum, 'mobile' => $callernum));
include 'init.php';
// the UCM init code.
$customer_id = $plugins['customer']->save_customer('new', array('customer_name' => $customer_import['customer_name']));
if (!$customer_id) {
    echo 'Failed to create customer';
    exit;
}
if (!empty($customer_import['customer_extra'])) {
    foreach ($customer_import['customer_extra'] as $extra_key => $extra_val) {
        // Add the Medium extra field to that newly created customer
        $extra_db = array('extra_key' => $extra_key, 'extra' => $extra_val, 'owner_table' => 'customer', 'owner_id' => $customer_id);
        $extra_id = update_insert('extra_id', false, 'extra', $extra_db);
    }
}
if (!empty($customer_import['address'])) {
    // Save the address for the customer
    $customer_import['address']['owner_id'] = $customer_id;
    $customer_import['address']['owner_table'] = 'customer';
    $customer_import['address']['address_type'] = 'physical';
    module_address::save_address(false, $customer_import['address']);
}
if (!empty($customer_import['contact'])) {
    // add the contact details to this customer record
    $customer_import['contact']['customer_id'] = $customer_id;
    $contact_user_id = $plugins['user']->create_user($customer_import['contact'], 'signup');
    if ($contact_user_id) {
        module_customer::set_primary_user_id($customer_id, $contact_user_id);
开发者ID:sgh1986915,项目名称:php-crm,代码行数:31,代码来源:insert-callrail-data.php

示例7: hook_job_task_after

    public static function hook_job_task_after($hook, $job_id, $task_id, $job_data, $task_data)
    {
        $comments = get_multiple('job_discussion', array('job_id' => $job_id, 'task_id' => $task_id), 'job_discussion_id', 'exact', 'job_discussion_id');
        if ($job_data && isset($job_data['job_discussion']) && $job_data['job_discussion'] == 1) {
            // disabled & hidden.
            return;
        }
        if ($job_data && isset($job_data['job_discussion']) && $job_data['job_discussion'] == 2 && count($comments) == 0) {
            // disabled & shown.
            return;
        }
        if (isset($_POST['job_discussion_add_job_id']) && isset($_POST['job_discussion_add_task_id']) && $_POST['job_discussion_add_job_id'] == $job_id && $_POST['job_discussion_add_task_id'] == $task_id && isset($_POST['note']) && strlen($_POST['note'])) {
            $x = 0;
            while (ob_get_level() && $x++ < 10) {
                ob_end_clean();
            }
            $current_user_id = module_security::get_loggedin_id();
            $customer = module_customer::get_customer($job_data['customer_id']);
            if (!$current_user_id) {
                if ($job_data['customer_id'] && $customer['primary_user_id']) {
                    $current_user_id = $customer['primary_user_id'];
                }
            }
            $result = array();
            // adding a new note.
            $job_discussion_id = update_insert('job_discussion_id', 0, 'job_discussion', array('job_id' => $job_id, 'task_id' => $task_id, 'user_id' => $current_user_id, 'note' => $_POST['note']));
            $result['job_discussion_id'] = $job_discussion_id;
            $result['count'] = count($comments) + 1;
            $tasks = module_job::get_tasks($job_id);
            $result['email_customer'] = array();
            if (isset($_POST['sendemail_customer']) && is_array($_POST['sendemail_customer'])) {
                //$_POST['sendemail_customer'] == 'yes' && $customer['primary_user_id']){
                // send email to customer primary user id.
                $customer_contacts = module_user::get_contacts(array('customer_id' => $job_data['customer_id']));
                foreach ($_POST['sendemail_customer'] as $user_id) {
                    $user_id = (int) $user_id;
                    if ($user_id && isset($customer_contacts[$user_id])) {
                        // we can email this user.
                        $user = module_user::get_user($user_id, false);
                        if ($user && $user['user_id'] == $user_id) {
                            $values = array_merge($user, $job_data);
                            $values['job_url'] = module_job::link_public($job_id);
                            $values['job_url'] .= (strpos($values['job_url'], '?') === false ? '?' : '&') . 'discuss=' . $task_id . '#discuss' . $task_id;
                            $values['job_name'] = $job_data['name'];
                            $values['customer_name'] = $user['name'] . ' ' . $user['last_name'];
                            $values['note'] = $_POST['note'];
                            //todo: no order if no showning numbers
                            $values['task_name'] = '#' . $tasks[$task_id]['task_order'] . ': ' . $tasks[$task_id]['description'];
                            $template = module_template::get_template_by_key('job_discussion_email_customer');
                            $template->assign_values($values);
                            $html = $template->render('html');
                            $email = module_email::new_email();
                            $email->replace_values = $values;
                            $email->set_to('user', $user['user_id']);
                            $email->set_from('user', $current_user_id);
                            $email->set_subject($template->description);
                            // do we send images inline?
                            $email->set_html($html);
                            if ($email->send()) {
                                // it worked successfully!!
                                $result['email_customer'][] = $user['user_id'];
                            } else {
                                /// log err?
                            }
                        }
                    }
                }
                /*$user = module_user::get_user($customer['primary_user_id'],false);
                                if($user['user_id'] == $customer['primary_user_id']){
                                    $values = array_merge($user,$job_data);
                                    $values['job_url'] = module_job::link_public($job_id);
                                    $values['job_url'] .= (strpos($values['job_url'],'?')===false ? '?' : '&').'discuss='.$task_id.'#discuss'.$task_id;
                                    $values['job_name'] = $job_data['name'];
                                    $values['customer_name'] = $user['name'].' '.$user['last_name'];
                                    $values['note'] = $_POST['note'];
                                    //todo: no order if no showning numbers
                                    $values['task_name'] = '#'.$tasks[$task_id]['task_order'].': '.$tasks[$task_id]['description'];
                
                                    $template = module_template::get_template_by_key('job_discussion_email_customer');
                                    $template->assign_values($values);
                                    $html = $template->render('html');
                
                                    $email = module_email::new_email();
                                    $email->replace_values = $values;
                                    $email->set_to('user',$user['user_id']);
                                    $email->set_from('user',$current_user_id);
                                    $email->set_subject($template->description);
                                    // do we send images inline?
                                    $email->set_html($html);
                
                                    if($email->send()){
                                        // it worked successfully!!
                                        $result['email_customer'] = 1;
                                    }else{
                                        /// log err?
                                        $result['email_customer'] = 0;
                                    }
                                }else{
                                    // log error?
                                    $result['email_customer'] = 0;
//.........这里部分代码省略.........
开发者ID:sgh1986915,项目名称:php-crm,代码行数:101,代码来源:job_discussion.php

示例8: external_hook

 public function external_hook($hook)
 {
     switch ($hook) {
         case 'event_ipn':
             $body = @file_get_contents('php://input');
             $event_json = json_decode($body);
             ob_start();
             echo "UCM coinbase DEBUG:<br><br>JSON: <br>\n";
             print_r($event_json);
             echo "<br><br>\n";
             $success = false;
             $bits = explode(':', isset($event_json->order->custom) ? $event_json->order->custom : '');
             if (count($bits) == 4) {
                 // we have our custom bits, invoice_id, invoice_payment_id and hash
                 // check they are right
                 $invoice_id = (int) $bits[0];
                 $invoice_payment_id = (int) $bits[1];
                 $invoice_payment_subscription_id = (int) $bits[2];
                 $hash = $bits[3];
                 $correct_hash = self::get_payment_key($invoice_id, $invoice_payment_id, $invoice_payment_subscription_id, true);
                 if ($invoice_id && $invoice_payment_id && $hash == $correct_hash) {
                     // This will send receipts on succesful invoices
                     // todo - coinbase doesnt sent this callback correctly just yet
                     if ($event_json && isset($event_json->recurring_payment) && $invoice_payment_subscription_id) {
                         // status changes on a recurring payment.
                         $invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
                         if (!$invoice_payment_subscription['date_start'] || $invoice_payment_subscription['date_start'] == '0000-00-00') {
                             // no start date yet, set the start date now.
                             if ($event_json->recurring_payment->status == 'active') {
                                 update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_ACTIVE, 'date_start' => date('Y-m-d')));
                             }
                         }
                         if ($event_json->recurring_payment->status == 'paused' || $event_json->recurring_payment->status == 'canceled') {
                             update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_FAILED));
                         }
                     }
                     if ($event_json && isset($event_json->order->status) && $event_json->order->status == 'completed' && isset($event_json->order->total_native) && isset($event_json->order->custom)) {
                         // crab out the custom bits so we know what to deal with.
                         $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id);
                         $currency = module_config::get_currency($invoice_payment_data['currency_id']);
                         if ($invoice_payment_subscription_id) {
                             // this API result is for a subscription payment.
                             $invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
                             if ($invoice_payment_subscription && $invoice_payment_subscription['invoice_payment_subscription_id'] == $invoice_payment_subscription_id && $currency['code'] == $event_json->order->total_native->currency_iso) {
                                 if (!$invoice_payment_subscription['date_start'] || $invoice_payment_subscription['date_start'] == '0000-00-00') {
                                     // no start date yet, set the start date now (this should really happen in the above callback, but coinbase isn't working right now)
                                     update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_ACTIVE, 'date_start' => date('Y-m-d')));
                                 }
                                 // we have a subscription payment. woo!
                                 // this gets a bit tricky, we have to work out if the invoice has been generated for this subscription yet.
                                 // if this invoice hasn't been generated yet then we have to generate it.
                                 // pass this back to the invoice class so we can reuse this feature in the future.
                                 $data = module_invoice::create_new_invoice_for_subscription_payment($invoice_id, $invoice_payment_id, $invoice_payment_subscription_id);
                                 if ($data && $data['invoice_id'] && $data['invoice_payment_id']) {
                                     $next_time = time();
                                     $next_time = strtotime('+' . abs((int) $invoice_payment_subscription['days']) . ' days', $next_time);
                                     $next_time = strtotime('+' . abs((int) $invoice_payment_subscription['months']) . ' months', $next_time);
                                     $next_time = strtotime('+' . abs((int) $invoice_payment_subscription['years']) . ' years', $next_time);
                                     update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('date_last_pay' => date('Y-m-d'), 'date_next' => date('Y-m-d', $next_time)));
                                     update_insert("invoice_payment_id", $data['invoice_payment_id'], "invoice_payment", array('date_paid' => date('Y-m-d'), 'amount' => $event_json->order->total_native->cents / 100, 'method' => self::get_payment_method_name() . ' (Subscription)', 'invoice_payment_subscription_id' => $invoice_payment_subscription_id));
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Invoice Payment Subscription Received!");
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "API IP is " . $_SERVER['REMOTE_ADDR']);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Received BTC: " . $event_json->order->total_btc->cents / 10000000);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Received " . $event_json->order->total_native->currency_iso . ': ' . $event_json->order->total_native->cents / 100);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Destination Address: " . $event_json->order->receive_address);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Currency code matches, marking invoice as paid.");
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Raw Event Data: \n" . json_encode($event_json));
                                     module_invoice::save_invoice($data['invoice_id'], array());
                                     echo "Successful Subscription Payment!";
                                 } else {
                                     send_error("Coinbase Subscription Error (failed to generate new invoice!) " . var_export($data, true));
                                 }
                             } else {
                                 send_error('Currency code missmatch on coinbase subscription payment');
                             }
                         } else {
                             // 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;
//.........这里部分代码省略.........
开发者ID:sgh1986915,项目名称:php-crm,代码行数:101,代码来源:paymethod_coinbase.php

示例9: handle_paypal_ipn

 function handle_paypal_ipn()
 {
     ob_end_clean();
     if (!isset($_REQUEST['custom'])) {
         return;
     }
     $paypal_bits = explode("|", $_REQUEST['custom']);
     $user_id = (int) $paypal_bits[0];
     $payment_id = (int) $paypal_bits[1];
     $invoice_id = (int) $paypal_bits[2];
     $invoice_payment_subscription_id = false;
     if (count($paypal_bits) == 4) {
         // normal IPN, single payment.
     } else {
         if (count($paypal_bits) == 5) {
             // subscription IPN, with subscription id.
             $invoice_payment_subscription_id = (int) $paypal_bits[3];
             $invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
         }
     }
     //send_error('bad?');
     if ($payment_id && $invoice_id) {
         $hash = $this->paypal_custom($user_id, $payment_id, $invoice_id, $invoice_payment_subscription_id);
         if ($hash != $_REQUEST['custom']) {
             send_error("PayPal IPN Error (incorrect hash) it should be " . $hash);
             exit;
         }
         /*$sql = "SELECT * FROM `"._DB_PREFIX."user` WHERE user_id = '$user_id' LIMIT 1";
                     $res = qa($sql);
                     if($res){
         
                         $user = array_shift($res);
                         if($user && $user['user_id'] == $user_id){*/
         // check for payment exists
         $payment = module_invoice::get_invoice_payment($payment_id);
         $invoice = module_invoice::get_invoice($invoice_id);
         if ($payment && $invoice) {
             /*if(isset($_REQUEST['fakepay'])){
                                         if($invoice_payment_subscription_id){
                                             // we have a subscription payment. woo!
                                             // this gets a bit tricky, we have to work out if the invoice has been generated for this subscription yet.
                                             // if this invoice hasn't been generated yet then we have to generate it.
                                             // pass this back to the invoice class so we can reuse this feature in the future.
                                             $data = module_invoice::create_new_invoice_for_subscription_payment($invoice_id, $payment_id, $invoice_payment_subscription_id);
                                             if($data && $data['invoice_id'] && $data['invoice_payment_id']){
             
                                                 $next_time = time();
                                                 $next_time = strtotime('+'.abs((int)$invoice_payment_subscription['days']).' days',$next_time);
                                                 $next_time = strtotime('+'.abs((int)$invoice_payment_subscription['months']).' months',$next_time);
                                                 $next_time = strtotime('+'.abs((int)$invoice_payment_subscription['years']).' years',$next_time);
                                                 update_insert('invoice_payment_subscription_id',$invoice_payment_subscription_id,'invoice_payment_subscription',array(
                                                     'date_last_pay' => date('Y-m-d'),
                                                     'date_next' => date('Y-m-d',$next_time),
                                                 ));
                                                 $new_payment_details = array(
                                                       'date_paid' => date('Y-m-d'),
                                                       'amount' => $_REQUEST['mc_gross'],
                                                       'method' => 'PayPal (Subscription)',
                                                       'invoice_payment_subscription_id' => $invoice_payment_subscription_id,
                                                  );
                                                 foreach(array('fee_percent','fee_amount','fee_description','fee_total') as $fee_field){
                                                     if(isset($payment[$fee_field])) {
                                                         $new_payment_details[ $fee_field ] = $payment[ $fee_field ];
                                                     }
                                                 }
                                                  update_insert("invoice_payment_id",$data['invoice_payment_id'],"invoice_payment",$new_payment_details);
             
                                                 module_invoice::save_invoice($data['invoice_id'],array());
             
                                                 echo "Successful Subscription Payment!";
             
                                             }else{
                                                 send_error("PayPal IPN Subscription Error (failed to generate new invoice!) ".var_export($result,true));
                                             }
             
                                         }else{
                                             // mark a normal payment as paid
             
                                             update_insert("invoice_payment_id",$payment_id,"invoice_payment",array(
                                                       'date_paid' => date('Y-m-d'),
                                                       'amount' => $_REQUEST['mc_gross'],
                                                       'method' => 'PayPal (IPN)',
                                              ));
             
                                             module_invoice::save_invoice($invoice_id,array());
             
                                             echo "Successful Payment!";
             
                                         }
                                         echo 'fakepay done';exit;
                                     }*/
             $invoice_currency = module_config::get_currency($invoice['currency_id']);
             $invoice_currency_code = $invoice_currency['code'];
             // check correct business
             if (!$_REQUEST['business'] && $_REQUEST['receiver_email']) {
                 $_REQUEST['business'] = $_REQUEST['receiver_email'];
             }
             if ($_REQUEST['business'] != module_config::c('payment_method_paypal_email', _ERROR_EMAIL)) {
                 send_error('PayPal error! Paid the wrong business name. ' . $_REQUEST['business'] . ' instead of ' . module_config::c('payment_method_paypal_email', _ERROR_EMAIL));
                 exit;
//.........这里部分代码省略.........
开发者ID:sgh1986915,项目名称:php-crm,代码行数:101,代码来源:paymethod_paypal.php

示例10: save_profile_field

function save_profile_field($field_type, $mode = 'create')
{
    global $cp, $db, $config, $user, $lang_defs;
    $field_id = request_var('field_id', 0);
    // Collect all informations, if something is going wrong, abort the operation
    $profile_sql = $profile_lang = $empty_lang = $profile_lang_fields = array();
    $default_lang_id = $lang_defs['iso'][$config['default_lang']];
    if ($mode == 'create') {
        $result = $db->sql_query('SELECT MAX(field_order) as max_field_order FROM ' . PROFILE_FIELDS_TABLE);
        $new_field_order = (int) $db->sql_fetchfield('max_field_order', 0, $result);
        $db->sql_freeresult($result);
        // We do not use a stripped down field name as identifier in order to retain sql compatibility, of course it would be nice to not have to look up the identifier and instead having a descriptive name, but this would produce more errors than needed, and do you want to have a totally crypted name just because of stripped characters? ;)
        $field_ident = 'field_' . ($new_field_order + 1);
    }
    // Save the field
    $profile_fields = array('field_name' => $cp->vars['field_name'], 'field_length' => $cp->vars['field_length'], 'field_minlen' => $cp->vars['field_minlen'], 'field_maxlen' => $cp->vars['field_maxlen'], 'field_novalue' => $cp->vars['field_novalue'], 'field_default_value' => $cp->vars['field_default_value'], 'field_validation' => $cp->vars['field_validation'], 'field_required' => $cp->vars['field_required'], 'field_show_on_reg' => $cp->vars['field_show_on_reg'], 'field_hide' => $cp->vars['field_hide']);
    if ($mode == 'create') {
        $profile_fields += array('field_type' => $field_type, 'field_ident' => $field_ident, 'field_order' => $new_field_order + 1, 'field_active' => 1);
        $db->sql_query('INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $db->sql_build_array('INSERT', $profile_fields));
        $field_id = $db->sql_nextid();
    } else {
        $db->sql_query('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $profile_fields) . "\r\n\t\t\tWHERE field_id = {$field_id}");
    }
    if ($mode == 'create') {
        // We are defining the biggest common value, because of the possibility to edit the min/max values of each field.
        $sql = 'ALTER TABLE ' . PROFILE_DATA_TABLE . " ADD {$field_ident} ";
        switch ($field_type) {
            case FIELD_STRING:
                $sql .= ' VARCHAR(255) DEFAULT NULL NULL';
                break;
            case FIELD_DATE:
                $sql .= 'VARCHAR(10) DEFAULT NULL NULL';
                break;
            case FIELD_TEXT:
                $sql .= 'TEXT NULL';
                break;
            case FIELD_BOOL:
                $sql .= 'TINYINT(2) DEFAULT NULL NULL';
                break;
            case FIELD_DROPDOWN:
                $sql .= 'MEDIUMINT(8) DEFAULT NULL NULL';
                break;
            case FIELD_INT:
                $sql .= 'BIGINT(20) DEFAULT NULL NULL';
                break;
        }
        $profile_sql[] = $sql;
    }
    $sql_ary = array('lang_name' => $cp->vars['lang_name'], 'lang_explain' => $cp->vars['lang_explain'], 'lang_default_value' => $cp->vars['lang_default_value']);
    if ($mode == 'create') {
        $sql_ary['field_id'] = $field_id;
        $sql_ary['lang_id'] = $default_lang_id;
        $profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
    } else {
        update_insert(PROFILE_LANG_TABLE, $sql_ary, array('field_id' => $field_id, 'lang_id' => $default_lang_id));
    }
    if (sizeof($cp->vars['l_lang_name'])) {
        foreach ($cp->vars['l_lang_name'] as $lang_id => $data) {
            if ($cp->vars['lang_name'] != '' && $cp->vars['l_lang_name'][$lang_id] == '' || $cp->vars['lang_explain'] != '' && $cp->vars['l_lang_explain'][$lang_id] == '' || $cp->vars['lang_default_value'] != '' && $cp->vars['l_lang_default_value'][$lang_id] == '') {
                $empty_lang[$lang_id] = true;
                break;
            }
            if (!isset($empty_lang[$lang_id])) {
                $profile_lang[] = array('field_id' => $field_id, 'lang_id' => $lang_id, 'lang_name' => $cp->vars['l_lang_name'][$lang_id], 'lang_explain' => $cp->vars['l_lang_explain'][$lang_id], 'lang_default_value' => $cp->vars['l_lang_default_value'][$lang_id]);
            }
        }
    }
    $cp->vars['l_lang_name'] = request_var('l_lang_name', '');
    $cp->vars['l_lang_explain'] = request_var('l_lang_explain', '');
    $cp->vars['l_lang_default_value'] = request_var('l_lang_default_value', '');
    $cp->vars['l_lang_options'] = request_var('l_lang_options', '');
    if (!empty($cp->vars['lang_options'])) {
        if (!is_array($cp->vars['lang_options'])) {
            $cp->vars['lang_options'] = explode("\n", $cp->vars['lang_options']);
        }
        foreach ($cp->vars['lang_options'] as $option_id => $value) {
            $sql_ary = array('field_type' => (int) $field_type, 'value' => $value);
            if ($mode == 'create') {
                $sql_ary['field_id'] = $field_id;
                $sql_ary['lang_id'] = $default_lang_id;
                $sql_ary['option_id'] = (int) $option_id;
                $profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
            } else {
                update_insert(PROFILE_FIELDS_LANG_TABLE, $sql_ary, array('field_id' => $field_id, 'lang_id' => (int) $default_lang_id, 'option_id' => (int) $option_id));
            }
        }
    }
    if (sizeof($cp->vars['l_lang_options'])) {
        foreach ($cp->vars['l_lang_options'] as $lang_id => $lang_ary) {
            if (!is_array($lang_ary)) {
                $lang_ary = explode("\n", $lang_ary);
            }
            if (sizeof($lang_ary) != sizeof($cp->vars['lang_options'])) {
                $empty_lang[$lang_id] = true;
            }
            if (!isset($empty_lang[$lang_id])) {
                foreach ($lang_ary as $option_id => $value) {
                    $profile_lang_fields[] = array('field_id' => (int) $field_id, 'lang_id' => (int) $lang_id, 'option_id' => (int) $option_id, 'field_type' => (int) $field_type, 'value' => $value);
                }
            }
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:101,代码来源:admin_profile.php

示例11: redirect_browser

}
if (!module_config::can_i('edit', 'Settings')) {
    redirect_browser(_BASE_HREF);
}
if (isset($_REQUEST['currency_id'])) {
    $currency_id = (int) $_REQUEST['currency_id'];
    $currency = get_single('currency', 'currency_id', $currency_id);
    if (isset($_REQUEST['butdelete_currency'])) {
        if (module_form::confirm_delete('currency_id', 'Really delete currency: ' . htmlspecialchars($currency['code']))) {
            delete_from_db('currency', 'currency_id', $currency_id);
            set_message(_l('Currency deleted successfully'));
            redirect_browser($_SERVER['REQUEST_URI'] . (strpos($_SERVER['REQUEST_URI'], '?') === false ? '?' : '&') . 'deleted=true');
        }
    } else {
        if (isset($_REQUEST['save'])) {
            update_insert('currency_id', $currency_id, 'currency', $_POST);
            set_message('Currency saved successfully');
            //redirect_browser('?saved=true');
            redirect_browser($_SERVER['REQUEST_URI'] . (strpos($_SERVER['REQUEST_URI'], '?') === false ? '?' : '&') . 'saved=true');
        }
    }
    $currency = get_single('currency', 'currency_id', $currency_id);
    print_heading(array('title' => 'Edit Currency', 'type' => 'h2', 'main' => true));
    ?>

        <form action="" method="post">
            <input type="hidden" name="currency_id" value="<?php 
    echo $currency_id;
    ?>
">
            <input type="hidden" name="save" value="true">
开发者ID:sgh1986915,项目名称:php-crm,代码行数:31,代码来源:currency.php

示例12: update

 public function update($field, $value)
 {
     // what fields to we allow? or not allow?
     if (in_array($field, array('social_twitter_message_id'))) {
         return;
     }
     if ($this->social_twitter_message_id) {
         $this->{$field} = $value;
         update_insert('social_twitter_message_id', $this->social_twitter_message_id, 'social_twitter_message', array($field => $value));
     }
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:11,代码来源:twitter.class.php

示例13: get_languages_attributes

 public static function get_languages_attributes()
 {
     $all = array();
     $language_files = glob(_UCM_FOLDER . 'includes/plugin_language/custom/*.php');
     if (is_array($language_files)) {
         foreach ($language_files as $language) {
             $language = strtolower(str_replace('.php', '', basename($language)));
             if ($language[0] == '_') {
                 continue;
             }
             $all[$language] = array('language_name' => $language, 'language_code' => $language);
         }
     }
     $language_files = glob(_UCM_FOLDER . 'includes/plugin_language/labels/*.php');
     if (is_array($language_files)) {
         foreach ($language_files as $language) {
             $language = strtolower(str_replace('.php', '', basename($language)));
             if ($language[0] == '_') {
                 continue;
             }
             $all[$language] = array('language_name' => $language, 'language_code' => $language);
         }
     }
     if (self::is_language_db_enabled()) {
         foreach ($all as $language_code => $language) {
             // does this language code exist in the database?
             $language_db = get_single('language', 'language_code', $language_code);
             if (!$language_db || $language_db['language_code'] != $language_code) {
                 update_insert('language_id', false, 'language', array('language_code' => $language['language_code'], 'language_name' => $language['language_name']));
             }
         }
         // now we get any language attributes from the database and overwrite the old file based ones with those.
         foreach (get_multiple('language', false, 'language_id', 'exact', 'language_code') as $language) {
             if (isset($all[strtolower($language['language_code'])])) {
                 // this language exists in the old file based method.
                 $all[strtolower($language['language_code'])] = $language;
             } else {
                 // this is a language that only exists in the new database translation method.
                 $all[strtolower($language['language_code'])] = $language;
             }
             // todo - well, not sure about the above. maybe we do some update here and remove the old files ??? move everything to the database or something?? meh..
         }
     }
     return $all;
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:45,代码来源:language.php

示例14: save_groups

 public static function save_groups($owner_table, $owner_key, $owner_id)
 {
     if (isset($_REQUEST['group_' . $owner_table . '_field']) && is_array($_REQUEST['group_' . $owner_table . '_field'])) {
         $owner_id = (int) $owner_id;
         if ($owner_id <= 0) {
             if (isset($_REQUEST[$owner_key])) {
                 $owner_id = (int) $_REQUEST[$owner_key];
             }
         }
         if ($owner_id <= 0) {
             return;
         }
         // failed for some reason?
         $existing_groups = self::get_groups(array('owner_table' => $owner_table, 'owner_id' => $owner_id));
         foreach ($_REQUEST['group_' . $owner_table . '_field'] as $group_id => $group_data) {
             $key = trim($group_data['key']);
             if (!$key) {
                 unset($_REQUEST['group_' . $owner_table . '_field'][$group_id]);
                 continue;
             }
             $group_id = (int) $group_id;
             $group_db = array('group_key' => $group_data['key'], 'group' => $group_data['val'], 'owner_table' => $owner_table, 'owner_id' => $owner_id);
             $group_id = update_insert('group_id', $group_id, 'group', $group_db);
         }
         // work out which ones were not saved.
         foreach ($existing_groups as $existing_group) {
             if (!isset($_REQUEST['group_' . $owner_table . '_field'][$existing_group['group_id']])) {
                 // remove it.
                 $sql = "DELETE FROM " . _DB_PREFIX . "group WHERE group_id = '" . (int) $existing_group['group_id'] . "' LIMIT 1";
                 query($sql);
             }
         }
     }
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:34,代码来源:group.php

示例15: process

 public function process()
 {
     if ('save_faq_product' == $_REQUEST['_process']) {
         if (!module_faq::can_i('edit', 'FAQ')) {
             die('No perms to save faq.');
         }
         if (isset($_POST['envato_item_ids'])) {
             $_POST['envato_item_ids'] = implode('|', $_POST['envato_item_ids']);
         }
         $faq_product_id = update_insert('faq_product_id', $_REQUEST['faq_product_id'], 'faq_product', $_POST);
         if (isset($_REQUEST['butt_del'])) {
             // deleting ticket type all together
             if (module_form::confirm_delete('customer_id', _l("Really delete FAQ Product?"), self::link_open_faq_product($_REQUEST['faq_product_id']))) {
                 delete_from_db('faq_product', 'faq_product_id', $_REQUEST['faq_product_id']);
                 set_message('FAQ Product deleted successfully.');
                 redirect_browser($this->link_open_faq_product(false));
             }
         }
         set_message('FAQ Product saved successfully');
         redirect_browser($this->link_open_faq_product($faq_product_id));
     } else {
         if ('save_faq' == $_REQUEST['_process']) {
             if (!module_faq::can_i('edit', 'FAQ')) {
                 die('No perms to save faq.');
             }
             if (isset($_REQUEST['new_product_name']) && strlen(trim($_REQUEST['new_product_name']))) {
                 $faq_product_id = update_insert('faq_product_id', false, 'faq_product', array('name' => trim($_REQUEST['new_product_name'])));
                 if (!isset($_REQUEST['faq_product_ids'])) {
                     $_REQUEST['faq_product_ids'] = array();
                 }
                 $_REQUEST['faq_product_ids'][] = $faq_product_id;
             }
             $faq_id = update_insert('faq_id', $_REQUEST['faq_id'], 'faq', $_POST);
             delete_from_db('faq_product_rel', 'faq_id', $faq_id);
             if (isset($_REQUEST['faq_product_ids']) && is_array($_REQUEST['faq_product_ids'])) {
                 foreach ($_REQUEST['faq_product_ids'] as $faq_product_id) {
                     if ((int) $faq_product_id > 0) {
                         $sql = "INSERT INTO `" . _DB_PREFIX . "faq_product_rel` SET faq_id = " . (int) $faq_id . ", faq_product_id = " . (int) $faq_product_id;
                         query($sql);
                     }
                 }
             }
             if (isset($_REQUEST['butt_del'])) {
                 // deleting ticket type all together
                 if (module_form::confirm_delete('customer_id', _l("Really delete FAQ item?"), self::link_open($_REQUEST['faq_id']))) {
                     delete_from_db('faq', 'faq_id', $_REQUEST['faq_id']);
                     delete_from_db('faq_product_rel', 'faq_id', $_REQUEST['faq_id']);
                     set_message('FAQ deleted successfully.');
                     redirect_browser($this->link_open(false));
                 }
             }
             set_message('FAQ saved successfully');
             redirect_browser($this->link_open($faq_id));
         }
     }
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:56,代码来源:faq.php


注:本文中的update_insert函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。