View difference between Paste ID: iykdb9hV and qRR7wSFn
SHOW: | | - or go back to the newest paste.
1
<?php
2
if(!defined('INITIALIZED'))
3
	exit;
4
5
$config['site']['item_images_url'] = 'http://item-images.ots.me/960/';
6
$config['site']['item_images_extension'] = '.gif';
7
8
if($config['site']['shop_system'])
9
{
10
	require(SYSTEM . 'pages/shop_schema.php');
11
12
	if($logged)
13
	{
14
		$user_premium_points = $account_logged->getCustomField('premium_points');
15
	}
16
	else
17
	{
18
		$user_premium_points = 'Login first';
19
	}
20
	function getItemByID($id)
21
	{
22
		$id = (int) $id;
23
		$SQL = $GLOBALS['SQL'];
24
		$data = $SQL->query('SELECT * FROM '.$SQL->tableName('z_shop_offer').' WHERE '.$SQL->fieldName('id').' = '.$SQL->quote($id).';')->fetch();
25
		if($data['offer_type'] == 'item')
26
		{
27
			$offer['id'] = $data['id'];
28
			$offer['type'] = $data['offer_type'];
29
			$offer['item_id'] = $data['itemid1'];
30
			$offer['item_count'] = $data['count1'];
31
			$offer['points'] = $data['points'];
32
			$offer['description'] = $data['offer_description'];
33
			$offer['name'] = $data['offer_name'];
34
		}
35
		elseif($data['offer_type'] == 'container')
36
		{
37
			$offer['id'] = $data['id'];
38
			$offer['type'] = $data['offer_type'];
39
			$offer['container_id'] = $data['itemid1'];
40
			$offer['container_count'] = $data['count1'];
41
			$offer['item_id'] = $data['itemid2'];
42
			$offer['item_count'] = $data['count2'];
43
			$offer['points'] = $data['points'];
44
			$offer['description'] = $data['offer_description'];
45
			$offer['name'] = $data['offer_name'];
46
		}
47
		return $offer;
48
	}
49
50
	function getOfferArray()
51
	{
52
		$offer_list = $GLOBALS['SQL']->query('SELECT * FROM '.$GLOBALS['SQL']->tableName('z_shop_offer').';');
53
		$i_item = 0;
54
		$i_container = 0;
55
		while($data = $offer_list->fetch())
56
		{
57
			if($data['offer_type'] == 'item')
58
			{
59
				$offer_array['item'][$i_item]['id'] = $data['id'];
60
				$offer_array['item'][$i_item]['item_id'] = $data['itemid1'];
61
				$offer_array['item'][$i_item]['item_count'] = $data['count1'];
62
				$offer_array['item'][$i_item]['points'] = $data['points'];
63
				$offer_array['item'][$i_item]['description'] = $data['offer_description'];
64
				$offer_array['item'][$i_item]['name'] = $data['offer_name'];
65
				$i_item++;
66
			}
67
			elseif($data['offer_type'] == 'container')
68
			{
69
				$offer_array['container'][$i_container]['id'] = $data['id'];
70
				$offer_array['container'][$i_container]['container_id'] = $data['itemid1'];
71
				$offer_array['container'][$i_container]['container_count'] = $data['count1'];
72
				$offer_array['container'][$i_container]['item_id'] = $data['itemid2'];
73
				$offer_array['container'][$i_container]['item_count'] = $data['count2'];
74
				$offer_array['container'][$i_container]['points'] = $data['points'];
75
				$offer_array['container'][$i_container]['description'] = $data['offer_description'];
76
				$offer_array['container'][$i_container]['name'] = $data['offer_name'];
77
				$i_container++;
78
			}
79
		}
80
		return $offer_array;
81
	}
82
	if(($action == '') or ($action == 'item') or ($action == 'container'))
83
	{
84
		unset($_SESSION['viewed_confirmation_page']);
85
		$offer_list = getOfferArray();
86
87
		if(empty($action))
88
		{
89
			if(count($offer_list['item']) > 0)
90
				$action = 'item';
91
			elseif(count($offer_list['container']) > 0)
92
				$action = 'container';
93
		}
94
95
		function selectcolor($value)
96
		{
97
			if($GLOBALS['action'] == $value)
98
				return '#505050; color: #FFFFFF';
99
			else
100
				return '#303030; color: #aaaaaa';
101
		}
102
103
		if((count($offer_list['item']) > 0) or (count($offer_list['container']) > 0))
104
		{
105
			echo '<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=4><TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white colspan="2"><B>Choose a categorie: </B>';
106
			if(isset($offer_list['item']) && count($offer_list['item']) > 0) echo '<a href="?subtopic=gifts&action=item" style="padding: 5px 5px 7px 5px; margin: 5px 1px 0px 1px; background-color: '.selectcolor('item').';">ITEMS</a>';
107
			if(isset($offer_list['container']) && count($offer_list['container']) > 0) echo '<a href="?subtopic=gifts&action=container" style="padding: 5px 5px 7px 5px; margin: 5px 1px 0px 1px; background-color: '.selectcolor('container').';">CONTAINERS</a>';
108
			echo '</TD></TR></TD></TR></table><table BORDER=0 CELLPaDDING="4" CELLSPaCING="1" style="width:100%;font-weight:bold;text-align:center;"><tr style="background:#505050;"><td colspan="3" style="height:px;"></td></tr></table>';
109
		}
110
111
		//show list of items offers
112
		if((count($offer_list['item']) > 0) and ($action == 'item'))
113
		{
114
			echo '<table border="0" cellpadding="4" cellspacing="1" width="100%"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td width="8%" align="center" class="white"><b>Points</b></td><td width="9%" align="center" class="white"><b>Picture</b></td><td width="350" align="left" class="white"><b>Description</b></td><td width="250" align="center" class="white"><b>Select product</b></td></tr>';
115
			$number_of_rows = 0;
116
			foreach($offer_list['item'] as $item)
117
			{
118
				if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
119
				echo '<tr bgcolor="'.$bgcolor.'"><td align="center"><b>'.$item['points'].'</b></td><td align="center"><img src="' . $config['site']['item_images_url'] . $item['item_id'] . $config['site']['item_images_extension'] . '"></td><td><b>'.htmlspecialchars($item['name']).'</b> ('.$item['points'].' points)<br />'.htmlspecialchars($item['description']).'</td><td align="center">';
120
				if(!$logged)
121
				{
122
					echo '<b>Login to buy</b>';
123
				}
124
				else
125
				{
126
					echo '<form action="?subtopic=gifts&action=select_player" method="POST" name="itemform_'.$item['id'].'"><input type="hidden" name="buy_id" value="'.$item['id'].'"><div class="navibutton"><a href="" onClick="itemform_'.$item['id'].'.submit();return false;">BUY</a></div></form>';
127
				}
128
				echo '</td></tr>';
129
			}
130
			echo '</table>';
131
		}
132
		//show list of containers offers
133
		if(isset($offer_list['container']) && (count($offer_list['container']) > 0) and ($action == 'container'))
134
		{
135
			if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
136
			echo '<table border="0" cellpadding="4" cellspacing="1" width="100%"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td width="8%" align="center" class="white"><b>Points</b></td><td width="9%" align="center" class="white"><b>Picture</b></td><td width="350" align="left" class="white"><b>Description</b></td><td width="250" align="center" class="white"><b>Select product</b></td></tr>';
137
			foreach($offer_list['container'] as $container)
138
			{
139
				echo '<tr bgcolor="'.$bgcolor.'"><td align="center"><b>'.$container['points'].'</b></td><td align="center"><img src="' . $config['site']['item_images_url'] . $container['item_id'] . $config['site']['item_images_extension'] . '"></td><td><b>'.htmlspecialchars($container['name']).'</b> ('.$container['points'].' points)<br />'.htmlspecialchars($container['description']).'</td><td align="center">';
140
				if(!$logged)
141
				{
142
					echo '<b>Login to buy</b>';
143
				}
144
				else
145
				{
146
					echo '<form action="?subtopic=gifts&action=select_player" method="POST" name="contform_'.$container['id'].'"><input type="hidden" name="buy_id" value="'.$container['id'].'"><div class="navibutton"><a href="" onClick="contform_'.$container['id'].'.submit();return false;">BUY</a></div></form>';
147
				}
148
				echo '</td></tr>';
149
			}
150
			echo '</table>';
151
		}
152
153
		if((count($offer_list['item']) > 0) or (count($offer_list['container']) > 0))
154
		{
155
			echo '<table BORDER=0 CELLPaDDING="4" CELLSPaCING="1" style="width:100%;font-weight:bold;text-align:center;">
156
			<tr style="background:#505050;">
157
					<td colspan="3" style="height:px;"></td>
158
			</tr>
159
			</table>';
160
		}
161
	}
162
	if($action == 'select_player')
163
	{
164
		unset($_SESSION['viewed_confirmation_page']);
165
		if(!$logged) {
166
			$errormessage .= 'Please login first.';
167
		}
168
		else
169
		{
170
			$buy_id = (int) $_REQUEST['buy_id'];
171
			if(empty($buy_id))
172
			{
173
				$errormessage .= 'Please <a href="?subtopic=gifts">select item</a> first.';
174
			}
175
			else
176
			{
177
				$buy_offer = getItemByID($buy_id);
178
				if(isset($buy_offer['id'])) //item exist in database
179
				{
180
					if($user_premium_points >= $buy_offer['points'])
181
					{
182
						echo '<table border="0" cellpadding="4" cellspacing="1" width="100%">
183
						<tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2" class="white"><b>Selected Offer</b></td></tr>
184
						<tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>Name:</b></td><td width="550">'.htmlspecialchars($buy_offer['name']).'</td></tr>
185
						<tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>Description:</b></td><td width="550">'.htmlspecialchars($buy_offer['description']).'</td></tr>
186
						</table><br />
187
						<form action="?subtopic=gifts&action=confirm_transaction" method="POST"><input type="hidden" name="buy_id" value="'.$buy_id.'">
188
						<table border="0" cellpadding="4" cellspacing="1" width="100%">
189
						<tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2" class="white"><b>Give item to player from your account</b></td></tr>
190
						<tr bgcolor="'.$config['site']['lightborder'].'"><td width="110"><b>Name:</b></td><td width="550"><select name="buy_name">';
191
						$players_from_logged_acc = $account_logged->getPlayersList();
192
						if(count($players_from_logged_acc) > 0)
193
						{
194
							foreach($players_from_logged_acc as $player)
195
							{
196
								echo '<option>'.htmlspecialchars($player->getName()).'</option>';
197
							}
198
						}
199
						else
200
						{
201
							echo 'You don\'t have any character on your account.';
202
						}
203
						echo '</select>&nbsp;<input type="submit" value="Give"></td></tr>
204
						</table>
205
						</form><br /><form action="?subtopic=gifts&action=confirm_transaction" method="POST"><input type="hidden" name="buy_id" value="'.$buy_id.'">
206
							<table border="0" cellpadding="4" cellspacing="1" width="100%">
207
							<tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2" class="white"><b>Give item to other player</b></td></tr>
208
							<tr bgcolor="'.$config['site']['lightborder'].'"><td width="110"><b>To player:</b></td><td width="550"><input type="text" name="buy_name"> - name of player</td></tr>
209
							<tr bgcolor="'.$config['site']['darkborder'].'"><td width="110"><b>From:</b></td><td width="550"><input type="text" name="buy_from">&nbsp;<input type="submit" value="Give"> - your nick, \'empty\' = Anonymous</td></tr>
210
							</table><br />
211
							</form>';
212
213
					}
214
					else
215
					{
216
						$errormessage .= 'For this item you need <b>'.$buy_offer['points'].'</b> points. You have only <b>'.$user_premium_points.'</b> premium points. Please <a href="?subtopic=gifts">select other item</a> or buy premium points.';
217
					}
218
				}
219
				else
220
				{
221
					$errormessage .= 'Offer with ID <b>'.$buy_id.'</b> doesn\'t exist. Please <a href="?subtopic=gifts">select item</a> again.';
222
				}
223
			}
224
		}
225
		if(!empty($errormessage))
226
		{
227
			echo '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
228
				<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Informations</B></TD></TR>
229
				<TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b>'.$errormessage.'</b></TD></TR>
230
				</table>';
231
		}
232
	}
233
	elseif($action == 'confirm_transaction')
234
	{
235
		$set_session = false;
236
		if(!$logged)
237
		{
238
			$errormessage .= 'Please login first.';
239
		}
240
		else
241
		{
242
			$buy_id = isset($_POST['buy_id']) ? (int) $_POST['buy_id'] : NULL;
243
			$buy_name = isset($_POST['buy_name']) ? $_POST['buy_name'] : NULL;
244
			$buy_from = isset($_POST['buy_from']) ? $_POST['buy_from'] : NULL;
245
			if(empty($buy_from))
246
			{
247
				$buy_from = 'Anonymous';
248
			}
249
			if(empty($buy_id))
250
			{
251
				$errormessage .= 'Please <a href="?subtopic=gifts">select item</a> first.';
252
			}
253
			else
254
			{
255
				if(!check_name($buy_from))
256
				{
257
					$errormessage .= 'Invalid nick ("from player") format. Please <a href="?subtopic=gifts&action=select_player&buy_id='.$buy_id.'">select other name</a> or contact with administrator.';
258
				}
259
				else
260
				{
261
					$buy_offer = getItemByID($buy_id);
262
					if(isset($buy_offer['id'])) //item exist in database
263
					{
264
						if($user_premium_points >= $buy_offer['points'])
265
						{
266
							if(check_name($buy_name))
267
							{
268
								$buy_player = $ots->createObject('Player');
269
								$buy_player->find($buy_name);
270
								if($buy_player->isLoaded())
271
								{
272
									$buy_player_account = $buy_player->getAccount();
273
									if(isset($_SESSION['viewed_confirmation_page']) && $_SESSION['viewed_confirmation_page'] == 'yes' && isset($_POST['buy_confirmed']) && $_POST['buy_confirmed'] == 'yes')
274
									{
275
										if($buy_offer['type'] == 'item')
276
										{
277
											$sql = 'INSERT INTO '.$SQL->tableName('z_ots_comunication').' ('.$SQL->fieldName('id').','.$SQL->fieldName('name').','.$SQL->fieldName('type').','.$SQL->fieldName('action').','.$SQL->fieldName('param1').','.$SQL->fieldName('param2').','.$SQL->fieldName('param3').','.$SQL->fieldName('param4').','.$SQL->fieldName('param5').','.$SQL->fieldName('param6').','.$SQL->fieldName('param7').','.$SQL->fieldName('delete_it').') VALUES (NULL, '.$SQL->quote($buy_player->getName()).', '.$SQL->quote('login').', '.$SQL->quote('give_item').', '.$SQL->quote($buy_offer['item_id']).', '.$SQL->quote($buy_offer['item_count']).', '.$SQL->quote('').', '.$SQL->quote('').', '.$SQL->quote('item').', '.$SQL->quote($buy_offer['name']).', '.$SQL->quote('').', '.$SQL->quote(1).');';
278
											$SQL->query($sql);
279
											$save_transaction = 'INSERT INTO '.$SQL->tableName('z_shop_history_item').' ('.$SQL->fieldName('id').','.$SQL->fieldName('to_name').','.$SQL->fieldName('to_account').','.$SQL->fieldName('from_nick').','.$SQL->fieldName('from_account').','.$SQL->fieldName('price').','.$SQL->fieldName('offer_id').','.$SQL->fieldName('trans_state').','.$SQL->fieldName('trans_start').','.$SQL->fieldName('trans_real').') VALUES ('.$SQL->lastInsertId().', '.$SQL->quote($buy_player->getName()).', '.$SQL->quote($buy_player_account->getId()).', '.$SQL->quote($buy_from).',  '.$SQL->quote($account_logged->getId()).', '.$SQL->quote($buy_offer['points']).', '.$SQL->quote($buy_offer['name']).', '.$SQL->quote('wait').', '.$SQL->quote(time()).', '.$SQL->quote(0).');';
280
											$SQL->query($save_transaction);
281
											$account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
282
											$user_premium_points = $user_premium_points - $buy_offer['points'];
283
											echo '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
284
												<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Item added!</B></TD></TR>
285
												<TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b>'.htmlspecialchars($buy_offer['name']).'</b> added to player <b>'.htmlspecialchars($buy_player->getName()).'</b> items (he will get this items after relog) for <b>'.$buy_offer['points'].' premium points</b> from your account.<br />Now you have <b>'.$user_premium_points.' premium points</b>.<br /><a href="?subtopic=gifts">GO TO MAIN SHOP SITE</a></TD></TR>
286
												</table>';
287
										}
288
										elseif($buy_offer['type'] == 'container')
289
										{
290
											$sql = 'INSERT INTO '.$SQL->tableName('z_ots_comunication').' ('.$SQL->fieldName('id').','.$SQL->fieldName('name').','.$SQL->fieldName('type').','.$SQL->fieldName('action').','.$SQL->fieldName('param1').','.$SQL->fieldName('param2').','.$SQL->fieldName('param3').','.$SQL->fieldName('param4').','.$SQL->fieldName('param5').','.$SQL->fieldName('param6').','.$SQL->fieldName('param7').','.$SQL->fieldName('delete_it').') VALUES (NULL, '.$SQL->quote($buy_player->getName()).', '.$SQL->quote('login').', '.$SQL->quote('give_item').', '.$SQL->quote($buy_offer['item_id']).', '.$SQL->quote($buy_offer['item_count']).', '.$SQL->quote($buy_offer['container_id']).', '.$SQL->quote($buy_offer['container_count']).', '.$SQL->quote('container').', '.$SQL->quote($buy_offer['name']).', '.$SQL->quote('').', '.$SQL->quote(1).');';
291
											$SQL->query($sql);
292
											$save_transaction = 'INSERT INTO '.$SQL->tableName('z_shop_history_item').' ('.$SQL->fieldName('id').','.$SQL->fieldName('to_name').','.$SQL->fieldName('to_account').','.$SQL->fieldName('from_nick').','.$SQL->fieldName('from_account').','.$SQL->fieldName('price').','.$SQL->fieldName('offer_id').','.$SQL->fieldName('trans_state').','.$SQL->fieldName('trans_start').','.$SQL->fieldName('trans_real').') VALUES ('.$SQL->lastInsertId().', '.$SQL->quote($buy_player->getName()).', '.$SQL->quote($buy_player_account->getId()).', '.$SQL->quote($buy_from).',  '.$SQL->quote($account_logged->getId()).', '.$SQL->quote($buy_offer['points']).', '.$SQL->quote($buy_offer['name']).', '.$SQL->quote('wait').', '.$SQL->quote(time()).', '.$SQL->quote(0).');';
293
											$SQL->query($save_transaction);
294
											$account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
295
											$user_premium_points = $user_premium_points - $buy_offer['points'];
296
											echo '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
297
												<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Container of items added!</B></TD></TR>
298
												<TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b>'.htmlspecialchars($buy_offer['name']).'</b> added to player <b>'.htmlspecialchars($buy_player->getName()).'</b> items (he will get this container with items after relog) for <b>'.$buy_offer['points'].' premium points</b> from your account.<br />Now you have <b>'.$user_premium_points.' premium points</b>.<br /><a href="?subtopic=gifts">GO TO MAIN SHOP SITE</a></TD></TR>
299
												</table>';
300
										}
301
									}
302
									else
303
									{
304
										$set_session = TRUE;
305
										$_SESSION['viewed_confirmation_page'] = 'yes';
306
										echo '<table border="0" cellpadding="4" cellspacing="1" width="100%">
307
										<tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3" class="white"><b>Confirm Transaction</b></td></tr>
308
										<tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>Name:</b></td><td width="550" colspan="2">'. htmlspecialchars($buy_offer['name']).'</td></tr>
309
										<tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>Description:</b></td><td width="550" colspan="2">'. htmlspecialchars($buy_offer['description']).'</td></tr>
310
										<tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>Cost:</b></td><td width="550" colspan="2"><b>'. htmlspecialchars($buy_offer['points']).' premium points</b> from your account</td></tr>
311
										<tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>For Player:</b></td><td width="550" colspan="2"><font color="red">'.htmlspecialchars($buy_player->getName()).'</font></td></tr>
312
										<tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>From:</b></td><td width="550" colspan="2"><font color="red">'.htmlspecialchars($buy_from).'</font></td></tr>
313
										<tr bgcolor="'.$config['site']['darkborder'].'"><td colspan="3"></td></tr>
314
										<tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>Transaction?</b></td><td width="275" align="left">
315
										<form action="?subtopic=gifts&action=confirm_transaction" method="POST"><input type="hidden" name="buy_confirmed" value="yes"><input type="hidden" name="buy_id" value="'.$buy_id.'"><input type="hidden" name="buy_from" value="'.htmlspecialchars($buy_from).'"><input type="hidden" name="buy_name" value="'.htmlspecialchars($buy_name).'"><input type="submit" value="Accept"></form></td>
316
										<td align="right"><form action="?subtopic=gifts" method="POST"><input type="submit" value="Cancel"></form></td></tr>
317
										<tr bgcolor="'.$config['site']['darkborder'].'"><td colspan="3"></td></tr>
318
										</table> 
319
										';
320
									}
321
								}
322
								else
323
								{
324
									$errormessage .= 'Player with name <b>'.htmlspecialchars($buy_name).'</b> doesn\'t exist. Please <a href="?subtopic=gifts&action=select_player&buy_id='.$buy_id.'">select other name</a>.';
325
								}
326
							}
327
							else
328
							{
329
								$errormessage .= 'Invalid name format. Please <a href="?subtopic=gifts&action=select_player&buy_id='.$buy_id.'">select other name</a> or contact with administrator.';
330
							}
331
						}
332
						else
333
						{
334
							$errormessage .= 'For this item you need <b>'.$buy_offer['points'].'</b> points. You have only <b>'.$user_premium_points.'</b> premium points. Please <a href="?subtopic=gifts">select other item</a> or buy premium points.';
335
						}
336
					}
337
					else
338
					{
339
						$errormessage .= 'Offer with ID <b>'.$buy_id.'</b> doesn\'t exist. Please <a href="?subtopic=gifts">select item</a> again.';
340
					}
341
				}
342
			}
343
		}
344
		if(!empty($errormessage))
345
		{
346
			echo '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
347
				<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Informations</B></TD></TR>
348
				<TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b>'.$errormessage.'</b></TD></TR>
349
				</table>';
350
		}
351
		if(!$set_session)
352
		{
353
			unset($_SESSION['viewed_confirmation_page']);
354
		}
355
	}
356
	elseif($action == 'show_history')
357
	{
358
		if(!$logged)
359
		{
360
			$errormessage .= 'Please login first.';
361
		}
362
		else
363
		{
364
			$items_received_text = '';
365
			$items_history_received = $SQL->query('SELECT * FROM '.$SQL->tableName('z_shop_history_item').' WHERE '.$SQL->fieldName('to_account').' = '.$SQL->quote($account_logged->getId()).' OR '.$SQL->fieldName('from_account').' = '.$SQL->quote($account_logged->getId()).';');
366
			if(is_object($items_history_received))
367
			{
368
				foreach($items_history_received as $item_received)
369
				{
370
					if($account_logged->getId() == $item_received['to_account'])
371
						$char_color = 'green';
372
					else
373
						$char_color = 'red';
374
					$items_received_text .= '<tr bgcolor="'.$config['site']['lightborder'].'"><td><font color="'.$char_color.'">'.htmlspecialchars($item_received['to_name']).'</font></td><td>';
375
					if($account_logged->getId() == $item_received['from_account'])
376
						$items_received_text .= '<i>Your account</i>';
377
					else
378
						$items_received_text .= htmlspecialchars($item_received['from_nick']);
379
					$items_received_text .= '</td><td>'.htmlspecialchars($item_received['offer_id']).'</td><td>'.date("j F Y, H:i:s", $item_received['trans_start']).'</td>';
380
					if($item_received['trans_real'] > 0)
381
						$items_received_text .= '<td>'.date("j F Y, H:i:s", $item_received['trans_real']).'</td>';
382
					else
383
						$items_received_text .= '<td><b><font color="red">Not realized yet.</font></b></td>';
384
					$items_received_text .= '</tr>';
385
				}
386
			}
387
			echo '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
388
				<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'"></TD></TR>
389
				<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><center><B>Transactions History</B></center></TD></TR>
390
				<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'"></TD></TR>
391
				</table><br>';
392
				
393
			if(!empty($items_received_text))
394
			{
395
				echo '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
396
					<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white colspan="5"><B>Item Transactions</B></TD></TR>
397
					<tr bgcolor="'.$config['site']['darkborder'].'"><td><b>To:</b></td><td><b>From:</b></td><td><b>Offer name</b></td><td><b>Bought on page</b></td><td><b>Received on OTS</b></td></tr>
398
					'.$items_received_text.'
399
					</table><br />';
400
			}
401
			if(empty($items_received_text))
402
				$errormessage .= 'You did not buy/receive any item.';
403
		}
404
		if(!empty($errormessage))
405
		{
406
			echo '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
407
				<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Informations</B></TD></TR>
408
				<TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b>'.$errormessage.'</b></TD></TR>
409
				</table>';
410
		}
411
	}
412
	echo '<br><TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
413
		<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Premium Points</B></TD></TR>
414
		<TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b><font color="green">You have premium points: </font></b>'.$user_premium_points.'</TD></TR>
415
		</table>';
416
}
417
else
418
	echo '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
419
	<TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=center CLASS=white ><B>Shop Information</B></TD></TR>
420
	<TR><TD BGCOLOR="'.$config['site']['darkborder'].'"><center>Shop is currently closed. [to admin: edit it in \'config/config.php\']</TD></TR>
421
	</table>';