librefm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Librefm-commits] [1478] Fix more space indentation and quoting


From: Michael Sheldon
Subject: [Librefm-commits] [1478] Fix more space indentation and quoting
Date: Sun, 10 May 2009 22:17:38 +0000

Revision: 1478
          http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1478
Author:   elleo
Date:     2009-05-10 22:17:37 +0000 (Sun, 10 May 2009)
Log Message:
-----------
Fix more space indentation and quoting

Modified Paths:
--------------
    trunk/nixtape/2.0/index.php
    trunk/nixtape/admin/report/mbid-mismatch.php
    trunk/nixtape/api/ArtistXML.php
    trunk/nixtape/api/UserXML.php
    trunk/nixtape/api/auth/index.php
    trunk/nixtape/api/xml.php

Modified: trunk/nixtape/2.0/index.php
===================================================================
--- trunk/nixtape/2.0/index.php 2009-05-10 21:55:45 UTC (rev 1477)
+++ trunk/nixtape/2.0/index.php 2009-05-10 22:17:37 UTC (rev 1478)
@@ -24,46 +24,46 @@
 require_once('../api/UserXML.php');
 
 # Error constants
-define("LFM_INVALID_SERVICE",  2);
-define("LFM_INVALID_METHOD",   3);
-define("LFM_INVALID_TOKEN",    4);
-define("LFM_INVALID_FORMAT",   5);
-define("LFM_INVALID_PARAMS",   6);
-define("LFM_INVALID_RESOURCE", 7);
-define("LFM_TOKEN_ERROR",      8);
-define("LFM_INVALID_SESSION",  9);
-define("LFM_INVALID_APIKEY",   10);
-define("LFM_SERVICE_OFFLINE",  11);
-define("LFM_SUBSCRIPTION_ERROR",12);
-define("LFM_INVALID_SIGNATURE",        13);
-define("LFM_SUBSCRIPTION_REQD",        18);
+define('LFM_INVALID_SERVICE',  2);
+define('LFM_INVALID_METHOD',   3);
+define('LFM_INVALID_TOKEN',    4);
+define('LFM_INVALID_FORMAT',   5);
+define('LFM_INVALID_PARAMS',   6);
+define('LFM_INVALID_RESOURCE', 7);
+define('LFM_TOKEN_ERROR',      8);
+define('LFM_INVALID_SESSION',  9);
+define('LFM_INVALID_APIKEY',   10);
+define('LFM_SERVICE_OFFLINE',  11);
+define('LFM_SUBSCRIPTION_ERROR',12);
+define('LFM_INVALID_SIGNATURE',        13);
+define('LFM_SUBSCRIPTION_REQD',        18);
 
 # Error descriptions as per API documentation
 $error_text = array(
-       LFM_INVALID_SERVICE             => "Invalid service - This service does 
not exist",
-       LFM_INVALID_METHOD              => "Invalid Method - No method with 
that name in this package",
-       LFM_INVALID_TOKEN               => "Invalid authentication token 
supplied",
-       LFM_INVALID_FORMAT              => "Invalid format - This service 
doesn't exist in that format",
-       LFM_INVALID_PARAMS              => "Invalid parameters - Your request 
is missing a required parameter",
-       LFM_INVALID_RESOURCE            => "Invalid resource specified",
-       LFM_TOKEN_ERROR                 => "There was an error granting the 
request token. Please try again later",
-       LFM_INVALID_SESSION             => "Invalid session key - Please 
re-authenticate",
-       LFM_INVALID_APIKEY              => "Invalid API key - You must be 
granted a valid key by last.fm",
-       LFM_SERVICE_OFFLINE             => "Service Offline - This service is 
temporarily offline. Try again later.",
-       LFM_SUBSCRIPTION_ERROR          => "Subscription Error - The user needs 
to be subscribed in order to do that",
-       LFM_INVALID_SIGNATURE           => "Invalid method signature supplied",
-       LFM_SUBSCRIPTION_REQD           => "This user has no free radio plays 
left. Subscription required."
+       LFM_INVALID_SERVICE             => 'Invalid service - This service does 
not exist',
+       LFM_INVALID_METHOD              => 'Invalid Method - No method with 
that name in this package',
+       LFM_INVALID_TOKEN               => 'Invalid authentication token 
supplied',
+       LFM_INVALID_FORMAT              => 'Invalid format - This service 
doesn\'t exist in that format',
+       LFM_INVALID_PARAMS              => 'Invalid parameters - Your request 
is missing a required parameter',
+       LFM_INVALID_RESOURCE            => 'Invalid resource specified',
+       LFM_TOKEN_ERROR                 => 'There was an error granting the 
request token. Please try again later',
+       LFM_INVALID_SESSION             => 'Invalid session key - Please 
re-authenticate',
+       LFM_INVALID_APIKEY              => 'Invalid API key - You must be 
granted a valid key by last.fm',
+       LFM_SERVICE_OFFLINE             => 'Service Offline - This service is 
temporarily offline. Try again later.',
+       LFM_SUBSCRIPTION_ERROR          => 'Subscription Error - The user needs 
to be subscribed in order to do that',
+       LFM_INVALID_SIGNATURE           => 'Invalid method signature supplied',
+       LFM_SUBSCRIPTION_REQD           => 'This user has no free radio plays 
left. Subscription required.'
 );
 
 # Resolves method= parameters to handler functions
 $method_map = array(
-       "auth.gettoken"                 => method_auth_gettoken,
-       "auth.getsession"               => method_auth_getsession,
-       "auth.getmobilesession"         => method_auth_getmobilesession,
-       "artist.getinfo"                => method_artist_getinfo,
-       "artist.gettoptracks"           => method_artist_gettoptracks,
-       "user.getinfo"                  => method_user_getinfo,
-       "user.gettoptracks"             => method_user_gettoptracks
+       'auth.gettoken'                 => method_auth_gettoken,
+       'auth.getsession'               => method_auth_getsession,
+       'auth.getmobilesession'         => method_auth_getmobilesession,
+       'artist.getinfo'                => method_artist_getinfo,
+       'artist.gettoptracks'           => method_artist_gettoptracks,
+       'user.getinfo'                  => method_user_getinfo,
+       'user.gettoptracks'             => method_user_gettoptracks
 );
 
 function method_user_gettoptracks() {
@@ -71,7 +71,7 @@
                report_failure(LFM_INVALID_SIGNATURE);
        }
 
