$include_app = 'mobile'; } } } } } // Special stuffs for Jappix apps? if ($include_app == 'desktop' || $include_app == 'mobile') { // Redirects the user to HTTPS if forced if (!useHttps() && httpsForce()) { // Apply some special headers header('Status: 301 Moved Permanently', true, 301); header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); // Kill the script! exit('HTTP/1.1 301 Moved Permanently'); } // Is it a static node? if (isStatic()) { $include_app = 'static'; } // Is it an upload node? if (isUpload()) { $include_app = 'upload'; } // Save this visit (for the stats) if (hasStatistics()) { writeVisit(); } } // Include it! include './server/' . $include_app . '.php';
------------------------------------------------- License: AGPL Author: Valérian Saliou Last revision: 27/05/11 */ // PHP base define('JAPPIX_BASE', '..'); // Get the needed files require_once './functions.php'; require_once './read-main.php'; require_once './read-hosts.php'; // Optimize the page rendering hideErrors(); compressThis(); // Not allowed for a special node if (isStatic() || isUpload()) { exit; } // If valid data was sent if (isset($_GET['searchquery']) && !empty($_GET['searchquery']) && (isset($_GET['location']) && !empty($_GET['location']))) { // Set a XML header header('Content-Type: text/xml; charset=utf-8'); // Get the values $searchquery = $_GET['searchquery']; $location = $_GET['location']; // Jamendo search? if ($location == 'jamendo') { exit(file_get_contents('http://api.jamendo.com/get2/name+id+duration+url/track/xml/?searchquery=' . urlencode($searchquery) . '&order=searchweight_desc')); } // Local music search $xml = '<data>';
function setupClient() { // make this a config option? $baseUrl = "assets/js/"; // precaution(s) in case this is the first time we are accessing the client globals (not needed?) if (!isset($GLOBALS['client'])) { $GLOBALS['client'] = array(); } if (!isset($GLOBALS['client']['require'])) { $GLOBALS['client']['require'] = array(); } // default require strucure $GLOBALS['client']['require'] = array("baseUrl" => WEB_FOLDER . $baseUrl, "paths" => array(), "shim" => array(), "deps" => array()); // first, process the require.config.json for cdn libs $file = isStatic("require.config.json"); if (is_file($file)) { $json = file_get_contents($file); } $libs = !empty($json) ? json_decode($json, true) : array(); if ($this->useRequire()) { // merge the libs with the client globals $GLOBALS['client']['require'] = array_merge($GLOBALS['client']['require'], $libs); } else { $this->client['require'] = $libs; } }
} if (!defined("TEMPLATES")) { define('TEMPLATES', $templates); } //=============================================== // Dependencies //=============================================== requireAll("lib"); // by default load the mvc.php first - which should only be one! requireAll("helpers", false, array("mvc.php", "section.php")); //=============================================== // Static Route(s) //=============================================== $url = parse_url($_SERVER['REQUEST_URI']); // first check if this is a "static" asset if ($output = isStatic($url['path'])) { // add headers if (isset($_SERVER['HTTP_ORIGIN'])) { header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}"); header("Access-Control-Allow-Credentials: true"); } else { header("Access-Control-Allow-Origin: *"); } header("Access-Control-Allow-Headers: X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, X-PINGOTHER"); header("Access-Control-Max-Age: 86400"); // cache for 1 day header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS"); // echo getFile($output); exit; }
function url($file = '', $cdn = false) { // get the full uri for the file $uri = uri($file); // check if it is a static if ($cdn && defined("CDN") && isStatic($uri)) { // load the cdn address instead // remove trailing slash, if any $domain = substr(CDN, -1) == "/" ? substr(CDN, 0, -1) : CDN; } else { // check if this is a secure connection $domain = isSSL() ? 'https://' : 'http://'; // load the regular server address //$domain .= ( substr($_SERVER['SERVER_NAME'], -1) == "/" ) ? substr($_SERVER['SERVER_NAME'], 0, -1) : $_SERVER['SERVER_NAME']; $domain .= substr($_SERVER['HTTP_HOST'], -1) == "/" ? substr($_SERVER['HTTP_HOST'], 0, -1) : $_SERVER['HTTP_HOST']; // add server port to the domain if not the default one /*if( $_SERVER['SERVER_PORT'] != "80" && $_SERVER['SERVER_PORT'] != "443" ){ $domain .= ":".$_SERVER['SERVER_PORT']; }*/ } // add the uri $url = $domain . $uri; return $url; }