1<?php 2/** 3 * Reads the path for a mediafile from the owncloud database identified by the fileID 4 * submitted by &fileid=... . Then redirects to fetch.php 5 * 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author Martin Schulte <lebowski[at]corvus[dot]uberspace[dot]de> 8 */ 9 10 11 12//error_reporting (E_ALL | E_STRICT); 13//ini_set ('display_errors', 'On'); 14 15// Prepare 16if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../../'); 17define('DOKU_DISABLE_GZIP_OUTPUT', 1); 18// $INPUT and $conf 19require_once(DOKU_INC.'inc/init.php'); 20 21 22 23$text = "sdfsdf{{wiki:dokuwiki-128.png|beschreibung|6}}sdfsd{{wiki:dokuwiki-128.png|beschreibung|5}}f"; 24 25 //$inhalt = preg_replace('#\[url=(.*)\](.*)\[/url\]#Uis', '<a href="\1">\2</a>', $text); 26 $inhalt = preg_replace('#\{\{(.+)\}\}#Uise', "'{{'.buildLink('\\1').'}}'", $text); 27 28echo $inhalt; 29//echo "<h1>".buildLink("wiki:dokuwiki-128.png?200&direcrt&nocache|Beschreibung|6")."</h1>"; 30 31function buildLiwnk($rawdata){ 32 $parts = explode("|",$rawdata); 33 $link = array_shift($parts); 34 //split into src and parameters (using the very last questionmark) from /inc/parser/handler.php 35 $pos = strrpos($link,'?'); 36 if($pos != false){ 37 $src = substr($link,0,$pos); 38 $param = substr($link,$pos+1); 39 }else{ 40 $src = $link; 41 $param = ''; 42 } 43 // get fileID 44 if(count($parts) > 1 ){ // We've a fileid 45 $last = array_pop($parts); 46 $fileid = intval($last); // Last element maybe fileid 47 $desc = implode("|",$parts); // The rest is the description, can contain | 48 if($fileid == 0 ) $desc .= "|".$last; // no fileid, is part of description 49 }else{ 50 $fileid = 0; 51 $desc = array_shift($parts); 52 } 53 // db access 54 $helper = new helper_plugin_cloud(); 55 if($fileid > 0){ // Then find source from id 56 $path = $helper->getFilenameForID($fileid); 57 if($path != ""){ 58 $src = str_replace('/',':',$path); 59 $notfound = false; 60 }else{ 61 $notfound = true; 62 } 63 }else{ 64 $notfound = true; 65 } 66 // We have no file from id, look for id using source 67 if($notfound){ // Try to find ID from source 68 $path = str_replace(':','/',$src); 69 $fileid = $helper->getIDForFilename($path); 70 } 71 72 return $src.(($param != "") ? "?$param":"")."|".$desc."|".$fileid; 73} 74 75