Esempio n. 1
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;
}
Esempio n. 2
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;
}