-       header("Content-Type: text/xml");
+       header('Content-Type: text/xml');
        print(XML::prettyXML(UserXML::getTopTracks($_GET['user'], 
$_GET['period'])));
 }
 
@@ -79,7 +79,7 @@
        if (!isset($_GET['user'])) {
                report_failure(LFM_INVALID_SIGNATURE);
        }
-       header("Content-Type: text/xml");
+       header('Content-Type: text/xml');
        print(XML::prettyXML(UserXML::getInfo($_GET['user'])));
 }
 
@@ -87,7 +87,7 @@
        if (!isset($_GET['artist'])) {
                report_failure(LFM_INVALID_SIGNATURE);
        }
-       header("Content-Type: text/xml");
+       header('Content-Type: text/xml');
        print(XML::prettyXML(ArtistXML::getInfo($_GET['artist'])));
 }
 
@@ -95,7 +95,7 @@
        if (!isset($_GET['artist'])) {
        report_failure(LFM_INVALID_SIGNATURE);
        }
-       header("Content-Type: text/xml");
+       header('Content-Type: text/xml');
        print(XML::prettyXML(ArtistXML::getTopTracks($_GET['artist'])));
 
 }
@@ -116,7 +116,7 @@
                report_failure(LFM_SERVICE_OFFLINE);
 
        print("<lfm status=\"ok\">\n");
-       print(" <token>$key</token></lfm>");
+       print(" <token>{$key}</token></lfm>");
 }
 
 function method_auth_getmobilesession() {
@@ -159,8 +159,8 @@
 
        print("<lfm status=\"ok\">\n");
        print(" <session>\n");
-       print("         <name>$username</name>\n");
-       print("         <key>$session</key>\n");
+       print("         <name>{$username}</name>\n");
+       print("         <key>{$session}</key>\n");
        print("         <subscriber>0</subscriber>\n");
        print(" </session>\n");
        print("</lfm>");
@@ -196,8 +196,8 @@
 
        print("<lfm status=\"ok\">\n");
        print(" <session>\n");
-       print("         <name>$username</name>\n");
-       print("         <key>$session</key>\n");
+       print("         <name>{$username}</name>\n");
+       print("         <key>{$session}</key>\n");
        print("         <subscriber>0</subscriber>\n");
        print(" </session>\n");
        print("</lfm>");
@@ -215,7 +215,7 @@
        global $error_text;
 
        print("<lfm status=\"failed\">\n");
-       print(" <error code=\"$code\">".$error_text[$code]."</error></lfm>");
+       print(" <error code=\"{$code}\">".$error_text[$code]."</error></lfm>");
        die();
 }
 

