Ejemplo n.º 1
0
 /**
  * The ProcessNewOrderNotification function is a shell function for 
  * handling a <new-order-notification>. You will need to modify this 
  * function to transfer the information contained in a 
  * <new-order-notification> to your internal systems that process that data.
  *
  * @param    $xml_response    asynchronous notification XML DOM
  */
 function ProcessNewOrderNotification($dom_data_root, $sn)
 {
     /*
      * +++ CHANGE ME +++
      * New order notifications inform you of new orders that have
      * been submitted through Google Checkout. A <new-order-notification>
      * message contains a list of the items in an order, the tax
      * assessed on the order, the shipping method selected for the
      * order and the shipping address for the order.
      *
      * If you are implementing the Notification API, you need to
      * modify this function to relay the information in the
      * <new-order-notification> to your internal systems that
      * process this order data.
      */
     global $db;
     $this->LogMessage("Google Checkout: New Order Notification #" . $dom_data_root['google-order-number'], $debug_only_msg = false);
     //$this->LogMessage ("DEBUG: [".serialize($dom_data_root)."]");
     $cart = $dom_data_root['shopping-cart'];
     $payment_id = $cart['merchant-private-data']['payment-id'];
     $memeber_id = $cart['merchant-private-data']['memeber-id'];
     $payments = array();
     if ($payment_id) {
         $payments[] = $payment_id;
     }
     $buyer = $dom_data_root['buyer-billing-address'];
     $email = trim($buyer['email']);
     $users = $db->users_find_by_string($email, 'email', $exact = 1);
     if (!$memeber_id && !$payment_id && $this->_allow_create) {
         // create new member/subscription
         if (!$users && check_email($email)) {
             // No member exists. Create new account.
             $name_f = trim($buyer['structured-name']['first-name']);
             $name_l = trim($buyer['structured-name']['last-name']);
             if (!$name_f && !$name_l) {
                 list($name_f, $name_l) = @explode(" ", $buyer['contact-name']);
             }
             $address = $buyer['address1'];
             $city = $buyer['city'];
             $zip = $buyer['postal-code'];
             $state = $buyer['region'];
             $country = $buyer['country-code'];
             $phone = $buyer['phone'];
             $v = array('email' => $email, 'name_f' => $name_f, 'name_l' => $name_l, 'address' => $address, 'city' => $city, 'zip' => $zip, 'state' => $state, 'country' => $country);
             $v['login'] = generate_login($v);
             $v['pass'] = generate_password($v);
             $member_id = $db->add_pending_user($v);
             // and add payment(s)
             foreach ((array) $dom_data_root['shopping-cart']['items'] as $item) {
                 $products = $db->get_products_list();
                 foreach ($products as $pr) {
                     if ($pr['google_merchant_item_id'] != '' && $pr['google_merchant_item_id'] == $item['merchant-item-id']) {
                         $product_id = $pr['product_id'];
                         $product = $db->get_product($product_id);
                         $price = $product['price'];
                         $begin_date = date("Y-m-d");
                         $duration = $this->get_days($product['expire_days']) * 3600 * 24;
                         $expire_date = date('Y-m-d', time() + $duration);
                         $payment_id = $db->add_waiting_payment($member_id, $product_id, $paysys_id = 'google_checkout', $price, $begin_date, $expire_date, $vars, $additional_values = false);
                         if ($payment_id) {
                             $payments[] = $payment_id;
                         }
                     }
                 }
             }
         }
     }
     //$member  = $db->get_user($memeber_id);
     foreach ($payments as $payment_id) {
         $q = $db->query($s = "UPDATE {$db->config['prefix']}payments\n                    SET receipt_id = '" . $db->escape($dom_data_root['google-order-number']) . "'\n                    WHERE payment_id='{$payment_id}'\n                    ");
         $payment = $db->get_payment($payment_id);
         $payment['receipt_id'] = $dom_data_root['google-order-number'];
         $payment['data']['google-order-number'] = $dom_data_root['google-order-number'];
         $payment['data']['fulfillment-order-state'] = $dom_data_root['fulfillment-order-state'];
         $payment['data']['financial-order-state'] = $dom_data_root['financial-order-state'];
         $err = $db->update_payment($payment_id, $payment);
         if ($err) {
             $this->LogMessage($err, $debug_only_msg = false);
         }
     }
     $this->SendNotificationAcknowledgment($sn);
 }
