function process_params() { $post_funcs = explode(',', POST_FUNCS); foreach ($post_funcs as $func) { if (!GET_EMPTY($func)) { // Process parametrized functions switch ($func) { case 'rate': update_rating(GET('file'), GET('rate'), SESSION()); break; // break for file/rate, return for all others // break for file/rate, return for all others case 'search': //move down //move down case 'q': get_results(GET('category'), GET('subcategory'), GET('sort'), GET('q', GET('search', '')), '', GET('order'), GET('commentsearch')); return; // default: // do nothing } // Process built-in functions switch ($func . ":" . GET($func)) { case 'comment:add': require "./comment_file.php"; return; case 'content:add': require "./add_file.php"; return; case 'content:update': require "./edit_file.php"; return; case 'content:delete': require "./delete_file.php"; return; case 'account:settings': require "./user_settings.php"; return; case 'action:show': show_file(GET("file"), SESSION()); return; case 'action:register': require "./register.php"; return; case 'action:browse': // Browsing by category seems is currently only supported "browse" option if (!GET_EMPTY('category')) { get_results(GET('category'), GET('subcategory'), GET('sort'), '', '', GET('order')); return; } else { if (!GET_EMPTY('user')) { get_results(GET('category'), GET('subcategory'), GET('sort'), '', GET('user'), GET('order')); return; } } // default: // do nothing } } } // All else fails, show the "Latest Uploads" page get_latest(); }
function get_pagination($count) { global $PAGE_SIZE, $LSP_URL; $commentsearch = GET('commentsearch', false) ? '&commentsearch=true' : ''; $user = !GET_EMPTY('user') ? '&user='******'user')) : ''; $category = !GET_EMPTY('category') ? '&category=' . rawurlencode(GET('category')) : ''; $subcategory = !GET_EMPTY('subcategory') ? '&subcategory=' . rawurlencode(GET('subcategory')) : ''; $browse = strlen("{$user}{$category}{$subcategory}") ? "?action=browse{$user}{$category}{$subcategory}" : ''; $search = !GET_EMPTY('search') ? '?search=' . rawurlencode(GET('search')) : ''; $sort = !GET_EMPTY('sort') ? '&sort=' . rawurlencode(GET('sort')) : ''; $pagination = ''; $pagination .= '<div class="lsp-pagination center"><ul class="pagination pagination-sm">'; $pages = $count / $PAGE_SIZE; $page = GET('page', 0); if ($pages > 1) { for ($j = 0; $j < $count / $PAGE_SIZE; ++$j) { $class = $j == $page ? 'active' : ''; $pagination .= '<li class="' . $class . '"><a href=' . $LSP_URL . "{$search}{$browse}&page={$j}{$sort}{$commentsearch}>" . ($j + 1) . '</a></li>'; } } $pagination .= '</ul></div>'; return $pagination; }
<?php require_once 'download_file.php'; require_once 'dbo.php'; if (GET('download') == 'resource' && !GET_EMPTY('id')) { $hash = GET('id'); $file_id = get_object_by_id('files', $hash, 'id', 'hash'); $file_name = get_object_by_id('files', $hash, 'filename', 'hash'); download_file($file_id, $file_name); } else { header('Content-Type: text/xml'); header('Content-Description: LMMS WebResources Index'); echo '<?xml version="1.0"?>'; echo '<!DOCTYPE lmms-webresources-index>'; if (GET('download') == 'index') { echo '<webresources>'; get_web_resources(); echo '</webresources>'; } else { echo '<error>Please contact the LMMS development team for API access</error>'; } flush(); }
{ global $DATA_DIR; $file_path = $DATA_DIR . $file_id; if (file_exists($file_path)) { increment_file_downloads($file_id); $content_type = get_content_type($file_name); header("Content-type: {$content_type}"); $user_agent = $_SERVER['HTTP_USER_AGENT']; if (!is_image($file_name)) { if (is_integer(strpos($user_agent, "msie")) && is_integer(strpos($user_agent, "win"))) { header("Content-Disposition:filename=\"{$file_name}\""); } else { header("Content-Disposition: attachment; filename=\"{$file_name}\""); } header("Content-Description: Download"); } ob_clean(); flush(); readfile($file_path); } else { require_once 'dbo.php'; header("HTTP/1.0 404 Not Found"); echo "<h1>HTTP/1.0 404 Not Found</h1>"; $link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; echo "Sorry, file was not found. Please notify <a href=\"mailto:webmaster@lmms.io" . "?subject=LSP 404&body=FYI: 404 Not Found: {$link}\">webmaster@lmms.io</a> of this error."; } exit; } if (!GET_EMPTY('file') && !GET_EMPTY('name')) { download_file(GET('file'), GET('name')); }
function get_categories() { global $LSP_URL; $dbh =& get_db(); $stmt = $dbh->prepare('SELECT categories.name AS name, COUNT(files.id) AS file_count, categories.id AS id ' . 'FROM categories LEFT JOIN files ON files.category = categories.id ' . 'GROUP BY categories.name ' . 'ORDER BY categories.name '); echo '<ul class="lsp-categories">'; $sort = GET('sort', 'date'); if ($stmt->execute()) { while ($object = $stmt->fetch(PDO::FETCH_ASSOC)) { echo '<li class="lsp-category"><a href="' . htmlentities($LSP_URL . "?action=browse&category=" . rawurlencode($object['name']) . "&sort={$sort}") . '">' . $object['name'] . ' <span class="count">(' . $object['file_count'] . ")</span></a>"; if (!GET_EMPTY('category') && GET('category') == $object['name']) { get_subcategories($object['name'], $object['id']); } echo '</li>'; } } echo "</ul>"; $stmt = null; $dbh = null; }