History of TikiExportUpdate

Differences from version 2 to 3



@@ -1,7 +1,7 @@

 (This appears to be code for exporting Wiki data.)
 
 Here are 2 updated files, tiki-export_wiki_pages.php and exportlib.php. They have a couple minor hacks
-1) new filename for a complete export: "tiki_export-<datestamp>.tar"
+1) new filename for a complete export: "tiki_export-<datestamp>.tar"
 2) better headers (fixed wget, etc)
 3) put directory and filenames into variables
 4) tarfile is no longer passed as a Location: header, readfile() is used to send file contents to the client so file may be moved to some arbitrary point outside of the document root

@@ -9,9 +9,10 @@

 Tested download with: Konqueror 3.1.3, Opera 7.23 Linux, Mozilla 1.6 Linux, Mozilla 1.4 Win, IE 6
 
 -=tiki-export_wiki_pages.php=-
-^
 
-&lt;?php
+{code in="php"}
+
+<?php
 
 // $Header: /cvsroot/tikiwiki/tiki/tiki-export_wiki_pages.php,v 1.6 2003/12/04 10:40:53 mose Exp $
 

@@ -25,7 +26,7 @@

 // Initialization
 require_once ('setup.php');
 
-include_once (&quot;lib/ziplib.php&quot;);
+include_once ("lib/ziplib.php");
 include_once ('lib/wiki/exportlib.php');
 
 /* I hate ifs without brackets ;) */

@@ -35,14 +36,14 @@

 }
 
 // this should probably use a global date format
-$datestamp = date(&quot;dMY&quot;);
+$datestamp = date("dMY");
 
