= AUTH_UPLOAD){ $UPLOADOK = true; //create the given namespace (just for beautification) $mdir = $conf['mediadir'].'/'.utf8_encodeFN(str_replace(':','/',$NS)); io_makeFileDir("$mdir/xxx"); }else{ $UPLOADOK = false; } if($_FILES['upload']['tmp_name'] && $UPLOADOK){ media_upload($NS); } //start output and load template header('Content-Type: text/html; charset=utf-8'); include(DOKU_INC.'tpl/'.$conf['template'].'/media.php'); //restore old umask umask($conf['oldumask']); /**********************************************/ /** * Handles Mediafile uploads * * @author Andreas Gohr */ function media_upload($NS){ global $conf; global $lang; // get file $id = $_POST['id']; $file = $_FILES['upload']; // get id if(empty($id)) $id = $file['name']; $id = cleanID($NS.':'.$id); // get filename $fn = utf8_encodeFN(str_replace(':','/',$id)); $fn = $conf['mediadir'].'/'.$fn; // prepare directory io_makeFileDir($fn); umask($conf['umask']); if(preg_match('/\.('.$conf['uploadtypes'].')$/i',$fn)){ if (move_uploaded_file($file['tmp_name'], $fn)) { msg($lang['uploadsucc'],1); return true; }else{ msg($lang['uploadfail'],-1); } }else{ msg($lang['uploadwrong'],-1); } return false; } /** * Userfunction for html_buildlist * * Prints available media namespaces * * @author Andreas Gohr */ function media_html_list_namespaces($item){ $ret = ''; $ret .= ''; $ret .= $item['id']; $ret .= ''; return $ret; } ?>