示例#1
0
/**
 * Get FedEx meter number
 */
function fn_settings_actions_shippings_fedex_fedex_meter_get(&$new_value, $old_value)
{
    if ($new_value != 'Y') {
        return false;
    }
    echo "Retreiving information from FEDEX server...";
    fn_flush();
    include_once DIR_SHIPPING_FILES . 'fedex/fedexdc.php';
    $shipping_settings = fn_get_settings('Shippings', 'fedex');
    $account_number = $shipping_settings['account_number'];
    $params = array('fedex_uri' => $shipping_settings['test_mode'] == 'Y' ? 'https://gatewaybeta.fedex.com:443/GatewayDC' : 'https://gateway.fedex.com:443/GatewayDC');
    $fed = new FedExDC($shipping_settings['account_number'], '', $params);
    $ship_ret = $fed->subscribe(array(1 => uniqid(TIME), 4003 => $shipping_settings['fedex_meter_name'], 4008 => $shipping_settings['fedex_meter_street'], 4011 => $shipping_settings['fedex_meter_city'], 4012 => $shipping_settings['fedex_meter_state'], 4013 => $shipping_settings['fedex_meter_zipcode'], 4014 => $shipping_settings['fedex_meter_country'], 4015 => $shipping_settings['fedex_meter_phone']));
    echo "<br />Done.";
    fn_flush();
    $error_tr = $fed->lookup('transaction_error_message');
    $error_req = $fed->getError();
    if ($error_tr || $error_req) {
        fn_set_notification('E', fn_get_lang_var('error'), (!empty($error_req) ? $error_req . '<br />' : '') . (!empty($error_tr) ? $error_tr : ''));
    } else {
        $meter_number = $fed->lookup('meter_number');
        db_query("UPDATE ?:settings SET ?u WHERE option_name = 'meter_number' AND section_id = 'Shippings' AND subsection_id = 'fedex'", array('value' => $meter_number));
    }
    $new_value = 'N';
}
示例#2
0
/**
 * Download the file
 *
 * @param string $path path to the file
 * @param string $filename file name to be displayed in download dialog
 */
