Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?
2
	  /*--------*/
3
	 /* PREFIX */
4
	/*--------*/
5
 
6
	// forget about any script timeouts
7
	set_time_limit(0);
8
 
9
	define ("ITEMTYPES_AUCTION", 1);
10
	define ("CURRENCYENUM_USDOLLAR", 1);
11
	define ("CURRENCYENUM_EURO", 7);
12
	define ("SHIPPINGRANGEENUM_SITEONLY", '0');
13
 
14
	require_once "/web/apache/content-management/ebayphpat/Ebay_ItemSellerQuery.php";
15
	require_once "/web/apache/content-management/Online-Shop/eBay/system/loadConf.php";
16
 
17
	  /*------------------*/
18
	 /* Function AddItem */
19
	/*------------------*/
20
 
21
	global $theItem;
22
	$theItem = null;
23
 
24
	function AddItem($session,$ItemData)
25
	{
26
		global $theItem;
27
		$theItem = new Ebay_Item($session);
28
 
29
		// Versandoptionen
30
		// müssen vor "Daten zusammenstellen" stehen!
31
 
32
		if ($ItemData[VersandCarrier] > 0)
33
		{
34
			// Versandoptionen erlauben
35
			$theItem->setCheckoutSpecified(true);
36
 
37
			// Flat shipping rate
38
			$theItem->setCheckoutShippingType(1);
39
 
40
			// shippingOptions
41
			$shipOption = new Ebay_ShippingServiceOption();
42
 
43
			$shipOption->setCarrier($ItemData[VersandCarrier]);
44
			$shipOption->setPriority(1);
45
			$shipOption->setCost($ItemData[VersandCost]);
46
			//$shipOption->setAdditionalCost('');
47
 
48
			$theItem->setShippingServiceOption($shipOption);
49
		}
50
		unset($ItemData[VersandCarrier]);
51
		unset($ItemData[VersandCost]);
52
 
53
		// Fixed Price Korrektur
54
		if
55
		(
56
			($ItemData[StartPrice] == 0)
57
			&&
58
			($ItemData[BuyItNowPrice] > 0)
59
		)
60
		{
61
			$ItemData[StartPrice] = $ItemData[BuyItNowPrice];
62
			$ItemData[BuyItNowPrice]='';
63
			$theItem->setPropType(9);
64
		}
65
 
66
		// Daten zusammenstellen
67
		foreach(array_keys($ItemData) as $elem)
68
		{
69
			if ($ItemData[$elem])
70
			{
71
				$theItem->{"set".$elem}($ItemData[$elem]);
72
			}
73
		}
74
 
75
		// Daten abschicken und Ergebnis zurückliefern
76
		return $theItem->Add();
77
	}
78
 
79
	    /*-----------------------------------------*/
80
	   /* Verbindung mit Datenbank(en) herstellen */
81
	  /* Alle im Array angegebenen Datenbanken   */
82
	 /* abarbeiten                              */
83
	/*-----------------------------------------*/
84
 
85
	mysql_connect("127.0.0.1:3306","content_managem","k-dp-u");
86
	foreach
87
	(
88
		array
89
		(
90
			"mediaran_de",
91
			"online_redaktionstool_de"
92
		)
93
		as $DB
94
	)
