Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // PhpNoAdmin (Handle Administration of MySQL in single page)
- #########################################
- #Database: db4free.net
- #Username: phpnoadmin
- #Email: [email protected]
- #Password : phpnoadmin
- #Demo : http://phpnoadmin.16mb.com
- #Download : http://pastebin.com/CqRiZdmy
- #Coded By : H4T3D
- #Changing Name Wont Make You l33t -_-
- #########################################
- define('VERSION','1.0');
- error_reporting(0);
- ini_set('error_log',NULL);
- ini_set('log_errors',0);
- ini_set('max_execution_time',0);
- set_time_limit(0);
- set_magic_quotes_runtime(0);
- ob_end_clean();
- ob_start();
- $servername = "db4free.net";
- $username = "phpnoadmin";
- $password = "phpnoadmin";
- echo '
- <head>
- <style>
- table, td {
- border: 3px solid black;
- width:100%;
- }
- th{
- border: 3px solid black;
- width:100%;
- color: blue;
- }
- ///////////////
- #wrapper {
- padding-left: 0;
- -webkit-transition: all 0.5s ease;
- -moz-transition: all 0.5s ease;
- -o-transition: all 0.5s ease;
- transition: all 0.5s ease;
- }
- #wrapper.toggled {
- padding-left: 250px;
- }
- #sidebar-wrapper {
- z-index: 1000;
- position: fixed;
- left: 250px;
- width: 0;
- height: 100%;
- margin-left: -250px;
- overflow-y: auto;
- background: #000;
- -webkit-transition: all 0.5s ease;
- -moz-transition: all 0.5s ease;
- -o-transition: all 0.5s ease;
- transition: all 0.5s ease;
- }
- #wrapper.toggled #sidebar-wrapper {
- width: 250px;
- }
- #page-content-wrapper {
- width: 100%;
- position: absolute;
- padding: 15px;
- }
- #wrapper.toggled #page-content-wrapper {
- position: absolute;
- margin-right: -250px;
- }
- /* Sidebar Styles */
- .sidebar-nav {
- position: absolute;
- top: 0;
- width: 250px;
- margin: 0;
- padding: 0;
- list-style: none;
- }
- .sidebar-nav li {
- text-indent: 20px;
- line-height: 40px;
- }
- .sidebar-nav li a {
- display: block;
- text-decoration: none;
- color: #999999;
- }
- .sidebar-nav li a:hover {
- text-decoration: none;
- color: #fff;
- background: rgba(255,255,255,0.2);
- }
- .sidebar-nav li a:active,
- .sidebar-nav li a:focus {
- text-decoration: none;
- }
- .sidebar-nav > .sidebar-brand {
- height: 65px;
- font-size: 18px;
- line-height: 60px;
- }
- .sidebar-nav > .sidebar-brand a {
- color: #999999;
- }
- .sidebar-nav > .sidebar-brand a:hover {
- color: #fff;
- background: none;
- }
- @media(min-width:768px) {
- #wrapper {
- padding-left: 250px;
- }
- #wrapper.toggled {
- padding-left: 0;
- }
- #sidebar-wrapper {
- width: 250px;
- }
- #wrapper.toggled #sidebar-wrapper {
- width: 0;
- }
- #page-content-wrapper {
- padding: 20px;
- position: relative;
- }
- #wrapper.toggled #page-content-wrapper {
- position: relative;
- margin-right: 0;
- }
- }
- </style>
- <link href="http://ironsummitmedia.github.io/startbootstrap-simple-sidebar/css/bootstrap.min.css" rel="stylesheet">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
- </head>
- ';
- echo '<body>';
- function headers(){
- echo'<div id="page-content-wrapper">
- <div class="container-fluid">
- <div class="row">
- <div class="col-lg-12">';
- }
- function footer(){
- echo' </div>
- </div>
- </div>
- </div>
- </div>';
- }
- echo'<div id="wrapper"><div id="sidebar-wrapper">
- <ul class="sidebar-nav">
- <img src="http://s4.postimg.org/jrc7m0j9p/g_gif_update_1.gif">
- <li class="sidebar-brand">
- <a href="?">
- <i><font color="white" size="3">php</font><b><font color="yellow" size="3">NOAdmin</font></a></b></i>
- </a>
- </li>
- <li >
- <a href="?" class="fa fa-database fa-lg" > DataBase</a></br>
- </li>
- <li>
- <a href="?info" class="fa fa-info-circle fa-lg" > System Info</a></br>
- </li>
- <li>
- <a href="?phpinfo" class="fa fa-info fa-lg" > PHP Info</a></br>
- </li>
- <li>
- <a href="?import" class="fa fa-upload fa-lg" > Import</a></br>
- </li>
- <li>
- <a href="?export" class="fa fa-download fa-lg" > Export</a></br>
- </li>
- <li>
- <a href="?sql" class="fa fa-terminal fa-lg" > Sql Query</a></br>
- </li>
- <li>
- <a href="?users" class="fa fa-users fa-lg" > Users</a></br>
- </li>
- <li>
- <a href="?search" class="fa fa-search fa-lg" > Search</a></br>
- </li>
- <li>
- <a href="http://dev.mysql.com/doc/refman/5.6/en/index.html" class="fa fa-file-text-o fa-lg" > Reference </a></br>
- </li>
- </ul>
- </div>';
- ob_start();
- headers();
- // Check connection
- if (!($conn = mysql_connect($servername, $username, $password))) {
- die("Connection failed: " . $conn->connect_error);
- }
- $result = mysql_query("SHOW DATABASES");
- echo'<h3><i class="fa fa-database fa-lg"> Databases </i> </h3><hr></hr>';
- echo "<code> Query : SHOW DATABASES </code><br></br>";
- while ($row = mysql_fetch_array($result)) {
- echo "<ul><li><a href=?dbname=".$row[0].">".$row[0]."</a></li></ul>";
- }//shuru ka show database
- footer();
- // Show Tables From DataBase
- if(isset($_GET['dbname'])){
- ob_end_clean();
- ob_start();
- headers();
- $dbname=$_GET['dbname'];
- echo "<h3> Database :".$dbname."</h3></br>";
- echo '<i class="fa fa-table fa-2x">
- Tables From '.$dbname.'</i><br></br>';
- $sql = "SHOW tables FROM $dbname";
- echo "<code> Query : $sql </code><br></br>";
- $result = mysql_list_tables($dbname);
- while ($row = mysql_fetch_row($result)) {
- print "<ul> <li><a href='?dbname=$dbname&tbl=$row[0]'>$row[0]</a></li></ul>";
- }
- footer();
- }// end of show Database Tables
- // Show Rows From Tables
- if(isset($_GET['tbl'])){
- ob_end_clean();
- ob_start();
- headers();
- // Check connection
- if (!($conn = mysql_connect($servername, $username, $password))) {
- die("Connection failed: " . $conn->connect_error);
- }
- $tbl=$_GET['tbl'];
- echo '<div class="main">';
- echo "<h3> Database :".$dbname."</h3></br>";
- echo "<h3> Table :".$tbl."</h3></br>";
- $conn = new mysqli($servername, $username, $password);
- $sql = "Select * FROM $dbname.$tbl";
- echo "<code> Query : $sql </code><br></br>";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo"<center><table><tr>";
- foreach ($row as $name => $value) {
- 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>";
- }
- echo"<tr></table></center>";
- }
- }
- else {
- echo'<div class="form-group has-success"><div class="alert alert-success alert-dismissable">
- <button type="button" class="close fa fa-check" data-dismiss="alert" aria-hidden="true">×</button>
- Mysql Query was Valid</br><hr></hr><a href="#" class="alert-link">MySQL returned an empty result set (i.e. zero rows)</a>.
- </div></div>';
- }
- echo'</div>';
- footer();
- }// end of show Database Tables
- if(isset($_GET['export'])){
- ob_end_clean();
- ob_start();
- headers();
- echo'<h3>Export Database</h3><hr></hr>';
- 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>";
- echo'<h5>Select Database</h5>';
- echo '<form action="" method="POST" >
- <select name="dbname">';
- $result = mysql_query("SHOW DATABASES");
- echo'<h3><i class="fa fa-database fa-2x"> Databases : </i> </h3>';
- while ($row = mysql_fetch_array($result)) {
- echo "<option value='".$row[0]."'>".$row[0]."</option>";
- }
- echo'</select><br></br><select name="filetype">
- <option value="filetype_sql">SQL</option>
- <option value="filetype_txt">TXT</option>
- </select><br></br><input type="submit" value="Export" class="btn btn-default" ></form>';
- if(isset($_POST['dbname'])){
- $DbName=$_POST['dbname'];
- function Export_Database($host,$user,$pass,$name, $tables=false, $backup_name=false )
- {
- $mysqli = new mysqli($host,$user,$pass,$name);
- $mysqli->select_db($name);
- $mysqli->query("SET NAMES 'utf8'");
- $queryTables = $mysqli->query('SHOW TABLES');
- while($row = $queryTables->fetch_row())
- {
- $target_tables[] = $row[0];
- }
- if($tables !== false)
- {
- $target_tables = array_intersect( $target_tables, $tables);
- }
- foreach($target_tables as $table)
- {
- $result = $mysqli->query('SELECT * FROM '.$table);
- $fields_amount = $result->field_count;
- $rows_num=$mysqli->affected_rows;
- $res = $mysqli->query('SHOW CREATE TABLE '.$table);
- $TableMLine = $res->fetch_row();
- $content = (!isset($content) ? '' : $content) . "\n\n".$TableMLine[1].";\n\n";
- for ($i = 0, $st_counter = 0; $i < $fields_amount; $i++, $st_counter=0)
- {
- while($row = $result->fetch_row())
- { //when started (and every after 100 command cycle):
- if ($st_counter%100 == 0 || $st_counter == 0 )
- {
- $content .= "\nINSERT INTO ".$table." VALUES";
- }
- $content .= "\n(";
- for($j=0; $j<$fields_amount; $j++)
- {
- $row[$j] = str_replace("\n","\\n", addslashes($row[$j]) );
- if (isset($row[$j]))
- {
- $content .= '"'.$row[$j].'"' ;
- }
- else
- {
- $content .= '""';
- }
- if ($j<($fields_amount-1))
- {
- $content.= ',';
- }
- }
- $content .=")";
- //every after 100 command cycle [or at last line] ....p.s. but should be inserted 1 cycle eariler
- if ( (($st_counter+1)%100==0 && $st_counter!=0) || $st_counter+1==$rows_num)
- {
- $content .= ";";
- }
- else
- {
- $content .= ",";
- }
- $st_counter=$st_counter+1;
- }
- } $content .="\n\n\n";
- }
- //$backup_name = $backup_name ? $backup_name : $name."___(".date('H-i-s')."_".date('d-m-Y').")__rand".rand(1,11111111).".sql";
- $filetype=$_POST['filetype'];
- if($filetype=="filetype_sql")
- {
- $backup_name = $backup_name ? $backup_name : $name.".sql";
- $myfile=fopen("$backup_name", "w") or die("Unable to open file!");
- fwrite($myfile,$content);
- fclose($myfile);
- echo'<div class="alert alert-info fade in">
- <a href="#" class="close" data-dismiss="alert" aria-label="close" title="close">×</a>
- <strong>Export : </strong> '.$backup_name.' Exported Successfully!
- </div>';
- exit;
- }
- else
- {
- $backup_name = $backup_name ? $backup_name : $name.".txt";
- $myfile=fopen("$backup_name", "w") or die("Unable to open file!");
- fwrite($myfile,$content);
- fclose($myfile);
- echo'<div class="alert alert-info fade in">
- <a href="#" class="close" data-dismiss="alert" aria-label="close" title="close">×</a>
- <strong>Export : </strong> '.$backup_name .' Exported Successfully!
- </div>';
- exit;
- }
- }
- Export_Database($servername,$username,$password,$DbName,$tables=false, $backup_name=false );
- footer();
- }
- }
- if(isset($_GET["info"])){
- ob_end_clean();
- ob_start();
- function convertByte($s) {
- if($s >= 1073741824)
- return sprintf('%1.2f',$s / 1073741824 ).' GB';
- elseif($s >= 1048576)
- return sprintf('%1.2f',$s / 1048576 ) .' MB';
- elseif($s >= 1024)
- return sprintf('%1.2f',$s / 1024 ) .' KB';
- else
- return $s .' B';
- }
- $ssys = "None";
- if(is_dir("/usr/local/cpanel")){
- $ssys = "Running On Cpanel";
- }elseif(is_dir("/usr/local/directadmin")){
- $ssys = "Running On Directadmin";
- }
- if( ini_get('safe_mode') ){
- $smde = " ON" ;
- }else{
- $smde = " OFF" ; }
- function showdisablefunctions() {
- if ($disablefunc=@ini_get("disable_functions")){ return "<span style='color:#00FF1E'>".$disablefunc."</span>"; }
- else { return "<span style='color:#00FF1E'>None</span>"; }
- }
- headers();
- echo"<h3 class=\"fa fa-cogs fa-3x\" > System Info </h3><br></br><hr></hr>";
- echo "<table>";
- echo " <tr><th><span style='color:red;'><strong>System:</strong></span></th><td>".php_uname()."</td></tr>";
- echo "<tr><th><span style='color:red;'><strong>DataBase Connection : </strong></span></th><td><font color='green'>Connected successfully !</font></td></tr>";
- echo "<tr><th><span style='color:red;'><strong>PHP version:</strong></span></th><td> ".phpversion()." on ".php_sapi_name()."</td></tr>";
- echo "<tr><th><span style='color:red;'><strong>MySQL Server Version:</strong></span></th><td> ".mysql_get_server_info()."</td></tr>";
- echo "<tr><th><span style='color:red;'><strong>MySQL Host Info:</strong></span></th><td> ".mysql_get_host_info()."</td></tr>";
- echo "<tr><th><span style='color:red;'><strong>MySQL client info:</strong></span></th><td> ".mysql_get_client_info()."</td></tr>";
- echo "<tr><th><span style='color:red;'><strong>MySQL protocol version:</strong></span></th><td> ".mysql_get_proto_info()."</td></tr>";
- echo "<tr><th><span style='color:red;'><strong>WebServer:</strong></span></th><td> ".$_SERVER['SERVER_SOFTWARE']."</td></tr>";
- if(function_exists("disk_total_space")){
- echo "<tr><th><span style='color:red;'><strong>Free Disk:</strong></span></th><td>".convertByte(disk_free_space("/"))." / ".convertByte(disk_total_space("/"))."</td></tr>";
- }
- echo "</table>";
- footer();
- }
- if(isset($_GET["phpinfo"])){
- ob_end_clean();
- ob_start();
- headers();
- phpinfo();
- footer();
- }
- if(isset($_GET["import"])){
- ob_end_clean();
- ob_start();
- headers();
- echo"<h3 class=\"fa fa-upload fa-2x \" > File to Import :</h3>";
- echo"<hr></hr>";
- echo"Upload [txt] or [sql] File.<br></br>
- 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>";
- echo '
- <form method=POST enctype="multipart/form-data" action="">
- <input type="file" name="files"></br>
- <input type="submit" value="Import" class="btn btn-default" id="menu-toggle">
- </form>
- ';
- $files = @$_FILES["files"];
- if ($files["name"] != '') {
- $fullpath = $files["name"];
- if (move_uploaded_file($files['tmp_name'], $fullpath)) {
- echo "<h5>Data Imported From $fullpath Successfully</h5>";
- $file = fopen($fullpath,"r");
- while(! feof($file))
- {
- $import=fgets($file);
- $sql = mysql_query($import);
- if (!($conn = mysql_connect($servername, $username, $password))) {
- die("Connection failed: " . $conn->connect_error);
- }
- }
- fclose($file);
- }
- }
- footer();
- }
- // user priviledges
- if(isset($_GET["users"])){
- ob_end_clean();
- ob_start();
- headers();
- echo"<h1 class=\"fa fa-user-secret fa-3x\" > User Priviledges </h1><br></br>";
- $conn = new mysqli($servername, $username, $password);
- $sql = "SELECT * From mysql.user";
- echo "<code> Query : $sql </code><br></br>";
- $result = $conn->query($sql);
- echo'<table>';
- 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>";
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- 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>";
- }
- echo'</table>';
- footer();
- } else {
- echo "0 results";
- }
- $conn->close();
- }
- if(isset($_GET['sql'])){
- ob_end_clean();
- ob_start();
- headers();
- echo'<h3>Run SQL Queries </h3>';
- echo'<hr></hr>';
- 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>';
- 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;">';
- if(isset($_GET['sqls'])){
- $sql=$_GET['sqls'];
- echo $sql;
- }
- echo'</textarea><br></br><input type="submit" value="GO" class="btn btn-default" id="menu-toggle"></form>';
- if(isset($_POST['sqlquery'])){
- $sql=$_POST['sqlquery'];
- if(mysql_query($sql)){
- echo'<div class="form-group has-success"><div class="alert alert-success alert-dismissable">
- <button type="button" class="close fa fa-check" data-dismiss="alert" aria-hidden="true">×</button>
- Mysql Query was Valid</br><hr></hr><a href="#" class="alert-link">MySql Query : '.$sql.'</a>.
- </div></div>';
- }
- else{
- echo'<div class="form-group has-success"><div class="alert alert-danger alert-dismissable">
- <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
- Error</br><hr></hr> MySql QUERY : <a href="#" class="alert-link">'.$sql.'</a>.
- </div></div>';
- }
- }
- }
- if(isset($_GET['search']))
- {
- ob_end_clean();
- ob_start();
- headers();
- echo'<h3 class="fa fa-search fa-3x" > Search </h3>';
- echo'<hr></hr>';
- echo'<br></br>This section describes the Search sub-page where single-table search is available.
- 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>';
- echo'<form action="" method="POST">
- <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;">';
- $result = mysql_query("SHOW DATABASES");
- echo'<h3><i class="fa fa-database fa-2x"> Databases : </i> </h3>';
- while ($row = mysql_fetch_array($result)) {
- echo "<option value='".$row[0]."'>".$row[0]."</option>";
- }
- echo'</select></td><td style="padding: 0.3em; margin: 0.1em; vertical-align: top; text-shadow: rgb(255, 255, 255) 0px 1px 0px;">';
- 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=">">></option><option value=">=">>=</option><option value="<"><</option><option value="<="><=</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>
- <td><input type="submit" value="GO" class="btn btn-default"></td></tr></tbody></table>
- </form>';
- }
- if(isset($_POST['databasename'])){
- $databasename=$_POST['databasename'];
- $like=$_POST['like'];
- $tbl=$_POST['tbl'];
- $Sql=" SELECT * FROM `$databasename.$tbl` WHERE `id` $like ";
- echo"<br></br><code> Query : $Sql </code> ";
- footer();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement