home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 August / PCWorld_2001-08_cd.bin / Komunikace / phptriad / phptriadsetup2-11.exe / htdocs / phpMyAdmin / db_dump.php < prev    next >
PHP Script  |  2000-08-20  |  2KB  |  96 lines

  1. <?php
  2. /* $Id: db_dump.php,v 1.12 2000/02/13 20:15:49 tobias Exp $ */
  3. @set_time_limit(600);
  4. $crlf="\n";
  5. if(empty($asfile))
  6. {
  7.     include("header.inc.php");
  8.     echo "<div align=left><pre>\n";
  9.  
  10. else 
  11. {
  12.     include("lib.inc.php");
  13.     header("Content-disposition: filename=$db.sql");
  14.     header("Content-type: application/octetstream");
  15.     header("Pragma: no-cache");
  16.     header("Expires: 0");
  17.    
  18.     // doing some DOS-CRLF magic...
  19.     $client = getenv("HTTP_USER_AGENT");
  20.     if(ereg('[^(]*\((.*)\)[^)]*',$client,$regs)) 
  21.     {
  22.         $os = $regs[1];
  23.         // this looks better under WinX
  24.         if (eregi("Win",$os)) 
  25.             $crlf="\r\n";
  26.     }
  27. }
  28.  
  29. function my_handler($sql_insert)
  30. {
  31.     global $crlf, $asfile;
  32.     
  33.     if(empty($asfile)) 
  34.     {
  35.         echo htmlspecialchars("$sql_insert;$crlf");
  36.     }
  37.     else
  38.     {
  39.         echo "$sql_insert;$crlf";
  40.     }
  41. }
  42.  
  43. $tables = mysql_list_tables($db);
  44.  
  45. $num_tables = @mysql_numrows($tables);
  46. if($num_tables == 0)
  47. {
  48.     echo $strNoTablesFound;
  49. }
  50. else
  51. {
  52.     $i = 0;
  53.     print "# phpMyAdmin MySQL-Dump$crlf";
  54.     print "# http://phpwizard.net/phpMyAdmin/$crlf";
  55.     print "#$crlf";
  56.     print "# $strHost: " . $cfgServer['host'];
  57.     if(!empty($cfgServer['port'])) 
  58.     {
  59.         print ":" . $cfgServer['port'];
  60.     }
  61.     print " $strDatabase: $db$crlf";
  62.  
  63.     while($i < $num_tables)
  64.     { 
  65.         $table = mysql_tablename($tables, $i);
  66.  
  67.         print $crlf;
  68.         print "# --------------------------------------------------------$crlf";
  69.         print "#$crlf";
  70.         print "# $strTableStructure '$table'$crlf";
  71.         print "#$crlf";
  72.         print $crlf;
  73.  
  74.         echo get_table_def($db, $table, $crlf).";$crlf$crlf";
  75.         
  76.         if($what == "data")
  77.         {
  78.             print "#$crlf";
  79.             print "# $strDumpingData '$table'$crlf";
  80.             print "#$crlf";
  81.             print $crlf;
  82.         
  83.             get_table_content($db, $table, "my_handler");
  84.         }
  85.         $i++;
  86.     }
  87. }
  88.  
  89. if(empty($asfile))
  90. {
  91.     print "</pre></div>\n";
  92.     include ("footer.inc.php");
  93. }
  94. ?>
  95.