function fn_get_file($path, $filename = '')
{
    $fd = fopen($path, 'r');
    if ($fd) {
        //Fixes: Filenames can't be sent to IE if there is any kind of traffic compression enabled on the server side
        if (function_exists('apache_setenv')) {
            apache_setenv('no-gzip', '1');
        }
        ini_set("zlib.output_compression", "Off");
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false);
        header("Content-type: " . fn_get_file_type($path));
        header("Content-Length: " . filesize($path));
        if (empty($filename)) {
            //Fixes: Non-ASCII filenames containing spaces and underscore characters are chunked
            setlocale(LC_ALL, 'en_US.UTF8');
            $filename = basename($path);
        }
        if (USER_AGENT == 'ie') {
            //Fixes: During the file download with IE, non-ASCII filenames appears with a broken encoding
            $filename = rawurlencode($filename);
        }
        header("Content-disposition: attachment; filename=\"{$filename}\"");
        while (!feof($fd)) {
            echo fread($fd, 30000);
            // Read by 30k blocks to avoid memory leaks
            fn_flush();
        }
        exit;
        // stop script execution after reading file contents
    }
    return true;
}
示例#3
0
             db_query('UPDATE ?:payments SET processor_params = ?s WHERE payment_id = ?i', $new_processor_data, $_REQUEST['payment_id']);
             Tygh::$app['ajax']->assign('secret_word_' . $_REQUEST['payment_id'], $processor_params['secret_word']);
         }
     }
     if ($mb_exit_needed) {
         exit;
     }
 }
 $pp_response = array();
 if ($mode == 'return') {
     if (!empty($_REQUEST['iframe_mode'])) {
         define('MB_MAX_TIME', 60);
         // Time for awaiting callback
         $view->assign('order_action', __('placing_order'));
         $view->display('views/orders/components/placing_order.tpl');
         fn_flush();
         $_placed = false;
         $times = 0;
         while (!$_placed) {
             $order_id = db_get_field('SELECT order_id FROM ?:order_data WHERE type = ?s AND data = ?s', 'E', $_REQUEST['order_id']);
             if (!empty($order_id)) {
                 $_placed = true;
             } else {
                 sleep(1);
             }
             $times++;
             if ($times > MB_MAX_TIME) {
                 break;
             }
         }
     } else {
示例#4
0
function fn_echo($value)
{
    echo $value;
    fn_flush();
}
示例#5
0
function fn_echo($value)
{
    if (defined('CONSOLE')) {
        $value = str_replace(array('<br>', '<br />', '<br/>'), "\n", $value);
        $value = strip_tags($value);
    }
    echo $value;
    fn_flush();
}
示例#6
0
function fn_exim_transfer_google_file($filename)
{
    if (defined('COMPANY_ID')) {
        fn_set_notification('W', fn_get_lang_var('warning'), fn_get_lang_var('warning_exim_vendor_no_data_exported'));
    } else {
        if (function_exists('ftp_connect')) {
            $google_sets = fn_get_settings('Google');
            $object = 'google';
            $_ftp_host = $google_sets[$object . '_host'];
            $ftp_login = $google_sets[$object . '_login'];
            $ftp_pass = $google_sets[$object . '_pass'];
            $__ftp_host = parse_url($_ftp_host);
            $ftp_host = empty($__ftp_host['host']) ? $__ftp_host['path'] : $__ftp_host['host'];
            if (empty($ftp_host) || empty($ftp_login) || empty($ftp_pass)) {
                $_hl = 'google_host,google_login,google_pass';
                $_set = "<a href=\"" . fn_url("settings.manage?section_id=Google&highlight={$_hl}", 'A', 'http') . "\">Google base</a>";
                fn_set_notification('W', fn_get_lang_var('warning'), str_replace('[settings]', $_set, fn_get_lang_var('specify_ftp_parameters')));
                return false;
            }
            $ftp = @ftp_connect($ftp_host);
            if ($ftp && @ftp_login($ftp, $ftp_login, $ftp_pass)) {
                ftp_pasv($ftp, true);
                $fp = fopen(DIR_EXIM . $filename, "rb");
                if ($fp) {
                    echo "<br> Copying file to the google server...";
                    fn_flush();
                    if (@ftp_fput($ftp, basename($filename), $fp, FTP_BINARY)) {
                        fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('file_succ_transfered'));
                    } else {
                        fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('file_transfer_failed'));
                        return false;
                    }
                    fclose($fp);
                } else {
                    fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('file_not_found'));
                    return false;
                }
                ftp_quit($ftp);
            } else {
                fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('ftp_connect_failed'));
                return false;
            }
        } else {
            fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('php_do_not_support_ftp'));
            return false;
        }
    }
    return true;
}
示例#7
0
function fn_cleanup_payment_info($order_id, $payment_info, $silent = false)
{
    if ($silent == false) {
        $processing_msg = fn_get_lang_var('processing_order');
        $done_msg = fn_get_lang_var('uc_ok');
        echo $processing_msg . '&nbsp;<b>#' . $order_id . '</b>...';
        fn_flush();
    }
    if (!is_array($payment_info)) {
        $info = @unserialize(fn_decrypt_text($payment_info));
    } else {
        $info = $payment_info;
    }
    if (!empty($info['cvv2'])) {
        $info['cvv2'] = 'XXX';
    }
    if (!empty($info['card_number'])) {
        $info['card_number'] = substr_replace($info['card_number'], str_repeat('X', strlen($info['card_number']) - 4), 0, strlen($info['card_number']) - 4);
    }
    foreach (array('start_month', 'start_year', 'expiry_month', 'expiry_year') as $v) {
        if (!empty($info[$v])) {
            $info[$v] = 'XX';
        }
    }
    $_data = fn_encrypt_text(serialize($info));
    db_query("UPDATE ?:order_data SET data = ?s WHERE order_id = ?i AND type = 'P'", $_data, $order_id);
    if ($silent == false) {
        echo $done_msg . '<br />';
    }
}
示例#8
0
function fn_build_products_cache($product_ids = array(), $category_ids = array())
{
    return false;
    // Temporarly disabled
    $condition = ' 1 ';
    $d_condition = ' 1 ';
    if (!empty($product_ids)) {
        $condition .= db_quote(" AND b.product_id IN (?n)", $product_ids);
    }
    if (!empty($category_ids)) {
        $condition .= db_quote(" AND b.category_id IN (?n)", $category_ids);
    }
    db_query("DELETE FROM ?:products_cache as b WHERE {$condition}");
    $_statuses = array('A', 'H');
    $total_rows = db_get_field("SELECT COUNT(*) FROM ?:products_categories as b INNER JOIN ?:categories as a ON a.category_id = b.category_id AND a.status IN (?a) WHERE ?p", $_statuses, $condition);
    for ($i = 0; $i < $total_rows; $i = $i + 50) {
        $data = db_get_array("SELECT a.category_id, b.position, a.usergroup_ids, b.product_id, c.price, c.usergroup_id as price_usergroup_id FROM ?:categories as a INNER JOIN ?:products_categories as b ON b.category_id = a.category_id INNER JOIN ?:product_prices as c ON c.product_id = b.product_id AND c.lower_limit = 1 WHERE ?p AND a.status IN (?a) LIMIT {$i}, 50", $_statuses, $condition);
        foreach ($data as $k => $v) {
            if (empty($v['usergroup_ids'])) {
                // category usergroup is empty
                $v['usergroup_ids'] = $v['price_usergroup_id'];
            }
            $ug_ids = explode(',', $v['usergroup_ids']);
            if (!empty($v['price_usergroup_id']) && !in_array($v['price_usergroup_id'], $ug_ids)) {
                continue;
            }
            unset($v['price_usergroup_id']);
            if (empty($product_ids) && empty($category_ids)) {
                echo ". ";
                fn_flush();
            }
            db_query("INSERT INTO ?:products_cache ?e", $v);
        }
    }
}