-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathitem_shop.php
executable file
·145 lines (96 loc) · 2.7 KB
/
item_shop.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/* I codici qui inseriti sono proprietà di
* Francesco Stasi, pertanto ne è vietata la
* vendita e la cessione a terzi senza previa
* autorizzazione dell' autore.
*/
require_once("config.php");
require_once("libs/common.php");
require_once("libs/item_lib.php");
require_once("libs/group_lib.php");
if(!isset($_SESSION))
{
session_start();
}
logged();
$MyChar_obj=new Character($_SESSION['char_id']);
$MyChar_obj->parseFromDb();
$buyRslt="";
$_SESSION['modlevel']=$MyChar_obj->Account()->getModLevel();
if ($admin_edit_items_required>$_SESSION['modlevel']){
$onlypublic=true;
}else{
$onlypublic=false;
}
if(isset($_REQUEST['buy'])){
$buyItem=new Item(null,$_REQUEST['buy']);
$buyItem->readFromDb();
if($buyItem->isBuyable($MyChar_obj)){
$buyItem->BuyItem($MyChar_obj);
$buyRslt="Oggetto: {$buyItem->getName()} acquistato.";
}else{
$buyRslt="Impossibile acquistare: {$buyItem->getName()}";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="author" content="Francesco Stasi"/>
<title>Forum</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type="text/javascript">
$(document).ready(function(){
$( ".buttonify" ).button();
});
</script>
</head>
<body>
<?php
echo "<p>$buyRslt</p>";
//se c'è la category e se è un tipo di oggetto valido, mostro l'elenco
if(isset($_REQUEST['cat']) && array_key_exists($_REQUEST['cat'],$items_types_array)){
$itemList=new ItemList();
$itemList->populateList($_REQUEST['cat'],null,null,null,$onlypublic);
echo "<table class=\"itemshop\">
<tr>
<th>Oggetto</th>
<th class=\"shopimg\">Immagine</th>
<th>Costo</th>
</tr>";
foreach($itemList->getList() as $k=>$v){
//$v=new Item();
$costArr=$v->getCostArray();
$moneyC="";
$pxC="";
if($costArr[0]>0)
$moneyC=$costArr[0]." ".$valuta_plurale;
if($costArr[1]>0)
$pxC=$costArr[1]." px";
if($v->isBuyable($MyChar_obj))
$buyable="<a href=\"item_shop.php?buy={$v->getId()}\" class=\"buttonify\">Acquista</a>";
else
$buyable="";
echo "<tr>
<td class=\"objN\"><span>{$v->getName()}</span><p class=\"desc\">{$v->getDescription()}</p></td>
<td><img src=\"{$v->getImage()}\" class=\"shopimg\"/></td>
<td><div>$moneyC $pxC</div><div>$buyable</div></td>
</tr>";
}
echo "</table>";
}else{
//altrimenti mostro le categorie di oggetti acquistabili
echo "<ul>";
foreach($items_types_array as $k => $v){
$itemList=new ItemList();
$itemList->populateList($k,null,null,null,$onlypublic);
echo "<li><a href=\"item_shop.php?cat=$k\">$v ({$itemList->getSize()})</a></li>";
}
echo "</ul>";
}
?>
</body>
</html>