Modified: trunk/nixtape/admin/report/mbid-mismatch.php
===================================================================
--- trunk/nixtape/admin/report/mbid-mismatch.php        2009-05-10 21:55:45 UTC 
(rev 1477)
+++ trunk/nixtape/admin/report/mbid-mismatch.php        2009-05-10 22:17:37 UTC 
(rev 1478)
@@ -19,7 +19,7 @@
 
 */
 
-require("../../config.php");
+require('../../config.php');
 require_once($install_path . '/database2.php');
 require_once($install_path . '/templating.php');
 require_once($install_path . '/data/sanitize.php');
@@ -36,7 +36,7 @@
        $recordSet->MoveNext();
 }
 
-$smarty->assign("entries", $aEntries);
+$smarty->assign('entries', $aEntries);
 
-$smarty->display("mbid-mismatch-report.tpl");
+$smarty->display('mbid-mismatch-report.tpl');
 ?>

Modified: trunk/nixtape/api/ArtistXML.php
===================================================================
--- trunk/nixtape/api/ArtistXML.php     2009-05-10 21:55:45 UTC (rev 1477)
+++ trunk/nixtape/api/ArtistXML.php     2009-05-10 22:17:37 UTC (rev 1478)
@@ -32,32 +32,32 @@
         * @param string $lang A 2 character ISO 639 alpha-2 code indicating 
the language to return the information in
         * @return A SimpleXMLElement containing the artist's information
         */
