Exemplo n.º 1
0
     // TODO: catch errors
     $jsons = gzencode(json_encode($json));
     header('Content-Encoding: gzip');
     echo $jsons;
     break;
 case "playlist_dirble_v2":
     // error("Not implemented yet :(");
     if (!$queryobj["dirble_id"]) {
         error("Error: 'dirble_id' not defined for get:{$queryobj['get']}");
     }
     $dirble_url = "http://api.dirble.com/v2/station/";
     $dirble_query = rawurlencode("{$queryobj['dirble_id']}") . "/song_history";
     $dirble_url = $dirble_url . $dirble_query . "?token={$cfg['dirble_apikey']}";
     $data = getdirblecache($queryobj["get"], $dirble_query);
     if (!$data) {
         $fg = fg($dirble_url);
         if (!$fg) {
             error("Error running query on Dirble: '" . $dirble_url . "'");
         }
         $data = json_decode($fg, true);
         savedirblecache($queryobj["get"], $dirble_query, $data);
     }
     $json["data"] = $data;
     $json["info"] = array();
     // TODO: catch errors
     $jsons = gzencode(json_encode($json));
     header('Content-Encoding: gzip');
     echo $jsons;
     break;
 case "register_device":
     if (!$queryobj["id"]) {
Exemplo n.º 2
0
    /* @var $class ReflectionClass */
    fg(sprintf("%s.xml", $class->getName())) or printf(" %s\n", $class->getName());
    foreach ($class->getConstants() as $name => $tmp) {
        re($class->getName() . ".xml", "#>{$name}<#") or printf("\t%s::%s (%s)\n", $class->getName(), $name, $tmp);
    }
    foreach ($class->getProperties() as $prop) {
        /* @var $prop ReflectionProperty */
        $prop->isPrivate() or re($class->getName() . ".xml", "#>{$prop->getName()}<#") or printf("\t%s::\$%s\n", $class->getName(), $prop->getName());
    }
    foreach ($class->getMethods() as $meth) {
        /* @var $meth ReflectionMethod */
        try {
            $meth->getPrototype();
        } catch (Exception $ex) {
            // if getPrototype throws an exception it's definitely not a method declared in an interface
            $meth->isPrivate() or fg(sprintf("%s/%s.xml", $class->getName(), strtr(trim($meth->getName(), '_'), '_', '-'))) or printf("\t%s%s::%s()\n", $meth->isStatic() ? 'static ' : '', $class->getName(), $meth->getName());
        }
    }
    printf("\n");
}
printf("\n");
printf("Undocumented request options:\n");
if (is_file($file = dirname(__FILE__) . "/../http_request_api.c")) {
    if (preg_match_all("#(?:http_request_option\\(request,\\s*options,\\s*\")(\\w+)(?=\")#", file_get_contents($file), $match)) {
        foreach ($match[1] as $opt) {
            re("request-options.xml", "#<term>\\s*{$opt}#") or printf("\t%s\n", $opt);
        }
        printf("\n");
        printf("List of request option entities:\n");
        foreach ($match[1] as $opt) {
            printf("\t<!ENTITY link.http.request.option.%1\$s '<link linkend=\"http.request.option.%1\$s\"><literal>%1\$s</literal> request option</link>'>\n", $opt);
Exemplo n.º 3
0
			header("Content-Disposition: filename=\"{$imgName}\"");
			header("Content-type: image/{$type}");
			echo $content;
			setIdle();
			die();
			}
		
	}

// Handle if image is located on remote server
if ($imgIsRemote) {
	
	// It is: attempt to download to local server
	$srcFileExtension = substr($imgFile, strrpos($imgFile,".")+1);
	$tmpfilepath = "rgthumb.cachedimg.{$imgName}";
	$fg = fg(str_replace(" ","%20",$imgFile)); if (!$fg) { error("File could not be loaded.\nCheck if FREAD may access external files."); }
	$fw = fw($tmpfilepath,$fg); if (!$fw) { error("File could not be saved to local server.\nTmpFilePath: {$tmpfilepath}"); }
	$imgFile = $tmpfilepath;
	
	}

// Catch errors
if (!file_exists($imgFile)) { error("File doesn't exist."); }
if (!isImage($imgFile) && !$force) { error("File is not an image."); }

// Create Image
	
	// Setup
	$offset_top = 0;
	$offset_left = 0;
	
Exemplo n.º 4
0
function savedirblecache($action, $query, $results)
{
    $filename = "data/cache.dirble.json.gz";
    $jsonsgz = fg($filename);
    $jsons = gzdecode($jsonsgz);
    $json = json_decode($jsons, true);
    $timediff = 60 * 60;
    // 60 minutes default..
    switch ($action) {
        case "search_dirble_v2":
            $timediff = 30;
            // 30 secs
            break;
        case "station_info_dirble_v2":
            $timediff = 60 * 60 * 24 * 7;
            // once per week more than enough, just needs dirble_id for ...
            break;
        case "playlist_dirble_v2":
            $timediff = 60 * 5;
            // 5 minutes
            break;
    }
    $entry = array("time" => time() + $timediff, "results" => $results);
    $json[$action][$query] = $entry;
    $jsons = json_encode($json);
    $jsonsgz = gzencode($jsons);
    fw($filename, $jsonsgz);
    logg(" -> Dirble saved cache: {$action} {$query}");
}
Exemplo n.º 5
0
            $port = substr($port, 0, strpos($port, "?"));
        }
    }
    // path
    $path = "/";
    if (strpos($rurl, "/") > 0) {
        $path = substr($rurl, strpos($rurl, "/"));
    }
    $queryj["host"] = trim($host);
    $queryj["port"] = intval(trim($port));
    $queryj["path"] = trim($path);
}
// Port?
if ($queryj["port"] != 80 && strpos($localserver, $_SERVER['HTTP_HOST']) === FALSE) {
    $query = $localserver . urlencode('{"station_id":"' . $queryj["station_id"] . '","host":"' . $queryj["host"] . '","port":"' . $queryj["port"] . '","path":"' . $queryj["path"] . '"}');
    $fg = fg($query);
    header("Content-Type: application/json");
    die($fg);
}
// Begin..
$timebgn = time();
// Open a socket
$fsock = @fsockopen($queryj["host"], $queryj["port"], $errno, $errstr, 5);
// Start reading from socket (if not false)
if (!$fsock) {
    $diddnslookup = 0;
    // IP or nameserver?
    if (count(explode(".", $queryj["host"])) < 4) {
        $diddnslookup = 1;
        // Try dns lookup
        $dns = dns_get_record($queryj["host"]);
Exemplo n.º 6
0
        } else {
            $type = strtolower($imgSrcExtension);
        }
        header("Content-Disposition: filename=\"{$imgName}\"");
        header("Content-type: image/{$type}");
        echo $content;
        setIdle();
        die;
    }
}
// Handle if image is located on remote server
if ($imgIsRemote) {
    // It is: attempt to download to local server
    $srcFileExtension = substr($imgFile, strrpos($imgFile, ".") + 1);
    $tmpfilepath = "rgthumb.cachedimg.{$imgName}";
    $fg = fg(str_replace(" ", "%20", $imgFile));
    if (!$fg) {
        error("File could not be loaded.\nCheck if FREAD may access external files.");
    }
    $fw = fw($tmpfilepath, $fg);
    if (!$fw) {
        error("File could not be saved to local server.\nTmpFilePath: {$tmpfilepath}");
    }
    $imgFile = $tmpfilepath;
}
// Catch errors
if (!file_exists($imgFile)) {
    error("File doesn't exist.");
}
if (!isImage($imgFile) && !$force) {
    error("File is not an image.");
Exemplo n.º 7
0
				$dirble_query = rawurlencode("{$queryobj['dirble_id']}");
				$fg = fg($dirble_url.$dirble_query);
				if (!$fg) { error("Error running query on Dirble: '". $dirble_url.$dirble_query."'"); }
				$json["data"] = json_decode($fg,true);
				$json["info"] = array();
				// TODO: catch errors
				$jsons = gzencode(json_encode($json));
				header('Content-Encoding: gzip');
				echo $jsons;
				break;
				
			case "nowplaying_dirble_v2":
				if (!$queryobj["dirble_id"]) { error("Error: 'dirble_id' not defined for get:{$queryobj['get']}"); }
				$dirble_url = "http://api.dirble.com/v2/station/id/";
				$dirble_query = rawurlencode("{$queryobj['dirble_id']}");
				$fg = fg($dirble_url.$dirble_query);
				if (!$fg) { error("Error running query on Dirble: '". $dirble_url.$dirble_query."'"); }
				$json["data"] = json_decode($fg,true);
				$json["info"] = array();
				// TODO: catch errors
				$jsons = gzencode(json_encode($json));
				header('Content-Encoding: gzip');
				echo $jsons;
				break;
			
			// default	
			default:
				error("Error in query: '$query', {$queryobj['get']}, {$queryobj}");
				break;