added xml-interface client reference implementation

This commit is contained in:
following
2012-08-16 23:47:40 +02:00
parent f7543f133a
commit 530567545a
4 changed files with 1341 additions and 6 deletions

View File

@ -287,12 +287,12 @@
<h4><a>Beispiele</a></h4>
<p>http://www.opencaching.de/xml/ocxml11.php?modifiedsince=20060320000000&amp;user=1&amp;cache=1&amp;cachelog=1&amp;cachedesc=1&amp;picture=1&amp;removedobject=1&amp;session=1&amp;charset=utf-8&amp;cdata=1&amp;xmldecl=0&amp;ocxmltag=0&amp;doctype=0<br/>
http://www.opencaching.de/xml/ocxml11.php?sessionid=4711&amp;file=1&amp;charset=utf-8&amp;cdata=1&amp;xmldecl=0&amp;ocxmltag=0&amp;doctype=0</p>
<h3>Sonstige Bemerkungen</h3>
<h3>Sonstige Anmerkungen</h3>
<ul>
<li>
Für den ersten Aufruf des Interface muss als modifiedsince das Datum 1.8.2005
um 00:00:00 Uhr angegeben werden. Es gibt keine Datensätze die vor diesem Datum
angelegt wurden.</li>
angelegt wurden.<br /><br /></li>
<li>
Um Probleme wegen Differenzen der Uhrzeit zwischen Client und Server zu
umgehen, muss für den nächsten Inkrementellen Abruf der Daten das Datum um Kopf
@ -308,19 +308,22 @@
</li>
<li>Zeitverschiebungen / unterschiedliche Zeitzonen zwischen Client und Server
werden nicht unterstützt.</li>
</ul>
<h3>Ressourcen</h3>
<ul>
<li>Das XML-Dokument enthält folgende DTD (Document Type Definition):
http://www.opencaching.de/xml/ocxml11.dtd</li>
<li>Der Quellcode ist hier erhältlich: <a href="https://github.com/OpencachingDeutschland/oc-server3/tree/stable/htdocs/xml">
https://github.com/OpencachingDeutschland/oc-server3/tree/stable/htdocs/xml</a></li>
<li>Eine Referenzimplementierung kann hier downgeloadet werden: <s>
http://devel.opencaching.de/viewcvs/viewcvs.cgi/html/util/ocxml11client/</s> (neue Adresse folgt ...)</li>
<li>Eine Referenzimplementierung kann hier heruntergeladen werden:
<a href="https://github.com/OpencachingDeutschland/oc-server3/tree/stable/htdocs/util-local/ocxml11client">https://github.com/OpencachingDeutschland/oc-server3/tree/stable/htdocs/util-local/ocxml11client</a></li>
<li>Fragen zum Interface können im Opencaching-Forum gestellt werden: <a href="http://forum.opencaching-network.org/">http://forum.opencaching-network.org/</a></a></li>
</ul>
<p>Lizenz:</p>
<ul>
<li>Der Quellcode steht unter der GNU Gerneral Public License Version 2 und später.</li>
<li>Der Quellcode steht unter der GNU Gerneral Public License Version 2 und später, siehe <a href="https://github.com/OpencachingDeutschland/oc-server3/tree/stable/doc/license.txt">https://github.com/OpencachingDeutschland/oc-server3/tree/stable/doc/license.txt</a>.</li>
<li>
Für Daten die über das XML-Interface abgerufen werden, gelten die
Für Daten, die über das XML-Interface abgerufen werden, gelten die
Nutzungsbedingungen von Opencaching.de: <a href="http://www.opencaching.de/articles.php?page=impressum#tos">
http://www.opencaching.de/articles.php?page=impressum#tos</a></li></ul>
<p>&nbsp;</p>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
<?php
// Unicode Reminder メモ
// safemode-unzip
$opt['unzip'] = '/srv/www/htdocs/www.opencaching.de/html/util/safemode_zip/phpunzip.php';
$opt['rel_tmpdir'] = 'util/ocxml11client/tmp';
// 2. DB z.B. als Backup einer sauberen DB
$opt['db'][1]['name'] = 'ocdublette';
$opt['db'][1]['username'] = $dbusername;
$opt['db'][1]['passwd'] = $dbpasswd;
$opt['db'][1]['server'] = $dbserver;
// Synchronisierungsoptionen
$opt['sync']['user'] = 1;
$opt['sync']['cache'] = 1;
$opt['sync']['cachedesc'] = 1;
$opt['sync']['cachelog'] = 1;
$opt['sync']['picture'] = 1;
$opt['sync']['picturefromcachelog'] = 1;
$opt['sync']['removedobject'] = 1;
// Bilder downloaden?
$opt['pictures']['download'] = 1;
$opt['pictures']['directory'] = $rootpath . 'images/uploads/';
$opt['pictures']['url'] = 'http://www.so-komm-ich-uebers-web-da.hin/www.opencaching.de/html/images/uploads/';
// Sessions verwenden?
$opt['session'] = 1;
$opt['zip'] = 'gzip'; // 0; zip; bzip2; gzip
// Gebietsauswahl nach Land
$opt['bycountry'] = 0;
$opt['country'] = 'DE';
// Gebietsauswahl nach Koordinaten
$opt['bycoords'] = 0;
$opt['lon'] = 50.12345;
$opt['lat'] = 9.12345;
$opt['distance'] = 150;
// sonstige Einstellungen
$opt['tmpdir'] = 'tmp/';
$opt['archivdir'] = 'data-files/';
$opt['url'] = 'http://www.opencaching.de/xml/ocxml11.php?modifiedsince={modifiedsince}&user={user}&cache={cache}&cachedesc={cachedesc}&cachelog={cachelog}&picture={picture}&picturefromcachelog={picturefromcachelog}&removedobject={removedobject}&session={session}&zip={zip}&charset=utf-8';
$opt['urlappend_country'] = '&country={country}';
$opt['urlappend_coords'] = '&lon={lon}&lat={lat}&distance={distance}';
$opt['url_getsession'] = 'http://www.opencaching.de/xml/ocxml11.php?sessionid={sessionid}&file={file}&zip={zip}&charset=utf-8';
?>

