Beispiel #1
0
require_once __DIR__ . "/../core/node.php";
require_once __DIR__ . "/../core/internal/sanitize.php";
require_once __DIR__ . "/../core/schedule.php";
$HIDE_FOOTER_STATS = true;
// Modes //
const M_DEFAULT = 1;
// Default State //
const M_USER = 2;
// User Page //
const M_NO_USER = -2;
// No User Found //
const M_ERROR = -255;
// Other Error //
$mode = M_DEFAULT;
// Retrieve Action and Arguments
$arg = core_ParseActionURL();
$user_name = array_shift($arg);
$arg_count = count($arg);
// Sanitize Input
$user_name = sanitize_Slug($user_name);
if (empty($user_name)) {
    $mode = M_ERROR;
}
//if ( $arg_count > 0 ) {
//	$arg[0] = sanitize_Slug($arg[0]);
//	if ( empty($arg[0]) ) {
//		$mode = M_ERROR;
//	}
//}
$user = [];
$meta = [];
Beispiel #2
0
// On WebP:
// 	WebP is currently not supported by php's image library. It is mostly supported, but
// 	none of the calls like getimagesize will acknowledge them.
// ALSO: WebP is currently only supported in Chrome, but Mozilla is *considering* support.
// 	Once Firefox officially gets WebP support, we will take steps to support it ourselves.
//
// Additional details:
// https://gauntface.com/blog/2014/09/02/webp-support-with-imagemagick-and-php
// TODO: Support percentages (i.e. any time a number ends with a %, use that instead of pixels)
// TODO: Add sub-cropping (i.e. return 50% of the image, at offset 25%)
// TODO: Add sprites (i.e. given cell sizes, give me sprite 4)
define('CACHE_TTL_IMAGE', 60);
$host = "//" . $_SERVER['HTTP_HOST'];
$self = substr($_SERVER['SCRIPT_NAME'], strrpos($_SERVER['SCRIPT_NAME'], '/') + 1);
$base = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
$image = "/" . implode('/', core_ParseActionURL());
//header("X-Real-URL: " . $image);
// To Crop or not to Crop //
$crop = isset($_GET['crop']);
// New Dimensions //
$out_width = isset($_GET['w']) ? intval($_GET['w']) : null;
$out_height = isset($_GET['h']) ? intval($_GET['h']) : null;
// Alignment Modifiers //
$top = isset($_GET['top']);
$left = isset($_GET['left']);
$right = isset($_GET['right']);
$bottom = isset($_GET['bottom']);
// Forced output types //
$jpeg = isset($_GET['jpeg']);
$png = isset($_GET['png']);
// Emit a CORS header, to avoid a Chrome warning //
Beispiel #3
0
// ** Begin ** //
$response = json_NewResponse();
$start_time = time();
function time_offset()
{
    global $start_time;
    return $start_time - time();
}
$need_admin = false;
$show_specific = false;
$show_db = false;
$show_redis = false;
$show_memcached = false;
$is_admin = false;
// Parse action URL
$action = core_ParseActionURL();
//$response['action'] = $action;
foreach ($action as $key => &$value) {
    if ($action[$key] == "db") {
        $show_db = true;
        $need_admin = true;
    } else {
        if ($action[$key] == "redis") {
            $show_redis = true;
            $need_admin = true;
        } else {
            if ($action[$key] == "memcached") {
                $show_memcached = true;
                $need_admin = true;
            } else {
                if ($action[$key] == "all") {
Beispiel #4
0
<?php

/** @file
*	@brief Public RESTful API for retrieving Items
**/
require_once __DIR__ . "/../../api.php";
// CMW API //
$out = json_NewResponse();
$out['item'] = 1;
//$out['args'] = $_GET;
//$out['server'] = $_SERVER;
$out['parsed'] = core_ParseActionURL();
/**
 * @api {GET} /v1/get/:item /v1/get
 * @apiName GetItem
 * @apiGroup Core
 * @apiPermission Everyone
 * @apiVersion 0.1.0
 *
 * @apiDescription Retrieve an item
*/
/**
 * @api {GET} /v1/games[/:offset] /v1/games
 * @apiName GetGames
 * @apiGroup Popular
 * @apiPermission Everyone
 * @apiVersion 0.1.0
 *
 * @apiDescription YOU GOT GAME?
*/
/**
Beispiel #5
0
const AUDIO_TYPE = ['mp3', 'm4a', 'aac'];
function is_audio($ext)
{
    return array_search($ext, AUDIO_TYPE) !== false;
}
function EmitErrorAndExit($err, $code = 404)
{
    http_response_code($code);
    header("Content-Type: text/plain");
    echo $err;
    exit;
}
const ORIGIN_DIR = '/raw/';
const CONTENT_DIR = '/content/';
// NOTE: Input is sanitized. URLs can only be basic ASCII //
$in_part = core_ParseActionURL();
$in_path = implode('/', $in_part);
$in_file = basename($in_path);
$in_dir = dirname($in_path);
$file_part = explode('.', $in_file);
// Bail if our files don't have 2 parts //
if (count($file_part) < 2) {
    EmitErrorAndExit("");
}
$file_id = array_shift($file_part);
$file_ext = array_shift($file_part);
$origin_file = $file_id . '.' . $file_ext;
// Output Extension //
if (count($file_part) >= 1) {
    // Always the last file extension //
    $file_out_ext = array_pop($file_part);