Location: PHPKode > projects > FeedMeLinks, Social BookmarkingSince2002 > feedmelinks.com/folder-as-xml.php
<% 
	# $Id: folder-as-xml.php,v 1.7 2005/10/23 02:31:16 hirokai Exp $
	include_once( "modules/utils.inc.php" );

	$pass = $PHP_AUTH_PW ? $PHP_AUTH_PW : $password;
	$u    = $PHP_AUTH_USER ? $PHP_AUTH_USER : ( $user ? $user : $_COOKIE["c_uid"] );
	$tok =  $authenticated = $_COOKIE["c_pass_token"];

	if( $u && ($pass && $pass == getPasswdForUser( $u ) || ($tok && $tok == md5( getPasswdForUser( $u ))))) {

		if( $folder ) {
			$con_xmlFolder = mysql_connect();
			mysql_selectdb( getDBName() );
				
			$qs = getQuery( "tag", $folder, $u );
			$q = mysql_query( $qs );
			if( $q && mysql_num_rows($q) ) {
				Header( "Content-type: text/xml");
				echo "<?xml version='1.0' standalone='yes'?>\n";

				$raw_tag_name = urldecode( mysql_result($q,0,"t.name"));
				$tag_name = makePrettyFolderName( $raw_tag_name );

%>
<posts tag="<%= $tag_name %>" is-public="<%= isPublic( $raw_tag_name ) ? 'true' : 'false' %>" tag-id="<%= $folder %>" user="<%= $u %>">
<%
				$numRows = mysql_num_rows($q);
				if( $q && $numRows ) {
					for( $i = 0; $i < $numRows; $i++ ) {
						$ID   = mysql_result($q,$i,"linkID");
						$name = str_replace( '"', '', encodeAmps( urldecode( mysql_result($q,$i,"links.name"))));
						$url = urldecode( mysql_result($q,$i,"url"));
						if( !strstr( $url, "&amp;" ))
							$url = str_replace( "&", "&amp;", $url );
						$ts = formatAsDCDate( mysql_result($q,$i,"createDate"));

%>
  <post href="<%= $url %>" id="<%= $ID %>" description="<%= $name %>" hash="" others="0" tag="<%= $tag_name %>" time="<%= $ts %>"/>
<%
					}
				}
%>
</posts>
<%
			} else
				$error = "no tag by that ID, or it's owned by someone else";
			conClose( $con_xmlFolder );
		} else
			$error = "no tag by that ID, or it's owned by someone else";
		if( $error ) {
			Header("HTTP/1.0 404 Not Found");
			echo $error;
		}
	} else {
		header('WWW-Authenticate: Basic realm="Feed Me Links XML API"');
		header('HTTP/1.0 401 Unauthorized');
		echo "login first, please.";
	}
%>

Return current item: FeedMeLinks, Social BookmarkingSince2002