95
	{
96
		mysql_query("use $DB");
97
 
98
		    /*------------------------------------------------*/
99
		   /* Settings aus der Datenbank.eBay_settings laden */
100
		  /* Settings in $settings, conf-Einträge in $conf  */
101
		 /*	speichern.                                     */
102
		/*------------------------------------------------*/
103
 
104
		$query=
105
		"
106
			select
107
				Name,
108
				Inhalt,
109
				Typ
110
			from
111
				eBay_settings
112
			where
113
				Name = 'pictureURLpfad'
114
				or Name = 'pictureURLfeld'
115
				or Typ  = 'confDatei'
116
		";
117
		$result=mysql_query($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
118
		$settings=array();
119
		while ($zeile=mysql_fetch_assoc($result))
120
		{
121
			if ($zeile[Typ] == "confDatei")
122
			{
123
				$conf[$zeile[Name]]=$zeile[Inhalt];
124
			}
125
			else
126
			{
127
				$settings[$zeile[Name]]=$zeile[Inhalt];
128
			}
129
		}
130
 
131
		   /*----------------------------------------------------*/
132
		  /* In den Settings stehen alle möglichen conf-Dateien */
133
		 /* Für jede conf-Einstellung eine Session erstellen.  */
134
		/*----------------------------------------------------*/
135
 
136
		foreach(array_keys($conf) as $Name)
137
		{
138
			$Sessions[$Name] = new Ebay_Session();
139
			$Sessions[$Name]->InitFromConfig($conf[$Name]);
140
		}
141
 
142
		  /*---------------------*/
143
		 /* Auktionsdaten laden */
144
		/*---------------------*/
145
 
146
		$query=
147
		"
148
			select
149
				eBay_Auktionen.ID,
150
				eBay_Auktionen.Title													as Title,
151
				eBay_Auktionen.Description												as Description,
152
				eBay_Auktionen.Category													as CategoryId,
153
				eBay_Auktionen.Quantity													as Quantity,
154
				eBay_Auktionen.MinimumBid												as StartPrice,
155
				if (eBay_Auktionen.BuyItNowPrice > 0,eBay_Auktionen.BuyItNowPrice,'')	as BuyItNowPrice,
156
				eBay_Auktionen.SubtitleText												as SubtitleText,
157
				eBay_Auktionen.Category2												as Category2Id,
158
				eBay_Auktionen.Duration													as Duration,
159
				eBay_Auktionen.Private													as PropPrivate,
160
				'true' 																	as PaymentTermsSeeDescription,
161
				if (eBay_Auktionen.Gallery = '','','true')								as PropGallery,
162
				if (eBay_Auktionen.Featured = '','','true')								as PropFeatured,
163
				if (eBay_Auktionen.BoldTitle = '','','true')							as PropBoldTitle,
164
				if (eBay_Auktionen.HighLight = '','','true')							as PropHighLight,
165
				eBay_Auktionen.Gallery													as GalleryURL,
166
				eBay_Auktionen.Gallery													as PictureURL,
167
 
168
				confDatei,
169
				eBay_Auktionen.VersandCarrier,
170
				eBay_Auktionen.VersandCost
171
			from
172
				eBay_Auktionen,artikel
173
			where
174
				eBay_Auktionen.artikel_ID = artikel.ID
175
			and
176
				artikel.Language='DE'
177
			and
178
				eBay_Id = 0
179
			and
180
				eBay_error = ''
181
			and
182
				ListingStartDay <= NOW()
183
			and
184
				ListingStartTime <= NOW()
185
		";
186
 
187
		$result=mysql_query($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
188
 
189
		while ($AuktionsData=mysql_fetch_assoc($result))
190
		{
191
			$zeile=array_merge(loadConf($conf[$AuktionsData[confDatei]]),$settings,$AuktionsData);
192
 
193
			unset($zeile[ID]);
194
			unset($zeile[pictureURLpfad]);
195
			unset($zeile[pictureURLfeld]);
196
 
197
			$mySession=$Sessions[$zeile[confDatei]];
198
			unset($zeile[confDatei]);
199
 
200
			$eBayRes=AddItem($mySession,$zeile);
201
 
202
			if ($eBayRes->isGood())
203
			{
204
				$names=array();
205
				$values=array();
206
				foreach($eBayRes->_xmlValues as $elem)
207
				{
208
					if ($elem[type] == "complete")
209
					{
210
						if
211
						(
212
							in_array
213
							(
214
								$elem[tag],
215
								array
216
								(
217
									"Id",
218
									"EBayTime",
219
									"StartTime",
220
									"EndTime",
221
									"ListingFee",
222
									"CurrencyId"
223
								)
224
							)
225
						)
226
						{
227
							$names[]=$elem[tag];
228
							$values[]=$elem[value];
229
						}
230
					}
231
				}
232
				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");
233
			}
234
			mysql_query ("update eBay_Auktionen set eBay_Id=".$theItem->getId()." where ID = ".$AuktionsData[ID]);
235
			mysql_query ("update eBay_Auktionen set eBay_error='".serialize($eBayRes->_errors)."' where ID = ".$AuktionsData[ID]);
236
		}
237
	}
238
?>