<?php

    /* return a list of all Firefox extensions parsed from the
     * XML source file provided by the InfoLister extension,
     * also returns the user-agent string, the upload time
     * and the total number of enabled extensions installed
     * to improve performance, we should cache the list
     */

    function list_extensions()  {

        global $format;  // handy date() formats

        $source = '/path/to/your/uploaded/file.xml';

        if (!$xml = file_get_contents($source)) return false;

        include('xml.php');
        $data = XML_unserialize($xml);

        // when was the last time I uploaded the XML data?

        $updated = strtotime($data['infolister']['info']['lastupd']);
        $info->upload['iso'] = gmdate($format['iso8601'], $updated);
        $info->upload['local'] = date($format['local'], $updated);

        // what browser and platform am I running?

        $info->agent = $data['infolister']['info']['useragent'];

        // the extensions

        $ext = $data['infolister']['info']['extensions']['ext'];
        $info->count = $n = count($ext) / 2;

        for ($i = 0; $i < $n; $i++)  {

            $attr = $ext[$i . ' attr'];

            // skip disabled extensions

            if ($attr['disabled'] == 'true')  { 
                $info->count--; 
                continue;
            }

            $li = '<li<>a href="' . $attr['homepageURL'] . '"';
            if ($attr['creator']) $li .= ' title=" by ' . $attr['creator'] . ' "';
            $li .= '>' . $ext[$i] . '</a> v' . $attr['version'] . ' &#8212; ';
            $li .= $attr['description'] . '</li>' .  "\n";
            $list[] = $li;
        }
        $info->list = implode('', $list);
        return $info;

    } // list_extensions()
?>