-if (!isset($_REQUEST[&quot;page&quot;])) {
+if (!isset($_REQUEST["page"])) {
 
- $exportlib-&gt;MakeWikiZip();
+ $exportlib->MakeWikiZip();
 
  /* This var should actually come from a global setting for a writable directory, but since there isn't one yet I'll just set it here */
- $dumpdir = &quot;dump&quot;;
+ $dumpdir = "dump";
 
  /*
  I'm not even sure yet if this next variable would show up here

@@ -50,11 +51,11 @@

  */
  if(!empty($tikidomain))
  {
- $filename = &quot;$dumpdir/$tikidomain/tiki_export-$datestamp.tar&quot;;
+ $filename = "$dumpdir/$tikidomain/tiki_export-$datestamp.tar";
  }
  else
  {
- $filename = &quot;$dumpdr/tiki_export-$datestamp.tar&quot;;
+ $filename = "$dumpdr/tiki_export-$datestamp.tar";
  }
 
  /*

@@ -66,55 +67,56 @@

 
  if(file_exists($filename))
  {
- header(&quot;Pragma: public&quot;);
- header(&quot;Expires: 0&quot;);
- header(&quot;Cache-Control: must-revalidate, post-check=0, pre-check=0&quot;);
- header(&quot;Content-Type: application/octet-stream&quot;);
- header(&quot;Content-Disposition: attachment; filename=\&quot;tiki_export-$datestamp.tar\&quot;&quot;);
- header(&quot;Content-Description: File Transfer&quot;);
+ header("Pragma: public");
+ header("Expires: 0");
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+ header("Content-Type: application/octet-stream");
+ header("Content-Disposition: attachment; filename=\"tiki_export-$datestamp.tar\"");
+ header("Content-Description: File Transfer");
 
- @readfile(&quot;$filename&quot;);
+ @readfile("$filename");
  }
  else
  {
- header(&quot;Status: 404 Not Found&quot;);
+ header("Status: 404 Not Found");
  }
 
 } else {
- if (isset($_REQUEST[&quot;all&quot;]))
+ if (isset($_REQUEST["all"]))
  $all = 0;
  else
  $all = 1;
 
- $data = $exportlib-&gt;export_wiki_page($_REQUEST[&quot;page&quot;], $all);
- $page = $_REQUEST[&quot;page&quot;];
+ $data = $exportlib->export_wiki_page($_REQUEST["page"], $all);
+ $page = $_REQUEST["page"];
 
- header(&quot;Pragma: public&quot;);
- header(&quot;Expires: 0&quot;);
- header(&quot;Cache-Control: must-revalidate, post-check=0, pre-check=0&quot;);
- header(&quot;Content-Type: application/octet-stream&quot;);
- header(&quot;Content-Disposition: inline; filename=\&quot;$page-$datestamp\&quot;&quot;);
- header(&quot;Content-Description: File Transfer&quot;);
+ header("Pragma: public");
+ header("Expires: 0");
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+ header("Content-Type: application/octet-stream");
+ header("Content-Disposition: inline; filename=\"$page-$datestamp\"");
+ header("Content-Description: File Transfer");
 
  echo $data;
 }
 
-?&gt;
+?>
 
-^
+{code}
 
 -=exportlib.php=-
-^
 
-&lt;?php
+{code in="php"}
+
+<?php
 
 class ExportLib extends TikiLib {
  function ExportLib($db) {
  # this is probably uneeded now
  if (!$db) {
- die (&quot;Invalid db object passed to ExportLib constructor&quot;);
+ die ("Invalid db object passed to ExportLib constructor");
  }
- $this-&gt;db = $db;
+ $this->db = $db;
  }
 
  function MakeWikiZip() {

@@ -122,41 +124,41 @@

 
  // added datestamp, changed filenames - mkc
 
- $datestamp = date(&quot;dMY&quot;);
- $zipname = &quot;wikidb-$datestamp.zip&quot;;
- include_once (&quot;lib/tar.class.php&quot;);
+ $datestamp = date("dMY");
+ $zipname = "wikidb-$datestamp.zip";
+ include_once ("lib/tar.class.php");
  $tar = new tar();
- $query = &quot;select `pageName` from `tiki_pages` order by &quot;.$this-&gt;convert_sortmode(&quot;pageName_asc&quot;);
- $result = $this-&gt;query($query,array());
+ $query = "select `pageName` from `tiki_pages` order by ".$this->convert_sortmode("pageName_asc");
+ $result = $this->query($query,array());
 
- while ($res = $result-&gt;fetchRow()) {
- $page = $res[&quot;pageName&quot;];
- $content = $this-&gt;export_wiki_page($page, 0);
- $tar-&gt;addData($page, $content, date(&quot;U&quot;));
+ while ($res = $result->fetchRow()) {
+ $page = $res["pageName"];
+ $content = $this->export_wiki_page($page, 0);
+ $tar->addData($page, $content, date("U"));
  }
 
- $tar-&gt;toTar(&quot;dump/$tikidomain/tiki_export-$datestamp.tar&quot;, FALSE);
+ $tar->toTar("dump/$tikidomain/tiki_export-$datestamp.tar", FALSE);
  return '';
  }
 
  function export_wiki_page($pageName, $nversions = 1) {
  $head = '';
- $head .= &quot;Date: &quot; . $this-&gt;get_rfc2822_datetime(). &quot;\r\n&quot;;
- $head .= sprintf(&quot;Mime-Version: 1.0 (Produced by Tiki)\r\n&quot;);
- $iter = $this-&gt;get_page_history($pageName);
- $info = $this-&gt;get_page_info($pageName);
+ $head .= "Date: " . $this->get_rfc2822_datetime(). "\r\n";
+ $head .= sprintf("Mime-Version: 1.0 (Produced by Tiki)\r\n");
+ $iter = $this->get_page_history($pageName);
+ $info = $this->get_page_info($pageName);
  $parts = array();
  $parts[] = MimeifyPageRevision($info);
 
- if ($nversions &gt; 1 || $nversions == 0) {
+ if ($nversions > 1 || $nversions == 0) {
  foreach ($iter as $revision) {
  $parts[] = MimeifyPageRevision($revision);
 
- if ($nversions &gt; 0 &amp;&amp; count($parts) &gt;= $nversions)
+ if ($nversions > 0 && count($parts) >= $nversions)
  break;
  }
  }
- if (count($parts) &gt; 1)
+ if (count($parts) > 1)
  return $head . MimeMultipart($parts);
 
  assert ($parts);

@@ -166,21 +168,21 @@

  // Returns all the versions for this page
  // without the data itself
  function get_page_history($page) {
- $query = &quot;select `pageName`, `description`, `version`, `lastModif`, `user`, `ip`, `data`, `comment` from `tiki_history` where `pageName`=? order by &quot;.$this-&gt;convert_sortmode(&quot;version_desc&quot;);
- $result = $this-&gt;query($query,array($page));
+ $query = "select `pageName`, `description`, `version`, `lastModif`, `user`, `ip`, `data`, `comment` from `tiki_history` where `pageName`=? order by ".$this->convert_sortmode("version_desc");
+ $result = $this->query($query,array($page));
  $ret = array();
 
- while ($res = $result-&gt;fetchRow()) {
+ while ($res = $result->fetchRow()) {
  $aux = array();
- $aux[&quot;version&quot;] = $res[&quot;version&quot;];
- $aux[&quot;lastModif&quot;] = $res[&quot;lastModif&quot;];
- $aux[&quot;user&quot;] = $res[&quot;user&quot;];
- $aux[&quot;ip&quot;] = $res[&quot;ip&quot;];
- $aux[&quot;data&quot;] = $res[&quot;data&quot;];
- $aux[&quot;pageName&quot;] = $res[&quot;pageName&quot;];
- $aux[&quot;description&quot;] = $res[&quot;description&quot;];
- $aux[&quot;comment&quot;] = $res[&quot;comment&quot;];
- //$aux[&quot;percent&quot;] = levenshtein($res[&quot;data&quot;],$actual);
+ $aux["version"] = $res["version"];
+ $aux["lastModif"] = $res["lastModif"];
+ $aux["user"] = $res["user"];
+ $aux["ip"] = $res["ip"];
+ $aux["data"] = $res["data"];
+ $aux["pageName"] = $res["pageName"];
+ $aux["description"] = $res["description"];
+ $aux["comment"] = $res["comment"];
+ //$aux["percent"] = levenshtein($res["data"],$actual);
  $ret[] = $aux;
  }
  return $ret;

@@ -189,6 +191,6 @@

 
 $exportlib = new ExportLib($dbTiki);
 
-?&gt;
+?>
 
-^
+{code}
Page History
Date/CommentUserIPVersion
16 May 2005 (20:12 UTC)
Categorized and added a comment at beginning
spiderr66.93.240.2043
Current • Source
SEWilco209.98.144.162
View • Compare • Difference • Source