View file cat/sql.php

File size: 2.02Kb
<?php

 /*
  *
  * Small php script for
  * import queryes
  * from SQL-file to
  * MySQL Server
  * written by myp3uk
  * [email protected]
  * 899545
  *
  */

header("Content-type: text/vnd.wap.wml; charset=utf-8");

echo '<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="main" title=".:SQL =&#xbb; MySQL:."><p align="left">';

if($mode!="do")

{

echo 'MySQL host:<br/>
<input name="host" value="localhost"/>
<br/>MySQL DataBase Name:<br/>
<input name="db"/><br/>
MySQL User Name:<br/>
<input name="user"/><br/>
MySQL Password:<br/>
<input name="password"/><br/>
SQL File address (full or local):<br/>
<input name="address" value="http://"/>
<br/><anchor>GO!
<go href="'.$_SERVER['PHP_SELF'].'?mode=do" method="post">
<postfield name="host" value="$(host)"/>
<postfield name="db" value="$(db)"/>
<postfield name="user" value="$(user)"/>
<postfield name="password" value="$(password)"/>
<postfield name="address" value="$(address)"/>
</go></anchor>';

}

if($mode=="do")

{

$data=@file_get_contents($address) or die("Could not read ".$address."! </p></card></wml>");

$queryes=preg_split("#(SELECT|CREATE|DROP|UPDATE|INSERT|SHOW|REVOKE|MATCH|LIKE|GRANT|DESCRIBE|OPTIMIZE|COUNT|ALTER|AGAINST|)[-a-z0-9_.:@&?=+,!/~*'%$\"\s\n]*;[^-)]#i", $data);

$connect=mysql_connect($host, $user, $password) or die("Could not connect with MySQL server Because ".mysql_error()."</p></card></wml>");

@mysql_select_db($db) or die("Could not select the database because ".mysql_error()."</p></card></wml>");

$i=0;
$ie=0;

foreach($queryes as $query)
{

$trim=trim($query);
if(!$query or $trim=="")
continue;
if(!@mysql_query($query))
{
echo '<strong>ERROR!</strong><br/>
<u>query:</u> '.$query.'<br/>
<u>server reply:</u> '.mysql_error().'<br/>------<br/>';
$ie++;
}
else $i++;
}

if($ie=="0")
echo 'Process finish!<br/>We have all '.$i. 'query and 0 errors!';
else echo 'We have '.($i+$ie).' query. '.$ie.' errors!';

@mysql_close();

}

echo '<br/><anchor>Go Back<prev/></anchor></p></card></wml>';

?>