From 23d74bb9214197d447738e07ff873e88c1e8b2d5 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Tue, 27 Sep 2011 20:36:57 -0500 Subject: [PATCH] delicious-dump: Handle changed XML output format --- delicious-dump/delicious-dump-allposts.php | 13 ++++++++++--- delicious-dump/delicious-dump-alltags.php | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/delicious-dump/delicious-dump-allposts.php b/delicious-dump/delicious-dump-allposts.php index 11be456..49fc846 100644 --- a/delicious-dump/delicious-dump-allposts.php +++ b/delicious-dump/delicious-dump-allposts.php @@ -29,9 +29,16 @@ $oPhpDelicious = new PhpDelicious(AUTH_DELICIOUS_USERNAME, AUTH_DELICIOUS_PASSWORD); if ($sXml = $oPhpDelicious->HttpRequest($sCmd)) { if (strlen($sXml) > 0) { - // Strip last two lines off the file, because these contain a timestamp - $sXml = substr($sXml, 0, strrpos($sXml,"\n")); - $sXml = substr($sXml, 0, strrpos($sXml,"\n")); + //// Strip last two lines off the file, because these contain a timestamp + //$sXml = substr($sXml, 0, strrpos($sXml,"\n")); + //$sXml = substr($sXml, 0, strrpos($sXml,"\n")); + + // If $sXml contains no line-breaks, pretty-ify the XML + if (strpos($sXml, "\n") !== true) { + $sXml = str_replace("?>\n\n ",">\n", $sXml); + } fwrite(STDOUT, $sXml); } diff --git a/delicious-dump/delicious-dump-alltags.php b/delicious-dump/delicious-dump-alltags.php index 8cc422c..80fcac6 100644 --- a/delicious-dump/delicious-dump-alltags.php +++ b/delicious-dump/delicious-dump-alltags.php @@ -29,9 +29,16 @@ $oPhpDelicious = new PhpDelicious(AUTH_DELICIOUS_USERNAME, AUTH_DELICIOUS_PASSWORD); if ($sXml = $oPhpDelicious->HttpRequest($sCmd)) { if (strlen($sXml) > 0) { - // Strip last two lines off the file, because these contain a timestamp - $sXml = substr($sXml, 0, strrpos($sXml,"\n")); - $sXml = substr($sXml, 0, strrpos($sXml,"\n")); + //// Strip last two lines off the file, because these contain a timestamp + //$sXml = substr($sXml, 0, strrpos($sXml,"\n")); + //$sXml = substr($sXml, 0, strrpos($sXml,"\n")); + + // If $sXml contains no line-breaks, pretty-ify the XML + if (strpos($sXml, "\n") !== true) { + $sXml = str_replace("?>\n\n ",">\n", $sXml); + } fwrite(STDOUT, $sXml); } -- 2.45.2