Просмотр файла sql.php

Размер файла: 1.78Kb
  1. <?php
  2.  
  3. header("Content-type: text/vnd.wap.wml; charset=utf-8");
  4.  
  5. echo '<?xml version="1.0"?>
  6. <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
  7. <wml>
  8. <card id="main" title=".:SQL =&#xbb; MySQL:."><p align="left">';
  9.  
  10. if($mode!="do")
  11.  
  12. {
  13.  
  14. echo 'MySQL host:<br/>
  15. <input name="host" value="localhost"/>
  16. <br/>MySQL DataBase Name:<br/>
  17. <input name="db"/><br/>
  18. MySQL User Name:<br/>
  19. <input name="user"/><br/>
  20. MySQL Password:<br/>
  21. <input name="password"/><br/>
  22. SQL File address (full or local):<br/>
  23. <input name="address" value="http://"/>
  24. <br/><anchor>GO!
  25. <go href="'.$_SERVER['PHP_SELF'].'?mode=do" method="post">
  26. <postfield name="host" value="$(host)"/>
  27. <postfield name="db" value="$(db)"/>
  28. <postfield name="user" value="$(user)"/>
  29. <postfield name="password" value="$(password)"/>
  30. <postfield name="address" value="$(address)"/>
  31. </go></anchor>';
  32.  
  33. }
  34.  
  35. if($mode=="do")
  36.  
  37. {
  38.  
  39. $data=@file_get_contents($address) or die("Could not read ".$address."! </p></card></wml>");
  40.  
  41. $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);
  42.  
  43. $connect=mysql_connect($host, $user, $password) or die("Could not connect with MySQL server Because ".mysql_error()."</p></card></wml>");
  44.  
  45. @mysql_select_db($db) or die("Could not select the database because ".mysql_error()."</p></card></wml>");
  46.  
  47. $i=0;
  48. $ie=0;
  49.  
  50. foreach($queryes as $query)
  51. {
  52. if(!@mysql_query($query))
  53. {
  54. echo '<strong>ERROR!</strong><br/>
  55. <u>query:</u> '.$query.'<br/>
  56. <u>server reply:</u> '.mysql_error().'<br/>------<br/>';
  57. $ie++;
  58. }
  59. else $i++;
  60. }
  61.  
  62. if($ie=="0")
  63. echo 'Process finish!<br/>We have all '.$i. 'query and 0 errors!';
  64. else echo 'We have '.($i+$ie).' query. '.$ie.' errors!';
  65.  
  66. @mysql_close();
  67.  
  68. }
  69.  
  70. echo '</p></card></wml>';
  71.  
  72. ?>