changed git call from https to git readonly
[atutor.git] / mods / wiki / tools / cron.d / S92binbackup.php
1 <?php
2 /*
3    Sends out a binary backup in the format accepted by the ../t_transfer
4    utility. You only must configure a recipient.
5 */
6
7 // define("BINBACKUP_TO", "you@example.com");   // who gets the backup
8    define("BINBACKUP_TEXTONLY", 1);   // include ?binary entries or not
9
10
11 #-- go
12 if (defined("BINBACKUP_TO")) {
13
14    // this is fixed
15    define("EWIKI_TRANSFER_IDF", "EWBF00000025");    // file magic
16
17    #-- start output
18    $mail = "";
19    $mail .= EWIKI_TRANSFER_IDF;
20
21    $result = ewiki_db::GETALL(array("id","version","flags"));
22    while ($row = $result->get()) {
23
24       $id = $row["id"];
25       for ($v=$row["version"]; $v>0; $v--) {
26
27          $row = ewiki_db::GET($id, $v);
28
29          if (BINBACKUP_TEXTONLY && !(EWIKI_DB_F_TEXT & $row["flags"]))
30          {
31             continue;
32          }
33
34          if ($row && ($row = serialize($row))) {
35              $mail .= "\n" . strlen($row) . "\n" . $row;
36          }
37
38       }
39    }
40    
41    #-- send
42    $mail = gzencode($mail);
43    $mail = base64_encode($mail);
44    mail(
45       BINBACKUP_TO,
46       "[backup] " . EWIKI_NAME . ":",
47       $mail,
48        "Content-Transfer-Encoding: base64\n"
49       ."Content-Encoding: deflate\n"
50       ."Content-Type: application/x.vnd.ewiki.transfer-file\n"
51       ."X-Mailer: ewiki/".EWIKI_VERSION."\n"
52       ."From: ewiki@$_SERVER[SERVER_NAME]\n"
53       ."Reply-To: trashbin@example.com\n"
54    );
55    unset($mail);
56
57 }
58
59
60 ?>