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); }
function cw_ups_register($license, $userinfo) { global $tables; $version = cw_query_first_cell("SELECT version FROM {$tables['addons']} WHERE addon='shipping_ups'"); $version = substr($version, 0, 16); $userinfo_orig = $userinfo; $userinfo = cw_ups_xml_quote($userinfo); $dl = UPS_LICENCE; $userinfo['software_installer'] = $userinfo['software_installer'] == 'Y' ? 'Y' : 'N'; $request = <<<EOT <?xml version='1.0' encoding='ISO-8859-1'?> <AccessLicenseRequest xml:lang='en-US'> \t<Request> \t\t<TransactionReference> \t\t\t<CustomerContext>License Test</CustomerContext> \t\t\t<XpciVersion>1.0001</XpciVersion> \t\t</TransactionReference> \t\t<RequestAction>AccessLicense</RequestAction> \t\t<RequestOption>AllTools</RequestOption> \t</Request> \t<CompanyName>{$userinfo['company']}</CompanyName> \t<Address> \t\t<AddressLine1>{$userinfo['address']}</AddressLine1> \t\t<City>{$userinfo['city']}</City> \t\t<StateProvinceCode>{$userinfo['state']}</StateProvinceCode> \t\t<PostalCode>{$userinfo['postal_code']}</PostalCode> \t\t<CountryCode>{$userinfo['country']}</CountryCode> \t</Address> \t<PrimaryContact> \t\t<Name>{$userinfo['contact_name']}</Name> \t\t<Title>{$userinfo['title_name']}</Title> \t\t<EMailAddress>{$userinfo['email']}</EMailAddress> \t\t<PhoneNumber>{$userinfo['phone']}</PhoneNumber> \t</PrimaryContact> \t<CompanyURL>{$userinfo['url']}</CompanyURL> \t<ShipperNumber>{$userinfo['shipper_number']}</ShipperNumber> \t<DeveloperLicenseNumber>{$dl}</DeveloperLicenseNumber> \t<AccessLicenseProfile> \t\t<CountryCode>US</CountryCode> \t\t<LanguageCode>EN</LanguageCode> \t\t<AccessLicenseText>{$license}</AccessLicenseText> \t</AccessLicenseProfile> \t<OnLineTool> \t\t<ToolID>RateXML</ToolID> \t\t<ToolVersion>1.0</ToolVersion> \t</OnLineTool> \t<OnLineTool> \t\t<ToolID>TrackXML</ToolID> \t\t<ToolVersion>1.0</ToolVersion> \t</OnLineTool> \t<ClientSoftwareProfile> \t\t<SoftwareInstaller>{$userinfo['software_installer']}</SoftwareInstaller> \t\t<SoftwareProductName>Ars</SoftwareProductName> \t\t<SoftwareProvider>CartWorks</SoftwareProvider> \t\t<SoftwareVersionNumber>{$version}</SoftwareVersionNumber> \t</ClientSoftwareProfile> </AccessLicenseRequest> EOT; $ret = cw_ups_process($request, 'License'); $error = cw_array_path($ret, 'ACCESSLICENSERESPONSE/RESPONSE/ERROR/ERRORCODE/0/#'); if ($error) { return cw_array_path($ret, 'ACCESSLICENSERESPONSE/RESPONSE/ERROR/ERRORDESCRIPTION/0/#'); } $accesskey = cw_array_path($ret, 'ACCESSLICENSERESPONSE/ACCESSLICENSENUMBER/0/#'); $ups_userinfo = $userinfo_orig; $post_counter = 0; $suggest = "suggest"; while ($post_counter < 10) { $username = cw_ups_generate_unique_string(0, 12); $password = cw_ups_generate_unique_string(16, 10); $request = <<<EOT <?xml version='1.0'?> <RegistrationRequest> \t<Request> \t\t<TransactionReference> \t\t\t<CustomerContext>x893</CustomerContext> \t\t\t<XpciVersion>1.0001</XpciVersion> \t\t</TransactionReference> \t\t<RequestAction>Register</RequestAction> \t\t<RequestOption>{$suggest}</RequestOption> \t</Request> \t<UserId>{$username}</UserId> \t<Password>{$password}</Password> \t<RegistrationInformation> \t\t<UserName>{$userinfo['contact_name']}</UserName> \t\t<Title>{$userinfo['title_name']}</Title> \t\t<CompanyName>{$userinfo['company']}</CompanyName> \t\t<Address> \t\t\t<AddressLine1>{$userinfo['address']}</AddressLine1> \t\t\t<City>{$userinfo['city']}</City> \t\t\t<StateProvinceCode>{$userinfo['state']}</StateProvinceCode> \t\t\t<PostalCode>{$userinfo['postal_code']}</PostalCode> \t\t\t<CountryCode>{$userinfo['country']}</CountryCode> \t\t</Address> \t\t<PhoneNumber>{$userinfo['phone']}</PhoneNumber> \t\t<EMailAddress>{$userinfo['email']}</EMailAddress> \t</RegistrationInformation> </RegistrationRequest> EOT; $ret = cw_ups_process($request, 'Register'); $error = cw_array_path($ret, 'REGISTRATIONRESPONSE/RESPONSE/RESPONSESTATUSCODE/0/#'); if ($error == 1) { break; } $post_counter++; } if ($error == 1) { cw_config_update('shipping_ups', array('accesskey' => $accesskey, 'username' => $username, 'password' => $password)); return; } return cw_array_path($ret, 'REGISTRATIONRESPONSE/RESPONSE/ERROR/ERRORDESCRIPTION/0/#'); }
<?php $items_per_page_targets =& cw_session_register('items_per_page_targets', array()); if (!empty($_GET['items_per_page']) || !empty($items_per_page) || !empty($_GET['view_all']) || !empty($view_all)) { if ((!empty($_GET['view_all']) || !empty($view_all)) && !empty($app_config_file['interface']['max_count_view_products']) && $current_area == 'C') { $items_per_page_targets[$target] = $app_config_file['interface']['max_count_view_products']; } else { $items_per_page_targets[$target] = empty($_GET['items_per_page']) ? intval($items_per_page) : intval($_GET['items_per_page']); } cw_core_save_navigation($customer_id, $items_per_page_targets); } if (AREA_TYPE == 'A' && $_POST['action'] == 'update_settings' && is_array($_POST['configuration']) && $_POST['category']) { global $top_message; cw_load('config'); cw_config_update($_POST['category'], $_POST['configuration']); // TOFIX: Move to addon as hook if ($_POST['category'] == 'Watermarks') { cw_load('in_images'); $watermark_url = cw_in_images_assign('watermark_url'); $watermark_url = $watermark_url['image_path']; touch($watermark_url); } $_tmp = parse_url($_POST['l_redirect']); parse_str($_tmp['query'], $merge_arr); if (!is_array($merge_arr)) { $merge_arr = array(); } $l_redirect = cw_core_assign_addition_params($_tmp['path'], $merge_arr, array(), '&', false); $top_message = array('content' => cw_get_langvar_by_name('txt_settings_was_updated'), 'type' => 'I'); if ($target != 'configuration' && $target != 'settings') { cw_header_location($l_redirect);
<?php if ($action == 'update') { cw_load('config'); cw_config_update('CSS', $configuration); cw_header_location('index.php?target=' . $target); } $location[] = array(cw_get_langvar_by_name('lbl_css_styles'), ''); $smarty->assign('main', 'custom_css');
<?php cw_load('config'); $saved_user_data =& cw_session_register('saved_user_data'); $top_message =& cw_session_register('top_message'); if ($action == 'clear_meter_number') { cw_config_update('shipping_fedex', array('meter_number' => '')); cw_header_location("index.php?target={$target}&mode=addons&addon=shipping_fedex"); } if ($action == 'get_meter_number') { $rules = array('person_name' => '', 'phone_number' => '', 'address_1' => '', 'city' => '', 'zipcode' => '', 'country' => ''); $fillerror = cw_error_check($posted_data, $rules); $saved_user_data = $posted_data; if ($fillerror) { $top_message = array('content' => $fillerror, 'type' => 'E'); cw_header_location("index.php?target={$target}&mode=addons&addon=shipping_fedex"); } $meter_number = cw_fedex_get_meter_number($posted_data, $error); if ($meter_number) { $saved_user_data = ''; cw_config_update('shipping_fedex', array('meter_number' => $meter_number)); } else { $top_message = array('content' => $error['msg'], 'type' => 'E'); } cw_header_location("index.php?target={$target}&mode=addons&addon=shipping_fedex"); } $smarty->assign('prepared_user_data', $saved_user_data);
function export() { global $REQUEST_METHOD, $smarty, $config, $addons, $top_message, $customer_id, $tables; global $mode, $action, $ebay_config; if ($REQUEST_METHOD != 'POST') { cw_header_location('index.php?target=' . addon_target); } $result = cw_ebay_check_fields($_POST); if (count($result)) { $top_message = array('content' => implode("<br />", $result), 'type' => 'E'); cw_header_location('index.php?target=' . addon_target); } if (empty($_POST['file_name'])) { $_filename = addon_files_location_path . 'ebay_export_' . date('Ymd') . '_' . date('His') . '.csv'; } else { $_filename = addon_files_location_path . $_POST['file_name'] . '.csv'; } $_copy_filename = $_filename; 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) { $ebay_config = cw_array_merge($ebay_config, $config['ebay'], $_POST); cw_config_update('ebay', $_POST); $data = array(); $header_put = false; $count_files = 0; 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\t FROM {$tables['attributes_values']} av, {$tables['attributes']} a\n\t WHERE av.item_id={$v} AND av.item_type='P' \n\t \tAND 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); $ebay_category = cw_ebay_get_category_value($prod['category_id'], $ebay_config['ebay_category']); if (!$ebay_category) { fclose($file); $top_message = array('content' => 'For <a href="index.php?target=categories&mode=edit&cat=' . $prod['category_id'] . '">Main category</a> for the product "' . $prod['product'] . '" option "Category" does not set.', 'type' => 'E'); cw_header_location('index.php?target=' . addon_target); } if (!$header_put) { // Set smart headers $data = array('Action' => $ebay_config['ebay_action'], 'ImmediatePayRequired=' . ($ebay_config['ebay_immediate_pay_required'] == 'Y' ? "1" : "0") => "", 'Category' => $ebay_category, 'ConditionID' => cw_ebay_get_condition_value($var, $ebay_config['ebay_condition_id']), 'Description' => substr(nl2br($var['descr']), 0, 500000), 'Duration=' . $ebay_config['ebay_duration'] => "", 'Format=' . $ebay_config['ebay_format'] => "", 'Location=' . $ebay_config['ebay_location'] => "", 'PayPalAccepted=' . ($ebay_config['ebay_paypal_accepted'] == 'Y' ? "1" : "0") => "", 'PayPalEmailAddress' => $ebay_config['ebay_paypal_accepted'] == 'Y' ? $ebay_config['ebay_paypal_email_address'] : "", 'Quantity' => $var['avail'], 'Title' => substr($var['product'], 0, 80), 'DispatchTimeMax=' . $ebay_config['ebay_dispatch_time_max'] => "", 'ReturnsAcceptedOption=' . $ebay_config['ebay_returns_accepted_option'] => "", 'StartPrice' => $var['price']); } else { $data = array('Action' => $ebay_config['ebay_action'], 'ImmediatePayRequired' => "", 'Category' => $ebay_category, 'ConditionID' => cw_ebay_get_condition_value($var, $ebay_config['ebay_condition_id']), 'Description' => substr(nl2br($var['descr']), 0, 500000), 'Duration' => "", 'Format' => "", 'Location' => "", 'PayPalAccepted' => "", 'PayPalEmailAddress' => $ebay_config['ebay_paypal_accepted'] == 'Y' ? $ebay_config['ebay_paypal_email_address'] : "", 'Quantity' => $var['avail'], 'Title' => substr($var['product'], 0, 80), 'DispatchTimeMax' => "", 'ReturnsAcceptedOption' => "", 'StartPrice' => $var['price']); } if (!$header_put) { fputcsv($file, array_keys($data), ","); $header_put = true; } fputcsv($file, $data, ","); // A single file cannot exceed 15 MB if (filesize($_filename) > 14680064) { fclose($file); $new_filename = str_replace(".csv", "_" . $count_files . ".csv", $_copy_filename); rename($_filename, $new_filename); $count_files++; $_filename = str_replace(".csv", "_" . $count_files . ".csv", $_copy_filename); $file = cw_fopen($_filename, 'w', true); $header_put = false; } } } } fclose($file); $top_message = array('content' => 'File <b>' . $_filename . '</b> successfully created'); } cw_header_location('index.php?target=' . addon_target); }
<?php cw_load('config'); if ($action == 'update') { cw_config_update($js_tab, $configuration); if (!empty($adv_search_configuration)) { db_query("update {$tables['config']} set value='" . serialize($adv_search_configuration) . "' where name='adv_search_attributes_config'"); } cw_header_location("index.php?target={$target}&js_tab={$js_tab}"); } # Cache .htaccess location $smarty->assign('cache_htaccess_location', $app_dir . '\\var\\cache\\.htaccess'); $smarty->assign('categories', cw_config_get_categories()); $memberships = cw_user_get_memberships(array('C', 'R')); if (!empty($memberships)) { $smarty->assign('memberships', $memberships); } $shippings = cw_query("select {$tables['shipping']}.* from {$tables['shipping']}, {$tables['shipping_carriers']} where {$tables['shipping']}.carrier_id={$tables['shipping_carriers']}.carrier_id and active=1 ORDER BY orderby"); $smarty->assign('shippings', $shippings); $location[] = array(cw_get_langvar_by_name('lbl_settings'), 'index.php?target=' . $target); $smarty->assign('js_tab', $js_tab); $smarty->assign('main', 'configuration');