All pastes #489847 Raw Edit

Something

public php v1 · immutable
·published 2007-05-15 18:51 UTC
rendered paste body
<?phpheader('Content-Type: text/xml');if(isset($_GET['type'])){	$type = $_GET['type'];}else{	$type = 'lunch'}//list_by_ext: returns an array containing an alphabetic list of files in the specified directory ($path) with a file extension that matches $extensionfunction list_by_ext($extension, $path){    $list = array(); //initialise a variable    $dir_handle = @opendir($path) or die("Unable to open $path"); //attempt to open path    while($file = readdir($dir_handle)){ //loop through all the files in the path        if($file == "." || $file == ".."){continue;} //ignore these        $filename = explode(".",$file); //seperate filename from extenstion        $cnt = count($filename); $cnt--; $ext = $filename[$cnt]; //as above        if(strtolower($ext) == strtolower($extension)){ //if the extension of the file matches the extension we are looking for...            array_push($list, $file); //...then stick it onto the end of the list array        }    }    if($list[0]){ //...if matches were found...    sort($list); //...sort the list...    return $list; //...return the array    } else {//otherwise...    return false;    }}echo '<?xml version="1.0" encoding="ISO-8859-1"?>';echo "<recipe>\n";define('NL', chr(10));if(isDir($type)){	if($recipes = list_by_ext("docx", "./recipes/.$type./")){	    for($i = 0; $i < count($recipes); $i++){		echo NL.'<type/>'.NL.'<fileName>'.$recipes[$i].'</fileName>';	    }	}}echo "</recipe>\n";?>