コード例 #1
0
 function config_set($k, $v, $store_type)
 {
     switch ($store_type) {
         case 0:
             $v = $v;
             //text
             break;
         case 1:
             $bv = serialize($v);
             $v = '';
             // serialize
             break;
         case 2:
             $bv = $v;
             $v = '';
             // blob
             break;
         case 3:
             $v = amember_crypt($v);
             // crypt
             break;
         case 4:
             $v = $v;
             //eval
             break;
         default:
             fatal_error("Unknown store_type");
     }
     $v = $this->escape($v);
     $bv = strlen($bv) ? "'" . $this->escape($bv) . "'" : 'NULL';
     $this->query("REPLACE INTO {$this->config[prefix]}config\n        (name, type,value,blob_value)\n        VALUES\n        ('{$k}', {$store_type}, '{$v}', {$bv})\n        ");
 }
コード例 #2
0
ファイル: cc.php プロジェクト: subashemphasize/test_site
function do_main()
{
    global $t, $db, $config, $vars;
    $cc_fields = array('street', 'city', 'state', 'zip', 'country');
    if ($config['cc_name']) {
        $cc_fields[] = 'name';
    }
    if ($config['cc_company']) {
        $cc_fields[] = 'company';
    }
    if ($config['cc_name_f']) {
        $cc_fields[] = 'name_f';
    }
    if ($config['cc_name_l']) {
        $cc_fields[] = 'name_l';
    }
    if ($config['cc_phone']) {
        $cc_fields[] = 'phone';
    }
    if ($vars['cc_code']) {
        $_SESSION['_amember_card_code'] = $vars['cc_code'];
    }
    $t->assign('renew_cc', $vars['renew_cc']);
    ///
    $member_id = intval($vars['member_id']);
    if (!$member_id) {
        $member_id = $_SESSION['_amember_id'];
    }
    if (!$member_id) {
        fatal_error(_PLUG_PAY_INETCOM_FERROR);
    }
    if ($vars['renew_cc']) {
        // cc info renewal, require auth, don't req. payment_id
        if ($member_id != $_SESSION['_amember_id']) {
            fatal_error(_PLUG_PAY_INETCOM_FERROR2, 0);
        }
    } else {
        //regular payment
        $payment_id = intval($vars['payment_id']);
        if (!$payment_id) {
            fatal_error(_PLUG_PAY_INETCOM_FERROR3);
        }
    }
    $db->log_error("member_id={$member_id},{$_SESSION[_amember_id]}");
    $member = $db->get_user($member_id);
    /// use old info if it's possible
    if (!$vars['renew_cc'] && !$vars['retry'] && $member['data']['cc-hidden'] && $member['data']['cc-expire'] > 0) {
        if ($vars['cc_number'] || $vars['cc_expire_Month'] || $vars['cc_expire_Year']) {
        } else {
            $vars['cc_number'] = amember_decrypt($member['data']['cc-hidden']);
            $vars['cc_expire_Month'] = intval(substr($member['data']['cc-expire'], 0, 2));
            $vars['cc_expire_Year'] = 2000 + intval(substr($member['data']['cc-expire'], 2, 2));
            foreach ($cc_fields as $f) {
                $vars['cc_' . $f] = $member['data']['cc_' . $f];
            }
            $vars['do_cc'] = 1;
        }
    }
    while ($vars['do_cc']) {
        // validate cc_vars
        $error = validate_cc_info($vars);
        if ($error) {
            break;
        }
        // get member
        $m = $db->get_user($member_id);
        if (!is_array($m)) {
            fatal_error(sprintf(_PLUG_PAY_INETCOM_FERROR4, $member_id, $payment_id));
        }
        $m['data']['cc-hidden'] = amember_crypt($vars['cc_number']);
        $m['data']['cc'] = get_visible_cc_number($vars['cc_number']);
        $m['data']['cc-expire'] = sprintf('%02d%02d', $vars['cc_expire_Month'], substr($vars['cc_expire_Year'], 2, 2));
        foreach ($cc_fields as $f) {
            $m['data']['cc_' . $f] = $vars['cc_' . $f];
        }
        $db->update_user($m['member_id'], $m);
        //        print_r($_POST);
        //        print_r($_GET);
        //        print_r($_SESSION);
        //        print_r($m);
        //        exit();
        ////// skip real payment if renew cc specified ///////////////
        if ($vars['renew_cc']) {
            header("Location: {$config['root_surl']}/member.php?cc_renew_done=1");
        } else {
            header("Location: {$config['root_surl']}/plugins/payment/theinternetcommerce/cc.php?" . "do_payment=1&payment_id={$payment_id}&member_id={$member_id}");
        }
        exit;
    }
    $t->assign('error', $error);
    if ($vars['payment_id']) {
        $payment = $db->get_payment($vars['payment_id']);
        $t->assign('payment', $payment);
    }
    /// handle address
    $cc_address = array();
    foreach ($cc_fields as $f) {
        $v = $vars['cc_' . $f];
        if (!isset($vars['cc_' . $f])) {
            if (!$v) {
                $v = $member['data']['cc_' . $f];
            }
            if (!$v) {
                $v = $member[$f];
            }
            if (!$v && $f == 'name') {
                $v = $member['name_f'] . ' ' . $member['name_l'];
            }
            if (!$v && $f == 'phone') {
                $v = $member['data']['phone'];
            }
            if (!$v && $f == 'company') {
                $v = $member['data']['company'];
            }
        }
        $cc_address['cc_' . $f] = $v;
    }
    $t->assign('cc_address', $cc_address);
    $t->display('cc/cc_info.html');
}
コード例 #3
0
function save_cc_info($cc_info, $member, $paysys_id)
{
    global $t, $db, $config;
    // get a plugin config
    $plugin =& instantiate_plugin('payment', $paysys_id);
    if (!method_exists($plugin, 'cc_bill')) {
        fatal_error("This plugin ({$paysys_id}) is not handled by cc_core!");
    }
    if (method_exists($plugin, 'save_cc_info')) {
        $plugin->save_cc_info($cc_info, $member);
    } else {
        $features = $plugin->get_plugin_features();
        $member['data']['cc-hidden'] = amember_crypt(preg_replace('/\\D+/', '', $cc_info['cc_number']));
        $member['data']['cc'] = get_visible_cc_number($cc_info['cc_number']);
        $member['data']['cc-expire'] = sprintf('%02d%02d', $cc_info['cc_expire_Month'], substr($cc_info['cc_expire_Year'], 2, 2));
        if ($features['maestro_solo_switch']) {
            $member['data']['cc_startdate'] = sprintf('%02d%02d', $cc_info['cc_startdate_Month'], substr($cc_info['cc_startdate_Year'], 2, 2));
            $member['data']['cc_issuenum'] = $cc_info['cc_issuenum'];
        }
        if ($features['type_options']) {
            $member['data']['cc_type'] = $cc_info['cc_type'];
        }
        if ($features['code'] > 1) {
            $member['data']['cc_code'] = $cc_info['cc_code'];
        }
        if ($features['name']) {
            $member['data']['cc_name'] = $cc_info['cc_name'];
        }
        if ($features['name_f']) {
            $member['data']['cc_name_f'] = $cc_info['cc_name_f'];
            $member['data']['cc_name_l'] = $cc_info['cc_name_l'];
        }
        if ($features['company']) {
            $member['data']['cc_company'] = $cc_info['cc_company'];
        }
        if ($features['phone']) {
            $member['data']['cc_phone'] = $cc_info['cc_phone'];
        }
        if ($features['housenumber']) {
            $member['data']['cc_housenumber'] = $cc_info['cc_housenumber'];
        }
        $member['data']['cc_street'] = $cc_info['cc_street'];
        $member['data']['cc_city'] = $cc_info['cc_city'];
        $member['data']['cc_state'] = $cc_info['cc_state'];
        if ($features['province_outside_of_us']) {
            $member['data']['cc_province'] = $cc_info['cc_province'];
        }
        $member['data']['cc_zip'] = $cc_info['cc_zip'];
        $member['data']['cc_country'] = $cc_info['cc_country'];
        $db->update_user($member['member_id'], $member);
    }
}
コード例 #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;
}
コード例 #5
0
ファイル: users.php プロジェクト: subashemphasize/test_site
function update_cc_info($member_id, $vars)
{
    global $db;
    $change = array();
    if (strlen($vars['cc_number']) && $vars['cc_expire_Month'] && $vars['cc_expire_Year']) {
        $vars['cc_number'] = preg_replace('/\\D+/', '', $vars['cc_number']);
        $change['cc-hidden'] = amember_crypt($vars['cc_number']);
        $change['cc'] = get_visible_cc_number($vars['cc_number']);
    }
    if ($vars['cc_expire_Month'] && $vars['cc_expire_Year']) {
        $change['cc-expire'] = sprintf('%02d%02d', $vars['cc_expire_Month'], substr($vars['cc_expire_Year'], 2, 2));
    }
    ////////////////////////////////////////////////////////////////////
    $m = $db->get_user($member_id);
    foreach ($change as $k => $v) {
        $m['data'][$k] = $v;
    }
    $db->update_user($member_id, $m);
}
コード例 #6
0
ファイル: cc.php プロジェクト: subashemphasize/test_site
function do_main()
{
    global $t, $db, $config, $vars;
    if ($vars['cc_code']) {
        $_SESSION['_amember_card_code'] = $vars['cc_code'];
    }
    $t->assign('renew_cc', $vars['renew_cc']);
    ///
    $member_id = intval($vars['member_id']);
    if (!$member_id) {
        $member_id = $_SESSION['_amember_id'];
    }
    if (!$member_id) {
        fatal_error("Member ID isn't specified");
    }
    if ($vars['renew_cc']) {
        // cc info renewal, require auth, don't req. payment_id
        if ($member_id != $_SESSION['_amember_id']) {
            fatal_error("You must be autorized to do it", 0);
        }
    } else {
        //regular payment
        $payment_id = intval($vars['payment_id']);
        if (!$payment_id) {
            fatal_error("Payment ID isn't specified");
        }
    }
    $db->log_error("member_id={$member_id},{$_SESSION[_amember_id]}");
    $member = $db->get_user($member_id);
    /// use old info if it's possible
    if (!$vars['renew_cc'] && !$vars['retry'] && $member['data']['cc-hidden'] && $member['data']['cc-expire'] > 0) {
        if ($vars['cc_number'] || $vars['cc_expire_Month'] || $vars['cc_expire_Year']) {
        } else {
            $vars['cc_number'] = amember_decrypt($member['data']['cc-hidden']);
            $vars['cc_expire_Month'] = intval(substr($member['data']['cc-expire'], 0, 2));
            $vars['cc_expire_Year'] = 2000 + intval(substr($member['data']['cc-expire'], 2, 2));
            foreach (array('street', 'city', 'state', 'zip', 'country') as $f) {
                $vars['cc_' . $f] = $member['data']['cc_' . $f];
            }
            $vars['do_cc'] = 1;
        }
    }
    while ($vars['do_cc']) {
        // validate cc_vars
        $error = validate_cc_info($vars);
        if ($error) {
            break;
        }
        // get member
        $m = $db->get_user($member_id);
        if (!is_array($m)) {
            fatal_error("Can not load member record #{$member_id} ({$payment_id})");
        }
        $m['data']['cc-hidden'] = amember_crypt($vars['cc_number']);
        $m['data']['cc'] = get_visible_cc_number($vars['cc_number']);
        $m['data']['cc-expire'] = sprintf('%02d%02d', $vars['cc_expire_Month'], substr($vars['cc_expire_Year'], 2, 2));
        foreach (array('street', 'city', 'state', 'zip', 'country') as $f) {
            $m['data']['cc_' . $f] = $vars['cc_' . $f];
        }
        $db->update_user($m['member_id'], $m);
        ////// skip real payment if renew cc specified ///////////////
        if ($vars['renew_cc']) {
            header("Location: {$config['root_surl']}/member.php?cc_renew_done=1");
        } else {
            header("Location: {$config['root_surl']}/plugins/payment/efsnet/cc.php?" . "do_payment=1&payment_id={$payment_id}&member_id={$member_id}");
        }
        exit;
    }
    $t->assign('error', $error);
    if ($vars['payment_id']) {
        $payment = $db->get_payment($vars['payment_id']);
        $t->assign('payment', $payment);
    }
    /// handle address
    $cc_address = array();
    foreach (array('street', 'city', 'state', 'zip', 'country') as $f) {
        $v = $vars['cc_' . $f];
        if (!isset($vars['cc_' . $f])) {
            if (!$v) {
                $v = $member['data']['cc_' . $f];
            }
            if (!$v) {
                $v = $member[$f];
            }
        }
        $cc_address['cc_' . $f] = $v;
    }
    $t->assign('cc_address', $cc_address);
    $t->display('cc/cc_info.html');
}
コード例 #7
0
ファイル: import.php プロジェクト: subashemphasize/test_site
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;
}