-       public static function getInfo($artistName, $api_key=false, 
$mbid=false, $lang="en") {
+       public static function getInfo($artistName, $api_key=false, 
$mbid=false, $lang='en') {
                // We assume $api_key is valid and set at this point
                
                if (!isset($artistName) && !isset($mbid)) {
-                       echo XML::error("failed", "7", "Invalid resource 
specified");
+                       echo XML::error('failed', '7', 'Invalid resource 
specified');
                        return;
                }
 
                $artist = new Artist($artistName, $mbid);
 
                if (PEAR::isError($artist)) {   
-                       return(XML::error("failed", "7", "Invalid resource 
specified"));
+                       return(XML::error('failed', '7', 'Invalid resource 
specified'));
                }
 
-               $xml = new SimpleXMLElement("<lfm status=\"ok\"></lfm>");
+               $xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
 
-               $artistXml = $xml->addChild("artist", null);
-               $artistXml->addChild("name", $artist->name);
-               $artistXml->addChild("mbid", $artist->mbid);
-               $artistXml->addChild("url", $artist->getURL());
-               $artistXml->addChild("streamable", $artist->streamable);
+               $artistXml = $xml->addChild('artist', null);
+               $artistXml->addChild('name', $artist->name);
+               $artistXml->addChild('mbid', $artist->mbid);
+               $artistXml->addChild('url', $artist->getURL());
+               $artistXml->addChild('streamable', $artist->streamable);
 
-               $bio = $artistXml->addChild("bio", null);
-               $bio->addChild("published", $artist->bio_published);
-               $bio->addChild("summary", $artist->bio_summary);
-               $bio->addChild("content", $artist->bio_content);
+               $bio = $artistXml->addChild('bio', null);
+               $bio->addChild('published', $artist->bio_published);
+               $bio->addChild('summary', $artist->bio_summary);
+               $bio->addChild('content', $artist->bio_content);
 
                return($xml);
        }
@@ -67,23 +67,23 @@
                $artist = new Artist($artistName);
 
                if (PEAR::isError($artist)) {
-                       return(XML::error("failed", "7", "Invalid resource 
specified"));
+                       return(XML::error('failed', '7', 'Invalid resource 
specified'));
                }
 
-               $xml = new SimpleXMLElement("<lfm status=\"ok\"></lfm>");
-               $root = $xml->addChild("toptracks", null);
-               $root->addAttribute("artist", $artist->name);
+               $xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
+               $root = $xml->addChild('toptracks', null);
+               $root->addAttribute('artist', $artist->name);
 
                $tracks = $artist->getTopTracks(50);
 
                // Loop over every result and add as children to "toptracks".
                for($i = 1; $i < count($tracks); $i++) {
-                       $track = $root->addChild("track", null);
-                       $track->addAttribute("rank", $i);
-                       $track->addChild("name", $tracks[$i]->name);
-                       $track->addChild("mbid", $tracks[$i]->mbid);
-                       $track->addChild("playcount", 
$tracks[$i]->getPlayCount());
-                       $track->addChild("listeners", 
$tracks[$i]->getListenerCount());
+                       $track = $root->addChild('track', null);
+                       $track->addAttribute('rank', $i);
+                       $track->addChild('name', $tracks[$i]->name);
+                       $track->addChild('mbid', $tracks[$i]->mbid);
+                       $track->addChild('playcount', 
$tracks[$i]->getPlayCount());
+                       $track->addChild('listeners', 
$tracks[$i]->getListenerCount());
                }
 
                return($xml);   

Modified: trunk/nixtape/api/UserXML.php
===================================================================
--- trunk/nixtape/api/UserXML.php       2009-05-10 21:55:45 UTC (rev 1477)
+++ trunk/nixtape/api/UserXML.php       2009-05-10 22:17:37 UTC (rev 1478)
@@ -24,109 +24,109 @@
 
 class UserXML {
 
-    public static function getInfo($username) {
-
-       $user = new User($username);
-       if (PEAR::isError($user)) {
-           return(XML::error("failed", "7", "Invalid resource specified"));
+       public static function getInfo($username) {
+       
+               $user = new User($username);
+               if (PEAR::isError($user)) {
+                       return(XML::error('failed', '7', 'Invalid resource 
specified'));
+               }
+       
+               $xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
+               $user_node = $xml->addChild('user', null);
+               $user_node->addChild('name', $user->name);
+               $user_node->addChild('email', $user->email);
+               $user_node->addChild('homepage', $user->homepage);
+               $user_node->addChild('location', $user->location);
+               $user_node->addChild('bio', $user->bio);
+               $user_node->addChild('profile_created', strftime('%c', 
$user->created));
+               if (isset($user->modified))
+                       $user_node->addChild('profile_updated', strftime('%c', 
$user->modified));
+       
+               return($xml);
        }
+    
+       public static function getTopTracks($username, $time) {
+               global $mdb2;
+       
+               $timestamp;
+               if (!isset($time)) 
+                       $time = 'overall';
+               //TODO: Do better, this is too ugly :\
+               if (strcmp($time, 'overall') == 0) {
+                       $timestamp = 0;
+               } else if (strcmp($time, '3month') == 0) {
+                       $timestamp = strtotime('-3 months');
+               } else if (strcmp($time, '6month') == 0) {
+                       $timestamp = strtotime('-6 months');
+               } else if (strcmp($time, '9month') == 0) {
+                       $timestamp = strtotime('-9 months');
+               } else if (strcmp($time, '12month') == 0) {
+                       $timestamp = strtotime('-12 months');
+               } else {
+                       return(XML::error('error', '13', 'Invalid method 
signature supplied'));
+               }
+       
+               $res = $mdb2->query('SELECT Track.*, Artist.mbid AS artmbid, 
COUNT(*) AS freq 
+                       FROM Track, Scrobbles,Artist 
+                       WHERE Scrobbles.username = ' . $mdb2->quote($username, 
'text') . '
+                       AND Scrobbles.track = Track.name AND Scrobbles.time > ' 
. $timestamp . ' AND Track.artist = Artist.name 
+                       GROUP BY Track.name ORDER BY freq DESC LIMIT 20');
+       
+               if (PEAR::isError($res) || !$res->numRows()) {
+                       return(XML::error('failed', '7', 'Invalid resource 
specified'));
+               }    
+               $xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
+       
+               $root = $xml->addChild('toptracks', null);
+               $root->addAttribute('user', $username);
+               $root->addAttribute('type', $time);
+               $i = 1;
+               while(($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) {
+           
+                       $track = $root->addChild('track', null);
+                       $track->addAttribute('rank', $i);
+                       $track->addChild('name', repamp($row['name']));
 
-       $xml = new SimpleXMLElement("<lfm status=\"ok\"></lfm>");
-       $user_node = $xml->addChild("user", null);
-       $user_node->addChild("name", $user->name);
-       $user_node->addChild("email", $user->email);
-       $user_node->addChild("homepage", $user->homepage);
-       $user_node->addChild("location", $user->location);
-       $user_node->addChild("bio", $user->bio);
-       $user_node->addChild("profile_created", strftime("%c", $user->created));
-       if (isset($user->modified))
-           $user_node->addChild("profile_updated", strftime("%c", 
$user->modified));
+                       $track->addChild('playcount', $row['freq']);
+                       $artist = $track->addChild('artist', 
repamp($row['artist']));
+                       $artist->addChild('mbid', $row['artmbid']);
+                       $i++;
+               }
 
-       return($xml);
-    }
-
-    public static function getTopTracks($username, $time) {
-       global $mdb2;
-
-       $timestamp;
-       if (!isset($time)) 
-           $time = "overall";
-       //TODO: Do better, this is too ugly :\
-       if (strcmp($time, "overall") == 0) {
-           $timestamp = 0;
-       } else if (strcmp($time, "3month") == 0) {
-           $timestamp = strtotime('-3 months');
-       } else if (strcmp($time, "6month") == 0) {
-           $timestamp = strtotime('-6 months');
-       } else if (strcmp($time, "9month") == 0) {
-           $timestamp = strtotime('-9 months');
-       } else if (strcmp($time, "12month") == 0) {
-           $timestamp = strtotime('-12 months');
-       } else {
-           return(XML::error("error", "13", "Invalid method signature 
supplied"));
+               return($xml);
+    
        }
-
-       $res = $mdb2->query("SELECT Track.*, Artist.mbid AS artmbid, COUNT(*) 
AS freq 
-           FROM Track, Scrobbles,Artist 
-           WHERE Scrobbles.username =" . $mdb2->quote($username, 'text') . "
-           AND Scrobbles.track = Track.name AND Scrobbles.time > " . 
$timestamp . " AND Track.artist = Artist.name 
-           GROUP BY Track.name ORDER BY freq DESC LIMIT 20");
-
-       if (PEAR::isError($res) || !$res->numRows()) {
-           return(XML::error("failed", "7", "Invalid resource specified"));
-       }
     
-       $xml = new SimpleXMLElement("<lfm status=\"ok\"></lfm>");
-
-       $root = $xml->addChild("toptracks", null);
-       $root->addAttribute("user", $username);
-       $root->addAttribute("type", $time);
-       $i = 1;
-       while(($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) {
-
-           $track = $root->addChild("track", null);
-           $track->addAttribute("rank", $i);
-           $track->addChild("name", repamp($row['name']));
-           $track->addChild("playcount", $row['freq']);
-           $artist = $track->addChild("artist", repamp($row['artist']));
-           $artist->addChild("mbid", $row['artmbid']);
-           $i++;
-       }
-
-       return($xml);
-
-    }
-
-    public static function getRecentTracks($user, $limit) {
-       global $mdb2;
-
-       if (!isset($limit)) {
-           $limit = 10;
-       }
-
-       $res = $mdb2->query("SELECT Track . * , COUNT( * ) AS freq
-           FROM Track, Scrobbles
-           WHERE Scrobbles.username = " . $mdb2->quote($user, 'text') . "
-           AND Scrobbles.track = Track.name
-           GROUP BY Track.name
-           LIMIT 10");
-
-       if (PEAR::isError($res) || !$res->numRows()) {
-           return(XML::error("error", "7", "Invalid resource specified"));
-       }
-
-       $xml = new SimpleXMLElement("<lfm status=\"ok\"></lfm>");
-       $root = $xml->addChild("recenttracks", null);
-       $root->addAttribute("user", $user);
-
-       while (($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) {
-           $track = $root->addChild("track", null);
-           $artist = $track->addChild("artist", repamp($row['artist']));
-           $artist->addAttribute("mbid", $row['artmbid']);
-           $track->addChild("name", repamp($row['name']));
-       }
-
-       return($xml);
-    }  
+       public static function getRecentTracks($user, $limit) {
+               global $mdb2;
+       
+               if (!isset($limit)) {
+                       $limit = 10;
+               }
+       
+               $res = $mdb2->query('SELECT Track . * , COUNT( * ) AS freq
+                       FROM Track, Scrobbles
+                       WHERE Scrobbles.username = ' . $mdb2->quote($user, 
'text') . '
+                       AND Scrobbles.track = Track.name
+                       GROUP BY Track.name
+                       LIMIT 10');
+       
+               if (PEAR::isError($res) || !$res->numRows()) {    
+                       return(XML::error('error', '7', 'Invalid resource 
specified'));
+               }
+       
+               $xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
+               $root = $xml->addChild('recenttracks', null);
+               $root->addAttribute('user', $user);
+       
+               while (($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) {
+                       $track = $root->addChild('track', null);
+                       $artist = $track->addChild('artist', 
repamp($row['artist']));
+                       $artist->addAttribute('mbid', $row['artmbid']);
+                       $track->addChild('name', repamp($row['name']));
+               }
+       
+               return($xml);
+       }       
 }
 ?>

Modified: trunk/nixtape/api/auth/index.php
===================================================================
--- trunk/nixtape/api/auth/index.php    2009-05-10 21:55:45 UTC (rev 1477)
+++ trunk/nixtape/api/auth/index.php    2009-05-10 22:17:37 UTC (rev 1478)
@@ -34,9 +34,9 @@
        . 'username = ' . $mdb2->quote($_POST['username'], 'text') . ' AND '
        . 'password = ' . $mdb2->quote(md5($_POST['password']), 'text'));
 if (PEAR::isError($result))
-       die("Database error");
+       die('Database error');
 if (!$result->numRows())
-       die("Authentication failed");
+       die('Authentication failed');
 
 // Bind the user to the token and cancel the expiration rule
 $result = $mdb2->query('UPDATE Auth SET '
@@ -45,7 +45,7 @@
        . 'WHERE '
        . 'token = ' . $mdb2->quote($_POST['token']));
 if (PEAR::isError($result))
-       die("Database error");
+       die('Database error');
 ?>
 
 <p>Thank you very much, <?php print($_POST['username']); ?>.  Your 
authorization has been recorded.</p>
@@ -64,9 +64,9 @@
        . 'token = ' . $mdb2->quote($_GET['token'], 'text') . ' AND '
        . 'username IS NULL');
 if (PEAR::isError($result))
-       die("Database error");
+       die('Database error');
 if (!$result->numRows())
-       die("Invalid token");
+       die('Invalid token');
 ?>
 
 <form method="post" action="">

Modified: trunk/nixtape/api/xml.php
===================================================================
--- trunk/nixtape/api/xml.php   2009-05-10 21:55:45 UTC (rev 1477)
+++ trunk/nixtape/api/xml.php   2009-05-10 22:17:37 UTC (rev 1478)
@@ -19,25 +19,26 @@
  */
 
 class XML {
-    public static function prettyXML($xml) {
-       $dom = new DOMDocument('1.0'); 
-       $dom->preserveWhitespace = false;
-       $dom->loadXML($xml->asXML());
-       $dom->formatOutput = true;
-       return($dom->saveXML());
-    } 
-
-    public static function error($status, $errcode, $errtext) {
-       $xml = new SimpleXMLElement("<lfm></lfm>");
-       $xml->addAttribute("status", $status);
-       $error = $xml->addChild("error", $errtext);
-       $error->addAttribute("code", $errcode);
-       return($xml);
-    }
+    
+       public static function prettyXML($xml) {
+               $dom = new DOMDocument('1.0'); 
+               $dom->preserveWhitespace = false;
+               $dom->loadXML($xml->asXML());
+               $dom->formatOutput = true;
+               return($dom->saveXML());
+       } 
+    
+       public static function error($status, $errcode, $errtext) {
+               $xml = new SimpleXMLElement('<lfm></lfm>');
+               $xml->addAttribute('status', $status);
+               $error = $xml->addChild('error', $errtext);
+               $error->addAttribute('code', $errcode);
+               return($xml);
+       }
 }
 
 function repamp($input) {
-    $input = str_replace('&', '&amp;', $input);
-    return($input);
+       $input = str_replace('&', '&amp;', $input);
+       return($input);
 }
 ?>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]