header("location: {$redir}", TRUE, 301); } if (config("views.counter") != "true") { if (!login()) { file_cache($_SERVER['REQUEST_URI']); } } $post = find_post($year, $month, $name); $current = $post['current']; if (!$current) { not_found(); } if (config("views.counter") == "true") { add_view($current->file); if (!login()) { file_cache($_SERVER['REQUEST_URI']); } } $author = get_author($current->author); if (isset($author[0])) { $author = $author[0]; } else { $author = default_profile($current->author); } if (array_key_exists('prev', $post)) { $prev = $post['prev']; } else { $prev = array(); } if (array_key_exists('next', $post)) { $next = $post['next'];
<?php global $CFG; // Turn file ID into a proper link if (isset($parameter)) { run("files:metadata:init"); $fileid = (int) $parameter; if ($file = get_record('files', 'ident', $fileid)) { require_once $CFG->dirroot . 'lib/filelib.php'; $filelocation = file_cache($file); if (run("users:access_level_check", $file->access) || $file->owner == $_SESSION['userid']) { if (!in_array(run("files:mimetype:inline", $filelocation), $data['mimetype:inline'])) { require_once $CFG->dirroot . 'lib/filelib.php'; $mimeinfo = mimeinfo('type', $file->location); $filepath = $CFG->wwwroot . user_info('username', $file->owner) . "/files/" . $file->folder . "/" . $file->ident . "/" . urlencode($file->originalname); switch ($mimeinfo) { case "audio/mpeg": case "audio/mp3": $filetitle = urlencode(stripslashes($file->title)); $run_result .= "\n <embed src=\"" . $CFG->wwwroot . "mod/file/mp3player/xspf_player_slim.swf?song_url={$filepath}&song_title={$filetitle}\"\n type=\"application/x-shockwave-flash\"\n height=\"15\" width=\"400\" />"; break; case "application/x-shockwave-flash": $run_result .= "<embed src=\"{$filepath}\" type=\"application/x-shockwave-flash\" />"; break; default: $extension = strtolower(substr($file->originalname, strpos($file->originalname, ".") + 1)); $type = array_key_exists($extension, get_mimetype_array()) ? " {$extension}" : ""; $run_result .= '<a class="mediafile' . $type . '" href="' . $filepath . '">'; $run_result .= stripslashes(!empty($file->title) ? $file->title : $file->originalname); $run_result .= "</a> "; break;