View File

@ -0,0 +1,82 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
***************************************************************************/
class xml2Array {
var $stack=array();
var $stack_ref;
var $arrOutput = array();
var $resParser;
var $strXmlData;
function push_pos(&$pos) {
$this->stack[count($this->stack)]=&$pos;
$this->stack_ref=&$pos;
}
function pop_pos() {
unset($this->stack[count($this->stack)-1]);
$this->stack_ref=&$this->stack[count($this->stack)-1];
}
function parse($strInputXML) {
$this->resParser = xml_parser_create("UTF-8");
xml_set_object($this->resParser,$this);
xml_set_element_handler($this->resParser, "tagOpen", "tagClosed");
xml_set_character_data_handler($this->resParser, "tagData");
$this->push_pos($this->arrOutput);
$this->strXmlData = xml_parse($this->resParser,$strInputXML );
if(!$this->strXmlData) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($this->resParser)),
xml_get_current_line_number($this->resParser)));
}
xml_parser_free($this->resParser);
return $this->arrOutput;
}
function tagOpen($parser, $name, $attrs) {
if (isset($this->stack_ref[$name])) {
if (!isset($this->stack_ref[$name][0])) {
$tmp=$this->stack_ref[$name];
unset($this->stack_ref[$name]);
$this->stack_ref[$name][0]=$tmp;
}
$cnt=count($this->stack_ref[$name]);
$this->stack_ref[$name][$cnt]=array();
if (isset($attrs))
$this->stack_ref[$name][$cnt]=$attrs;
$this->push_pos($this->stack_ref[$name][$cnt]);
}
else {
$this->stack_ref[$name]=array();
if (isset($attrs))
$this->stack_ref[$name]=$attrs;
$this->push_pos($this->stack_ref[$name]);
}
}
function tagData($parser, $tagData) {
if(mb_trim($tagData)) {
if(isset($this->stack_ref['DATA']))
$this->stack_ref['DATA'] .= $tagData;
else
$this->stack_ref['DATA'] = $tagData;
}
}
function tagClosed($parser, $name) {
$this->pop_pos();
}
}
?>