コード例 #1
0
function export()
{
    global $REQUEST_METHOD, $smarty, $config, $addons, $top_message, $customer_id, $tables;
    global $mode, $action, $amazon_config;
    $success = false;
    if ($REQUEST_METHOD != 'POST') {
        cw_header_location('index.php?target=' . addon_target);
    }
    if ($_POST['export_type'] == 'PaQ' && (empty($_POST['price']) && empty($_POST['quantity']))) {
        $top_message = array('content' => 'At least Price or Quantity must be exported.', 'type' => 'E');
        cw_header_location('index.php?target=' . addon_target);
        return false;
    }
    $_filename = 'files/amazon/' . date('Ymd') . '_' . date('His') . '_' . $_POST['export_type'] . '.csv';
    if (($filename = cw_allow_file($_filename, true)) && ($file = cw_fopen($_filename, 'w', true))) {
        $pids = cw_call('cw_objects_get_list_ids', array('P'));
        if (empty($pids)) {
            $pids = cw_query_column("SELECT product_id FROM {$tables['products']} WHERE status=1");
            // Very bad. Use API
        }
        if ($pids) {
            $amazon_config = cw_array_merge($amazon_config, $config['amazon'], $_POST);
            cw_config_update('amazon', $_POST);
            $warnings = array();
            $data = array();
            $header_put = false;
            foreach ($pids as $v) {
                $variants = array();
                $prod = cw_func_call('cw_product_get', array('id' => $v, 'info_type' => 8 | 64 | 128 | 256 | 512 | 2048));
                $attr = cw_query_hash("SELECT a.field, av.value\n                    FROM {$tables['attributes_values']} av, {$tables['attributes']} a\n                    WHERE av.item_id={$v} AND av.item_type='P' AND a.attribute_id=av.attribute_id", 'field', false, true);
                // very bad. Use API
                if ($prod['is_variants']) {
                    $variants = cw_call('cw_get_product_variants', array($v));
                } else {
                    $variants[0] = $prod;
                }
                foreach ($variants as $var) {
                    $var = cw_array_merge($var, $attr);
                    if ($_POST['export_type'] == 'PaQ') {
                        $data = array('sku' => $var['productcode'], 'price' => $_POST['price'] ? $var['price'] : '', 'quantity' => $_POST['quantity'] ? $var['avail'] : '', 'leadtime-to-ship' => $amazon_config['default_leadtime_to_ship']);
                    }
                    if ($_POST['export_type'] == 'InvLoad') {
                        $data = array('sku' => $var['productcode'], 'product-id' => empty($amazon_config['product_id_type']) ? '' : (string) $var[$amazon_config['product_id']], 'product-id-type' => $amazon_config['product_id_type'], 'price' => $var['price'], 'item-condition' => empty($var[$amazon_config['item_condition']]) ? $amazon_config['default_item_condition'] : $var[$amazon_config['item_condition']], 'quantity' => empty($amazon_config['fulfillment_center_id']) ? $var['avail'] : '', 'add-delete' => empty($_POST['add-delete']) ? 'a' : $_POST['add-delete'], 'will-ship-internationally' => empty($var[$amazon_config['ship_internationally']]) ? $amazon_config['default_ship_internationally'] : $var[$amazon_config['ship_internationally']], 'expedited-shipping' => empty($var[$amazon_config['expedited_shipping']]) ? $amazon_config['default_expedited_shipping'] : $var[$amazon_config['expedited_shipping']], 'standard-plus' => empty($var[$amazon_config['standard_plus']]) ? $amazon_config['default_standard_plus'] : $var[$amazon_config['standard_plus']], 'item-note' => $var[$amazon_config['item_note']], 'fulfillment-center-id' => $amazon_config['fulfillment_center_id'], 'product-tax-code' => $amazon_config['default_product_tax_code'], 'leadtime-to-ship' => $amazon_config['default_leadtime_to_ship']);
                    }
                    if (!$header_put) {
                        fputcsv($file, array_keys($data), "\t");
                        $header_put = true;
                    }
                    fputcsv($file, $data, "\t");
                }
            }
        }
        fclose($file);
        $top_message = array('content' => 'File <b>' . $_filename . '</b> successfully created');
    }
    cw_header_location('index.php?target=' . addon_target);
}
コード例 #2
0
<?xml version="1.0" encoding="UTF-8"?>
   <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <sitemap>
      <loc>http://www.example.com/sitemap1.xml.gz</loc>
      <lastmod>2004-10-01T18:23:17+00:00</lastmod>
   </sitemap>
   <sitemap>
      <loc>http://www.example.com/sitemap2.xml.gz</loc>
      <lastmod>2005-01-01</lastmod>
   </sitemap>
   </sitemapindex>
