Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?
2
	// forget about any script timeouts
3
	set_time_limit(0);
4
 
5
	define ("ITEMTYPES_AUCTION", 1);
6
	define ("CURRENCYENUM_USDOLLAR", 1);
7
	define ("CURRENCYENUM_EURO", 7);
8
	define ("SHIPPINGRANGEENUM_SITEONLY", '0');
9
 
10
	require_once "/web/apache/content-management/ebayphpat/Ebay_ItemSellerQuery.php";
11
 
12
	$mySession = new Ebay_Session();
13
	$mySession->InitFromConfig("/web/apache/content-management/ebay.config");
14
 
15
	global $theItem;
16
	$theItem = null;
17
 
18
	function AddItem($session,$ItemData)
19
	{
20
		global $theItem;
21
		$theItem = new Ebay_Item($session);
22
 
23
		if
24
		(
25
			($ItemData[StartPrice] == 0)
26
			&&
27
			($ItemData[BuyItNowPrice] > 0)
28
		)
29
		{
30
			$ItemData[StartPrice] == $zeile[BuyItNowPrice];
31
			$ItemData[BuyItNowPrice]='';
32
			$theItem->setPropIsFixedPrice(true);
33
		}
34
 
35
		foreach(array_keys($ItemData) as $elem)
36
		{
37
			if ($ItemData[$elem])
38
			{
39
				$theItem->{"set".$elem}($ItemData[$elem]);
40
			}
41
		}
42
		return $theItem->Add();
43
	}
44
 
45
/* ------------------------------------------------------------------------------------------------ */
46
 
47
	mysql_connect("localhost","content_managem","k-dp-u");
48
	mysql_query("use mediaran_de");
49
 
50
	// Settings laden
51
	$query=
52
	"
53
		select
54
			Name,
55
			Inhalt
56
		from
57
			eBay_settings
58
		where
59
			Name = 'Location'
60
			or Name = 'Currency'
61
			or Name = 'Country'
62
			or Name = 'Region'
63
	";
64
	$result=mysql_query($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
65
	$settings=array();
66
	while ($zeile=mysql_fetch_assoc($result)) {$settings[$zeile[Name]]=$zeile[Inhalt];}
67
 
68
	// WIRD VON DER SANDBOX BENÖTIGT. KANN IN DER PRODUKTIONSUMGEBUNG WEG.
69
	//$settings[Currency]=1;
70
 
71
	// Auktionsdaten laden
72
	$query=
73
	"
74
		select
75
			eBay_Auktionen.ID,
76
			eBay_Auktionen.Title													as Title,
77
			eBay_Auktionen.Description												as Description,
78
			eBay_Auktionen.Category													as CategoryId,
79
			eBay_Auktionen.Quantity													as Quantity,
80
			eBay_Auktionen.MinimumBid												as StartPrice,
81
			if (eBay_Auktionen.BuyItNowPrice > 0,eBay_Auktionen.BuyItNowPrice,'')	as BuyItNowPrice,
82
			eBay_Auktionen.SubtitleText												as SubtitleText,
83
			eBay_Auktionen.Category2												as Category2Id,
84
			eBay_Auktionen.Duration													as Duration,
85
			eBay_Auktionen.Private													as PropPrivate,
86
			'true' 																	as PaymentTermsSeeDescription,
87
			if (eBay_Auktionen.Gallery = '','','true')								as PropGallery,
88
			if (eBay_Auktionen.Featured = '','','true')								as PropFeatured,
89
			if (eBay_Auktionen.BoldTitle = '','','true')							as PropBoldTitle,
90
			if (eBay_Auktionen.HighLight = '','','true')							as PropHighLight,
91
			eBay_Auktionen.Gallery													as GalleryURL,
92
			concat('http://pictures.weban.de/35/',artikel.bild_6_url)				as PictureURL,
93
 
94
		from
95
			eBay_Auktionen,artikel
96
		where
97
			eBay_Auktionen.artikel_ID = artikel.ID
98
		and
99
			artikel.Language='DE'
100
		and
101
			eBay_Id = 0
102
		and
103
			eBay_error = ''
104
		and
105
			ListingStartDay <= NOW()
106
		and
107
			ListingStartTime <= NOW()
108
	";
109
 
110
	$result=mysql_query($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
111
 
112
	while ($AuktionsData=mysql_fetch_assoc($result))
113
	{
114
		$zeile=array_merge($settings,$AuktionsData);
115
		unset($zeile[ID]);
116
 
117
		$eBayRes=AddItem($mySession,$zeile);
118
 
119
		if ($eBayRes->isGood())
120
		{
121
			$names=array();
122
			$values=array();
123
			foreach($eBayRes->_xmlValues as $elem)
124
			{
125
				if ($elem[type] == "complete")
126
				{
127
					$names[]=$elem[tag];
128
					$values[]=$elem[value];
129
				}
130
			}
131
			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");
132
		}
133
		mysql_query ("update eBay_Auktionen set eBay_Id=".$theItem->getId()." where ID = ".$AuktionsData[ID]);
134
		mysql_query ("update eBay_Auktionen set eBay_error='".serialize($eBayRes->_errors)."' where ID = ".$AuktionsData[ID]);
135
	}
136
 
137
/* ------------------------------------------------------------------------------------------------ */
138
?>