<?php

/* Sample php include for displaying bbs-scene.org onelinerz.
Edit the variables below to match your settings. 

By Frank Linhars aka netsurge
http://bbs-scene.org/contact.php
 
Include this file with a php include in your document like this:
 
<?php include "inc/onelinerz_parse.php"; ?>

then call parseOnelinerz($doc); anywhere in your document you want
the onelinerz to display like this:

<?php parseOnelinerz($doc); ?> 
*/

/* Edit the css style of the onelinerz display below */
?>

<style type="text/css">
.oneliner {
	color: #999;
}
.alias {
	color: #FFF;
}
.alias_bracket {
	color: #666;
}
.oneliner_bbsname {
	color: #09C;
	font-style: italic;
}                      
</style>

<?php
/* Edit settings below */

$username = "me@bbs-scene.org"; // bbs-scene.org username
$password = "password"; // bbs-scene.org password
$number = "8"; // Number of onelinerz to display

/* DON'T EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING */

$url = "http://bbs-scene.org/api/onelinerz.php?limit=" . $number;

$ch = curl_init($url); // Initialize curl and set curl options

curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);

$data = curl_exec($ch);
curl_close($ch);

$doc = new SimpleXmlElement($data, LIBXML_NOCDATA); // Set XML element

 function parseOnelinerz($xml) // Function to parse and display onelinerz
{
    $cnt = count($xml->node);
    for($i=0; $i<$cnt; $i++)
    {
	$oneliner 	= $xml->node[$i]->oneliner;
	$alias 	= $xml->node[$i]->alias;
	$bbs = $xml->node[$i]->bbsname;
 
	echo("<span class=\"oneliner\">" . $oneliner . "</span> <span class=\"alias_bracket\">(</span><span class=\"alias\">" . $alias . "</span><span class=\"alias_bracket\">)</span> - <span class=\"oneliner_bbsname\">" . $bbs . "</span><br />");
    }
}
?>