*/
if ($success && is_array($index)) {
    cw_flush('Sitemap Index');
    $_filename = cw_sitemap_name('index', false);
    if (($filename = cw_allow_file($_filename, true)) && ($file = cw_fopen($_filename, 'w', true))) {
        $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
        $xml .= '<?xml-stylesheet type="text/xsl" href="' . $smarty->get_template_vars('SkinDir') . '/addons/sitemap_xml/style.xsl"?>' . "\n";
        $xml .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . "\n";
        $xml .= '//<![CDATA[#Generated by sitemap_xml generator by CartWorks software, http://www.cartworks.com //]]>' . "\n";
        fwrite($file, $xml);
        foreach ($index as $sitemap) {
            $xml = '<sitemap><loc>' . $sitemap . '</loc><lastmod>' . $today . '</lastmod></sitemap>' . "\n";
            fwrite($file, $xml);
        }
        fwrite($file, '</sitemapindex>');
        fclose($file);
        if ($config['sitemap_xml']['sm_pack_result'] == 'Y') {
            @unlink($filename . '.gz');
            exec("gzip --suffix .gz {$filename}");
        }
コード例 #3
0
function delete_file()
{
    global $current_location;
    cw_load('files');
    $_file = trim($_GET['file']);
    $_filename = addon_files_location_path . $_file;
    if (!empty($_file) && cw_allow_file($_filename)) {
        unlink($_filename);
    }
    $content = "No files";
    $files = cw_ebay_get_avail_export_files_list();
    if (count($files)) {
        $content = "";
        foreach ($files as $file) {
            $content .= '<a href="' . $file['path'] . '">' . $file['name'] . '</a>&nbsp;<a href="javascript:delete_export_file(\'' . $file['name'] . '\');"><img src="' . $current_location . '/skins/images/delete_cross.gif"></a><br>';
        }
    }
    cw_add_ajax_block(array('id' => 'export_files_container', 'action' => 'update', 'content' => $content));
}
コード例 #4
0
function cw_image_check_posted($image_posted)
{
    $return = false;
    if (!cw_allow_file($image_posted['file_path'], true)) {
        return false;
    }
    if ($image_posted['source'] == "U") {
        if ($fd = cw_fopen($image_posted['file_path'], "rb", true)) {
            fclose($fd);
            $return = true;
        }
    } else {
        $return = file_exists($image_posted['file_path']);
    }
    return $return;
}
コード例 #5
0
 if (!cw_query_first_cell("select count(*) from {$tables['languages_settings']} where code='{$new_language}'")) {
     cw_array2insert('languages_settings', array('code' => $new_language));
 }
 if (!$exists_result) {
     $result = cw_query("select * from {$tables['languages']} where code='{$config['default_customer_language']}'");
     if ($result) {
         foreach ($result as $key => $value) {
             db_query("INSERT INTO {$tables['languages']} (code, name, value, topic) VALUES ('{$new_language}', '" . addslashes($value['name']) . "','" . addslashes($value['value']) . "','{$value['topic']}')");
         }
     }
     $lngs = cw_query_column("SELECT code FROM {$tables['languages']} GROUP BY code");
 }
 if ($source == "server" && !empty($localfile)) {
     # File is located on the server
     $localfile = stripslashes($localfile);
     if (cw_allow_file($localfile, true) && is_file($localfile)) {
         $import_file = $localfile;
         $is_import = true;
     } else {
         $top_message['content'] = cw_get_langvar_by_name("msg_err_file_wrong");
         $top_message['type'] = "E";
         $serverfile = $localfile;
         cw_header_location("index.php?target=languages");
     }
 } elseif ($source == "upload" && $import_file && $import_file != "none") {
     $import_file = cw_move_uploaded_file("import_file");
     $is_import = true;
 } else {
     $is_import = false;
 }
 if ($is_import) {
コード例 #6
0
function cw_file($file, $is_root = false)
{
    $file = cw_allow_file($file, $is_root);
    if ($file === false) {
        return array();
    }
    $result = @file($file);
    return is_array($result) ? $result : array();
}