$resource = new File(); $resource->name = $_REQUEST['file']; if (!$resource->isValidName($_REQUEST['file'])) { pieError("FileNameInvalid"); } if (!$resource->exists($_REQUEST['file'])) { pieError("FileNotFound"); } if (!$resource->read($_REQUEST['file'], 0)) { pieError("FileReadError"); } if ($resource->meta['type'] == "alias") { pieError("AliasRedirect", array('file' => htmlspecialchars($resource->meta['original']), 'alias' => htmlspecialchars($_REQUEST['file']))); } $context = 'file'; $history = $resource->history($_REQUEST['file']); } else { pieError("PageNotFound"); } // Display the history. if (@$_REQUEST['order'] == "descend") { krsort($history); $n = count($history); } else { ksort($history); $n = 1; } $hint_info = $GLOBALS['pie']['locale']->key("Info"); $hint_show = $GLOBALS['pie']['locale']->key("Show"); $hint_edit = $GLOBALS['pie']['locale']->key("RevertTo"); $ip = pieMakeString('[[$^icon_link]]');
$data['author'] = htmlspecialchars($file->meta['author']); $data['size'] = pieMakeSize($file->meta['size']); if (preg_match('/.*\\.([0-9a-z]{1,5})$/', $file->name, $match)) { $data['type'] = strtoupper($match[1]); } else { $data['type'] = $GLOBALS['pie']['locale']->key("BinaryFile"); } if (preg_match('%^(\\w+)/.*$%', $file->meta['type'], $match)) { $data['kind'] = $GLOBALS['pie']['locale']->key(ucfirst($match[1]) . 'File'); } if ($file->meta['comment']) { $data['comment'] = htmlspecialchars($file->meta['comment']); } else { $data['comment'] = "—"; } $history = $file->history($file->name); $data['history_count'] = count($history); $t = 0; ksort($history); $n = 0; foreach ($history as $k => $v) { $n++; if ($stamp == $k) { break; } } $data['history_index'] = $n; // Present results: pieNotice("FileInfo", $data); switch ($file->meta['type']) { case 'image/jpeg':
} elseif ($context == "file") { $object = new File(); if (!$object->isValidName($target)) { pieError("FileNameInvalid"); } if (!$object->exists($target)) { pieError("FileNotFound"); } if (!$object->read($target, 0)) { pieError("FileReadError"); } } else { pieError("ActionInvalid"); } // Check permissions to delete the resource: $history = $object->history($object->name); if (@$_REQUEST['approve']) { // The user asked to delete the resource, no matter what. if ($GLOBALS['pie']['deny_removal'] && !pieIsSuperuser($GLOBALS['pie']['user'])) { pieError("ActionNotPermitted"); } } else { // Check for referers. if (($referers = pieRefererList($target, $context)) === false) { pieError("RefererError"); } if (count($referers)) { // There are pages linking to the target. pieError("RefererNotice"); } // Check for co-authors.