| [ PHPXref.com ] | [ Generated: Sun Jul 20 17:32:23 2008 ] | [ ErfurtWiki 1.02b ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 #-- libs 4 if (!function_exists("gzeof")) { 5 die("This tool requires the 'zlib' extension of PHP 3.x or higher. Switch your provider."); 6 } 7 include ("t_config.php"); 8 9 #-- config 10 define("EWIKI_TRANSFER_IDF", "EWBF00000025"); // file magic 11 12 #-- downloading 13 if ($type = $_REQUEST["fetch"]) { 14 $gzip = ($type == "dat.gz"); 15 16 $date = strftime("%Y-%m-%d", time()); 17 $title = EWIKI_NAME; 18 header("Content-Type: application/octet-stream"); 19 header("Content-Disposition: attachment; filename=\"ewiki_transfer.$title.$date.$type\""); 20 if ($gzip) { 21 ob_start("ob_gzhandler"); 22 } 23 24 echo(EWIKI_TRANSFER_IDF); 25 $n=0; 26 27 $result = ewiki_db::GETALL(array("id","version","flags")); 28 while ($row = $result->get()) { 29 $n++; 30 31 $id = $row["id"]; 32 for ($v=$row["version"]; $v>0; $v--) { 33 34 $row = ewiki_db::GET($id, $v); 35 36 if ($_REQUEST["textonly"] 37 && (EWIKI_DB_F_TEXT != ($row["flags"] & EWIKI_DB_F_TYPE)) ) 38 { 39 continue; 40 } 41 42 if ($row && ($row = serialize($row))) { 43 echo "\n" . strlen($row) . "\n" . $row; 44 } 45 46 } 47 48 if ($gzip && !($n % 15)) { 49 ob_flush(); 50 } 51 } 52 } 53 54 #-- uploading 55 elseif (!empty($_FILES["data"])) { 56 57 #error_reporting(E_ALL); 58 if ($i = gzopen($_FILES["data"]["tmp_name"], "rb")) { 59 $feof = "gzeof"; 60 $fgets = "gzgets"; 61 $fread = "gzread"; 62 } 63 elseif ($i = fopen($_FILES["data"]["tmp_name"], "rb")) { 64 $feof = "feof"; 65 $fgets = "fgets"; 66 $fread = "fread"; 67 } 68 else { 69 die("could not open incoming file"); 70 } 71 72 $n = 0; 73 74 while ($i && !$eof($i)) { 75 76 /*stripCRLF*/ $idf = $fgets($i, 4096); 77 if ($n==0) { 78 $idf = trim($idf); 79 if ($idf != EWIKI_TRANSFER_IDF) { 80 die("This is not an ewiki transfer binary. (wrong magic code 0x".bin2hex($idf).")"); 81 } 82 } 83 84 $count = $fgets($i, 4096); 85 if (($count === false) || (($count = trim($count)) <= 0)) { 86 87 if ($feof($i)) { 88 $fclose($i); 89 die("<br><b>finished reading</b> $n entries"); 90 } 91 else { 92 die("<br><b>file broken</b> (zero count block) after $n entries"); 93 } 94 } 95 96 $row = $fread($i, $count); 97 $row = unserialize($row); 98 99 if (ewiki_db::WRITE($row)) { 100 echo $row["id"] .".". $row["version"] . " \n"; 101 } 102 103 $n++; 104 } 105 106 } 107 108 #-- activation form 109 else { 110 ?> 111 <html> 112 <head> 113 <title>make binary backup of whole database</title> 114 <link rel="stylesheet" type="text/css" href="t_config.css"> 115 </head> 116 <body bgcolor="#ffffff" text="#000000"> 117 118 <h1>database dump</h1> 119 If you cannot make use of the <b>ewikictl</b> cmdline utility, and need 120 a way to transfer the whole database from one server to another, you 121 can make a downloadable binary dump using this util. 122 <br><br> 123 124 <h4>generate dump</h4> 125 <form action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="GET" enctype="application/x-www-form-urlencoded"> 126 <select name="textonly"> 127 <option value="0">full dump (+ binary entries)</option> 128 <option value="1" selected>retrieve only text pages</option> 129 </select> 130 <select name="fetch"> 131 <option value="dat.gz">.dat.gz</option> 132 <option value="dat">.dat</option> 133 </select> 134 <br> <input type="submit" value="save"> 135 </form> 136 <br> 137 138 <h4>reinsert dump</h4> 139 <form action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="POST" enctype="multipart/form-data"> 140 <input type="file" name="data"> 141 <br> <input type="submit" value="upload"> 142 </form> 143 <br> 144 145 </body></html> 146 <?php 147 } 148 149 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |