2 require_once(dirname(__FILE__
) . "/../interface/globals.php");
5 $document_id = $_GET['doc_id'];
6 $d = new Document($document_id);
8 $storagemethod = $d->get_storagemethod();
9 $couch_docid = $d->get_couch_docid();
10 $couch_revid = $d->get_couch_revid();
12 if($couch_docid && $couch_revid){
13 $couch = new CouchDB();
14 $data = array($GLOBALS['couchdb_dbase'],$couch_docid);
15 $resp = $couch->retrieve_doc($data);
16 $xml = base64_decode($resp->data
);
17 if($content=='' && $GLOBALS['couchdb_log']==1){
18 $log_content = date('Y-m-d H:i:s')." ==> Retrieving document\r\n";
19 $log_content = date('Y-m-d H:i:s')." ==> URL: ".$url."\r\n";
20 $log_content .= date('Y-m-d H:i:s')." ==> CouchDB Document Id: ".$couch_docid."\r\n";
21 $log_content .= date('Y-m-d H:i:s')." ==> CouchDB Revision Id: ".$couch_revid."\r\n";
22 $log_content .= date('Y-m-d H:i:s')." ==> Failed to fetch document content from CouchDB.\r\n";
23 //$log_content .= date('Y-m-d H:i:s')." ==> Will try to download file from HardDisk if exists.\r\n\r\n";
24 $this->document_upload_download_log($d->get_foreign_id(),$log_content);
25 die(xlt("File retrieval from CouchDB failed"));
28 $url = preg_replace("|^(.*)://|","",$url);
29 // Collect filename and path
30 $from_all = explode("/",$url);
31 $from_filename = array_pop($from_all);
32 $from_pathname_array = array();
33 for ($i=0;$i<$d->get_path_depth();$i++
) {
34 $from_pathname_array[] = array_pop($from_all);
36 $from_pathname_array = array_reverse($from_pathname_array);
37 $from_pathname = implode("/",$from_pathname_array);
38 $temp_url = $GLOBALS['OE_SITE_DIR'] . '/documents/' . $from_pathname . '/' . $from_filename;
39 if (!file_exists($temp_url)) {
40 echo xl('The requested document is not present at the expected location on the filesystem or there are not sufficient permissions to access it.','','',' ') . $temp_url;
44 $xml = fread($f,filesize($url));
50 $xmlDom = new DOMDocument();
51 $xmlDom->loadXML($xml);
52 $ss = new DOMDocument();
53 $ss->load(dirname(__FILE__
).'/stylesheet/ccr.xsl');
54 $proc = new XSLTProcessor();
55 $proc->importStylesheet($ss);
56 $s_html = $proc->transformToXML($xmlDom);
59 $xmlDom = new DOMDocument();
60 $xmlDom->loadXML($xml);
61 $ss = new DOMDocument();
62 $ss->load(dirname(__FILE__
).'/stylesheet/cda.xsl');
63 $xslt = new XSLTProcessor();
64 $xslt->importStyleSheet($ss);
65 $html = $xslt->transformToXML($xmlDom);