Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $lineaPar=1;
- function pegaform() {
- echo "<form action=\"insertar.php\" method=\"POST\">
- <TABLE border=\"0\">
- <TR>
- <TD>host:</TD>
- <TD><INPUT TYPE=\"password\" value=\"sql104.zobyhost.com\" NAME=\"host\" SIZE=\"20\" MAXLENGTH=\"30\"></TD>
- </TR>
- <TR>
- <TD>userid:</TD>
- <TD><INPUT TYPE=\"password\" value=\"zoby_5231271\" NAME=\"user\" SIZE=\"20\" MAXLENGTH=\"30\"></TD>
- </TR>
- <TR>
- <TD>password:</TD>
- <TD><INPUT TYPE=\"password\" NAME=\"pass\" SIZE=\"20\" MAXLENGTH=\"30\"></TD>
- </TR>
- </TABLE>
- <INPUT TYPE=\"submit\" NAME=\"accion\" VALUE=\"conectar\">
- </FORM>";
- }
- function conectar($host, $user, $pass) {
- $conex = mysql_connect($host, $user, $pass);
- /*if (mysql_select_db($db, $conex)) {
- return $conex;
- } else {
- print (mysql_error());
- }*/
- return $conex;
- }
- function desconectar($conex) {
- mysql_close($conex);
- }
- function insertar($host, $user, $pass) {
- if(isset($_COOKIE["PHPSESSID"]) && isset($_SESSION["pass"])) {
- // echo 'if(isset($_COOKIE["PHPSESSID"]) && isset($_SESSION["pass"])) { $pass'.$pass.' $_SESSION["pass"]'.$_SESSION["pass"];
- if ($load=0) {
- if (isset($_POST["nombre"])) {
- if (isset($_SESSION['host']) && isset($_SESSION['user']) && isset($_SESSION['pass'])) {
- $conex=conectar($_SESSION['host'], $_SESSION['user'], $_SESSION['pass']);
- if (mysql_select_db("zoby_5231271_lj", $conex)) {
- if ($result=mysql_query("INSERT INTO juegos VALUES ('".$_POST["nombre"]."',".$_POST["discos"].",'".$_POST["reg"]."',".$_POST["w"].",".$_POST["ss"].",".$_POST["st"].",'".$_POST["audio"]."','".$_POST["text"]."') ",$conex)) {
- echo $result.' <table border=0><tr><td>'.$_POST["nombre"].'</td><td>'.$_POST["discos"].'</td><td>'.$_POST["reg"].'</td><td>'.$_POST["w"].'</td><td>'.$_POST["ss"].'</td><td>'.$_POST["st"].'</td><td>'.$_POST["audio"].'</td><td>'.$_POST["text"].'</td><td>'.$conex.'</td></tr></table>';
- } else {
- print (mysql_error());
- }
- } else {
- print (mysql_error());
- }
- desconectar($conex);
- } else {
- echo "Faltan datos de loggeo<br> Redireccionando<br><meta http-equiv=\"refresh\" content=\"5;URL=admin.php\">";
- }
- }
- } elseif ($load=1) {
- $tablaHtml=$_POST['tablahtml'];
- if (isset($tablaHtml)) {
- tablaHtml($tablaHtml);
- }
- }
- echo"<form name=\"form1\" method=\"post\" action=\"insertar.php?load=0\">
- <table>
- <tr>
- <td>Juego</td><td>DVDs</td><td>Region</td><td>Wave</td><td>SSv</td><td>Stealth</td><td>Audio</td><td>Textos, Subs.</td>
- </tr>
- <tr>
- <td><input type=\"text\" name=\"nombre\"></td><td><input type=\"text\" name=\"discos\"></td><td><input type=\"text\" name=\"reg\"></td><td><input type=\"text\" name=\"w\"></td><td><input type=\"text\" name=\"ss\"></td><td><input type=\"text\" name=\"st\"></td><td><input type=\"text\" name=\"audio\"></td><td><input type=\"text\" name=\"text\"></td>
- </tr>
- <tr>
- <td><input type=\"submit\" name=\"Submit\" value=\"Insertar datos\"></td>
- </tr>
- </table>
- </form><br>
- <form name=\"form2\" method=\"post\" action=\"insertar.php?load=1\">
- <table>
- <tr>
- <td>cargar desde tabla html</td>
- </tr>
- <tr>
- <td><textarea name=\"tablahtml\" cols=\"80\" rows=\"20\"></textarea></td>
- </tr>
- <tr>
- <td><input type=\"submit\" name=\"Submit\" value=\"Cargar Tabla\"></td>
- </tr>
- </table>
- </form>";
- } else {
- // echo 'ELSEif(isset($_COOKIE["PHPSESSID"]) && isset($_SESSION["pass"])) { $pass'.$pass.' $_SESSION["pass"]'.$_SESSION["pass"];
- if (isset($host, $user, $pass)) {
- // echo 'ELSEif(isset($_COOKIE["PHPSESSID"]) && isset($_SESSION["pass"])) {<br>if (isset($host, $user, $pass)) { $pass'.$pass.' $_SESSION["pass"]'.$_SESSION["pass"];
- $_SESSION['host']=$host;
- $_SESSION['user']=$user;
- $_SESSION['pass']=$pass;
- } else {
- echo "Faltan datos de loggeo<br> Redireccionando<br><meta http-equiv=\"refresh\" content=\"5;URL=admin.php\">";
- }
- }
- }
- function mostrar() {
- $conex=conectar("sql104.zobyhost.com", "zoby_5231271", "m4Sj0D10");
- mysql_select_db("zoby_5231271_lj", $conex);
- $result=mysql_query("SELECT * FROM juegos ORDER BY Juego",$conex);
- echo"<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#999999\">
- <tr bgcolor=\"#FFFF66\">
- <td width=\"35%\"> <div align=\"left\"><font face=\"MS Serif\">Juego</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">DVDs</font></div></td>
- <td width=\"20%\"> <div align=\"center\"><font face=\"MS Serif\">Region</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">Wave</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">SSv</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">Stealth</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">Audio</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">Textos, Subs.</font></div></td>
- </tr>
- ";
- while($row=mysql_fetch_row($result)){
- if (!is_odd($lineaPar)) {
- echo"<tr>
- <td width=\"35%\"><div align=\"left\"><font face=\"MS Serif\">$row[0]</font></div></td>
- <td width=\"5%\"><div align=\"center\"><font face=\"MS Serif\">$row[1]</font></div></td>
- <td width=\"20%\"> <div align=\"center\"><font face=\"MS Serif\">$row[2]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[3]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[4]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[5]</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">$row[6]</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">$row[7]</font></div></td>
- </tr>";
- $lineaPar++;
- } else if (is_odd($lineaPar)) {
- echo"<tr bgcolor=\"#99CCCC\">
- <td width=\"35%\"><div align=\"left\"><font face=\"MS Serif\">$row[0]</font></div></td>
- <td width=\"5%\"><div align=\"center\"><font face=\"MS Serif\">$row[1]</font></div></td>
- <td width=\"20%\"> <div align=\"center\"><font face=\"MS Serif\">$row[2]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[3]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[4]</font></div></td>
- <td width=\"5%\"> <div align=\"center\"><font face=\"MS Serif\">$row[5]</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">$row[6]</font></div></td>
- <td width=\"15%\"> <div align=\"center\"><font face=\"MS Serif\">$row[7]</font></div></td>
- </tr>";
- $lineaPar++;
- }
- } /* else {
- print (mysql_error());
- }*/
- echo"</table>";
- desconectar($conex);
- }
- function is_odd($number) {
- return $number & 1; // 0 = par, 1 = impar
- }
- function tablaHtml($tablaHtml) {
- $ElCualo = array("<TR VALIGN=TOP>
- <TD WIDTH=40%>
- <P STYLE=\"font-weight: normal\"><FONT COLOR=\"#000000\"><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2>",
- "</FONT></FONT></FONT></P>
- </TD>
- <TD WIDTH=6% SDVAL=\"1\" SDNUM=\"3082;\">
- <P ALIGN=CENTER STYLE=\"font-weight: normal\"><FONT COLOR=\"#000000\"><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2>",
- "</FONT></FONT></FONT></P>
- </TD>
- <TD WIDTH=15%>
- <P ALIGN=CENTER STYLE=\"font-weight: normal\"><FONT COLOR=\"#000000\"><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2>",
- "</FONT></FONT></FONT></P>
- </TD>
- <TD WIDTH=6% SDVAL=\"4\" SDNUM=\"3082;\">
- <P ALIGN=CENTER STYLE=\"font-weight: normal\"><FONT COLOR=\"#000000\"><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2>",
- "</FONT></FONT></FONT></P>
- </TD>
- <TD WIDTH=5% SDVAL=\"1\" SDNUM=\"3082;\">
- <P ALIGN=CENTER STYLE=\"font-weight: normal\"><FONT COLOR=\"#000000\"><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2>",
- "</FONT></FONT></FONT></P>
- </TD>
- <TD WIDTH=7%>
- <P ALIGN=CENTER STYLE=\"font-weight: normal\"><FONT COLOR=\"#000000\"><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2>",
- "</FONT></FONT></FONT></P>
- </TD>
- <TD WIDTH=9%>
- <P ALIGN=CENTER STYLE=\"font-weight: normal\"><FONT COLOR=\"#000000\"><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2><SPAN STYLE=\"background: transparent\">",
- "</SPAN></FONT></FONT></FONT></P>
- </TD>
- <TD WIDTH=13%>
- <P ALIGN=CENTER STYLE=\"font-weight: normal\"><FONT COLOR=\"#000000\"><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2><SPAN STYLE=\"background: transparent\">",
- "</SPAN></FONT></FONT></FONT></P>
- </TD>
- </TR>");
- $PorElCualo=array("", " ", " ", " ", " ", " ", " ", " ", "");
- $a = htmlentities($tablaHtml); // usar $a con str_replace <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- $lineas=substr_count($a, htmlentities("<TR VALIGN=TOP>"));
- for ( $k = 1 ; $k <= $lineas ; $k++) {
- $posS=strpos($a, htmlentities("<TR VALIGN=TOP>"), $k);
- $posE=strpos($a, htmlentities("</TR>"), $k)+11;
- if ($k>1) {
- //y tu dirás, esto para que? rectifica los cuelgues del strpos()
- $g=$k;
- while ($posS<=$overS) {
- $g++;
- $posS=strpos($a, htmlentities("<TR VALIGN=TOP>"), $g);
- }
- }
- //lo mismo q lo de arriba
- $f=$k;
- while ($posE<$posS) {
- $f++;
- $posE=strpos($a, htmlentities("</TR>"), $f)+11;
- }
- //no se porque, pero substr también se cuelga a partir de la 2º vuelta
- if ($k>1) {
- $posE=$posE+2;
- }
- /* esto solventa un fallo gordo que tenia, le daba $posE como
- * final y eso hace que pilla ese parametro como caracteres a contar
- * hasta el final y no la posicion del caracter final, hago la resta
- * y listo
- */
- $posEnd=$posE-$posS;
- // echo '$posStart['.$k.'] '.$posS.' ';
- // echo '- $posEnd['.$k.'] '.$posE.' = '.$posEnd.'<br>';
- $lineaHtml=substr($a, $posS, $posEnd);
- $aBece = str_replace($ElCualo, $PorElCualo, $lineaHtml);
- // echo '$aBece['.$k.'] '.html_entity_decode($aBece).'<br>';
- $overS=$posS; //variables de override, para que no se atasque strpos()
- $overE=$posE; //variables de override, para que no se atasque strpos()
- $datosMySQL = explode(" ", $aBece); // cortamos el string por el punto
- /* for ( $j = 0 ; $j <= count($datosMySQL) ; $j ++) {
- echo '$datosMySQL['.$j.'] '.html_entity_decode($datosMySQL[$j]).'<br>';
- }*/
- $datosMySQL[6]=html_entity_decode($datosMySQL[6]);
- $datosMySQL[7]=html_entity_decode($datosMySQL[7]);
- //echo '$k'.$k.' $posS'.$posS.' $posE'.$posE.' $datosMySQL '.html_entity_decode($datosMySQL[0]).' '.html_entity_decode($datosMySQL[1]).' '.html_entity_decode($datosMySQL[2]).' '.html_entity_decode($datosMySQL[3]).' '.html_entity_decode($datosMySQL[4]).' '.html_entity_decode($datosMySQL[5]).' '.$datosMySQL[6].' '.$datosMySQL[7].'<br>';
- // echo $datosMySQL[6].' '.$datosMySQL[7].'<br>';
- if (isset($_SESSION['host']) && isset($_SESSION['user']) && isset($_SESSION['pass'])) {
- $conex=conectar($_SESSION['host'], $_SESSION['user'], $_SESSION['pass']);
- if (mysql_select_db("zoby_5231271_lj", $conex)) {
- if ($result=mysql_query("INSERT INTO juegos VALUES ('".$datosMySQL[0]."',".$datosMySQL[1].",'".$datosMySQL[2]."',".$datosMySQL[3].",".$datosMySQL[4].",".$datosMySQL[5].",'".html_entity_decode($datosMySQL[6],ENT_QUOTES)."','".html_entity_decode($datosMySQL[7],ENT_QUOTES)."') ",$conex)) {
- echo $result.' <table border=0><tr><td>'.$datosMySQL[0].'</td><td>'.$datosMySQL[1].'</td><td>'.$datosMySQL[2].'</td><td>'.$datosMySQL[3].'</td><td>'.$datosMySQL[4].'</td><td>'.$datosMySQL[5].'</td><td>'.$datosMySQL[6].'</td><td>'.$datosMySQL[7].'</td><td>'.$conex.'</td></tr></table>';
- } else {
- print (mysql_error());
- }
- } else {
- print (mysql_error());
- }
- desconectar($conex);
- } else {
- echo "faltan datos para conectar a MySQL. host=".$_SESSION['host']." user=".$_SESSION['user']." pass=".$_SESSION['pass'];
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement