header(':', true, $code); } } if (!Session::is_user() && (substr(LINK_FILE, 0, 4) == "ajax" && LINK_FILE != "ajax/login.php")) { http_response_code(403); exit(json_encode(array("error" => "Your session has timed out, or you have logged out in another tab. Please log in again."))); } if (substr(LINK_FILE, 0, 6) == "studio") { MainTemplate::set_barebones(true); if (isset($_REQUEST["key"])) { if (is_null(Locations::get_by_key($_REQUEST["key"]))) { exit("Sorry, you provided an invalid security key."); } } else { Output::require_user(); } } if (LINK_FILE != "index.php" && LINK_FILE != "ajax/login.php" && substr(LINK_FILE, 0, 6) != "studio" && substr(LINK_FILE, 0, 5) != "audio") { Output::require_user(); } if (Session::is_developer()) { ini_set("display_errors", "1"); ini_set("display_startup_errors", "1"); ini_set("html_errors", "1"); ini_set("docref_root", "http://www.php.net/"); ini_set("error_prepend_string", "<div class=\"alert alert-error\">"); ini_set("error_append_string", "</div>"); } if (substr(LINK_FILE, 0, 4) != "ajax") { Output::set_template("MainTemplate"); }
<?php Output::set_template(); $query = $_REQUEST['q']; if ($query) { $search = Search::prerecords(str_replace(" ", " | ", $query), 5); } $tracks = $search["results"]; $tracks_array = array(); if ($tracks) { foreach ($tracks as $track_id) { $track_object = Tracks::get($track_id); $track = array('id' => $track_object->get_id(), 'title' => $track_object->get_title(), 'by' => $track_object->get_artists_str(), 'href' => LINK_ABS . "music/detail/" . $track_object->get_id()); array_push($tracks_array, $track); } } $array = array("title" => "Prerecords", "href" => LINK_ABS . "music/search/?i=title&q=" . $query, "data" => $tracks_array); echo json_encode($array);