Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- PHP NO ADMIN (MYSQL Management System)
- PhpNoAdmin (Handle Administration of MySQL in single page)
- Mini PhpMyadmin Version 1.6 Beta
- https://www.facebook.com/HAT.programmers
- Demo : http://phpnoadmin.viper-7.com/H3PAVx/5.6.10?
- Servername:db4free.net
- Username :phpnoadmin
- Password :phpnoadmin
- Coded By Hat programmers
- Disclaimer :
- *Free Distribution But With Orignal Coders name
- *Only For Educational purposes We Dont Take Any Responsiblity Of Any Type
- */
- define('Name', 'MySql Management System PhpNoAdmin');
- define('VERSION', '1.6');
- define('Copyright', 'HAT Programmers');
- error_reporting(0);
- ini_set('max_execution_time', 0);
- set_time_limit(0);
- set_magic_quotes_runtime(0);
- ob_end_clean();
- ob_start();
- session_start();
- function sql($sql)
- {
- if(isset($_GET['dbname'])){
- mysql_select_db($_GET['dbname']);
- }
- echo '<div class="row">
- <div class="col-lg-12">';
- if (mysql_query($sql))
- {
- $result = 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 : ' . htmlspecialchars($sql) . '</a>.
- </div>
- </div>';
- if ((is_bool($result === false))) {
- echo "<table class=\"order-table table\">";
- $arr = mysql_fetch_assoc($result);
- if (is_bool($arr) === true) {return;}
- array_unique($arr);
- echo "<thead><tr>";
- foreach($arr as $name => $value)
- {
- echo "<th>" . htmlspecialchars($name) . "</th>";
- }
- echo "</tr></thead>
- <tbody id=\"myTable\">";
- $results = mysql_query($sql);
- while ($arrs = mysql_fetch_assoc($results))
- {
- echo "<tr>";
- foreach($arrs as $name => $value)
- {
- echo '<td>' . htmlspecialchars($value) . "</td>";
- }
- echo "</tr>";
- }
- echo "</tbody>
- </table>
- ";
- // FOR PAGINATION
- if (isset($_GET['pages'])) {
- echo "
- <div class=\"col-md-12 text-center\">
- <ul class=\"pagination\" id=\"myPager\"></ul>
- </div>
- </div>
- </div>";
- echo '
- <script>
- $.fn.pageMe = function(opts){
- var $this = this,
- defaults = {
- perPage: 7,
- showPrevNext: false,
- hidePageNumbers: false
- },
- settings = $.extend(defaults, opts);
- var listElement = $this;
- var perPage = settings.perPage;
- var children = listElement.children();
- var pager = $(\'.pager\');
- if (typeof settings.childSelector!="undefined") {
- children = listElement.find(settings.childSelector);
- }
- if (typeof settings.pagerSelector!="undefined") {
- pager = $(settings.pagerSelector);
- }
- var numItems = children.size();
- var numPages = Math.ceil(numItems/perPage);
- pager.data("curr",0);
- if (settings.showPrevNext){
- $(\'<li><a href="#" class="prev_link">«</a></li>\').appendTo(pager);
- }
- var curr = 0;
- while(numPages > curr && (settings.hidePageNumbers==false)){
- $(\'<li><a href="#" class="page_link">\'+(curr+1)+\'</a></li>\').appendTo(pager);
- curr++;
- }
- if (settings.showPrevNext){
- $(\'<li><a href="#" class="next_link">»</a></li>\').appendTo(pager);
- }
- pager.find(\'.page_link:first\').addClass(\'active\');
- pager.find(\'.prev_link\').hide();
- if (numPages<=1) {
- pager.find(\'.next_link\').hide();
- }
- pager.children().eq(1).addClass("active");
- children.hide();
- children.slice(0, perPage).show();
- pager.find(\'li .page_link\').click(function(){
- var clickedPage = $(this).html().valueOf()-1;
- goTo(clickedPage,perPage);
- return false;
- });
- pager.find(\'li .prev_link\').click(function(){
- previous();
- return false;
- });
- pager.find(\'li .next_link\').click(function(){
- next();
- return false;
- });
- function previous(){
- var goToPage = parseInt(pager.data("curr")) - 1;
- goTo(goToPage);
- }
- function next(){
- goToPage = parseInt(pager.data("curr")) + 1;
- goTo(goToPage);
- }
- function goTo(page){
- var startAt = page * perPage,
- endOn = startAt + perPage;
- children.css(\'display\',\'none\').slice(startAt, endOn).show();
- if (page>=1) {
- pager.find(\'.prev_link\').show();
- }
- else {
- pager.find(\'.prev_link\').hide();
- }
- if (page<(numPages-1)) {
- pager.find(\'.next_link\').show();
- }
- else {
- pager.find(\'.next_link\').hide();
- }
- pager.data("curr",page);
- pager.children().removeClass("active");
- pager.children().eq(page+1).addClass("active");
- }
- };
- $(document).ready(function(){
- $(\'#myTable\').pageMe({pagerSelector:\'#myPager\',showPrevNext:true,hidePageNumbers:false,perPage:4});
- });
- </script>';
- }// end of pages
- } //check if result is boolean
- }//end of if query is right
- 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 MySql QUERY : ' . htmlspecialchars($sql) . ' </br><hr></hr> <a href="#" class="alert-link">' . htmlspecialchars(mysql_error()) . '</a>.
- </div></div>
- ';
- }
- echo '</div></div>';
- }
- function checkingsql($sql){ echo "
- <script>var r = confirm('Do You Really Want To Execute\\n \"$sql\"');
- if(r){
- window.location.assign(\"?checksql=$sql\");
- }
- </script>
- ";}
- function getrows($dbname, $tbl)
- {
- $servername = $GLOBALS['servername'];
- $username = $GLOBALS['username'];
- $password = $GLOBALS['password'];
- $conn = new mysqli($servername, $username, $password);
- $sql3 = "SHOW COLUMNS FROM $dbname.$tbl";
- $result = mysqli_query($conn, $sql3);
- while ($row = mysqli_fetch_array($result))
- {
- echo $row['Field'] . ",";
- }
- mysqli_close($conn);
- }
- if (!isset($_SESSION['username']))
- {
- echo "
- <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
- <link href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css\" rel=\"stylesheet\">
- <style>
- body {
- z-index: 1030;
- background-color: #333333;
- }
- legend {color:white;}
- .footer_bottom {
- background: #333;
- padding: 1em 0;
- text-align: center;
- }
- .copy p {
- color: #fff;
- font-size: 0.85em;
- }
- </style>
- <body>
- <center>
- <div class=\"container\">
- <div class=\"row\">
- <div class=\"col-sm-12\">
- <div class=\"col-sm-3\"></div>
- <div class=\"col-sm-6\">
- <fieldset class=\"scheduler-border\">
- <legend class=\"scheduler-border\">Database Connection</legend>
- <font color=\"white\" size=\"10\">PHP</font><b><font color=\"yellow\" size=\"8\">NOAdmin</font></a></b>
- <hr></hr>
- <form action='' method='POST' role=\"form\">
- <div class=\"form-group\">
- <label for=\"email\">Servername:</label>
- <div class=\"form-group input-group\">
- <span class=\"input-group-addon\">Servername</span>
- <input type=\"text\" name=\"servername\" class=\"form-control\" value='localhost'/></div>
- <label for=\"email\">UserName:</label>
- <div class=\"form-group input-group\">
- <span class=\"input-group-addon\">Username</span>
- <input type=\"text\" name=\"username\" class=\"form-control\" value='root'/></div>
- <label for=\"email\">Password:</label>
- <div class=\"form-group input-group\">
- <span class=\"input-group-addon\">Password</span>
- <input type=\"password\" class=\"form-control\" name=\"password\" /></div></br>
- <input type=\"submit\" name=\"connct_now\" class=\"btn btn-default form-control\" value=\"Connect\"/>
- </div>
- </form>
- </div>
- </div>
- </fieldset>
- </div>
- </div>
- </div>
- </body>
- <div class=\"footer_bottom\">
- <div class=\"container\">
- <div class=\"copy\">
- <p>Copyright © 2015 HAT programmers. All Rights Reserved . Developed by <a href=\"https://www.facebook.com/HAT.programmers/\" target=\"_blank\"> HAT Programmers</a> </p>
- </div>
- </div>
- </div>
- ";
- if (isset($_GET['error']))
- {
- header('HTTP/1.0 401 Unauthorized');
- echo "
- <div class=\"container\">
- <div class=\"alert alert-danger\">
- <strong> Invalid Credentials </strong> Failed To Connect !
- </div>
- </div>
- ";
- }
- if (isset($_POST['connct_now']))
- {
- $servername = $_POST['servername'];
- $username = $_POST['username'];
- $password = $_POST['password'];
- $connection = mysql_connect($servername, $username, $password);
- $_SESSION['servername'] = $servername;
- $_SESSION['username'] = $username;
- $_SESSION['password'] = $password;
- $_SESSION['connection'] = $connection;
- header("location:?");
- }
- }
- else
- {
- $GLOBALS['servername'] = $_SESSION['servername'];
- $GLOBALS['username'] = $_SESSION['username'];
- $GLOBALS['password'] = $_SESSION['password'];
- echo '
- <head>
- <style>
- table,td,tr{
- border: 1px solid black;
- width:100%;
- }
- th{
- border: 1px 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;
- }
- }
- div.related {
- background-color: #888;
- line-height: 30px;
- color: #ffffff;
- }
- div.related {
- width: 100%;
- font-size: 90%;
- }
- div.related ul {
- margin: 0;
- padding: 0 0 0 10px;
- list-style: none;
- }
- div.related li.right {
- float: right;
- margin-right: 5px;
- }
- div.related li {
- display: inline;
- }
- user agent stylesheetli {
- display: list-item;
- text-align: -webkit-match-parent;
- }
- .footer_bottom {
- background: #333;
- padding: 1em 0;
- text-align: center;
- }
- .copy p {
- color: #fff;
- font-size: 0.85em;
- }
- .fa-minus-circle{color:red;}
- }
- </style>
- </style>
- <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
- <link rel="stylesheet" href="http://lucas.ucs.ed.ac.uk/test/codemirror/lib/codemirror.css">
- <script src="http://lucas.ucs.ed.ac.uk/test/codemirror/lib/codemirror.js"></script>
- <script src="http://lucas.ucs.ed.ac.uk/test/codemirror/mode/mysql/mysql.js"></script>
- <style>.CodeMirror {margin: 0px; width: 100%; height: 359px; background-color: aliceblue; border: 4px solid #765942; border-radius: 10px;}</style>
- </head>
- ';
- echo '<body>';
- function headers()
- {
- echo '
- <nav class="navbar navbar-default';
- if (isset($_GET['popup'])) {
- echo "hidden-xs";
- }
- else{
- echo "visible-xs";
- }
- echo'">
- <div class="container-fluid">
- <!-- Brand and toggle get grouped for better mobile display -->
- <div class="navbar-header">
- <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="?">PhpNoAdmin</a>
- </div>
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
- <ul class="nav navbar-nav">
- <li class="active"><a href="?status"><i class="fa fa-bar-chart"></i><span class="sr-only">(current)</span></a></li>
- <li><a href="#">Link</a></li>
- <li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
- <ul class="dropdown-menu">
- <li><a href="#">Action</a></li>
- <li><a href="#">Another action</a></li>
- <li><a href="#">Something else here</a></li>
- <li role="separator" class="divider"></li>
- <li><a href="#">Separated link</a></li>
- <li role="separator" class="divider"></li>
- <li><a href="#">One more separated link</a></li>
- </ul>
- </li>
- </ul>
- <form class="navbar-form navbar-left" role="search" action="https://search.oracle.com/search/search?" method="GET" target="_blank">
- <div class="form-group">
- <input type="text" class="form-control" placeholder="Search" name="q">
- <input type="hidden" name="group" value="MySQL">
- <input type="hidden" name="x" value="0">
- </div>
- <button type="submit" class="btn btn-default">Go</button>
- </form>
- <ul class="nav navbar-nav navbar-right">
- <li><a href="#">Link</a></li>
- <li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-user fa-fw"></i><span class="caret"></span></a>
- <ul class="dropdown-menu">
- <li><a href="#">Action</a></li>
- <li><a href="#">Another action</a></li>
- <li><a href="#">Something else here</a></li>
- <li role="separator" class="divider"></li>
- <li><a href="?logout" class="fa fa-sign-out">logout</a></li>
- </ul>
- </li>
- </ul>
- </div><!-- /.navbar-collapse -->
- </div><!-- /.container-fluid -->
- </nav>
- <div class="related">
- <ul>
- <li class="right" style="margin-right: 10px">
- <a href="#" onclick="javascript:window.history.foward();" title="Go Foward" accesskey="I">→</a></li>
- <li class="right">
- <a href="#" onclick="javascript:window.history.back();" title="Go Back" accesskey="N">←</a> |</li>
- <li><a href="?"><b>Server:</b> ' . $_SERVER['SERVER_NAME'] . '</a> >> ';
- if (isset($_GET['dbname']))
- {
- echo $_GET['dbname'] . ">>";
- }
- if (isset($_GET['tbl']))
- {
- echo $_GET['tbl'];
- }
- echo '</li>
- </ul>
- </div>
- ';
- echo "<script>
- (function(document) {
- 'use strict';
- var LightTableFilter = (function(Arr) {
- var _input;
- function _onInputEvent(e) {
- _input = e.target;
- var tables = document.getElementsByClassName(_input.getAttribute('data-table'));
- Arr.forEach.call(tables, function(table) {
- Arr.forEach.call(table.tBodies, function(tbody) {
- Arr.forEach.call(tbody.rows, _filter);
- });
- });
- }
- function _filter(row) {
- var text = row.textContent.toLowerCase(), val = _input.value.toLowerCase();
- row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';
- }
- return {
- init: function() {
- var inputs = document.getElementsByClassName('light-table-filter');
- Arr.forEach.call(inputs, function(input) {
- input.oninput = _onInputEvent;
- });
- }
- };
- })(Array.prototype);
- document.addEventListener('readystatechange', function() {
- if (document.readyState === 'complete') {
- LightTableFilter.init();
- }
- });
- })(document);
- </script>
- ";
- echo '<div id="page-content-wrapper">
- <div class="container-fluid">
- <div class="row">
- <div class="col-lg-12">';
- }
- function footer()
- {
- echo ' </div>
- </div>
- <hr></hr>
- <div class="footer_bottom">
- <div class="container">
- <div class="copy">
- <p>Copyright © ' . date("Y") . ' HAT programmers. All Rights Reserved . Developed By <a href="https://www.facebook.com/HAT.programmers/" target="_blank"> HAT Programmers</a> </p>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- ';
- } // end of footer
- echo '<div id="wrapper">
- <div id="sidebar-wrapper">
- <ul class="sidebar-nav">
- <img src="http://i.imgur.com/7CzBtVF.gif">
- <li class="sidebar-brand dropdown">
- <a href="?">
- <i><font color="white" size="3">php</font><b><font color="yellow" size="3">NOAdmin</font></a></b></i>
- </a>
- </li>
- <li class="sidebar-brand dropdown">
- <a href="?">
- <i class="fa fa-home"> DashBoard</i>
- </a>
- </li>
- <li>
- <a href="#demo4" data-toggle="collapse" class="fa fa-database fa-lg"> Databases</a></br>
- <div class="collapse" id="demo4">
- ';
- if (!($conn = mysql_connect($servername, $username, $password)))
- {
- session_destroy();
- session_unset();
- header("location:?error");
- }
- $result = mysql_query("SHOW DATABASES");
- while ($row = mysql_fetch_array($result))
- {
- echo '<a href="?dbname='.$row[0].'" href="#demo3" data-parent="#MainMenu">'.$row[0].'</a>';
- }
- echo '</div>
- </li>
- </br>
- <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';if (isset($_GET['dbname'])) {
- echo "&dbname=".$_GET['dbname'];
- }
- echo'" class="fa fa-upload fa-lg" > Import</a></br>
- </li>
- <li>
- <a href="?export';if (isset($_GET['dbname'])) {
- echo "&dbname=".$_GET['dbname'];
- }
- echo'" class="fa fa-download fa-lg" > Export</a></br>
- </li>
- <li>
- <a href="?sql';if (isset($_GET['dbname'])) {
- echo "&dbname=".$_GET['dbname'];
- }
- echo'" class="fa fa-terminal fa-lg" > Sql Query</a></br>
- </li>
- <li>
- <a href="#demo5" data-toggle="collapse" class="fa fa-code fa-lg">MySQL 2 php</a></br>
- <div class="collapse" id="demo5">
- <a href="#" data-toggle="collapse" data-parent="#SubMenu1">PHP Connect</a>
- <div class="collapse list-group-submenu" id="SubMenu1">
- <a href="#" class="list-group-item" data-parent="#SubMenu1">Subitem 1 a</a>
- <a href="#" class="list-group-item" data-parent="#SubMenu1">Subitem 2 b</a>
- </div>
- <a href="?mysql2php&database">PHP Database</a>
- <a href="?mysql2php&table">PHP Create Tables</a>
- <a href="?mysql2php&insert">PHP Insert Data</a>
- <a href="?mysql2php&update">PHP Update Data</a>
- <a href="?mysql2php&delete">PHP Delete Data</a>
- </div>
- </li>
- </br>
- <li>
- <a href="?users" class="fa fa-users fa-lg" > Users</a></br>
- </li>
- <li>
- <a href="?chart" class="fa fa-line-chart fa-lg" > Chart</a></br>
- </li>
- <li>
- <a href="?search&';if (isset($_GET['dbname'])) {
- echo "dbname=".$_GET['dbname'];
- }
- echo'" class="fa fa-search fa-lg" > Search</a></br>
- </li>
- <li>
- <a href="?eng" class="fa fa-server fa-lg" > ENGINES</a></br>
- </li>
- <li>
- <a href="?kill" class="fa fa-trash-o fa-lg" > Kill</a></br>
- </li>
- </ul>
- </div>
- ';
- if (isset($_GET['popup']))
- {
- echo "<button class=\"btn btn-default\" id=\"menu-toggle\" onClick=\"JavaScript:window.close();\" style=\"width:100%\">Close Window</button>";
- }
- else
- {
- echo '<a href="#menu-toggle" class="btn btn-default" id="menu-toggle" style="width:100%">← Menu</a>';
- }
- echo '
- <script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
- <!-- Bootstrap Core JavaScript -->
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
- <!-- Menu Toggle Script -->
- <script>
- $("#menu-toggle").click(function(e) {
- e.preventDefault();
- $("#wrapper").toggleClass("toggled");
- });
- </script>
- ';
- ob_start();
- headers();
- // Check connection
- if (!($conn = mysql_connect($servername, $username, $password)))
- {
- // die("Connection failed: " . $conn->connect_error);
- session_destroy();
- session_unset();
- header("location:?error");
- }
- $result = mysql_query("SHOW DATABASES");
- echo '<h3><i class="fa fa-database fa-lg"> Databases </i> </h3><hr></hr>';
- echo '<form method="POST">
- <div class="form-inline"><div class="form-group input-group">
- <span class="input-group-addon">Create Database</span>
- <input type="text" class="form-control" name="CreateDatabase" id="inputError"></div>
- <button type="submit" class="btn btn-default" name="dbmaker">Create</button>
- </div></form>';
- if (isset($_POST['dbmaker']))
- {
- if (!($conn = mysql_connect($servername, $username, $password)))
- {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = 'CREATE DATABASE ' . $_POST['CreateDatabase'];
- sql($sql,$showbox="show");
- } //end of make db
- echo '<input type="search" class="light-table-filter form-control" data-table="order-table" placeholder="Filter">';
- echo "</br><code> Query : SHOW DATABASES </code><br><br />";
- echo "<table class=\"order-table table\"><thead><tr><th>DataBase Name</th><th><i class=\"fa fa-minus-circle\"></i></th><th><i class=\"fa fa-area-chart\"></i></th></tr></thead><tbody>";
- while ($row = mysql_fetch_array($result))
- {
- echo "<tr><td><a href=?dbname=" . $row[0] . ">" . $row[0] . "</a></td><td><a href='?drop=" . $row[0] . "'><i class=\"fa fa-minus-circle\"></i></a></td><td><a href='?chart&dbname=".$row[0]."'><i class=\"fa fa-area-chart\"></i></a></td></tr>";
- } //shuru ka show database
- echo "</tbody></table>";
- if (isset($_GET['drop']))
- {
- $drop = $_GET['drop'];
- $sql = "Drop Database $drop";
- checkingsql($sql);
- }
- if (isset($_GET['checksql'])) {
- $sql=$_GET['checksql'];
- sql($sql);
- }
- 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 '<div class="form-inline"><div class="form-group input-group">
- <span class="input-group-addon">Create Table</span>
- <form method="GET">
- <input type="text" class="form-control" name="Createtable" id="inputError"></div>
- <div class="form-group input-group">
- <span class="input-group-addon">COLUMNS</span>
- <input type="number" class="form-control" name="COLUMNS" id="inputError" style="width: 5em;" value="1"/></div>
- <input type="hidden" class="form-control" name="dbname" value="' . $_GET['dbname'] . '">
- <button type="submit" class="btn btn-default">Create</button>
- </div></br></hr>';
- 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);
- echo "<table class=\"table table-striped table-hover\"><thead><tr><th>Table Name</th><th>Define</th><th>Empty</th><th>Drop</th></tr></thead>";
- // echo"<tr>";
- while ($row = mysql_fetch_row($result))
- {
- print "<tr><td><a href='?dbname=$dbname&tbl=$row[0]'>$row[0]</a></td><td><a href='#' onclick=\"window.open('?define&dbname=$dbname&tbl=$row[0]&popup','1444238799072','toolbar=no,width=573,height=638,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;\" > Define</a></td><td><a href='?dbname=$dbname&truncate=$row[0]'><i class=\"fa fa-paint-brush\"></i></a></td><td><a href='?dbname=$dbname&drop=$row[0]'><i class=\"fa fa-minus-circle\"></i></a></td></tr>";
- }
- if (isset($_GET['truncate']))
- {
- $sql = "Truncate Table " . $_GET['dbname'].".".$_GET['truncate'];
- checkingsql($sql);
- }
- if (isset($_GET['drop']))
- {
- $sql = "Drop Table " .$_GET['dbname'].".".$_GET['drop'];
- checkingsql($sql);
- }
- // echo"</tr></table>";// end of while
- } // end of show Database Tables
- // Show Rows From Tables
- if (isset($_GET['tbl']))
- {
- ob_end_clean();
- ob_start();
- headers();
- // Check connection
- $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);
- $sql3 = "SHOW COLUMNS FROM $dbname.$tbl";
- $sql = "Select * FROM $dbname.$tbl";
- $result = mysqli_query($conn, $sql3);
- echo '<input type="search" class="light-table-filter form-control" data-table="order-table" placeholder="Filter">';
- echo "</br><code> Query : $sql </code><br /></br>";
- sql($sql);
- echo "</br>
- <script>
- $(document).ready(function(){
- $(\"#flip\").click(function(){
- $(\"#panel\").slideToggle(\"slow\");
- });
- });
- </script>
- ";
- $sql="SHOW INDEX FROM $dbname.$tbl";
- echo '<a id="flip">INDEXES+</a>
- <div id="panel" style="display:none;">';sql($sql);echo'</div>';
- echo"</div>";
- footer();
- } // end of show Database Tables
- if (isset($_POST['Update'])) {
- # code...
- echo "Update now ??";
- }
- 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" class="form-inline">
- <select name="dbname" class="form-control">';
- $result = mysql_query("SHOW DATABASES");
- echo '<h3><i class="fa fa-database fa-2x"> Databases : </i> </h3>';
- if ((isset($_GET['dbname']))) {
- echo "<option value='" . $_GET['dbname'] . "' selected>" . $_GET['dbname'] . "</option>";
- }
- while ($row = mysql_fetch_array($result))
- {
- echo "<option value='" . $row[0] . "'>" . $row[0] . "</option>";
- }
- echo '</select><select name="filetype" class="form-control">
- <option value="filetype_sql">SQL</option>
- <option value="filetype_txt">TXT</option>
- </select>
- <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>";
- }
- $arr=explode("GB", convertByte(disk_free_space("/")) );
- $arr1=explode("GB", convertByte(disk_total_space("/")) );
- echo "</table></br>";
- echo'
- <div class="panel-body">
- <div class="flot-chart">
- <script type="text/javascript" src="https://www.google.com/jsapi"></script>
- <script type="text/javascript">
- google.load("visualization", "1", {packages:["corechart"]});
- google.setOnLoadCallback(drawChart);
- function drawChart() {
- var data = google.visualization.arrayToDataTable([
- [\'disk_total_space\', \'GB Space\'],
- [\'Occupied Space\', '. $arr[0] .' ],
- [\'Free Space\', '. $arr1[0] .']
- ]);
- var options = {
- title: \'Total Free Space On Server\'
- };
- var chart = new google.visualization.PieChart(document.getElementById(\'piechart\'));
- chart.draw(data, options);
- }
- </script>
- </head>
- <body>
- <div id="piechart" style="width: 900px; height: 500px;"></div>
- </body>
- </html>
- </div>
- </div>
- ';
- footer();
- }
- if (isset($_GET["phpinfo"]))
- {
- ob_end_clean();
- ob_start();
- headers();
- ob_start();
- phpinfo();
- $pinfo = ob_get_contents();
- ob_end_clean();
- echo "<style>
- #phpinfo {}
- #phpinfo pre {}
- #phpinfo a:link {}
- #phpinfo a:hover {}
- #phpinfo table {}
- #phpinfo .center {}
- #phpinfo .center table {}
- #phpinfo .center th {}
- #phpinfo td, th {}
- #phpinfo h1 {}
- #phpinfo h2 {}
- #phpinfo .p {}
- #phpinfo .e {}
- #phpinfo .h {}
- #phpinfo .v {}
- #phpinfo .vr {}
- #phpinfo img {}
- #phpinfo hr {}
- </style>";
- $pinfo = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $pinfo);
- echo $pinfo;
- 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="" class="form-inline">
- <span class="btn btn-default btn-file"><input type="file" name="files" ></span>
- <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);
- // }
- sql($import);
- }
- 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>";
- sql($sql);
- // $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>
- // <br />
- // </br>';
- //
- // }
- // else
- // {
- // echo "0 results";
- // }
- // $conn->close();
- echo '<div class="form-inline"><div class="form-group input-group">
- <span class="input-group-addon"><i class="fa fa-user-plus"> Username</i></span>
- <form method="POST">
- <input type="text" class="form-control" name="newuser" id="inputError"></div>
- <div class="form-group input-group">
- <span class="input-group-addon"><i class="fa fa-unlock-alt"> Password</i></span>
- <input type="password" class="form-control" name="newpass" id="inputError"/></div>
- <button type="submit" class="btn btn-default" name="createnewuser">Create New User</button>
- </div></br></hr>';
- footer();
- }
- if (isset($_POST['createnewuser']))
- {
- $sql = "CREATE USER '" . $_POST["newuser"] . "'@'localhost' IDENTIFIED BY '" . $_POST["newpass"] . "';";
- sql($sql);
- }
- 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" id="code">';
- 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>';
- echo '<script>
- var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
- mode: "text/x-mysql",
- lineNumbers: true,
- indentUnit: 4,
- tabMode: "indent",
- matchBrackets: true
- });
- </script>';
- if (isset($_POST['sqlquery']))
- {
- $sql = $_POST['sqlquery'];
- sql($sql);
- }
- }
- 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>';
- if (!(isset($_POST["dbname"]) || isset($_GET["dbname"])))
- {
- echo '<h5>Select Database</h5>';
- echo '<form action="" method="POST" >
- <select name="dbname" class="form-inline form-group glyphicon glyphicon-search">';
- $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> <input type="submit" value="Select Database" class="btn btn-default"></form>';
- }
- else
- {
- if (isset($_POST["dbname"])) {
- $dbname = $_POST["dbname"];
- }
- elseif (isset($_GET["dbname"])){
- $dbname = $_GET["dbname"];
- }
- echo '<h5>Select Tables From Database ' . $dbname . '</h5>';
- echo '<form action="" method="POST" >
- <input type="hidden" value="' . $dbname . '" name="dbname"/>
- <select name="tbname" class="form-inline glyphicon glyphicon-search">';
- $result = mysql_query("SHOW tables FROM $dbname");
- 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> <input type="submit" value="Select Table" class="btn btn-default" ></form>';
- }
- if (isset($_POST["tbname"]))
- {
- $dbname = $_POST["dbname"];
- $tbname = $_POST["tbname"];
- echo '<form action="" method="POST">
- <input type="hidden" value="' . $dbname . '" name="dbname"/>
- <input type="hidden" value="' . $tbname . '" name="tbname"/>
- <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 COLUMNS FROM $dbname.$tbname");
- 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>';
- } // end of if is set db name
- } // end of search
- if (isset($_POST['databasename']))
- {
- // Testing
- ob_end_clean();
- ob_start();
- headers();
- // Testing
- $tbname = $_POST["tbname"];
- $feild = $_POST['databasename'];
- $like = $_POST['like'];
- $value_to_search = $_POST['value_to_search'];
- $Sql = "SELECT * FROM $dbname.$tbname WHERE $feild $like '$value_to_search'";
- // $Sql="SELECT * FROM $dbname.CHARACTER_SETS WHERE $databasename $like '$value_to_search'";
- echo "<br /></br><code> Query : $Sql </code>";
- sql($Sql);
- footer();
- }
- if (isset($_GET['define']))
- {
- ob_end_clean();
- ob_start();
- headers();
- $dbname = $_GET['dbname'];
- $tbl = $_GET['tbl'];
- $Sql = "DESCRIBE $dbname.$tbl";
- echo "<code> Query : $Sql </code><br /></br>";
- sql($Sql);
- }
- if (isset($_GET['chart']))
- {
- ob_end_clean();
- ob_start();
- headers();
- echo '<h3 class="fa fa-area-chart fa-3x" > Hierarchical Database Model</h3>';
- echo '<hr></hr>
- A hierarchical database model is a data model in which the data is organized into a tree-like structure. The data is stored as records which are connected to one another through links. A record is a collection of fields, with each field containing only one value. The entity type of a record defines which fields the record contains.
- <br></br>';
- echo "
- <script type='text/javascript' src='https://www.google.com/jsapi'></script>
- <script type='text/javascript'>
- google.load('visualization', '1', {packages:['orgchart']});
- google.setOnLoadCallback(drawChart);
- function drawChart() {
- var data = new google.visualization.DataTable();
- data.addColumn('string', 'Node');
- data.addColumn('string', 'Parent');
- ";
- if (isset($_GET['dbname']))
- {
- $dbname = $_GET['dbname'];
- echo "data.addRows([ ";
- echo "['" . $dbname . "', ''],";
- $sql = "SHOW TABLES FROM " . $dbname;
- $result = mysql_query($sql);
- while ($rows = mysql_fetch_row($result))
- {
- echo "['" . $rows[0] . "','" . $dbname . "'],";
- }
- echo "]);
- var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
- chart.draw(data);
- }
- </script>
- <center><div id='chart_div'></div></center>
- ";
- }
- else
- {
- echo "data.addRows([ ";
- $result = mysql_query("SHOW DATABASES");
- while ($row = mysql_fetch_array($result)) {
- echo "['" . $row[0] . "', 'Databases'],";
- }
- echo "]);
- var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
- chart.draw(data);
- }
- </script>
- <center><div id='chart_div'></div></center>
- ";
- }
- }
- if (isset($_GET['Createtable']))
- {
- ob_end_clean();
- ob_start();
- headers();
- echo "Create Table " . $_GET['Createtable'] . "." . $_GET['dbname'];
- echo '<form method="POST">
- <div class="form-group">
- <div class="form-group input-group">
- <span class="input-group-addon">Table Name</span>
- <input type="text" class="form-control" name="tablename" id="inputError" value="' . $_GET['Createtable'] . '">
- </div></div>';
- for ($i = 0; $i < $_GET['COLUMNS']; $i++)
- {
- echo '<div class="form-group">
- <div class="form-group input-group">
- <span class="input-group-addon">Name</span>
- <input type="text" class="form-control" name="colname" id="inputError">
- </div>
- <select class="form-control" name="type'.$i.'">
- <option value="int">Int</option>
- <option value="varchar">varchar</option>
- <option value="text">text</option>
- <option value="date">date</option>
- <optgroup label="Numeric">
- <option value="INT">INT</option>
- <option value="TINYINT">TINYINT</option>
- <option value="SMALLINT">SMALLINT</option>
- <option value="MEDIUMINT">MEDIUMINT</option>
- <option value="BIGINT">BIGINT</option>
- <option value="FLOAT">FLOAT</option>
- <option value="DOUBLE">DOUBLE</option>
- <option value="DECIMAL">DECIMAL</option>
- <optgroup label="Date and Time">
- <option value="DATE">DATE</option>
- <option value="DATETIME">DATETIME</option>
- <option value="TIMESTAMP">TIMESTAMP</option>
- <option value="TIME">TIME</option>
- <option value="YEAR">YEAR</option>
- <optgroup label="String">
- <option value="CHAR">CHAR</option>
- <option value="VARCHAR">VARCHAR</option>
- <option value="BLOB">BLOB</option>
- <option value="TEXT">TEXT</option>
- <option value="TINYTEXT">TINYTEXT</option>
- <option value="MEDIUMTEXT">MEDIUMTEXT</option>
- <option value="LONGTEXT">LONGTEXT</option>
- <option value="ENUM">ENUM</option>
- </select>
- <div class="form-group input-group">
- <span class="input-group-addon">Length/Values</span>
- <input type="text" class="form-control" name="length'.$i.'" id="inputError">
- </div>
- </div>
- <div class="form-group">
- <select class="form-control" name="default">
- <option value="None">None</option>
- <option value="NULL">NULL</option>
- <option value="int">Int</option>
- <option value="int">Int</option>
- </select>
- <select class="form-control" name="collation">
- </select>
- <select class="form-control" name="attributes">
- </select>
- <div class="form-group input-group">
- <label>NULL</label>
- <input name="null'.$i.'" type="checkbox" value="null" class="allow_null">
- </div>
- <div class="form-group input-group">
- <span class="input-group-addon">Index</span>
- <select class="form-control" name="index" id="inputError">
- <option value="PRIMARY">PRIMARY</option>
- <option value="UNIQUE">UNIQUE</option>
- <option value="INDEX">INDEX</option>
- <option value="FULLTEXT">FULLTEXT</option>
- </select>
- </div>
- <div class="form-group input-group">
- <label>AUTO_INCREMENT</label>
- <input name="AUTO_INCREMENT'.$i.'" type="checkbox" value="AUTO_INCREMENT">
- </div>
- <div class="form-group input-group">
- <span class="input-group-addon">Comments</span>
- <input type="text" class="form-control" name="comments'.$i.'" id="inputError">
- </div>
- ';
- }
- echo '<button type="submit" class="btn btn-default" name="tbmaker">Create</button>
- </div>
- </div>
- </form>';
- footer();
- }
- if (isset($_GET['kill']))
- {
- echo "
- <script>
- var txt;
- var r = confirm(\"Do You Want To Kill Me ! \\n:( \");
- if (r == true) {
- window.location.assign(\"?killed\");
- } else {
- alert('Thanx For Spearing My Life :)');
- }
- </script>
- ";
- }
- if (isset($_POST['tbmaker']))
- {
- $tablename = $_POST['tablename'];
- $db = $_GET['dbname'];
- $index = $_POST['index'];
- $AUTO_INCREMENT = $_POST['AUTO_INCREMENT'];
- for($i=0;$i<=$_GET['COLUMNS'];$i++){
- $colname.$i = $_POST["colname$i"];
- $length.$i = $_POST['length'.$i];
- $type.$i = $_POST['type'.$i];
- $null.$i = $_POST['null'.$i];
- }
- // CREATE TABLE MyGuests (
- // id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- // firstname VARCHAR(30) NOT NULL,
- // lastname VARCHAR(30) NOT NULL,
- // email VARCHAR(50),
- // reg_date TIMESTAMP
- // )
- echo $sql="CREATE TABLE ".$tablename.".".$db."(";
- for($i=0;$i<=$_GET['COLUMNS'];$i++){
- echo $colname.$i." ".$type."(".$length.") ".$AUTO_INCREMENT." ".$index." ,";
- }
- echo ")";
- // $url = explode("\r\n", $_POST['url']);
- // $sql="CREATE TABLE `$db`.`$tablename` ( `$colname` $type($length) NOT NULL ) ENGINE = InnoDB;";
- // CREATE TABLE MyGuests (
- // id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- // firstname VARCHAR(30) NOT NULL,
- // lastname VARCHAR(30) NOT NULL,
- // email VARCHAR(50),
- // reg_date TIMESTAMP
- // )
- //$sql = "CREATE TABLE `$db`.`$tablename` ( `$colname` $type($length) NOT NULL ) ENGINE = InnoDB;";
- echo '<div class="row">
- <div class="col-lg-12">';
- sql($sql);
- echo '</div>
- </div>';
- // footer();
- }
- if (isset($_GET['mysql2php']))
- {
- ob_end_clean();
- ob_start();
- headers();
- function phpmaker()
- {
- echo '<?php
- $servername = "' . $GLOBALS['servername'] . '";
- $username = "' . $GLOBALS['username'] . '";
- $password = "' . $GLOBALS['password'] . '";
- // Create connection
- $conn = new mysqli($servername, $username, $password);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- echo "Connected successfully";
- ';
- }
- echo '<h3 class="fa fa-code fa-3x">MySQL 2 php</h3><hr></hr>';
- echo "Mysql 2 Php Converts your Mysql Queries To php in one click Just Select The Type and Let Mysql Do the rest work !<br /></br>";
- echo '
- <form action=""method="POST">
- <textarea class="form-control" name="converter" id="code">';
- if (isset($_GET['connect']))
- {
- echo phpmaker() . "?>";
- }
- elseif (isset($_GET['database']))
- {
- echo phpmaker() . '// Create database
- $sql = "CREATE DATABASE' . $_GET['database'] . '
- if ($conn->query($sql) === TRUE) {
- echo "Database created successfully";
- } else {
- echo "Error creating database: " . $conn->error;
- }
- $conn->close();
- ?>';
- }
- elseif (isset($_GET['table']))
- {
- // http://localhost/test.php?mysql2php&table&dbname=information_schema&tbl=CHARACTER_SETS
- $dbname = $_GET['dbname'];
- $tbl = $_GET['tbl'];
- echo phpmaker() . '$sql = "INSERT INTO ' . $dbname . '.' . $tbl . ' (';
- getrows($dbname, $tbl);
- echo ')
- VALUES (\'John\', \'Doe\', \'john@example.com\')";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br />" . $conn->error;
- }
- $conn->close();
- ?>';
- }
- echo '</textarea>
- <script>
- var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
- mode: "text/x-mysql",
- tabMode: "indent",
- matchBrackets: true
- });
- </script>
- </br>
- <input class="btn btn-default" type="submit" name="start_converting" value="Convert"/>
- </form>
- ';
- if (isset($_GET['start_converting']))
- {
- }
- }
- if (isset($_GET['killed']))
- {
- session_destroy();
- session_unset();
- unlink(__FILE__);
- header("location:?");
- }
- if (isset($_GET['logout']))
- {
- session_destroy();
- session_unset();
- header("location:?");
- }
- } // end of else connection in start
- if (isset($_GET['status'])) {
- ob_end_clean();
- ob_start();
- headers();
- $sql="SHOW GLOBAL STATUS;";
- sql($sql);
- }
- if (isset($_GET['eng'])) {
- ob_end_clean();
- ob_start();
- headers();
- $sql="SHOW ENGINES;";
- sql($sql);
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement