Esempio n. 1
0
 /**
  * Return product UUID
  * @return string
  */
 public function getUUID()
 {
     return md5($this->id . Helpdesk::getStoreKey() . $this->template_id);
 }
Esempio n. 2
0
    public function AddItems($products = array(), $template, $images_data)
    {
        $credentials = $this->credentials;
        $currency = CART_PRIMARY_CURRENCY;
        $company = fn_get_company_placement_info(0);
        $site = $template['site'];
        $items = '';
        $i = 0;
        $item_hashes = array();
        foreach ($products as $k => $product) {
            $i += 1;
            $shipping = $this->prepareShipping($product, $template);
            $price = fn_format_price($product['price']);
            $uuid = md5($product['product_id'] . Helpdesk::getStoreKey() . $product['ebay_template_id']);
            $payments = '<PaymentMethods>' . implode("</PaymentMethods>\n<PaymentMethods>", $template['payment_methods']) . '</PaymentMethods>';
            if (in_array('PayPal', $template['payment_methods'])) {
                $payments .= "\n<PayPalEmailAddress>{$template['paypal_email']}</PayPalEmailAddress>";
            }
            if ($product['override'] == "Y") {
                $title = substr(strip_tags($product['ebay_title']), 0, 80);
                $description = !empty($product['ebay_description']) ? $product['ebay_description'] : $product['full_description'];
            } else {
                $title = substr(strip_tags($product['product']), 0, 80);
                $description = $product['full_description'];
            }
            $hash_data = array('price' => $price, 'title' => $title, 'description' => $description);
            $picture_details = '';
            if (!empty($product['main_pair']) && !empty($product['main_pair']['detailed']) && !empty($product['main_pair']['detailed']['http_image_path'])) {
                if ($images_data[md5($product['main_pair']['detailed']['http_image_path'])]) {
                    $picture_details .= "<PictureURL>" . $images_data[md5($product['main_pair']['detailed']['http_image_path'])] . "</PictureURL>\n";
                } else {
                    $picture_details .= "<PictureURL>" . $product['main_pair']['detailed']['http_image_path'] . "</PictureURL>\n";
                }
            }
            if ($product['image_pairs']) {
                foreach ($product['image_pairs'] as $image_pair) {
                    if (!empty($image_pair['detailed']) && !empty($image_pair['detailed']['http_image_path'])) {
                        if ($images_data[md5($image_pair['detailed']['http_image_path'])]) {
                            $picture_details .= "<PictureURL>" . $images_data[md5($image_pair['detailed']['http_image_path'])] . "</PictureURL>\n";
                        }
                    }
                }
            }
            $picture_details = empty($picture_details) ? '' : "<PictureDetails>\n{$picture_details}</PictureDetails>";
            $product_features = '';
            if (!empty($product['product_features'])) {
                $hash_data['product_features'] = serialize($product['product_features']);
                $product_features = '<ItemSpecifics>' . fn_prepare_xml_product_features($product['product_features']) . '</ItemSpecifics>';
            }
            $product_options = '';
            $inventory_combinations = db_get_array("SELECT combination FROM ?:product_options_inventory WHERE product_id = ?i AND amount > 0 AND combination != ''", $product['product_id']);
            if (!empty($product['product_options']) && !empty($inventory_combinations)) {
                $params = array('page' => 1, 'product_id' => $product['product_id']);
                $product_options = '<Variations>' . fn_prepare_xml_product_options($params, $product, $images_data) . '</Variations>';
            }
            if (empty($product_options)) {
                $start_price = <<<EOT
                <StartPrice currencyID="{$currency}">{$price}</StartPrice>
EOT;
                $product_quantity = <<<EOT
                <Quantity>{$product['amount']}</Quantity>

EOT;
            } else {
                $start_price = '';
                $product_quantity = '';
            }
            $product_out_of_weight = array();
            if ($product['weight'] == 0) {
                $product_out_of_weight[] = $product['product_id'];
            }
            $location = fn_get_country_name($company['company_country']);
            $items .= <<<EOT
            <AddItemRequestContainer>
                <MessageID>{$i}</MessageID>
                <Item>
                    <UUID>{$uuid}</UUID>
                    <Site>{$site}</Site>
                    <ListingType>FixedPriceItem</ListingType>
                    <Currency>{$currency}</Currency>
                    <PrimaryCategory>
                        <CategoryID>{$template['category']}</CategoryID>
                    </PrimaryCategory>
                    <SecondaryCategory>
                        <CategoryID>{$template['sec_category']}</CategoryID>
                    </SecondaryCategory>
                    <ConditionID>{$template['condition_id']}</ConditionID>
                    <CategoryMappingAllowed>true</CategoryMappingAllowed>
                    <Country>{$company['company_country']}</Country>
                    <PostalCode>{$company['company_zipcode']}</PostalCode>
                    <Location>{$location}</Location>
                    <Title><![CDATA[{$title}]]></Title>
                    <Description><![CDATA[{$description}]]></Description>
                    {$payments}
                    <ListingDuration>{$template['ebay_duration']}</ListingDuration>
                    <DispatchTimeMax>{$template['dispatch_days']}</DispatchTimeMax>
                    {$shipping}
                    {$picture_details}
                    {$product_features}
                    {$product_options}
                    {$start_price}
                    {$product_quantity}
                </Item>
            </AddItemRequestContainer>
EOT;
            $item_hashes[$k] = fn_crc32(implode('_', $hash_data));
        }
        $xml = <<<EOT
            <?xml version="1.0" encoding="utf-8"?>
            <AddItemsRequest xmlns="urn:ebay:apis:eBLBaseComponents">
                {$credentials}
                <MessageID>1</MessageID>
                {$items}
            </AddItemsRequest>
EOT;
        list($trans_id, $result) = $this->_request($xml, 'AddItems');
        $_result = array();
        if ($result->Ack != 'Failure') {
            if ($result->AddItemResponseContainer) {
                $count = 0;
                foreach ($result->AddItemResponseContainer as $k => $item) {
                    if (!empty($item->Errors)) {
                        $this->_errors($item, $trans_id, 'AddItems');
                    }
                    $_result[$count] = (array) $item;
                    $_result[$count]['product_hash'] = $item_hashes[$count];
                    $count++;
                }
            }
        }
        if (!empty($product_out_of_weight) && $template['shipping_type'] == 'C') {
            fn_set_notification('W', __('warning'), __('product_out_of_weight', array("[ids]" => implode(",", $product_out_of_weight))));
        }
        return array($trans_id, $_result);
    }
