-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathsubasta.php
executable file
·205 lines (156 loc) · 7.21 KB
/
subasta.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php # POL.VirtualPol.com — Copyright (c) 2008 Javier González González <[email protected]> — MIT License
// carga config
$result = mysql_query_old("SELECT valor, dato FROM config WHERE pais = '".PAIS."' AND autoload = 'no'", $link);
while ($row = mysqli_fetch_array($result)) { $pol['config'][$row['dato']] = $row['valor']; }
if ($_GET[1] == 'editar') {
if ($pol['user_ID'] == $pol['config']['pols_fraseedit']) {
$url = str_replace("http://", "", explodear("\"", $pol['config']['pols_frase'], 1));
$frase = explodear("<", explodear(">", $pol['config']['pols_frase'], 1), 0);
echo '<fieldset><legend>La frase</legend>
<form action="/accion/mercado/editarfrase" method="post">
<table border="0"><tr>
<td align="right">Texto: <input value="' . $frase . '" type="text" name="frase" size="50" maxlength="70" required /><br />
http://<input type="text" name="url" size="50" maxlength="150" value="' . $url . '" /></td><td>
'.boton('Editar', 'submit', false, 'blue').'
</form></b></td></tr>
<tr><td align="right">
<form action="/accion/mercado/cederfrase" method="post">
Ceder al Ciudadano: <input type="text" name="nick" size="14" maxlength="20" value="" required />
</td><td>
'.boton('Ceder', 'submit', false, 'small pill').'
</form>
</td></tr></table>
</fieldset>';
}
// ;ID:URL:TEXT;
foreach(explode(";", $pol['config']['palabras']) as $num => $t) {
$t = explode(":", $t);
if ($t[1]) { $t[1] = 'http://'.$t[1]; }
if (($t[0] == $pol['user_ID']) OR (nucleo_acceso($vp['acceso']['control_gobierno']))) {
echo '<fieldset><legend>Palabra '.($num + 1).'</legend>
<form action="/accion/mercado/editarpalabra?ID='.$num.'" method="post">
<table border="0"><tr>
<td>Texto: <input value="'.$t[2].'" type="text" name="text" size="20" maxlength="20" required /><br />
<input type="url" name="url" size="50" maxlength="150" value="'.$t[1].'" placeholder="http://" /></td><td>
'.boton('Editar', 'submit', false, 'blue').'
</form></b></td></tr>
<tr><td align="right">
<form action="/accion/mercado/cederpalabra?ID='.$num.'" method="post">
Ceder al Ciudadano: <input type="text" name="nick" size="14" maxlength="20" value="" required />
</td><td>
'.boton('Ceder', 'submit', false, 'small pill').'
</form></td>
</tr></table>
</fieldset>';
}
}
} else { // SUBASTAS
$txt_header .= '
<script type="text/javascript">
window.onload = function(){
setTimeout(function(){ $(".pujar").removeAttr("disabled"); $(".pujar").removeClass("disabled"); }, 2000);
}
</script>';
// datos graficos
$i = 0;
$result = mysql_query_old("SELECT mercado_ID, pols
FROM pujas WHERE pais = '".PAIS."' AND mercado_ID = '1' OR mercado_ID = '2'
ORDER BY time ASC LIMIT 500", $link);
while($row = mysqli_fetch_array($result)){
$dgrafico[$row['mercado_ID']][] = $row['pols'];
$i++;
}
if ($dgrafico[1]) { $dgrafico_max_1 = max($dgrafico[1]); } else { $dgrafico_max_1 = 0; }
if ($dgrafico[2]) { $dgrafico_max_2 = max($dgrafico[2]); } else { $dgrafico_max_2 = 0; }
$queda = duracion(strtotime(date('Y-m-d 20:00:00')) - time());
if (substr($queda, 0, 1) == '-') { $queda = '1 dia'; }
$result = mysql_query_old("SELECT valor,
(SELECT nick FROM users WHERE ID = config.valor LIMIT 1) AS nick
FROM config WHERE pais = '".PAIS."' AND dato = 'pols_fraseedit' LIMIT 1", $link);
while($row = mysqli_fetch_array($result)){ $nick = $row['nick']; }
echo '<h1>Subastas (<a href="/subasta/">Actualizar</a>) <span class="gris">Proceso en <span class="timer" value="'.strtotime(date('Y-m-d 20:00:00')).'"></span></span></h1>
<br />
<table border="0"><tr><td width="50%" valign="top">
<table border="0" cellspacing="2" cellpadding="0" class="pol_table">
<tr>
</tr>';
$ganador = 'ok';
$init = false;
$result = mysql_query_old("SELECT user_ID, pols, time,
(SELECT nick FROM users WHERE ID = pujas.user_ID LIMIT 1) AS nick
FROM pujas
WHERE pais = '".PAIS."' AND mercado_ID = 1
ORDER BY pols DESC
LIMIT 10", $link);
while($row = mysqli_fetch_array($result)) {
$init = true;
if ($ganador == 'ok') {
echo '
<tr>
<td colspan="4" class="amarillo"><form action="/accion/mercado/puja?ID=1" method="post">
<b><input type="text" name="puja" value="" size="4" maxlength="7" style="text-align:right;" class="pols" /> '.MONEDA.' <input class="pujar" disabled="disabled" type="submit" value="Pujar" /> "La frase"</b></form></td>
</tr>';
$bold = ' style="font-weight:bold;"';
$ganador = '<b>(Ganador)</b>';
} else { $ganador = false; $bold = ''; }
echo '<tr><td align="right"><b style="font-size:20px;">' . pols($row['pols']) . '</b></td><td' . $bold . '>' . crear_link($row['nick']) . '</td><td' . $bold . '><span class="timer" value="'.strtotime($row['time']).'"></span></td><td>' . $ganador . '</td></tr>';
}
if ($init == false) {
echo '
<tr>
<td colspan="4" class="amarillo"><form action="/accion/mercado/puja?ID=1" method="post">
<b><input type="text" name="puja" value="1" size="4" maxlength="7" style="text-align:right;" class="pols" /> '.MONEDA.' <input class="pujar" disabled="disabled" type="submit" value="Pujar" /> "La frase"</b></form></td>
</tr>';
}
echo '</table>
<p>Propietario actual: <b style="font-size:22px;">' . crear_link($nick) . '</b></p>
</td><td width="50%" valign="top">
<table border="0" cellspacing="2" cellpadding="0" class="pol_table">
<tr>
</tr>';
$gan = 0;
$ganador = '';
$init = false;
$result = mysql_query_old("SELECT user_ID, MAX(pols) AS los_pols, time,
(SELECT nick FROM users WHERE ID = pujas.user_ID LIMIT 1) AS nick
FROM pujas
WHERE pais = '".PAIS."' AND mercado_ID = 2
GROUP BY user_ID
ORDER BY los_pols DESC
LIMIT 10", $link);
while($row = mysqli_fetch_array($result)) {
$init = true;
$gan++;
if ($gan == 1) {
echo '
<tr>
<td colspan="4" class="amarillo"><form action="/accion/mercado/puja?ID=2" method="post">
<b><input type="text" name="puja" value="'.($row['los_pols']+1).'" size="4" maxlength="7" readonly="readonly" style="text-align:right;" class="pols" /> '.MONEDA.' <input type="submit" value="Pujar" class="pujar" disabled="disabled" /> "las palabras"</b></form></td>
</tr>';
}
if ($gan <= $pol['config']['palabras_num']) { $bold = ' style="font-weight:bold;"'; $ganador = '<b>(Ganador)</b>'; } else { $bold = ''; $ganador = false; }
echo '<tr><td align="right"><b style="font-size:20px;">' . pols($row['los_pols']) . '</b></td><td' . $bold . '>' . crear_link($row['nick']) . '</td><td' . $bold . '><span class="timer" value="'.strtotime($row['time']).'"></span></td><td>' . $ganador . '</td></tr>';
}
if ($init == false) {
echo '
<tr>
<td colspan="4" class="amarillo"><form action="/accion/mercado/puja?ID=2" method="post">
<b><input type="text" name="puja" value="1" size="4" class="pols" readonly="readonly" maxlength="7" style="text-align:right;" /> '.MONEDA.' <input type="submit" value="Pujar" class="pujar" disabled="disabled" /> "las palabras"</b></form></td>
</tr>';
}
echo '</table>
<p>Propietarios actuales:<br /><b>';
foreach(explode(";", $pol['config']['palabras']) as $t) {
$t = explode(":", $t);
$result = mysql_query_old("SELECT nick FROM users WHERE ID = '" . $t[0] . "' LIMIT 1", $link);
while($row = mysqli_fetch_array($result)){
echo crear_link($row['nick']) . ' ';
}
}
echo '</b></p></td></tr></table>';
}
//THEME
$txt_title = 'Subastas';
$txt_nav = array('Subastas');
$txt_menu = 'econ';
?>