PageRenderTime 73ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/ASTRA_Demo_Server/udrive/home/admin/www/phpMyBackupPro/db_info.php

https://github.com/shafiqissani/ASTRA-College-Website
PHP | 163 lines | 97 code | 26 blank | 40 comment | 15 complexity | c729f4c793f779c624f3d0fb873d25ca MD5 | raw file
  1. <?php
  2. /*
  3. +--------------------------------------------------------------------------+
  4. | phpMyBackupPro |
  5. +--------------------------------------------------------------------------+
  6. | Copyright (c) 2004-2007 by Dirk Randhahn |
  7. | http://www.phpMyBackupPro.net |
  8. | version information can be found in definitions.php. |
  9. | |
  10. | This program is free software; you can redistribute it and/or |
  11. | modify it under the terms of the GNU General Public License |
  12. | as published by the Free Software Foundation; either version 2 |
  13. | of the License, or (at your option) any later version. |
  14. | |
  15. | This program is distributed in the hope that it will be useful, |
  16. | but WITHOUT ANY WARRANTY; without even the implied warranty of |
  17. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
  18. | GNU General Public License for more details. |
  19. | |
  20. | You should have received a copy of the GNU General Public License |
  21. | along with this program; if not, write to the Free Software |
  22. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.|
  23. +--------------------------------------------------------------------------+
  24. */
  25. require_once("login.php");
  26. // used variables
  27. if (!isset($_GET['table'])) $_GET['table']=FALSE;
  28. // connect to mySQL
  29. $con=@mysql_connect($CONF['sql_host'],$CONF['sql_user'],$CONF['sql_passwd']);
  30. // get start time to calculate duration
  31. if (function_exists("microtime")) {
  32. $microtime=explode(" ",microtime());
  33. $starttime=($microtime[0]+$microtime[1]);
  34. } else {
  35. $starttime=time();
  36. }
  37. // tables info popUp
  38. if ($_GET['table']) {
  39. // select the db
  40. mysql_select_db($_GET['table']);
  41. $stati=mysql_query("show table status");
  42. while($status=mysql_fetch_array($stati)) {
  43. $table_names[]=$status['Name'];
  44. $table_rows[]=$status['Rows'];
  45. $size=PMBP_size_type($status['Data_length']+$status['Index_length']);
  46. $table_size[]=$size['value']." ".$size['type'];
  47. }
  48. // get number of fields
  49. if (is_array($table_names))
  50. foreach($table_names as $table) {
  51. mysql_query("show columns from `".$table."`");
  52. $table_fields[]=mysql_affected_rows();
  53. }
  54. echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
  55. \"http://www.w3.org/TR/html4/loose.dtd\">
  56. <html".ARABIC_HTML.">
  57. <head>
  58. <title>phpMyBackupPro - ".F_DB_INFO."</title>
  59. <meta http-equiv=\"Content-Type\" content=\"text/html;charset=".BD_CHARSET_HTML."\">
  60. <link rel=\"stylesheet\" href=\"./".PMBP_STYLESHEET_DIR.$CONF['stylesheet'].".css\" type=\"text/css\">\n";
  61. readfile(PMBP_JAVASCRIPTS);
  62. echo "</head>
  63. <body class=\"white\">
  64. <table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">\n
  65. <tr><th colspan=\"4\" class=\"active\">\n";
  66. echo PMBP_image_tag("logo.png","phpMyBackupPro PMBP_WEBSITE",PMBP_WEBSITE);
  67. echo " ".PMBP_VERSION."</th></tr>\n";
  68. echo "<tr>\n<td colspan=\"4\"><br><div class=\"bold_left\">".DB_TAB_TITLE.$_GET['table'].":</div><br></td>\n</tr>\n";
  69. echo "<tr>\n<th class=\"active\">".DB_TAB_NAME."</th>\n<th class=\"active\">".DB_TAB_COLS."</th>\n<th class=\"active\">".DB_NUM_ROWS."</th>\n<th class=\"active\">".DB_SIZE."</th>\n</tr>\n";
  70. for($i=0;$i<count($table_names);$i++) {
  71. echo "<tr ".PMBP_change_color("#FFFFFF","#000000").">\n<th class=\"active\">".$table_names[$i]."</th>\n<td class=\"list\">".$table_fields[$i]."</td>";
  72. echo "\n<td class=\"list\">".$table_rows[$i]."</td>\n<td class=\"list\">".$table_size[$i]."</td>\n</tr>\n";
  73. }
  74. // show execution duration
  75. if (function_exists("microtime")) {
  76. $microtime=explode(" ",microtime());
  77. $endtime=($microtime[0]+$microtime[1]);
  78. } else {
  79. $endtime=time();
  80. }
  81. echo "<tr>\n<td colspan=\"4\">\n<br><div class=\"bold_left\">".F_DURATION.": ".number_format($endtime-$starttime,3)." ".F_SECONDS."</div>\n</td>\n</tr>\n";
  82. echo "</table>\n</body>\n</html>";
  83. exit;
  84. }
  85. PMBP_print_header(ereg_replace(".*/","",$_SERVER['SCRIPT_NAME']));
  86. // if first use or no db-connection possible
  87. if (!$con) {
  88. echo "<div class=\"red\">".I_SQL_ERROR."</div>";
  89. }
  90. //else
  91. {
  92. echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">\n";
  93. // list all databases
  94. $all_dbs=PMBP_get_db_list();
  95. if (count($all_dbs)) {
  96. natsort($all_dbs);
  97. echo "<tr>\n<th class=\"active\">".DB_NAME."</th>\n<th class=\"active\">".DB_NUM_TABLES."</th>\n<th class=\"active\">".DB_NUM_ROWS."</th>\n<th class=\"active\">".DB_SIZE."</th>\n</tr>\n";
  98. // print html table
  99. foreach($all_dbs as $db_name) {
  100. // select the db
  101. mysql_select_db($db_name,$con);
  102. $num_tables=$num_rows=$data_size=0;
  103. // get number of rows and size of tables
  104. $stati=mysql_query("show table status",$con);
  105. while ($status=@mysql_fetch_array($stati)) {
  106. $data_size+=($status['Data_length']+$status['Index_length']);
  107. $num_rows+=$status['Rows'];
  108. }
  109. $size=PMBP_size_type($data_size);
  110. // get number of tables
  111. $num_tables=mysql_affected_rows($con);
  112. // first field for the db name
  113. echo "<tr ".PMBP_change_color("#FFFFFF","#000000").">";
  114. echo "\n<th class=\"active\">\n".$db_name;
  115. if ($num_tables>0) echo "<span class=\"standard\">".PMBP_pop_up("db_info.php?table=".$db_name," [".DB_TABLES."]","view")."</span>";
  116. elseif ($num_tables<0) $num_tables="<span class=\"red\">".C_WRONG_DB."</span>";
  117. echo "\n</th>\n";
  118. echo "<td class=\"list\">".$num_tables."</td>\n";
  119. echo "<td class=\"list\">".$num_rows."</td>\n";
  120. echo "<td class=\"list\">".$size['value']." ".$size['type']."</td>\n";
  121. }
  122. // show execution duration
  123. if (function_exists("microtime")) {
  124. $microtime=explode(" ",microtime());
  125. $endtime=($microtime[0]+$microtime[1]);
  126. } else {
  127. $endtime=time();
  128. }
  129. echo "<tr>\n<td colspan=\"4\">\n<br><div class=\"bold_left\">".F_DURATION.": ".number_format($endtime-$starttime,3)." ".F_SECONDS."</div>\n".DB_DIFF."\n</td>\n</tr>\n";
  130. } else {
  131. // if there are no databases
  132. echo "<tr>\n<td><div class=\"bold\">".DB_NO_DB.".</div>\n</td>\n</tr>\n";
  133. }
  134. echo "</table>\n";
  135. }
  136. PMBP_print_footer();
  137. ?>