4 if (!function_exists("gzeof")) {
5 die("This tool requires the 'zlib' extension of PHP 3.x or higher. Switch your provider.");
7 include("t_config.php");
10 define("EWIKI_TRANSFER_IDF", "EWBF00000025"); // file magic
13 if ($type = $_REQUEST["fetch"]) {
14 $gzip = ($type == "dat.gz");
16 $date = strftime("%Y-%m-%d", time());
18 header("Content-Type: application/octet-stream");
19 header("Content-Disposition: attachment; filename=\"ewiki_transfer.$title.$date.$type\"");
21 ob_start("ob_gzhandler");
24 echo(EWIKI_TRANSFER_IDF);
27 $result = ewiki_db::GETALL(array("id","version","flags"));
28 while ($row = $result->get()) {
32 for ($v=$row["version"]; $v>0; $v--) {
34 $row = ewiki_db::GET($id, $v);
36 if ($_REQUEST["textonly"]
37 && (EWIKI_DB_F_TEXT != ($row["flags"] & EWIKI_DB_F_TYPE)) )
42 if ($row && ($row = serialize($row))) {
43 echo "\n" . strlen($row) . "\n" . $row;
48 if ($gzip && !($n % 15)) {
55 elseif (!empty($_FILES["data"])) {
57 #error_reporting(E_ALL);
58 if ($i = gzopen($_FILES["data"]["tmp_name"], "rb")) {
63 elseif ($i = fopen($_FILES["data"]["tmp_name"], "rb")) {
69 die("could not open incoming file");
74 while ($i && !$eof($i)) {
76 /*stripCRLF*/ $idf = $fgets($i, 4096);
79 if ($idf != EWIKI_TRANSFER_IDF) {
80 die("This is not an ewiki transfer binary. (wrong magic code 0x".bin2hex($idf).")");
84 $count = $fgets($i, 4096);
85 if (($count === false) || (($count = trim($count)) <= 0)) {
89 die("<br><b>finished reading</b> $n entries");
92 die("<br><b>file broken</b> (zero count block) after $n entries");
96 $row = $fread($i, $count);
97 $row = unserialize($row);
99 if (ewiki_db::WRITE($row)) {
100 echo $row["id"] .".". $row["version"] . " \n";
113 <title>make binary backup of whole database</title>
114 <link rel="stylesheet" type="text/css" href="t_config.css">
116 <body bgcolor="#ffffff" text="#000000">
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.
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>
130 <select name="fetch">
131 <option value="dat.gz">.dat.gz</option>
132 <option value="dat">.dat</option>
134 <br> <input type="submit" value="save">
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">