Esempio n. 3
0
            $uc_settings = Settings::instance()->getValues('Upgrade_center');
            $is_valid = fn_get_contents(Registry::get('config.resources.updates_server') . '/index.php?dispatch=validators.validate_request&token=' . $_REQUEST['token'] . '&license_key=' . $uc_settings['license_number']);
            if ($is_valid == 'valid') {
                $data = simplexml_load_string(urldecode($_REQUEST['request']));
                Helpdesk::processMessages($data->Messages);
                echo 'OK';
                exit(0);
            } else {
                return array(CONTROLLER_STATUS_NO_PAGE);
            }
        }
    }
}
if ($mode == 'auth') {
    header('Content-Type: image/png');
    echo base64_decode('iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAlJJREFUeNqkUztoVEEUPfN5k7gf4q4J6yduxKDRQhBEUCQ2KbaJCiI2Wtgt0cJCUEGxshJs/EBSWCoWFhKxULtFDUYXBUFMjJFl1WVBVkX39/a9N96ZfbtuoYU4cLgz8+45986ZeUxrjf8ZMjfBTIxxjqzgyAiJpBT0Qf4ZXKDCGR4whhni/ZQ0ASE7mE4cH9qYGFYRpRhlciHATeyA1owQtFpurVgYbXwqmsKXJVU1AhlDrjerquU3IShREqkDhGRGbQrGVDQ9MkwCmbaAtAJJU9mQV1/4CFAMKh8QFB5Dv7kDXi2DE5kxe1xw1afIuqSd2/MK2DZN5ebcdbRe3QLqXyG3H4Vz+DbE1gNdsjG9DVjYDs03HrbtPr1iozbrwU3g46eBveeIyqAXZi0Zvt8V4F13w/PGTy1gxdQ8nMmrVhSPzgCll8Cuk9CxNcQlsuch+JtAkL8B/f4hWGobMDlNF5yCfnKJkvqBLQfhGTJBB0AQ9Aiw0AM9fw3IXQTuHmu/lJ0noCvL0NQFG9nTFfCJ7PcIuKZdIyCmKDGbB358Bgo5YO0O23bwZREsseG3gAeXABm+5FLnnjvDmlWvgDlRS5JujQr0tQVIsFpFyaSw14eMv5gZ2zd+RDZq0d6rMpUNoRdmT6lINX/v3U3yICuelYGJVUi7nh6NrxsaEPGoRD8ZphTgONSBA04QBIf2ghZvLL6oLBWX6/fPL+G5eR3p9RGkzo5h/+YYdkNjpXG347IfRgsfdHB8e/sdc9NlzJY9lI3AAIFKQvzjn0xyaPwSYACS4hG3ZjB6zgAAAABJRU5ErkJggg==');
    if (Tygh::$app['session']['auth']['area'] == 'A' && !empty(Tygh::$app['session']['auth']['user_id'])) {
        $domains = '';
        if (fn_allowed_for('ULTIMATE')) {
            $storefronts = db_get_fields('SELECT storefront FROM ?:companies WHERE storefront != ""');
            if (!empty($storefronts)) {
                $domains = implode(',', $storefronts);
            }
        }
        $extra_fields = array('token' => Helpdesk::token(true), 'store_key' => Helpdesk::getStoreKey(), 'domains' => $domains);
        $data = Helpdesk::getLicenseInformation('', $extra_fields);
        Helpdesk::parseLicenseInformation($data, $auth);
    }
    exit;
}
return array(CONTROLLER_STATUS_NO_PAGE);