Subversion-Projekte lars-tiefland.content-management

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?
        // forget about any script timeouts
        set_time_limit(0);
        
        define ("ITEMTYPES_AUCTION", 1);
        define ("CURRENCYENUM_USDOLLAR", 1);
        define ("CURRENCYENUM_EURO", 7);
        define ("SHIPPINGRANGEENUM_SITEONLY", '0');

        require_once "/web/apache/content-management/ebayphpat/Ebay_ItemSellerQuery.php";

        $mySession = new Ebay_Session();
        $mySession->InitFromConfig("/web/apache/content-management/ebay.config");

        global $theItem;
        $theItem = null;

        function AddItem($session,$ItemData)
        {
                global $theItem;
                $theItem = new Ebay_Item($session);
                
                if
                (
                        ($ItemData[StartPrice] == 0)
                        &&
                        ($ItemData[BuyItNowPrice] > 0)                  
                )
                {
                        $ItemData[StartPrice] == $zeile[BuyItNowPrice];
                        $ItemData[BuyItNowPrice]='';
                        $theItem->setPropIsFixedPrice(true);
                }

                foreach(array_keys($ItemData) as $elem)
                {
                        if ($ItemData[$elem])
                        {
                                $theItem->{"set".$elem}($ItemData[$elem]);
                        }
                }
                return $theItem->Add();
        }

/* ------------------------------------------------------------------------------------------------ */

        mysql_connect("localhost","content_managem","k-dp-u");
        mysql_query("use mediaran_de");

        // Settings laden
        $query=
        "
                select
                        Name,
                        Inhalt
                from
                        eBay_settings
                where 
                        Name = 'Location'
                        or Name = 'Currency'
                        or Name = 'Country'
                        or Name = 'Region'
        ";
        $result=mysql_query($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
        $settings=array();
        while ($zeile=mysql_fetch_assoc($result)) {$settings[$zeile[Name]]=$zeile[Inhalt];}

        // WIRD VON DER SANDBOX BENÖTIGT. KANN IN DER PRODUKTIONSUMGEBUNG WEG.
        //$settings[Currency]=1;
        
        // Auktionsdaten laden
        $query=
        "
                select
                        eBay_Auktionen.ID,
                        eBay_Auktionen.Title                                                                                                    as Title,
                        eBay_Auktionen.Description                                                                                              as Description,
                        eBay_Auktionen.Category                                                                                                 as CategoryId,
                        eBay_Auktionen.Quantity                                                                                                 as Quantity,
                        eBay_Auktionen.MinimumBid                                                                                               as StartPrice,
                        if (eBay_Auktionen.BuyItNowPrice > 0,eBay_Auktionen.BuyItNowPrice,'')   as BuyItNowPrice,
                        eBay_Auktionen.SubtitleText                                                                                             as SubtitleText,
                        eBay_Auktionen.Category2                                                                                                as Category2Id,
                        eBay_Auktionen.Duration                                                                                                 as Duration,
                        eBay_Auktionen.Private                                                                                                  as PropPrivate,
                        'true'                                                                                                                                  as PaymentTermsSeeDescription,
                        if (eBay_Auktionen.Gallery = '','','true')                                                              as PropGallery,
                        if (eBay_Auktionen.Featured = '','','true')                                                             as PropFeatured,
                        if (eBay_Auktionen.BoldTitle = '','','true')                                                    as PropBoldTitle,
                        if (eBay_Auktionen.HighLight = '','','true')                                                    as PropHighLight,
                        eBay_Auktionen.Gallery                                                                                                  as GalleryURL,
                        concat('http://pictures.weban.de/35/',artikel.bild_6_url)                               as PictureURL,
                        0                                                                                                                                                as ReservePrice
                from
                        eBay_Auktionen,artikel
                where 
                        eBay_Auktionen.artikel_ID = artikel.ID
                and
                        artikel.Language='DE'
                and
                        eBay_Id = 0
                and 
                        eBay_error = ''
                and 
                        ListingStartDay <= NOW()
                and
                        ListingStartTime <= NOW()
        ";

        $result=mysql_query($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");

        while ($AuktionsData=mysql_fetch_assoc($result))
        {
                $zeile=array_merge($settings,$AuktionsData);
                unset($zeile[ID]);
                
                $eBayRes=AddItem($mySession,$zeile);

                if ($eBayRes->isGood())
                {
                        $names=array();
                        $values=array();
                        foreach($eBayRes->_xmlValues as $elem)
                        {
                                if ($elem[type] == "complete")
                                {
                                        $names[]=$elem[tag];
                                        $values[]=$elem[value];
                                }
                        }
                        mysql_query("insert into eBay_AuktionsDaten (".implode(",",$names).") values ('".implode("','",$values)."')") or mail("lautsch@weban.de","eBay runQueue: Fehler bei insert into insert into eBay_AuktionsDaten",mysql_errno().": ".mysql_error(),"from: runQueue");
                }
                mysql_query ("update eBay_Auktionen set eBay_Id=".$theItem->getId()." where ID = ".$AuktionsData[ID]);
                mysql_query ("update eBay_Auktionen set eBay_error='".serialize($eBayRes->_errors)."' where ID = ".$AuktionsData[ID]);
        }

/* ------------------------------------------------------------------------------------------------ */  
?>