Example #1
0
	function send($ret) {
		global $rtype;
		
		// get the newest timestamp in the dataset (if possible) and conditional GET
		if(is_object($ret) && method_exists($ret, "timestamp")) {
				conditionalGet($ret->timestamp());
		} else if(is_array($ret) && count($ret) > 0) {
			$timestamp = 0;
			foreach($ret as $val) {
				if(is_object($val) && method_exists($val, "timestamp") && 
				   // this line is silly, but it avoids an extra call to strtotime.
				   ($tmpstamp = strtotime($val->timestamp())) > $timestamp) {
					$timestamp = $tmpstamp;
				}
			}
			if($timestamp > 0) {
				conditionalGet($timestamp);
			}
		}
		
		$send_html = $_REQUEST['html'] == '1';

		// send the data back
		if(in_array($rtype, array("plist", "xml"))) {
			header("Content-type: text/xml");
		} else if($rtype == "json") {
			header("Content-type: text/json");
		} else {
			header("Content-type: text/plain");
		}
		echo call_user_func("tmbo_".$rtype."_encode", $ret, $send_html);
		exit;
	}
require_once("offensive/assets/classes.inc");
require_once("offensive/assets/core.inc");
require_once("offensive/assets/id3.inc");

$sql = "SELECT offensive_uploads.timestamp
		FROM offensive_uploads USE KEY (t_t_id)
			LEFT JOIN users ON offensive_uploads.userid = users.userid
		WHERE type='audio' AND status='normal'
 		ORDER BY timestamp DESC
		LIMIT 1";
$res = tmbo_query($sql);
$row = mysql_fetch_array($res);
$lastBuildDate = array_pop($row);
$lastBuildTime = strtotime($lastBuildDate);
conditionalGet($lastBuildTime);

header( "Content-type: text/xml" ); 
?>
<rss version="2.0"
	xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd" 	
>
	<channel>
		<title>[ this might be offensive ] : audio</title>
		<link>https://<?= $_SERVER['HTTP_HOST'] ?>/offensive/</link>
		<description>[ this might be offensive ]</description>
		<lastBuildDate><? echo date("r"); ?></lastBuildDate>

<?	
	$args = $_REQUEST;
	if(!array_key_exists("type", $args)) {
	require_once("offensive/assets/conditionalGet.inc");
	
	$fileList = array();

	$path = "./zips";
	$dir = opendir( $path );
	while( ($file = readdir($dir) ) !== false) {
		if( strpos( $file, ".zip" ) !== false ) {
			$fileList[] = $file;									
		}
	}
	
	rsort( $fileList );
	
	$time = count($fileList) > 0 ? filectime($path."/".$fileList[0]) : 0;
	conditionalGet($time);
	
	header('Content-type: text/xml');
	$dateFormat = "r"; 
	
?><rss version="2.0">
	<channel>
		<title>[ this might be offensive ] : archives</title>
		<link>https://<?= $_SERVER['HTTP_HOST'] ?>/offensive/</link>
		<description>[ this might be offensive ]</description>
		<lastBuildDate><?= gmdate($dateFormat, $time); ?></lastBuildDate>

<?php
	foreach( $fileList as $file ) {
	
	$url = "https://".$_SERVER['HTTP_HOST']."/offensive/zips/$file";