} if (is_array($tag[3])) { $t = array_merge($t, $tag[3]); } $value = tpl_img_getTag($t); if ($value) { echo '<dt>' . $lang[$tag[1]] . ':</dt><dd>'; if ($tag[2] == 'date') { echo dformat($value); } else { echo hsc($value); } echo '</dd>'; } } $t_array = media_inuse(tpl_img_getTag('IPTC.File.Name', $IMG)); if (isset($t_array[0])) { echo '<dt>' . $lang['reference'] . ':</dt>'; foreach ($t_array as $t) { echo '<dd>' . html_wikilink($t, $t) . '</dd>'; } } ?> </dl> <?php //Comment in for Debug// dbg(tpl_img_getTag('Simple.Raw')); ?> </div> <div class="clearer"></div> </div><!-- /.content -->
unset($_FILES['upload']); } // handle upload if ($_FILES['upload']['tmp_name']) { $JUMPTO = media_upload($NS, $AUTH); if ($JUMPTO) { $NS = getNS($JUMPTO); } } // handle meta saving if ($IMG && $_REQUEST['do']['save']) { $JUMPTO = media_metasave($IMG, $AUTH, $_REQUEST['meta']); } // handle deletion if ($DEL) { $INUSE = media_inuse($DEL); if (!$INUSE) { if (media_delete($DEL, $AUTH)) { msg(sprintf($lang['deletesucc'], noNS($DEL)), 1); } else { msg(sprintf($lang['deletefail'], noNS($DEL)), -1); } } else { if (!$conf['refshow']) { unset($INUSE); msg(sprintf($lang['mediainuse'], noNS($DEL)), 0); } } } // finished - start output header('Content-Type: text/html; charset=utf-8');
/** * Handles media file deletions * * If configured, checks for media references before deletion * * @author Andreas Gohr <*****@*****.**> * @return int One of: 0, DOKU_MEDIA_DELETED, DOKU_MEDIA_DELETED | DOKU_MEDIA_EMPTY_NS, DOKU_MEDIA_NOT_AUTH, DOKU_MEDIA_INUSE */ function media_delete($id, $auth) { if ($auth < AUTH_DELETE) { return DOKU_MEDIA_NOT_AUTH; } if (media_inuse($id)) { return DOKU_MEDIA_INUSE; } $file = mediaFN($id); // trigger an event - MEDIA_DELETE_FILE $data['id'] = $id; $data['name'] = basename($file); $data['path'] = $file; $data['size'] = @file_exists($file) ? filesize($file) : 0; $data['unl'] = false; $data['del'] = false; $evt = new Doku_Event('MEDIA_DELETE_FILE', $data); if ($evt->advise_before()) { $data['unl'] = @unlink($file); if ($data['unl']) { addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE); $data['del'] = io_sweepNS($id, 'mediadir'); } } $evt->advise_after(); unset($evt); if ($data['unl'] && $data['del']) { return DOKU_MEDIA_DELETED | DOKU_MEDIA_EMPTY_NS; } return $data['unl'] ? DOKU_MEDIA_DELETED : 0; }
/** * Handles media file deletions * * If configured, checks for media references before deletion * * @author Andreas Gohr <*****@*****.**> * @param string $id media id * @param int $auth no longer used * @return int One of: 0, * DOKU_MEDIA_DELETED, * DOKU_MEDIA_DELETED | DOKU_MEDIA_EMPTY_NS, * DOKU_MEDIA_NOT_AUTH, * DOKU_MEDIA_INUSE */ function media_delete($id, $auth) { global $lang; $auth = auth_quickaclcheck(ltrim(getNS($id) . ':*', ':')); if ($auth < AUTH_DELETE) { return DOKU_MEDIA_NOT_AUTH; } if (media_inuse($id)) { return DOKU_MEDIA_INUSE; } $file = mediaFN($id); // trigger an event - MEDIA_DELETE_FILE $data['id'] = $id; $data['name'] = utf8_basename($file); $data['path'] = $file; $data['size'] = @file_exists($file) ? filesize($file) : 0; $data['unl'] = false; $data['del'] = false; $evt = new Doku_Event('MEDIA_DELETE_FILE', $data); if ($evt->advise_before()) { $old = @filemtime($file); if (!@file_exists(mediaFN($id, $old)) && @file_exists($file)) { // add old revision to the attic media_saveOldRevision($id); } $data['unl'] = @unlink($file); if ($data['unl']) { addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE, $lang['deleted']); $data['del'] = io_sweepNS($id, 'mediadir'); } } $evt->advise_after(); unset($evt); if ($data['unl'] && $data['del']) { return DOKU_MEDIA_DELETED | DOKU_MEDIA_EMPTY_NS; } return $data['unl'] ? DOKU_MEDIA_DELETED : 0; }
public function handle() { global $conf, $ID; //$this->_debug_print_r($data); //$this->_debug_print_r($_REQUEST); //If delete requested if(isset($_REQUEST['media_id_to_delete'])){ if(checkSecurityToken($_REQUEST['sectok'])){ $mediaToDelete = $_REQUEST['media_id_to_delete']; $file = mediaFN($mediaToDelete); if(file_exists($file)){ if(media_inuse($mediaToDelete)===false){ // trigger an event - MEDIA_DELETE_FILE $data['id'] = $mediaToDelete; $data['name'] = basename($file); $data['path'] = $file; $data['size'] = (@file_exists($file)) ? filesize($file) : 0; $data['unl'] = false; $data['del'] = false; $evt = new Doku_Event('MEDIA_DELETE_FILE',$data); if ($evt->advise_before()) { $data['unl'] = @unlink($file); if($data['unl']){ addMediaLogEntry(time(), $mediaToDelete, DOKU_CHANGE_TYPE_DELETE); $data['del'] = io_sweepNS($mediaToDelete,'mediadir'); } } $evt->advise_after(); unset($evt); $this->ok = sprintf($this->getLang('delete_file_ok'),$mediaToDelete); ; }else{ $this->error = sprintf($this->getLang('delete_file_in_use'),$mediaToDelete); } }else{ $this->error = sprintf($this->getLang('delete_file_not_found'),$mediaToDelete); } }//end of csrf check } //Searching for orphaned medias $data = array(); //getting all medias search($data,$conf['mediadir'],'search_media', array('showmsg'=>true,'depth'=>500),str_replace(':', '/', getNS($ID))); //check if they are (still) in use or not. foreach($data as $media){ $isUsed = media_inuse($media['id']); if($isUsed === false){ $this->orphans_medias[$media['id']] = $media; } } }