Ejemplo n.º 2
0
    if (!$vars['i_agree']) {
        $error[] = _SIGNUP_USER_AGREEMENT;
        display_agreement($vars['data']);
        exit;
    }
    $vars = unserialize($vars['data']);
    $vars['i_agree']++;
    foreach ($vars as $k => $v) {
        $t->_smarty_vars['request'][$k] = $v;
    }
}
if (!$config['login_dont_lowercase']) {
    $vars['login'] = strtolower($vars['login']);
}
if ($config['generate_login']) {
    $vars['login'] = generate_login($vars);
}
if ($config['generate_pass']) {
    $vars['pass'] = $vars['pass0'] = $vars['pass1'] = generate_password($vars);
}
/////
if ($vars['do_affiliate'] && check_form()) {
    /*
    //check for agreement
    $display_agreement = 0;
    
    foreach ((array)$vars['product_id'] as $pid){   
        $product = $db->get_product($pid);
        if ($product['need_agreement'])
            $display_agreement++;
    }
Ejemplo n.º 3
0
function fb_connect_create_account()
{
    global $config, $db, $plugin_config;
    $this_config = $plugin_config['protect']['fb_connect'];
    $testmode = $this_config['testmode'];
    // Check create account is allowed
    if (!$this_config['newaccount']) {
        header("Location: " . $config['root_url'] . "/signup.php?fb=manual");
        exit;
    }
    // Check login to Facebook
    $fbuserid = fb_connect_get_fbuser();
    if (!$fbuserid) {
        header("Location: " . $config['root_url'] . "/signup.php?fb=cancel");
        exit;
    }
    // Check there is not already a linked account
    list($l, $p) = fb_connect_check_logged_in();
    if (strlen($l) && strlen($p)) {
        header("Location: " . $config['root_url'] . "/login.php");
        exit;
    }
    // Check facebook email is available, that it is not proxied (too long), and not already exists in aMember
    if (!$_SESSION['fbme']['email'] || strlen($_SESSION['fbme']['email']) > 64 || $config['unique_email'] && $db->users_find_by_string($_SESSION['fbme']['email'], 'email', 1)) {
        if ($testmode == 1) {
            $db->log_error("fb_connect: Create account aborted: Has a proxied email, no email address or email already exists ({$_SESSION['fbme']['email']})");
        }
        header("Location: " . $config['root_url'] . "/signup.php?fb=email");
        exit;
    }
    // Ok, now we can create the account
    $vars = array();
    $vars['name_f'] = $_SESSION['fbme']['first_name'];
    $vars['name_l'] = $_SESSION['fbme']['last_name'];
    $vars['email'] = $_SESSION['fbme']['email'];
    $vars['login'] = generate_login($vars);
    $vars['pass'] = $vars['pass0'] = $vars['pass1'] = generate_password($vars);
    if ($GLOBALS['_LANG_SELECTED'] != get_default_lang()) {
        $vars['selected_lang'] = $GLOBALS['_LANG_SELECTED'];
    }
    $member_id = $db->add_pending_user($vars);
    $db->query("UPDATE {$db->config['prefix']}members SET fbuserid = '{$fbuserid}' WHERE member_id = '{$member_id}' LIMIT 1");
    $db->log_error("fb_connect: Created aMember account for Facebook user ({$fbuserid}) - " . print_r($vars, 1));
    $is_affiliate = '0';
    //only member newsletters
    if ($db->get_signup_threads_c($is_affiliate)) {
        $db->subscribe_member($member_id, $is_affiliate);
    }
    if ($config['auto_login_after_signup']) {
        $_SESSION['_amember_login'] = $vars['login'];
        $_SESSION['_amember_pass'] = $vars['pass'];
    }
    // Now add Facebook product subscripton, if set
    if ($this_config['newaccountproduct']) {
        $fb_product =& get_product($this_config['newaccountproduct']);
        $fb_payment = array('member_id' => $member_id, 'product_id' => $fb_product->config['product_id'], 'completed' => 0, 'paysys_id' => 'free', 'begin_date' => $begin_date = date('Y-m-d'), 'expire_date' => $fb_product->get_expire($begin_date));
        $db->add_payment($fb_payment);
        if ($testmode == 1) {
            $db->log_error("fb_connect: Added subscription (product #{$this_config['newaccountproduct']} ) for Facebook user ({$fbuserid}), login = {$vars['login']}");
        }
        // Now go to thanks page...
        $payment_id = $GLOBALS['_amember_added_payment_id'];
        $vcode = md5($payment_id . $begin_date . $member_id);
        header("Location: " . $config['root_url'] . "/plugins/protect/fb_connect/thanks.php?payment_id={$payment_id}&vcode={$vcode}");
        exit;
    }
    // Account only - go to member page...
    header("Location: " . $config['root_url'] . "/member.php");
    exit;
}
Ejemplo n.º 4
0
function line_to_record($l)
{
    global $__fields, $vars;
    if ($__fields) {
        $fields = $__fields;
    } else {
        $fields = get_rev_fields($vars);
        $__fields = $fields;
    }
    $rec = array();
    foreach ($fields as $fn => $nn) {
        $rec[$fn] = trim($l[$nn]);
    }
    if ($vars['login'] == 'GENERATE') {
        $rec['login'] = generate_login();
    }
    if ($vars['pass'] == 'FIXED') {
        $rec['pass'] = $vars['pass_fixed'];
    }
    if ($vars['pass'] == 'GENERATE') {
        $rec['pass'] = generate_password();
    }
    if ($rec['cc']) {
        $cc = preg_replace('/\\D+/', '', $rec['cc']);
        $rec['cc-hidden'] = amember_crypt($cc);
        $rec['cc'] = get_visible_cc_number($cc);
        $cc = '';
    }
    if ($rec['cc-expire']) {
        $rec['cc-expire'] = format_cc_expire($rec['cc-expire']);
    }
    if ($vars['product_id'] != 'EMPTY') {
        if (intval($vars['product_id'])) {
            $rec['product_id'] = $vars['product_id'];
        }
        if ($vars['expire_date'] == 'FIXED') {
            $rec['expire_date'] = $vars['expire_date_fixed'];
        }
        if ($vars['begin_date'] == 'FIXED') {
            $rec['begin_date'] = $vars['begin_date_fixed'];
        }
        if (!preg_match('/^FIELD-/', $vars['paysys_id'])) {
            $rec['paysys_id'] = $vars['paysys_id'];
        }
        if ($vars['receipt_id'] == 'FIXED') {
            $rec['receipt_id'] = $vars['receipt_id_fixed'];
        }
        $rec['is_completed'] = intval($vars['is_completed']);
    }
    $rec['begin_date'] = convert_date($rec['begin_date']);
    $rec['expire_date'] = convert_date($rec['expire_date']);
    return $rec;
}
Ejemplo n.º 5
0
function edit_save()
{
    global $db, $t;
    global $member_additional_fields, $config;
    $vars = get_input_vars();
    $oldm = $db->get_user($vars['member_id']);
    $vars['email_verified'] = $oldm['email_verified'];
    $vars['security_code'] = $oldm['security_code'];
    $vars['securitycode_expire'] = $oldm['securitycode_expire'];
    $errors = array();
    if (strlen($vars['generate_login'])) {
        $vars['login'] = generate_login($vars);
    }
    if (strlen($vars['generate_pass'])) {
        $vars['pass'] = generate_password($vars);
    }
    if (!strlen($vars['login'])) {
        $errors[] = "'Login' is a required field";
    }
    if ($vars['pass'] == '' && $config['hide_password_cp']) {
        $vars['pass'] = $oldm['pass'];
    }
    if (!strlen($vars['pass'])) {
        $errors[] = "'Password' is a required field";
    }
    foreach ($member_additional_fields as $f) {
        $fname = $f['name'];
        if ($f['validate_func']) {
            foreach ((array) $f['validate_func'] as $func) {
                if (!function_exists($func)) {
                    fatal_error("Validation function '{$func}' for field: '{$fname}' not defined. Internal error");
                }
                if ($err = $func($vars[$fname], $f['title'], $f)) {
                    $errors[] = $err;
                }
            }
        }
    }
    foreach ($member_additional_fields as $f) {
        if ($f['sql']) {
            continue;
        }
        $fname = $f['name'];
        if (isset($vars[$fname])) {
            $vars['data'][$fname] = $vars[$fname];
        }
        unset($vars[$fname]);
    }
    if ($errors) {
        $t->assign('errors', $errors);
        return display_edit_form($vars);
    }
    // no subscriptions for updated user
    //$db->subscribe_member ($vars['member_id'], $vars['is_affiliate']);
    //
    $err = $db->update_user($vars['member_id'], $vars);
    $db->delete_member_threads($vars['member_id']);
    $db->add_member_threads($vars['member_id'], $vars['threads']);
    if ($err) {
        fatal_error("Cannot update user info: {$err}");
    }
    update_cc_info($vars['member_id'], $vars);
    admin_log("Member record changed ({$oldm['login']})", 'members', $vars['member_id']);
    if ($config['manually_approve']) {
        if ($oldm['data']['is_approved'] != $vars['data']['is_approved'] && $vars['data']['is_approved']) {
            check_for_signup_mail(0, $vars['member_id']);
        }
    }
    $t->assign('link', "users.php?member_id={$vars['member_id']}&action=edit");
    $t->display("admin/user_saved.html");
}
Ejemplo n.º 6
0
function array_to_record($line_array)
{
    global $vars, $rev_fields, $db, $import_products_cache;
    if (!$rev_fields) {
        $rev_fields = get_rev_fields($vars);
    }
    $rec = array();
    foreach ($rev_fields as $fn => $nn) {
        $rec[$fn] = trim($line_array[$nn]);
    }
    if ($vars['login'] == 'GENERATE') {
        $rec['login'] = generate_login();
    }
    if ($vars['pass'] == 'FIXED') {
        $rec['pass'] = $vars['pass_fixed'];
    }
    if ($vars['pass'] == 'GENERATE') {
        $rec['pass'] = generate_password();
    }
    if ($rec['cc']) {
        $cc = preg_replace('/\\D+/', '', $rec['cc']);
        $rec['cc-hidden'] = amember_crypt($cc);
        $rec['cc'] = get_visible_cc_number($cc);
        $cc = '';
    }
    if ($rec['cc-expire']) {
        $rec['cc-expire'] = format_cc_expire($rec['cc-expire']);
    }
    if ($vars['product_id'] != 'EMPTY') {
        if (is_numeric($vars['product_id'])) {
            $rec['product_id'] = $vars['product_id'];
        } else {
            if (!is_numeric($rec['product_id'])) {
                if (!isset($import_products_cache[$rec['product_id']])) {
                    $product_title = $db->escape($rec['product_id']);
                    if ($import_products_cache[$rec['product_id']] = $db->query_first("SELECT * FROM {$db->config['prefix']}products WHERE title = '{$product_title}'")) {
                        $rec['product_id'] = $import_products_cache[$rec['product_id']]['product_id'];
                    }
                } else {
                    $rec['product_id'] = $import_products_cache[$rec['product_id']]['product_id'];
                }
            }
        }
        if ($vars['expire_date'] == 'FIXED') {
            $rec['expire_date'] = $vars['expire_date_fixed'];
        }
        if ($vars['begin_date'] == 'FIXED') {
            $rec['begin_date'] = $vars['begin_date_fixed'];
        }
        if ($vars['amount'] == 'FIXED') {
            $rec['amount'] = $vars['amount_fixed'];
        }
        if (!preg_match('/^FIELD-/', $vars['paysys_id'])) {
            $rec['paysys_id'] = $vars['paysys_id'];
        }
        if ($vars['receipt_id'] == 'FIXED') {
            $rec['receipt_id'] = $vars['receipt_id_fixed'];
        }
        $rec['completed'] = intval($vars['is_completed']);
    }
    $rec['begin_date'] = convert_date($rec['begin_date']);
    $rec['expire_date'] = convert_date($rec['expire_date']);
    return $rec;
}
Ejemplo n.º 7
0
function openid_create_account()
{
    global $config, $db, $plugin_config;
    $this_config = $plugin_config['protect']['openid'];
    $testmode = $this_config['testmode'];
    // Check create account is allowed
    if (!$this_config['newaccount']) {
        header("Location: " . $config['root_url'] . "/signup.php");
        exit;
    }
    // Check login to OpenID
    if (!$_SESSION['openid']['identity']) {
        header("Location: " . $config['root_url'] . "/signup.php");
        exit;
    }
    // Check there is not already a linked account
    list($l, $p) = openid_check_logged_in();
    if (strlen($l) && strlen($p)) {
        header("Location: " . $config['root_url'] . "/login.php");
        exit;
    }
    // Check OpenID email is available, that it is not too long, and not already exists in aMember
    $email = $_SESSION['openid']['data']['contact/email'];
    if (!$email || strlen($email) > 64 || $config['unique_email'] && $db->users_find_by_string($email, 'email', 1)) {
        if ($testmode == 1) {
            $db->log_error("openid: Create account aborted: Email address too long, not provided, or already exists ({$email})");
        }
        header("Location: " . $config['root_url'] . "/signup.php");
        exit;
    }
    // Check all required information has been supplied
    $ax_required = array_filter((array) $this_config['ax_required']);
    $ax_missing = array();
    foreach ($ax_required as $ax) {
        if (!$_SESSION['openid']['data'][$ax]) {
            $ax_missing[] = $ax;
        }
    }
    if (count($ax_missing) > 0) {
        $ax_missing = implode(", ", $ax_missing);
        if ($testmode == 1) {
            $db->log_error("openid: Auto-create account aborted: The following required items were missing ({$ax_missing})");
        }
        header("Location: " . $config['root_url'] . "/signup.php");
        exit;
    }
    // Ok, now we can create the account
    $vars = array();
    if ($_SESSION['openid']['data']['namePerson/first'] && $_SESSION['openid']['data']['namePerson/last']) {
        $vars['name_f'] = $_SESSION['openid']['data']['namePerson/first'];
        $vars['name_l'] = $_SESSION['openid']['data']['namePerson/last'];
    } else {
        if ($_SESSION['openid']['data']['namePerson']) {
            list($vars['name_f'], $vars['name_l']) = explode(" ", $_SESSION['openid']['data']['namePerson']);
        }
    }
    foreach ($ax_required as $ax) {
        $vars[openid_ax2field($ax)] = $_SESSION['openid']['data'][$ax];
        if ($ax == 'person/gender') {
            $vars['is_male'] = $_SESSION['openid']['data'][$ax] == "M" ? 1 : 0;
        }
    }
    $vars['pass'] = $vars['pass0'] = $vars['pass1'] = generate_password($vars);
    $vars['email'] = $email;
    $vars['login'] = generate_login($vars);
    if ($GLOBALS['_LANG_SELECTED'] != get_default_lang()) {
        $vars['selected_lang'] = $GLOBALS['_LANG_SELECTED'];
    }
    $member_id = $db->add_pending_user($vars);
    $openid = $db->escape($_SESSION['openid']['identity']);
    $db->query("UPDATE {$db->config['prefix']}members SET openid = '{$openid}' WHERE member_id = '{$member_id}' LIMIT 1");
    $db->log_error("openid: Created aMember account for OpenID user ({$openid}) - " . print_r($vars, 1));
    $is_affiliate = '0';
    //only member newsletters
    if ($db->get_signup_threads_c($is_affiliate)) {
        $db->subscribe_member($member_id, $is_affiliate);
    }
    // Now add OpenID product subscripton, if set
    if ($this_config['newaccountproduct']) {
        $openid_product =& get_product($this_config['newaccountproduct']);
        $openid_payment = array('member_id' => $member_id, 'product_id' => $openid_product->config['product_id'], 'completed' => 0, 'paysys_id' => 'free', 'begin_date' => $begin_date = date('Y-m-d'), 'expire_date' => $openid_product->get_expire($begin_date));
        $db->add_payment($openid_payment);
        if ($testmode == 1) {
            $db->log_error("openid: Added subscription (product #{$this_config['newaccountproduct']} ) for OpenID user ({$openid}), login = {$vars['login']}");
        }
        // Now go to thanks page...
        $payment_id = $GLOBALS['_amember_added_payment_id'];
        $vcode = md5($payment_id . $begin_date . $member_id);
        header("Location: " . $config['root_url'] . "/plugins/protect/openid/thanks.php?payment_id={$payment_id}&vcode={$vcode}");
        exit;
    }
    // Account only - go to member page...
    header("Location: " . $config['root_url'] . "/member.php");
    exit;
}
Ejemplo n.º 8
0
 function create_new_payment(&$vars)
 {
     global $db;
     // Check if enabled;
     if (!$this->config['allow_create']) {
         return;
     }
     $member = array();
     foreach (array('name_f', 'name_l', 'email', 'street', 'city', 'zip', 'country', 'state') as $v) {
         $member[$v] = $this->get_value_from_vars($v, $vars);
     }
     $member['to_subscribe'] = 1;
     // mod added for aMail
     // Try to find existing user with the same email;
     $users = $db->users_find_by_string($member['email'], 'email', $exact = 1);
     $u = $users['0'];
     if (!$u['member_id']) {
         $member['login'] = generate_login($member);
         $member['pass'] = generate_password($member);
         $member_id = $db->add_pending_user($member);
         $u = $db->get_user($member_id);
     }
     if (!($product_id = intval($this->get_value_from_vars('product_id', $vars)))) {
         return;
     }
     $product = get_product($product_id);
     $amount = $this->get_value_from_vars("amount", $vars);
     if ($amount == '' || $amount === false) {
         $amount = $product->config['price'];
     }
     $begin_date = date('Y-m-d');
     $expire_date = $product->get_expire($begin_date, 'expire_days');
     $payment_id = $db->add_waiting_payment($u['member_id'], $product_id, $this->get_plugin_name(), $amount, $begin_date, $expire_date, $vars);
     // Set receipt_id will be required by some payment plugins;
     $payment = $db->get_payment($payment_id);
     $payment['receipt_id'] = $this->get_value_from_vars('receipt_id', $vars);
     $db->update_payment($payment['payment_id'], $payment);
     return $payment_id;
 }