Advertisement
H4T3D

PHP NO ADMIN (MYSQL)

Aug 21st, 2015
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.25 KB | None | 0 0
  1. <?php
  2.  
  3. // PhpNoAdmin (Handle Administration of MySQL in single page)
  4.  
  5. #########################################
  6. #Database: db4free.net          
  7. #Username: phpnoadmin                  
  8. #Email: [email protected]          
  9. #Password : phpnoadmin
  10. #Demo : http://phpnoadmin.16mb.com
  11. #Download : http://pastebin.com/CqRiZdmy
  12. #Coded By : H4T3D
  13. #Changing Name Wont Make You l33t -_-          
  14. #########################################
  15.  
  16.  
  17. define('VERSION','1.0');
  18. error_reporting(0);
  19. ini_set('error_log',NULL);
  20. ini_set('log_errors',0);
  21. ini_set('max_execution_time',0);
  22. set_time_limit(0);
  23. set_magic_quotes_runtime(0);
  24.  
  25.  
  26. ob_end_clean();
  27. ob_start();
  28. $servername = "db4free.net";
  29. $username = "phpnoadmin";
  30. $password = "phpnoadmin";
  31.  
  32.  
  33. echo '
  34. <head>
  35. <style>
  36. table, td {
  37. border: 3px solid black;
  38.    width:100%;
  39. }
  40.  
  41. th{
  42. border: 3px solid black;
  43.    width:100%;
  44. color: blue;
  45. }
  46.  
  47.  
  48. ///////////////
  49.  
  50.  
  51. #wrapper {
  52.    padding-left: 0;
  53.    -webkit-transition: all 0.5s ease;
  54.    -moz-transition: all 0.5s ease;
  55.    -o-transition: all 0.5s ease;
  56.    transition: all 0.5s ease;
  57. }
  58.  
  59. #wrapper.toggled {
  60.    padding-left: 250px;
  61. }
  62.  
  63. #sidebar-wrapper {
  64.    z-index: 1000;
  65.    position: fixed;
  66.    left: 250px;
  67.    width: 0;
  68.    height: 100%;
  69.    margin-left: -250px;
  70.    overflow-y: auto;
  71.    background: #000;
  72.    -webkit-transition: all 0.5s ease;
  73.    -moz-transition: all 0.5s ease;
  74.    -o-transition: all 0.5s ease;
  75.    transition: all 0.5s ease;
  76. }
  77.  
  78. #wrapper.toggled #sidebar-wrapper {
  79.    width: 250px;
  80. }
  81.  
  82. #page-content-wrapper {
  83.    width: 100%;
  84.    position: absolute;
  85.    padding: 15px;
  86. }
  87.  
  88. #wrapper.toggled #page-content-wrapper {
  89.    position: absolute;
  90.    margin-right: -250px;
  91. }
  92.  
  93. /* Sidebar Styles */
  94.  
  95. .sidebar-nav {
  96.    position: absolute;
  97.    top: 0;
  98.    width: 250px;
  99.    margin: 0;
  100.    padding: 0;
  101.    list-style: none;
  102. }
  103.  
  104. .sidebar-nav li {
  105.    text-indent: 20px;
  106.    line-height: 40px;
  107. }
  108.  
  109. .sidebar-nav li a {
  110.    display: block;
  111.    text-decoration: none;
  112.    color: #999999;
  113. }
  114.  
  115. .sidebar-nav li a:hover {
  116.    text-decoration: none;
  117.    color: #fff;
  118.    background: rgba(255,255,255,0.2);
  119. }
  120.  
  121. .sidebar-nav li a:active,
  122. .sidebar-nav li a:focus {
  123.    text-decoration: none;
  124. }
  125.  
  126. .sidebar-nav > .sidebar-brand {
  127.    height: 65px;
  128.    font-size: 18px;
  129.    line-height: 60px;
  130. }
  131.  
  132. .sidebar-nav > .sidebar-brand a {
  133.    color: #999999;
  134. }
  135.  
  136. .sidebar-nav > .sidebar-brand a:hover {
  137.    color: #fff;
  138.    background: none;
  139. }
  140.  
  141. @media(min-width:768px) {
  142.    #wrapper {
  143.        padding-left: 250px;
  144.    }
  145.  
  146.    #wrapper.toggled {
  147.        padding-left: 0;
  148.    }
  149.  
  150.    #sidebar-wrapper {
  151.        width: 250px;
  152.    }
  153.  
  154.    #wrapper.toggled #sidebar-wrapper {
  155.        width: 0;
  156.    }
  157.  
  158.    #page-content-wrapper {
  159.        padding: 20px;
  160.        position: relative;
  161.    }
  162.  
  163.    #wrapper.toggled #page-content-wrapper {
  164.        position: relative;
  165.        margin-right: 0;
  166.    }
  167. }
  168.  
  169. </style>
  170. <link href="http://ironsummitmedia.github.io/startbootstrap-simple-sidebar/css/bootstrap.min.css" rel="stylesheet">
  171. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
  172.  
  173. </head>
  174. ';
  175. echo '<body>';
  176. function headers(){
  177. echo'<div id="page-content-wrapper">
  178.            <div class="container-fluid">
  179.                <div class="row">
  180.                    <div class="col-lg-12">';
  181. }
  182.  
  183. function footer(){
  184.  
  185. echo' </div>
  186. </div>
  187.                </div>
  188.            </div>
  189.        </div>';
  190. }
  191.  
  192.  
  193. echo'<div id="wrapper"><div id="sidebar-wrapper">
  194.            <ul class="sidebar-nav">
  195. <img src="http://s4.postimg.org/jrc7m0j9p/g_gif_update_1.gif">
  196.                <li class="sidebar-brand">
  197.                    <a href="?">
  198.                        <i><font color="white" size="3">php</font><b><font color="yellow" size="3">NOAdmin</font></a></b></i>
  199.                    </a>
  200.                </li>
  201.                <li >
  202.                    <a href="?" class="fa fa-database fa-lg" > DataBase</a></br>
  203.                </li>
  204.                <li>
  205.                    <a href="?info" class="fa fa-info-circle fa-lg" > System Info</a></br>
  206.                </li>
  207.                <li>
  208.                    <a href="?phpinfo" class="fa fa-info fa-lg" > PHP Info</a></br>
  209.                </li>
  210.                <li>
  211.                    <a href="?import" class="fa fa-upload fa-lg" > Import</a></br>
  212.                </li>
  213.                  <li>
  214.                    <a href="?export" class="fa fa-download fa-lg" > Export</a></br>
  215.                </li>
  216.                <li>
  217.                    <a href="?sql" class="fa fa-terminal fa-lg" > Sql Query</a></br>
  218.                </li>
  219.                 <li>
  220.                    <a href="?users" class="fa fa-users fa-lg" > Users</a></br>
  221.                </li>
  222.                
  223.                 <li>
  224.                    <a href="?search" class="fa fa-search fa-lg" > Search</a></br>
  225.                </li>
  226.                <li>
  227.                    <a href="http://dev.mysql.com/doc/refman/5.6/en/index.html" class="fa fa-file-text-o fa-lg" > Reference </a></br>
  228.                </li>
  229.              
  230.            </ul>
  231.        </div>';
  232. ob_start();
  233. headers();
  234. // Check connection
  235. if (!($conn = mysql_connect($servername, $username, $password))) {
  236.     die("Connection failed: " . $conn->connect_error);
  237. }
  238.  
  239.           $result = mysql_query("SHOW DATABASES");
  240.          
  241.           echo'<h3><i class="fa fa-database fa-lg"> Databases </i> </h3><hr></hr>';
  242.            echo "<code> Query : SHOW DATABASES </code><br></br>";
  243.           while ($row = mysql_fetch_array($result)) {  
  244.      
  245.     echo "<ul><li><a href=?dbname=".$row[0].">".$row[0]."</a></li></ul>";
  246.  
  247.  
  248. }//shuru ka show database
  249.  
  250. footer();
  251.  
  252.  
  253. // Show Tables From DataBase
  254.  
  255. if(isset($_GET['dbname'])){
  256.  
  257. ob_end_clean();
  258.  
  259. ob_start();
  260. headers();
  261. $dbname=$_GET['dbname'];
  262. echo "<h3> Database :".$dbname."</h3></br>";
  263. echo '<i class="fa fa-table fa-2x">
  264. Tables From '.$dbname.'</i><br></br>';
  265.  
  266.  
  267.   $sql = "SHOW tables FROM $dbname";
  268. echo "<code> Query : $sql </code><br></br>";
  269. $result = mysql_list_tables($dbname);
  270.  
  271. while ($row = mysql_fetch_row($result)) {
  272.  
  273.          print "<ul> <li><a href='?dbname=$dbname&tbl=$row[0]'>$row[0]</a></li></ul>";
  274.  
  275.        
  276.        
  277.     }
  278.  
  279. footer();
  280.  
  281.  
  282.  
  283. }// end of show Database Tables
  284.  
  285.  
  286.  
  287.  
  288.  
  289. // Show Rows From Tables
  290.  
  291. if(isset($_GET['tbl'])){
  292.  
  293. ob_end_clean();
  294. ob_start();
  295. headers();
  296.  
  297. // Check connection
  298. if (!($conn = mysql_connect($servername, $username, $password))) {
  299.     die("Connection failed: " . $conn->connect_error);
  300. }
  301.  
  302. $tbl=$_GET['tbl'];
  303.  
  304. echo '<div class="main">';
  305. echo "<h3> Database :".$dbname."</h3></br>";
  306. echo "<h3> Table :".$tbl."</h3></br>";
  307.  
  308. $conn = new mysqli($servername, $username, $password);
  309.  
  310.   $sql = "Select * FROM $dbname.$tbl";
  311.  
  312. echo "<code> Query : $sql </code><br></br>";
  313.  
  314. $result = $conn->query($sql);
  315.  
  316. if ($result->num_rows > 0) {
  317.     // output data of each row
  318.     while($row = $result->fetch_assoc()) {
  319.  
  320. echo"<center><table><tr>";
  321. foreach ($row as $name => $value) {
  322.  
  323.  echo "<tr><th>$name</th></tr><tr><td>$value</td><td ><a href='?sql&sqls=UPDATE $dbname.$tbl SET $name= WHERE $name=$value' class=\"fa fa-pencil\">Edit</a><td><td><a href='?sql&sqls=DELETE FROM $dbname.$tbl WHERE $name=$value' class=\"fa fa-trash-o\" >Delete</a><td></tr>";
  324. }
  325.  
  326.  
  327.  
  328. echo"<tr></table></center>";
  329.  
  330.  }
  331.  
  332.  
  333. }
  334.  
  335. else {
  336.  
  337. echo'<div class="form-group has-success"><div class="alert alert-success alert-dismissable">
  338.                                <button type="button" class="close fa fa-check" data-dismiss="alert" aria-hidden="true">×</button>
  339.           Mysql Query was Valid</br><hr></hr><a href="#" class="alert-link">MySQL returned an empty result set (i.e. zero rows)</a>.
  340.                            </div></div>';
  341.  
  342.  
  343. }
  344.  
  345. echo'</div>';
  346.  
  347.  
  348. footer();
  349.  
  350. }// end of show Database Tables
  351.  
  352.  
  353.  
  354.  
  355. if(isset($_GET['export'])){
  356.  
  357. ob_end_clean();
  358.  
  359. ob_start();
  360.  
  361. headers();
  362.  
  363.  
  364. echo'<h3>Export Database</h3><hr></hr>';
  365.  
  366. echo"When you export a database, you are creating a backup file of the database. This backup file is usually a .sql file (a text file), and can be used to copy and import the database onto another server. In this article we'll show you how to export your database.<br></br>";
  367. echo'<h5>Select Database</h5>';
  368. echo '<form action="" method="POST" >
  369. <select name="dbname">';
  370.  
  371.           $result = mysql_query("SHOW DATABASES");
  372.           echo'<h3><i class="fa fa-database fa-2x"> Databases : </i> </h3>';
  373.           while ($row = mysql_fetch_array($result)) {  
  374.      
  375.            echo "<option value='".$row[0]."'>".$row[0]."</option>";
  376.  
  377.  
  378. }
  379.  
  380. echo'</select><br></br><select name="filetype">
  381.  
  382. <option value="filetype_sql">SQL</option>
  383. <option value="filetype_txt">TXT</option>
  384.  
  385. </select><br></br><input type="submit" value="Export" class="btn btn-default" ></form>';
  386.  
  387. if(isset($_POST['dbname'])){
  388.  
  389. $DbName=$_POST['dbname'];
  390.  
  391. function Export_Database($host,$user,$pass,$name,  $tables=false, $backup_name=false )
  392. {
  393.     $mysqli = new mysqli($host,$user,$pass,$name);
  394.     $mysqli->select_db($name);
  395.     $mysqli->query("SET NAMES 'utf8'");
  396.  
  397.     $queryTables    = $mysqli->query('SHOW TABLES');
  398.     while($row = $queryTables->fetch_row())
  399.     {
  400.         $target_tables[] = $row[0];
  401.     }  
  402.     if($tables !== false)
  403.     {
  404.         $target_tables = array_intersect( $target_tables, $tables);
  405.     }
  406.     foreach($target_tables as $table)
  407.     {
  408.         $result         =   $mysqli->query('SELECT * FROM '.$table);  
  409.         $fields_amount  =   $result->field_count;  
  410.         $rows_num=$mysqli->affected_rows;    
  411.         $res            =   $mysqli->query('SHOW CREATE TABLE '.$table);
  412.         $TableMLine     =   $res->fetch_row();
  413.         $content        = (!isset($content) ?  '' : $content) . "\n\n".$TableMLine[1].";\n\n";
  414.  
  415.         for ($i = 0, $st_counter = 0; $i < $fields_amount;   $i++, $st_counter=0)
  416.         {
  417.             while($row = $result->fetch_row())  
  418.             { //when started (and every after 100 command cycle):
  419.                 if ($st_counter%100 == 0 || $st_counter == 0 )  
  420.                 {
  421.                         $content .= "\nINSERT INTO ".$table." VALUES";
  422.                 }
  423.                 $content .= "\n(";
  424.                 for($j=0; $j<$fields_amount; $j++)  
  425.                 {
  426.                     $row[$j] = str_replace("\n","\\n", addslashes($row[$j]) );
  427.                     if (isset($row[$j]))
  428.                     {
  429.                         $content .= '"'.$row[$j].'"' ;
  430.                     }
  431.                     else
  432.                     {  
  433.                         $content .= '""';
  434.                     }    
  435.                     if ($j<($fields_amount-1))
  436.                     {
  437.                             $content.= ',';
  438.                     }      
  439.                 }
  440.                 $content .=")";
  441.                 //every after 100 command cycle [or at last line] ....p.s. but should be inserted 1 cycle eariler
  442.                 if ( (($st_counter+1)%100==0 && $st_counter!=0) || $st_counter+1==$rows_num)
  443.                 {  
  444.                     $content .= ";";
  445.                 }
  446.                 else
  447.                 {
  448.                     $content .= ",";
  449.                 }
  450.                 $st_counter=$st_counter+1;
  451.             }
  452.         } $content .="\n\n\n";
  453.     }
  454.     //$backup_name = $backup_name ? $backup_name : $name."___(".date('H-i-s')."_".date('d-m-Y').")__rand".rand(1,11111111).".sql";
  455.    
  456.  
  457.  
  458.  
  459.  
  460. $filetype=$_POST['filetype'];
  461.  
  462. if($filetype=="filetype_sql")
  463. {
  464.  
  465. $backup_name = $backup_name ? $backup_name : $name.".sql";
  466.  
  467. $myfile=fopen("$backup_name", "w") or die("Unable to open file!");
  468. fwrite($myfile,$content);
  469. fclose($myfile);
  470.  
  471. echo'<div class="alert alert-info fade in">
  472.    <a href="#" class="close" data-dismiss="alert" aria-label="close" title="close">×</a>
  473.    <strong>Export : </strong> '.$backup_name.' Exported Successfully!
  474. </div>';
  475.  
  476. exit;
  477.  
  478.  
  479. }
  480. else
  481. {
  482.  
  483. $backup_name = $backup_name ? $backup_name : $name.".txt";
  484.  
  485.  
  486. $myfile=fopen("$backup_name", "w") or die("Unable to open file!");
  487. fwrite($myfile,$content);
  488. fclose($myfile);
  489.  
  490. echo'<div class="alert alert-info fade in">
  491.    <a href="#" class="close" data-dismiss="alert" aria-label="close" title="close">×</a>
  492.    <strong>Export : </strong> '.$backup_name .' Exported Successfully!
  493. </div>';
  494. exit;
  495.  
  496.  
  497. }
  498.  
  499.  
  500.  
  501.  
  502. }
  503.  
  504. Export_Database($servername,$username,$password,$DbName,$tables=false, $backup_name=false );
  505.  
  506. footer();
  507.  
  508. }
  509.  
  510. }
  511.  
  512.  
  513.  
  514. if(isset($_GET["info"])){
  515.  
  516. ob_end_clean();
  517. ob_start();
  518. function convertByte($s) {
  519. if($s >= 1073741824)
  520. return sprintf('%1.2f',$s / 1073741824 ).' GB';
  521. elseif($s >= 1048576)
  522. return sprintf('%1.2f',$s / 1048576 ) .' MB';
  523. elseif($s >= 1024)
  524. return sprintf('%1.2f',$s / 1024 ) .' KB';
  525. else
  526. return $s .' B';
  527. }
  528. $ssys = "None";
  529. if(is_dir("/usr/local/cpanel")){
  530. $ssys = "Running On Cpanel";
  531. }elseif(is_dir("/usr/local/directadmin")){
  532. $ssys = "Running On Directadmin";
  533. }
  534.  
  535. if( ini_get('safe_mode') ){
  536. $smde = " ON" ;
  537. }else{
  538. $smde = " OFF" ; }
  539.  
  540.  
  541. function showdisablefunctions() {
  542.     if ($disablefunc=@ini_get("disable_functions")){ return "<span style='color:#00FF1E'>".$disablefunc."</span>"; }
  543.     else { return "<span style='color:#00FF1E'>None</span>"; }
  544.     }
  545.  
  546. headers();
  547. echo"<h3 class=\"fa fa-cogs fa-3x\" > System Info </h3><br></br><hr></hr>";
  548. echo "<table>";
  549. echo " <tr><th><span style='color:red;'><strong>System:</strong></span></th><td>".php_uname()."</td></tr>";
  550. echo "<tr><th><span style='color:red;'><strong>DataBase Connection : </strong></span></th><td><font color='green'>Connected successfully !</font></td></tr>";
  551. echo "<tr><th><span style='color:red;'><strong>PHP version:</strong></span></th><td> ".phpversion()." on ".php_sapi_name()."</td></tr>";
  552. echo "<tr><th><span style='color:red;'><strong>MySQL Server Version:</strong></span></th><td> ".mysql_get_server_info()."</td></tr>";
  553. echo "<tr><th><span style='color:red;'><strong>MySQL Host Info:</strong></span></th><td> ".mysql_get_host_info()."</td></tr>";
  554. echo "<tr><th><span style='color:red;'><strong>MySQL client info:</strong></span></th><td> ".mysql_get_client_info()."</td></tr>";
  555. echo "<tr><th><span style='color:red;'><strong>MySQL protocol version:</strong></span></th><td> ".mysql_get_proto_info()."</td></tr>";
  556. echo "<tr><th><span style='color:red;'><strong>WebServer:</strong></span></th><td> ".$_SERVER['SERVER_SOFTWARE']."</td></tr>";
  557. if(function_exists("disk_total_space")){
  558. echo "<tr><th><span style='color:red;'><strong>Free Disk:</strong></span></th><td>".convertByte(disk_free_space("/"))." / ".convertByte(disk_total_space("/"))."</td></tr>";
  559. }
  560.  
  561. echo "</table>";
  562.  
  563. footer();
  564.  
  565. }
  566.  
  567.  
  568. if(isset($_GET["phpinfo"])){
  569.  
  570. ob_end_clean();
  571.  
  572. ob_start();
  573. headers();
  574. phpinfo();
  575. footer();
  576.  
  577. }
  578.  
  579.  
  580.  
  581. if(isset($_GET["import"])){
  582.  
  583. ob_end_clean();
  584.  
  585. ob_start();
  586.  
  587. headers();
  588.  
  589.  
  590. echo"<h3 class=\"fa fa-upload fa-2x \" > File to Import :</h3>";
  591.  
  592. echo"<hr></hr>";
  593.  
  594. echo"Upload [txt] or [sql] File.<br></br>
  595. PHP No Admin's ability to import databases makes it much easier to recover from disaster and even migrate a database from one server to another. Since the process is done through a web-based interface, you don't have to sit in front of the server to recover your database.<br></br>";
  596.  
  597. echo '
  598. <form method=POST enctype="multipart/form-data" action="">
  599. <input type="file" name="files"></br>
  600. <input type="submit" value="Import" class="btn btn-default" id="menu-toggle">
  601. </form>
  602. ';
  603.  
  604. $files = @$_FILES["files"];
  605. if ($files["name"] != '') {
  606.  
  607.     $fullpath = $files["name"];
  608.     if (move_uploaded_file($files['tmp_name'], $fullpath)) {
  609.         echo "<h5>Data Imported From $fullpath Successfully</h5>";
  610.  
  611. $file = fopen($fullpath,"r");
  612.  
  613. while(! feof($file))
  614.   {
  615.     $import=fgets($file);
  616.  
  617.   $sql = mysql_query($import);
  618.  
  619. if (!($conn = mysql_connect($servername, $username, $password))) {
  620.     die("Connection failed: " . $conn->connect_error);
  621. }
  622.  
  623.  
  624.  
  625.   }
  626.  
  627. fclose($file);
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.            
  635.     }
  636. }
  637.  
  638.  
  639.  
  640.  
  641.  
  642. footer();
  643.  
  644.  
  645.  
  646. }
  647.  
  648.  
  649. // user priviledges
  650.  
  651.  
  652. if(isset($_GET["users"])){
  653.  
  654. ob_end_clean();
  655.  
  656. ob_start();
  657.  
  658. headers();
  659.  
  660. echo"<h1 class=\"fa fa-user-secret fa-3x\" > User Priviledges </h1><br></br>";
  661. $conn = new mysqli($servername, $username, $password);
  662.  
  663. $sql = "SELECT * From mysql.user";
  664.  
  665. echo "<code> Query : $sql </code><br></br>";
  666.  
  667. $result = $conn->query($sql);
  668.   echo'<table>';
  669. echo "<tr><th>Host</th><th>User</th><th>Password</th><th>Private</th><th>Update Private<th>Delete Private</th><th>Password Expired</th></tr>";
  670.  
  671. if ($result->num_rows > 0) {
  672.     // output data of each row
  673.     while($row = $result->fetch_assoc()) {
  674.  
  675.      
  676. echo "<tr><td>".$row["Host"]."</td><td>".$row["User"]."</td><td>".$row["Password"]."</td><td>".$row["Select_priv"]."</td><td>".$row["Update_priv"]."<td>".$row["Delete_priv"]."</td><td>".$row['password_expired']."</td></tr>";
  677.  
  678.  
  679.  
  680.  
  681.     }
  682. echo'</table>';
  683.  
  684. footer();
  685. } else {
  686.     echo "0 results";
  687. }
  688. $conn->close();
  689.  
  690.  
  691. }
  692.  
  693. if(isset($_GET['sql'])){
  694.  
  695. ob_end_clean();
  696.  
  697. ob_start();
  698.  
  699. headers();
  700.  
  701. echo'<h3>Run SQL Queries </h3>';
  702. echo'<hr></hr>';
  703.  
  704. echo'SQL queries are commands that you issue to the MySQL server to tell it to perform various functions. Designed for advanced users, this allows you to quickly make changes to your database simply by issuing the appropriate commands.<br></br>';
  705.  
  706. echo'<form action="" method="POST"><textarea name="sqlquery" style="margin: 0px; width: 605px; height: 209px; background-color: aliceblue; border: 4px solid #765942; border-radius: 10px;">';
  707. if(isset($_GET['sqls'])){
  708.  
  709. $sql=$_GET['sqls'];
  710. echo $sql;
  711.  
  712. }
  713. echo'</textarea><br></br><input type="submit"  value="GO" class="btn btn-default" id="menu-toggle"></form>';
  714.  
  715.  
  716. if(isset($_POST['sqlquery'])){
  717.  
  718. $sql=$_POST['sqlquery'];
  719.  
  720. if(mysql_query($sql)){
  721.  
  722. echo'<div class="form-group has-success"><div class="alert alert-success alert-dismissable">
  723.                                <button type="button" class="close fa fa-check" data-dismiss="alert" aria-hidden="true">×</button>
  724.           Mysql Query was Valid</br><hr></hr><a href="#" class="alert-link">MySql Query : '.$sql.'</a>.
  725.                            </div></div>';
  726.  
  727.  
  728.  
  729.  
  730. }
  731. else{
  732.  
  733. echo'<div class="form-group has-success"><div class="alert alert-danger alert-dismissable">
  734.                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
  735.                                Error</br><hr></hr> MySql QUERY : <a href="#" class="alert-link">'.$sql.'</a>.
  736.                            </div></div>';
  737.  
  738. }
  739.  
  740.  
  741. }
  742.  
  743. }
  744.  
  745.  
  746.  
  747. if(isset($_GET['search']))
  748. {
  749. ob_end_clean();
  750. ob_start();
  751. headers();
  752.  
  753. echo'<h3 class="fa fa-search fa-3x" > Search </h3>';
  754. echo'<hr></hr>';
  755.  
  756. echo'<br></br>This section describes the Search sub-page where single-table search is available.
  757.  
  758. The main use for the tool for some users is with the Search mode, for finding and updating data. For this, the phpNOAdmin team has made it possible to define which sub-page is the starting page in Table view<br></br>';
  759.  
  760. echo'<form action="" method="POST">
  761.  
  762. <table class="data" style="margin: 0px 0px 12px; color: rgb(68, 68, 68); font-family: sans-serif; font-size: 13.1199998855591px; background-color: rgb(255, 255, 255);"><tbody><tr class="noclick odd" style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><td style="padding: 0.3em; margin: 0.1em; vertical-align: top; text-shadow: rgb(255, 255, 255) 0px 1px 0px;"><select name="databasename" style="margin: 6px; font-size: 1em; color: rgb(51, 51, 51); outline: none; transition: all 0.2s; border-radius: 2px; border-color: rgb(187, 187, 187); padding: 3px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">';
  763.           $result = mysql_query("SHOW DATABASES");
  764.           echo'<h3><i class="fa fa-database fa-2x"> Databases : </i> </h3>';
  765.           while ($row = mysql_fetch_array($result)) {  
  766.      
  767.            echo "<option value='".$row[0]."'>".$row[0]."</option>";
  768.  
  769.  
  770. }
  771.  
  772. echo'</select></td><td style="padding: 0.3em; margin: 0.1em; vertical-align: top; text-shadow: rgb(255, 255, 255) 0px 1px 0px;">';
  773.  
  774.  
  775. echo'<select name="like" style="margin: 6px; font-size: 1em; color: rgb(51, 51, 51); outline: none; transition: all 0.2s; border-radius: 2px; border-color: rgb(187, 187, 187); padding: 3px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><option value="=">=</option><option value=">">&gt;</option><option value=">=">&gt;=</option><option value="<">&lt;</option><option value="<=">&lt;=</option><option value="!=">!=</option><option value="LIKE">LIKE</option><option value="LIKE %...%">LIKE %...%</option><option value="NOT LIKE">NOT LIKE</option><option value="IN (...)">IN (...)</option><option value="NOT IN (...)">NOT IN (...)</option><option value="BETWEEN">BETWEEN</option><option value="NOT BETWEEN">NOT BETWEEN</option><option value="IS NULL">IS NULL</option><option value="IS NOT NULL">IS NOT NULL</option></select></td><td data-type="int(11)" style="padding: 0.3em; margin: 0.1em; vertical-align: top; text-shadow: rgb(255, 255, 255) 0px 1px 0px;"><input type="text" name="value_to_search" size="20" class="textfield" id="fieldID_0" style="margin: 6px; font-size: 1em; color: rgb(85, 85, 85); outline: none; border-radius: 2px; border: 1px solid rgb(124, 124, 124); padding: 4px; transition: all 0.2s; box-shadow: rgb(170, 170, 170) 0px 1px 3px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"></td>
  776. <td><input type="submit" value="GO" class="btn btn-default"></td></tr></tbody></table>
  777.  
  778. </form>';
  779.  
  780. }
  781.  
  782.  
  783. if(isset($_POST['databasename'])){
  784.  
  785. $databasename=$_POST['databasename'];
  786.  
  787. $like=$_POST['like'];
  788. $tbl=$_POST['tbl'];
  789.  
  790. $Sql=" SELECT * FROM `$databasename.$tbl` WHERE `id` $like ";
  791.  
  792. echo"<br></br><code> Query : $Sql </code> ";
  793.  
  794.  
  795.  
  796. footer();
  797. }
  798.  
  799. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement