Subversion-Projekte lars-tiefland.content-management

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?
          /*--------*/
         /* PREFIX */
        /*--------*/
        
        // 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";
        require_once "/web/apache/content-management/Online-Shop/eBay/system/loadConf.php";
        
          /*------------------*/
         /* Function AddItem */
        /*------------------*/

        global $theItem;
        $theItem = null;

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

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

            /*-----------------------------------------*/
           /* Verbindung mit Datenbank(en) herstellen */
          /* Alle im Array angegebenen Datenbanken   */
         /* abarbeiten                              */
        /*-----------------------------------------*/

        mysql_connect("localhost","content_managem","k-dp-u");
        foreach
        (
                array
                (
                        "mediaran_de",
                        "online_redaktionstool_de"
                )
                as $DB
        )
        {
                mysql_query("use $DB");

                    /*------------------------------------------------*/
                   /* Settings aus der Datenbank.eBay_settings laden */
                  /* Settings in $settings, conf-Einträge in $conf  */
                 /*     speichern.                                     */
                /*------------------------------------------------*/
        
                $query=
                "
                        select
                                Name,
                                Inhalt,
                                Typ
                        from
                                eBay_settings
                        where 
                                Name = 'pictureURLpfad'
                                or Name = 'pictureURLfeld'
                                or Typ  = 'confDatei'
                ";
                $result=mysql_query($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
                $settings=array();
                while ($zeile=mysql_fetch_assoc($result))
                {
                        if ($zeile[Typ] == "confDatei")
                        {
                                $conf[$zeile[Name]]=$zeile[Inhalt];
                        }
                        else
                        {
                                $settings[$zeile[Name]]=$zeile[Inhalt];
                        }
                }

                   /*----------------------------------------------------*/
                  /* In den Settings stehen alle möglichen conf-Dateien */
                 /* Für jede conf-Einstellung eine Session erstellen.  */
                /*----------------------------------------------------*/

                foreach(array_keys($conf) as $Name)
                {
                        $Sessions[$Name] = new Ebay_Session();
                        $Sessions[$Name]->InitFromConfig($conf[$Name]);
                }

                  /*---------------------*/
                 /* 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('".$settings[pictureURLpfad]."',".$settings[pictureURLfeld].")   as PictureURL,
                                0                                                                                                                                                as ReservePrice,
                                confDatei
                        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(loadConf($conf[$AuktionsData[confDatei]]),$settings,$AuktionsData);

                        unset($zeile[ID]);
                        unset($zeile[pictureURLpfad]);
                        unset($zeile[pictureURLfeld]);          

                        $mySession=$Sessions[$zeile[confDatei]];
                        unset($zeile[confDatei]);

                        $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]);
                }
        }
?>