Page MenuHomeCode

No OneTemporary

diff --git a/README b/README
--- a/README
+++ b/README
@@ -1,110 +1,121 @@
ZzzzzzZ zz
Z z z The spatial gallery / social network / lounge
z z (c) 2010, Dereckson, some rights reserved.
z zzzzz zzzzz
z z z z z 0.1 alpha technical preview
z zzzzzzz z z
z z z z Last update hypership time: 5.096
z Z z z z z
ZzzzzzZ zzzzz zzzzzz
===========
LOCATIONS
===========
* Global location is a 9 letters code
<B,S> <body or spaceship id> <place where you are in this body/spaceship>
zerofilled 5 digits zerofilled 3 digits
You can also find 6 digits expressions e.g. B00001 is the hypership
* Local location varies of the place.
- On hypership core (B00001002): Sector C<0-8> Level <z> Zone <x-y>
- 0 is the gravity center
- 1-8 the 8 cubes surrounding it: 1-4 below, 5-8 above
- On the ship tower (B00001001): Sector T<z> Couloir <1-6>
- z is the level
- couloir depends of your x, y position (polar coordinates could help)
=================
HYPERSHIP TIME?
=================
* the amount of days since hypership launch, January 25th 2010 00:00 UTC
* So the decimal part is like internet time, but in GMT and not CET/CEST
===============
SIDE PROJECTS
===============
* A pazaak game, to have something to play
* Will be an Arzakon client
=================
I WANT TO HELP!
=================
* You can create new SmartLine commands
* You can translate it in a new language
Start point: http://zed.dereckson.be/lang/en/core.conf
* You can code a bit of adventure, places description, stuff to do
as long you don't transform it in ogame clone (we're building a community
who want or don't want to play, but not a mechanic game)
and as long no money is involved (if you ask why, read Iain M. Banks novels)
in the hypership (in far asteroids, orbitals, planets you do what you want)
============
KNOWN BUGS
============
* Javascript get_hypership_time will returns 5.94 instead 5.094
Some %03d to add in /js/misc.js
* All URLs outside homepage will return Unknown URL
Well... only the home controller is coded.
* The floater rendering adds a black line under Opera
dojox.layout.floatingPane bug, need to check with last dojo version
* API /location query will break indent on location->body->location
beautify XML code to improve
-=====
- API
-======
+=======================
+ API - General methods
+=======================
* /api.php/time
Returns hypership time
Public access
* /api.php/perso/<perso_id>
Returns perso object
Created only to test extensively recursivity of api xml output
+ It's disabled since 10.811 on zed.dereckson.be, if you need an alternative,
+ open a bug report with the fields you need. Ship API should be able to manage
+ inventory if user is on. Ship API must also be able to get/set custom flags.
Requires a key
* /api.php/location/<location code or name>
Returns location object
Tip: to get the full name, use string eg /api.php/location/Zeta?format=string
Requires a key
* GET/POST API parameters
- key
API key, ask it at zed at dereckson be, object [DEV] api key request
- format
- preview print_r representation, so you've an idea of the object
- json json_encode() output
- php serialize() output
- wddx WDDX were an early universal serialization attempt
- xml XML document
- - string output "as is" if it's an object, __toString() call
\ No newline at end of file
+ - string output "as is" (or if it's an object, calls __toString())
+
+============
+ API - Ship
+=============
+
+ * /api.php/ship/authenticate/<perso nickname>
+
+ Allows
\ No newline at end of file
diff --git a/includes/api/BeautyXML.class.php b/includes/api/BeautyXML.class.php
--- a/includes/api/BeautyXML.class.php
+++ b/includes/api/BeautyXML.class.php
@@ -1,97 +1,94 @@
<?php
//==============================================================================
// This class is simple XML beautifer
// it's very, very, very simple - feature version will be better :-)
//
//
// IMPORTANT NOTE
// there is no warranty, implied or otherwise with this software.
//
// version 0.1 | August 2004
//
// released under a LGPL licence.
//
// Slawomir Jasinski,
// http://www.jasinski.us (polish only - my home page)
// http://www.cgi.csd.pl (english & polish)
// contact me - sj@gex.pl
//==============================================================================
class BeautyXML {
- var $how_to_ident = " "; // you can user also \t or more/less spaces
- var $wrap = false; // wrap long tekst ?
- var $wrap_cont = 90; // where wrap words
-
- var $colors = array('green', 'red', 'pink', 'yellow', 'gray');
+ var $how_to_ident = " "; // you can user also \t or more/less spaces
+ var $wrap = false; // wrap long tekst ?
+ var $wrap_cont = 90; // where wrap words
// gives ident to string
function ident(&$str, $level) {
$level--;
for ($a = 0; $a < $level; $a++)
$spaces .= $this->how_to_ident;
return $spaces .= $str;
}
-
// main funcion
function format($str) {
$str = preg_replace("/<\?[^>]+>/", "", $str);
$tmp = explode("\n", $str); // extracting string into array
// cleaning string from spaces and other stuff like \n \r \t
for ($a = 0, $c = count($tmp); $a < $c; $a++)
$tmp[$a] = trim($tmp[$a]);
// joining to string ;-)
$newstr = join("", $tmp);
$newstr = preg_replace("/>([\s]+)<\//", "></", $newstr);
// adding \n lines where tags ar near
$newstr = str_replace("><", ">\n<", $newstr);
// exploding - each line is one XML tag
$tmp = explode("\n", $newstr);
// preparing array for list of tags
$stab = array('');
// lets go :-)
for ($a = 0, $c = count($tmp); $a <= $c; $a++) {
$add = true;
preg_match("/<([^\/\s>]+)/", $tmp[$a], $match);
$lan = trim(strtr($match[0], "<>", " "));
$level = count($stab);
if (in_array($lan, $stab) && substr_count($tmp[$a], "</$lan") == 1) {
$level--;
$s = array_pop($stab);
$add = false;
}
if (substr_count($tmp[$a], "<$lan") == 1 && substr_count($tmp[$a], "</$lan") == 1)
$add = false;
if (preg_match("/\/>$/", $tmp[$a], $match))
$add = false;
$tmp[$a] = $this->ident($tmp[$a], $level);
if ($this->wrap) $tmp[$a] = wordwrap($tmp[$a], $this->wrap_cont, "\n" . $this->how_to_ident . $this->how_to_ident . $this->how_to_ident);
if ($add && !@in_array($lan, $stab) && $lan != '') array_push($stab, $lan);
}
return join("\n", $tmp);
}
}
\ No newline at end of file
diff --git a/includes/api/api_helpers.php b/includes/api/api_helpers.php
--- a/includes/api/api_helpers.php
+++ b/includes/api/api_helpers.php
@@ -1,128 +1,128 @@
<?php
//
// API helpers function
//
// XML outputs code uses:
// - http://www.thedeveloperday.com/xml-beautifier-tool/
// - http://snipplr.com/view/3491/convert-php-array-to-xml-or-simple-xml-object-if-you-wish/
/**
* The main function for converting to an XML document.
* Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
*
* @param mixed $data
* @param string $rootNodeName - what you want the root node to be - defaultsto data.
* @param SimpleXMLElement $xml - should only be used recursively
* @param string $unknownNodeName - name to give to unknown (numeric) keys
* @return string XML
*/
function toXml($data, $rootNodeName = 'data', $xml = null, $unknownNodeName = 'unknownNode')
{
if (!$rootNodeName) $rootNodeName = 'data';
if (!$unknownNodeName) $unknownNodeName = 'unknownNode';
// turn off compatibility mode as simple xml throws a wobbly if you don't.
if (ini_get('zend.ze1_compatibility_mode') == 1)
ini_set ('zend.ze1_compatibility_mode', 0);
if ($xml == null) {
if (!is_array($data) && !is_object($data)) {
//We've a singleton
- return "<?xml version='1.0' encoding='utf-8'?><$rootNodeName>$data<$rootNodeName>";
+ return "<?xml version='1.0' encoding='utf-8'?><$rootNodeName>$data</$rootNodeName>";
}
//Starts with simple document
$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$rootNodeName />");
}
// loop through the data passed in.
foreach($data as $key => $value) {
// no numeric keys in our xml please!
if (is_numeric($key)) {
// make string key...
$key = $unknownNodeName . '_'. (string) $key;
}
// replace anything not alpha numeric
$key = preg_replace('/[^a-z]/i', '', $key);
//If there is another array found recrusively call this function
if (is_array($value)) {
$node = $xml->addChild($key);
//Recursive call.
toXml($value, $rootNodeName, $node, $unknownNodeName);
} elseif (is_object($value)) {
$node = $xml->addChild($key);
foreach ($value as $subkey => $subvalue) {
if ($subkey == "lastError") continue;
if ($subvalue === null) {
//Ignore null values
continue;
} elseif (is_array($subvalue) || is_object($subvalue)) {
//TODO: test this
//Recursive call.
$subnode = $node->addChild($subkey);
toXml($subvalue, $rootNodeName, $subnode, $unknownNodeName);
} else {
$node->addChild($subkey, htmlentities($subvalue));
}
}
//die();
//$array = array();
//$node = $xml->addChild($key);
//toXml($value, $rootNodeName, $node, $unknownNodeName);
} else {
//Adds single node.
if ($value || $value === 0) {
$value = htmlentities($value);
$xml->addChild($key,$value);
}
}
}
// pass back as string. or simple xml object if you want!
return $xml->asXML();
}
function api_output ($reply, $xmlRoot = null, $xmlChildren = null) {
$format = isset($_REQUEST['format']) ? $_REQUEST['format'] : 'preview';
switch ($format) {
case 'preview':
echo '<pre>';
print_r($reply);
echo '</pre>';
break;
case 'php':
echo serialize($reply);
break;
case 'wddx':
require_once('BeautyXML.class.php');
$bc = new BeautyXML();
echo $bc->format(wddx_serialize_value($reply));
break;
case 'json':
echo json_encode($reply);
break;
case 'xml':
require_once('BeautyXML.class.php');
$bc = new BeautyXML();
echo '<?xml version="1.0" encoding="utf-8"?>';
echo "\n";
echo $bc->format(toXml($reply, $xmlRoot, null, $xmlChildren));
break;
case 'string':
echo $reply;
break;
default:
echo "Unknown API format: $_GET[format]";
break;
}
}
?>
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Sun, Nov 3, 21:50 (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21008
Default Alt Text
(11 KB)

Event Timeline