M4_HAX0R

MySQL Database Manager

Jan 20th, 2016
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.97 KB | None | 0 0
  1. <?php
  2. #INJ3CTOR_M4
  3. if(isset($_POST['hstnm']) && isset($_POST['usrnm'])){
  4.     $_COOKIE["hstnm"] = trim($_POST['hstnm']);
  5.         /*AND*/ setcookie("hstnm", trim($_POST['hstnm']));
  6.     $_COOKIE["usrnm"] = trim($_POST['usrnm']);
  7.         /*AND*/ setcookie("usrnm", trim($_POST['usrnm']));
  8.     if(isset($_POST['psswrd'])){
  9.         $_COOKIE["psswrd"] = trim($_POST['psswrd']);
  10.             /*AND*/ setcookie("psswrd", trim($_POST['psswrd']));
  11.     }else{  $_COOKIE["psswrd"] == "";}
  12. }
  13. if(!isset($_COOKIE["hstnm"]) || !isset($_COOKIE["usrnm"])){
  14. echo'
  15. <center>
  16. <img src="http://i.imgur.com/TotOzm6.jpg">
  17. <br /><b><font size="3">MYSQL Manager.</b>
  18. <br />`MOROCCAN HAXORS`</font>
  19. <form method="POST">
  20. <pre>
  21. <b>Hostname:</b> <input name="hstnm" type="text" value="localhost"/>
  22. <b>Username:</b> <input name="usrnm" type="text"/>
  23. <b>Password:</b> <input name="psswrd" type="password"/><br />
  24. <input type="submit" value="Login >>" />
  25. </pre>
  26. ';
  27. exit;
  28. }
  29. ?>
  30. <style>
  31. body{
  32.     font-family: "Courier";
  33.     background-color: #F5F5F5;
  34.     margin: 8;
  35. }.input,select,textarea{
  36.     border:1px solid #4F4F4F; font-family:Courier; font-size:14px;
  37. }
  38. </style>
  39. <?php
  40. @set_time_limit(0);
  41. error_reporting(0);
  42. # MySQL Info ---------
  43. $hostname = $_COOKIE["hstnm"];
  44. $db_user= $_COOKIE["usrnm"];
  45. $db_pass= $_COOKIE["psswrd"];
  46. $db_name="information_schema";
  47. #---------------------
  48.  
  49. echo'
  50. <center>
  51. <table border="1" cellpadding="1" style="width: 100%; max-width: 1400px;">
  52. <tr>
  53.    <th>uname</th>
  54.    <td><u><font size="2" color="green">'.php_uname().'</font></u></td>
  55. </tr>
  56. <tr>
  57.    <th>PHP Version</th>
  58.    <td><u><font size="2" color="green">'.phpversion().'</font></u></td>
  59. </tr>
  60. <tr>
  61.    <th>MySQL Version</th>
  62.    <td><u><font size="2" color="green">'.mysql_get_server_info().'</font></u></td>
  63. </tr>
  64. </table>
  65. ';
  66. echo'
  67. <table border="1" cellpadding="1" style="width: 100%; max-width: 1400px;">
  68. <tr><td align="center"><b><font size="2">[ <a href="'.basename(__FILE__).'" >./HOME</a> ]</font></b></td></tr>
  69. ';
  70.  
  71. $conn = mysqli_connect($hostname, $db_user, $db_pass);
  72. if(!$conn){ die("<tr><td align='center'>Connection failed: " . mysqli_connect_error()." </tr></td>");   }
  73. if(!isset($_GET['db'])){
  74.     $e = mysqli_query($conn, "SHOW DATABASES");
  75.     while($row = mysqli_fetch_assoc($e)){
  76.         $databases[]= $row['Database'];
  77.     }
  78.     mysqli_free_result($e);
  79.     echo'</table><table border="1" cellpadding="1" style="width: 100%; max-width: 1400px;">';
  80.     echo'<td>Database</td><td>Action</td>';
  81.     foreach($databases as $database){
  82.         echo'<tr><th align="left"><small>'.$database.'</small></th>';
  83.         echo'<td><a href="?db='.$database.'" ><small>Afficher</small></a></td></tr>';
  84.     }
  85. }elseif(isset($_GET['db'])){
  86.     $db = $_GET['db'];
  87.     mysqli_select_db($conn, $db);
  88.     $e = mysqli_query($conn, "SHOW TABLES");
  89.     while($row = mysqli_fetch_assoc($e)){
  90.         $tables[]= $row['Tables_in_'.$db];
  91.     }
  92.     mysqli_free_result($e);
  93.     echo'</td></tr></table>';
  94.     echo'<table border="1" cellpadding="1" style="width: 100%; max-width: 1400px;">';
  95.     if(!isset($_GET['table'])){
  96.         echo'<td>Table</td><td>Action</td>';
  97.         foreach($tables as $table){
  98.             echo'<tr><th align="left"><small>'.$table.'</small></th>';
  99.             echo'<td><a href="?db='.$db.'&table='.$table.'" ><small>Afficher</small></a></td></tr>';
  100.         }
  101.            
  102.     }elseif(isset($_GET['table'])){
  103.         $table = $_GET['table'];
  104.         $e = mysqli_query($conn, "show columns from $table");
  105.         while($row = mysqli_fetch_assoc($e)){
  106.             $columns[]= $row['Field'];
  107.         }
  108.         mysqli_free_result($e);
  109.         if(isset($_GET['edit'])){
  110.             $num=$_GET['edit'];
  111.             echo'<tr>';
  112.             foreach($columns as $column){
  113.                 echo"<td><small><b>$column</b></small></td>";
  114.             }
  115.             echo"</tr><tr>";
  116.             $e = mysqli_query($conn, "SELECT * FROM `$table` LIMIT $num,1");
  117.             $row = mysqli_fetch_array($e, MYSQL_NUM);
  118.             for($i=0;$i<sizeof($row);$i++){
  119.                 echo"<td><small><form method='post'><input name='$columns[$i]$i' type='text' value='{$row[$i]}' /></small></td>";
  120.             }
  121.             echo'</tr></table><table border="1" cellpadding="1" style="width: 100%; max-width: 1400px;">';
  122.             echo'<tr><td align="center"><a href="?db='.$db.'&table='.$table.'">[Quitter >>]</a></td><td align="center"><small><br /><input name="update" type="submit" value="Executer >>"></form></small></td></tr>';
  123.             if(isset($_POST['update'])){
  124.                 for($i=0;$i<sizeof($row);$i++){
  125.                     $e = mysqli_query($conn, "UPDATE `$db`.`$table` SET `{$columns[$i]}` = '".$_POST["$columns[$i]$i"]."' where {$columns['0']} = {$row['0']}");
  126.                     mysqli_free_result($e);
  127.                 }
  128.             }
  129.         }elseif(!isset($_GET['edit'])){
  130.             echo'<tr><td><small><b>#</b></small></td>';
  131.             foreach($columns as $column){
  132.                 echo"<td><small><b>$column</b></small></td>";
  133.             }
  134.             echo'</tr>';
  135.             $e = mysqli_query($conn, "SELECT * FROM `$table`");
  136.             $count='0';
  137.             while($row = mysqli_fetch_assoc($e)){
  138.                 echo'<tr><td><a href="?db='.$db.'&table='.$table.'&edit='.$count.'"><small>Edit</small></a></td>';
  139.                 foreach($columns as $column){
  140.                     echo'<td><small>'.$row[$column].'</small></td>';
  141.                 }
  142.                 echo'</tr>';
  143.                 $count++;
  144.             }
  145.         }
  146.     }
  147. }
  148. mysqli_close($conn);
Advertisement
Add Comment
Please, Sign In to add comment