Guest User

agregar.php

a guest
Apr 3rd, 2013
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.14 KB | None | 0 0
  1. <?php
  2. #######################
  3. # www.marcofbb.com.ar #
  4. #######################
  5. // Incluimos la configuracion y conexion a la MySQL.
  6.  
  7. session_start();
  8. if(!session_is_registered(myusername)){
  9. header("location:main_login.php");
  10. }
  11. // Check if session is not registered, redirect back to main page.
  12. // Put this code in first line of web page.
  13.  
  14. // Definimos la variable $msg por seguridad.
  15. $msg = "";
  16. // Si se apreta el boton Agendar, da la condicion como true.
  17. if($_POST['agendar'])
  18. {
  19. // Verificamos que no haya ningun dato sin rellenar.
  20. if(!empty($_POST['local']) || !empty($_POST['visitante']) || !empty($_POST['ratiol']) || !empty($_POST['ratiov']) || !empty($_POST['ratioe']) || !empty($_POST['sportid']) || !empty($_POST['start']))
  21. {
  22. // Pasamos los datos de los POST a Variables, y le ponemos seguridad.
  23. $local = htmlentities($_POST['local']);
  24. $visitante = htmlentities($_POST['visitante']);
  25. $ratiol = htmlentities($_POST['ratiol']);
  26. $ratiov = htmlentities($_POST['ratiov']);
  27. $ratioe = htmlentities($_POST['ratioe']);
  28. $sportid = htmlentities($_POST['sportid']);
  29. $start = htmlentities($_POST['start']);
  30. $liga = htmlentities($_POST['liga']);
  31.  
  32. $take = floatval("0.91");
  33. $ratio1 = floatval($ratiol);
  34. $ratio2 = floatval($ratiov);
  35. $ratio3 = floatval($ratioe);
  36.  
  37.  
  38. // Configuracion de la base de datos.
  39. $dbhost = "localhost"; // Servidor
  40. $dbuser = "kv000179_bet"; // Usuario
  41. $dbpass = "Betiana1"; // Contraseña
  42. $dbname = "kv000179_bet"; // Tabla
  43.  
  44. // Creando conexion.
  45. $link = mysql_connect($dbhost,$dbuser,$dbpass);
  46. mysql_select_db($dbname,$link);
  47.  
  48. // Insertamos los datos en la base de datos, si da algun error lo muestra.
  49.  
  50. $sql = "INSERT INTO events (hometeam, awayteam, ratiohome, ratioaway, ratiox, sportid, starttime, liga) VALUES ('".$local."','".$visitante."','".$ratio1 * $take."', '".$ratio2 * $take."', '".$ratio3 * $take."', '".$sportid."', '".$start."', '".$liga."')";
  51. mysql_query($sql,$link) or die(mysql_error());
  52. // Mostramos un mensaje diciendo que todo salio como lo esperado
  53. $msg = "Evento cargado correctamente.";
  54. } else {
  55. // Si hay un dato sin rellenar mostramos el siguiente texto.
  56. $msg = "Falta rellenar algun dato.";
  57. }
  58.  
  59. }
  60. ?>
  61. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  62. <html xmlns="http://www.w3.org/1999/xhtml">
  63. <head>
  64. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  65. <title>Agregar Eventos</title>
  66. </head>
  67. <style type="text/css">
  68. .agenda {
  69. margin:10px auto 0 auto;
  70. width:701px;
  71. height:468px;
  72. background-image:url(imagenes/agenda.jpg);
  73. }
  74. .agenda #contenidor {
  75. padding:5px;
  76. width:276px;
  77. height:428px;
  78. }
  79. .style2 {color: #000000}
  80. .style5 {color: #990000; font-weight: bold; }
  81. .style6 {color: #000000; font-weight: bold; }
  82. </style>
  83. <body>
  84. <script language="javascript">
  85. function toggle() {
  86. var ele = document.getElementById("toggleText");
  87. var text = document.getElementById("displayText");
  88. if(ele.style.display == "block") {
  89. ele.style.display = "none";
  90. text.innerHTML = "Mostrar Apuestas en Progreso";
  91. }
  92. else {
  93. ele.style.display = "block";
  94. text.innerHTML = "Esconder Apuestas en Progreso";
  95. }
  96. }
  97. </script>
  98.  
  99.  
  100.  
  101. <tr>
  102. <td valign="top"><center><em><span style="color:red;"><?=$msg;?></span></em></center>
  103. <form action="agregar.php" method="post">
  104. <p align="center">CARGAR EVENTOS</p>
  105. <table width="200" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  106. <tr>
  107. <td><table width="465" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#FFFFFF">
  108. <tr>
  109. <td width="318"><strong>Local</strong></td>
  110. <td width="185"><input type="text" name="local" id="local" /></td>
  111. </tr>
  112. <tr>
  113. <td><strong>Visitante</strong></td>
  114. <td><input type="text" name="visitante" id="visitante" /></td>
  115. </tr>
  116. <tr>
  117. <td><strong>Ratio Local</strong></td>
  118. <td><input type="text" name="ratiol" id="ratiol" /></td>
  119. </tr>
  120. <tr>
  121. <td><strong>Ratio Visitante</strong></td>
  122. <td><input type="text" name="ratiov" id="ratiov" /></td>
  123. </tr>
  124. <tr>
  125. <td><strong>Ratio Empate</strong></td>
  126. <td><input type="text" name="ratioe" id="ratioe" /></td>
  127. </tr>
  128. <tr>
  129. <td><strong>Sport ID (1 Futbol 2 Tennis)</strong></td>
  130. <td><input name="sportid" type="text" id="sportid" value="1" /></td>
  131. </tr>
  132. <tr>
  133. <td><strong>Comienzo (Ejemplo: 2012/05/07 14:00)</strong></td>
  134. <td><input name="start" type="text" id="start" value="2012/11/" /></td>
  135. </tr>
  136. <tr>
  137. <td><strong>Liga</strong></td>
  138. <td><label>
  139. <select name="liga" id="liga">
  140. <option value="LFP">A. Liga Española</option>
  141. <option value="BRA">B. Liga Brasilera</option>
  142. <option value="ARG">C. Liga Argentina</option>
  143. <option value="ITA">D. Liga Italiana</option>
  144. <option value="CHL">E. Champions League</option>
  145. <option value="EUL">F. Europa League</option>
  146. <option value="LIB">G. Copa Libertadores</option>
  147. <option value="SUD">H. Copa Sudamericana</option>
  148. <option value="ENG">I. Liga Inglesa</option>
  149. <option value="NBA">J. Basquet</option>
  150. <option value="ATP">K. Tennis</option>
  151. <option value="OTH">L. Otros</option>
  152. <option value="TUR">M. Liga Turquia</option>
  153. <option value="GER">N. Liga Alemania</option>
  154. <option value="FRA">O. Liga Francia</option>
  155. <option value="INT">P. Internacional</option>
  156. </select>
  157. </label></td>
  158. </tr>
  159. <tr>
  160. <td>&nbsp;</td>
  161. <td><div align="right">
  162.  
  163. <div align="left">
  164. <input type="submit" name="agendar" value="Cargar" />
  165. </div></td>
  166. </tr>
  167. </table></td>
  168. </tr>
  169. </table>
  170.  
  171.  
  172. <table width="424" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" bgcolor="#FFFFFF">
  173. <tr>
  174. <td width="315"><div align="center">(copiar exacto de <a href="http://www.livescore.in/" target="_blank">www.livescore.in</a>)</div></td>
  175. </tr>
  176. <tr>
  177. <td><div align="center"><a href="http://www.goleado.com.ar/bet/extra/logout.php"><img src="http://www.enlacepymes.com/enlaceb2b/images/logout.gif" alt="SALIR" width="32" height="32" /></a></div> </td>
  178. </tr>
  179. </table>
  180. <div align="center">
  181. <?php
  182. include('config.php');
  183.  
  184. $sql2 = "SELECT SUM(`money`) as jugador FROM `users` WHERE `status` ='0'";
  185. $result2 = mysql_query($sql2) or die(mysql_error());
  186. $r = mysql_fetch_array($result2, MYSQL_ASSOC);
  187.  
  188. $sql3 = "SELECT SUM(`enjuego`) as apostado FROM `users` WHERE `status` ='0'";
  189. $result3 = mysql_query($sql3) or die(mysql_error());
  190. $t = mysql_fetch_array($result3, MYSQL_ASSOC);
  191.  
  192. $sql4 = "SELECT SUM(`depositado`) as depositado FROM `users` WHERE status = 0";
  193. $result4 = mysql_query($sql4) or die(mysql_error());
  194. $w = mysql_fetch_array($result4, MYSQL_ASSOC);
  195.  
  196. $sql4 = "SELECT SUM(`depositado`) as depositado FROM `users` WHERE status = 1";
  197. $result4 = mysql_query($sql4) or die(mysql_error());
  198. $xx = mysql_fetch_array($result4, MYSQL_ASSOC);
  199.  
  200. $sql = "SELECT * FROM users WHERE userid='marketing'";
  201. $result = mysql_query($sql) or die(mysql_error());
  202. $d = mysql_fetch_array($result, MYSQL_ASSOC);
  203.  
  204. $tot_dep = $w[depositado];
  205. $en_apuesta = $t[apostado];
  206. $dinero_jug = $r[jugador];
  207. $marketing = $d[depositado];
  208. $div = $xx[depositado] - $marketing;
  209. $ganancia = $tot_dep - $en_apuesta - $dinero_jug - $div - $marketing;
  210.  
  211. ?>
  212. </div>
  213. </form>
  214. <table width="493" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#000000" bgcolor="#CCCCFF">
  215. <tr>
  216. <td width="276"> Total Depositado: </td>
  217. <td width="217">$
  218. <?=number_format($tot_dep, 2);?></td>
  219. </tr>
  220. <tr>
  221. <td>Dinero de Jugadores:</td>
  222. <td>$
  223. <?=number_format($dinero_jug, 2);?></td>
  224. </tr>
  225. <tr>
  226. <td>Apuestas en Progreso:</td>
  227. <td>$
  228. <?=number_format($en_apuesta, 2);?></td>
  229. </tr>
  230. <tr>
  231. <td>Marketing:</td>
  232. <td>$
  233. <?=number_format($marketing, 2) ;?></td>
  234. </tr>
  235. <tr>
  236. <td>Dividendos Pagados:</td>
  237. <td>$
  238. <?=number_format($div, 2); ?></td>
  239. </tr>
  240. <tr>
  241. <td>Ganancias Sin Repartir:</td>
  242. <td>$
  243. <?=number_format($ganancia, 2);?></td>
  244. </tr>
  245. </table>
  246.  
  247. <p>&nbsp;</p>
  248.  
  249. <div align="center"><a href="javascript:toggle();" id="displayText">Mostrar/Esconder Apuestas en Progreso</a>
  250. </div>
  251. <div id="toggleText" style="display: none;"><table width="54%" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#000000" bgcolor="#CCCCCC">
  252. <tr>
  253. <td colspan="5">
  254.  
  255. <div align="center">
  256. <?php
  257. include('config.php');
  258. $sql5 = "SELECT * FROM bets ORDER BY ticket";
  259. $result5 = mysql_query($sql5) or die (mysql_error());
  260.  
  261. while($r = mysql_fetch_array($result5))
  262. {
  263.  
  264. $sqlz = "SELECT * FROM events WHERE id =$r[eventid]";
  265. $resultz = mysql_query($sqlz) or die (mysql_error());
  266. $e = mysql_fetch_array($resultz) or die (mysql_error());
  267.  
  268. $mybetz .= "$e[hometeam] - $e[awayteam] </br>";
  269. $eventid .= "$r[eventid] </br>";
  270. $user .= "$r[userid] </br>";
  271. $seleccion .= "$r[bet] </br>";
  272. $dinero .= "$r[money] </br>";
  273. $ticket .= "$r[ticket] </br>";
  274. $pubdate .= "$r[pubdate] </br>";
  275.  
  276.  
  277.  
  278. }
  279.  
  280. ?>
  281. Apuestas en Progreso </div></td>
  282. <td>
  283.  
  284. Total Bets:
  285. <?php
  286. include('config.php');
  287. $sql = "SELECT `id` FROM `bets` GROUP BY `ticket`";
  288. $result = mysql_query($sql) or die(mysql_error());
  289. $total_bets_count = mysql_num_rows($result);
  290.  
  291. ?>
  292. <?php echo $total_bets_count; ?> </td>
  293. </tr>
  294. <tr>
  295. <td width="36%"><div align="center" class="style5">Event ID</div></td>
  296. <td width="14%"><div align="center" class="style5">Usuario</div></td>
  297. <td width="10%"><div align="center" class="style5">Seleccion</div></td>
  298. <td width="9%"><div align="center" class="style5">Dinero</div></td>
  299. <td width="12%"><div align="center" class="style5">Ticket</div></td>
  300. <td width="19%"><div align="center" class="style5">Pubdate</div></td>
  301. </tr>
  302.  
  303. <tr>
  304. <td><div align="center" class="style2"><?php echo $mybetz; ?></div></td>
  305. <td><div align="center" class="style2"><?php echo $user; ?></div></td>
  306. <td><div align="center" class="style2"><?php echo $seleccion; ?></div></td>
  307. <td><div align="center" class="style2"><?php echo $dinero; ?></div></td>
  308. <td><div align="center" class="style2"><?php echo $ticket; ?></div></td>
  309. <td><div align="center" class="style2"><?php echo $pubdate; ?></div></td>
  310. </tr>
  311. </table></div>
  312.  
  313.  
  314. <p>&nbsp;</p>
  315. <table width="54%" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#000000" bgcolor="#CCCCCC">
  316. <tr>
  317. <td colspan="6"><div align="center">
  318. <?php
  319. include('config.php');
  320. $sql5 = "SELECT * FROM users WHERE enjuego > 0 ORDER BY enjuego DESC";
  321. $result5 = mysql_query($sql5) or die (mysql_error());
  322.  
  323. while($w = mysql_fetch_array($result5))
  324. {
  325.  
  326. $jugador .= "$w[userid] </br>";
  327. $enjuego .= "$w[enjuego] </br>";
  328.  
  329. }
  330.  
  331. ?>
  332. Cantidad Apostada por Jugador</div></td>
  333. </tr>
  334. <tr>
  335. <td colspan="2"><div align="center" class="style5">Usuario</div> <div align="center" class="style2"><?php echo $jugador; ?></div></td>
  336. <td colspan="4"><div align="center" class="style5">Total en Apuestas</div> <div align="center" class="style2"><?php echo $enjuego; ?></div></td>
  337. </tr>
  338. </table>
  339. </td>
  340. </tr>
  341. </table>
  342.  
  343. </body>
  344.  
  345. </html>
Advertisement
Add Comment
Please, Sign In to add comment