function CommonFooter()
{
    foreach (array('iconv', 'zlib', 'exif', 'mysql', 'dba') as $ext) {
        $support[] = (extension_loaded($ext) ? '+' : '-') . $ext;
    }
    echo xml_gen::br();
    echo xml_gen::p('getID3() ' . getid3::VERSION . '.<br>PHP ' . phpversion() . ' (' . implode(xml_gen::space(2), $support) . ').');
    echo xml_gen::p(xml_gen::a('http://getid3.sourceforge.net/', 'http://getid3.sourceforge.net'));
    echo '</body></html>';
}
function FormatEncoderOptionsReport()
{
    echo xml_gen::h3('Format/Encoder/Options Distribution');
    global $dbh;
    $t = new Table(11, 'class=table', null, 'left;left;left;;right;left;right;left;right;left;right;left');
    // NOTE: Left joining because encoder_options might not be set....
    $dbh->query("select N.name as format_name, E.name as encoder_version, O.name as encoder_options, count(X.id) as counter, sum(X.filesize)/1024/1024/1024 as sumsize, sum(X.playtime)/3600 as sumplay, sum(X.avg_bit_rate)/1000 as sumbitr from getid3_file X left join getid3_encoder_options O on O.id = X.encoder_options_id, getid3_format_name N, getid3_encoder_version E where N.id = X.format_name_id and E.id = X.encoder_version_id  group by N.id,E.id,O.id order by N.name, E.name");
    while ($dbh->next_record()) {
        $t->data($dbh->f('format_name') . xml_gen::space(3));
        $t->data($dbh->f('encoder_version') . xml_gen::space(3));
        $t->data($dbh->f('encoder_options') . xml_gen::space(3));
        $t->data(number_format($dbh->f('counter')));
        $t->data('files' . xml_gen::space(3));
        $t->data(number_format($dbh->f('sumsize')));
        $t->data('Gb' . xml_gen::space(3));
        $t->data(number_format($dbh->f('sumplay'), 1));
        $t->data('hours' . xml_gen::space(3));
        $t->data(number_format($dbh->f('sumbitr') / $dbh->f('counter')));
        $t->data('kbps (avg)');
    }
    $t->done();
}
 /**
  * Common XHTML header
  *
  * @param    string      title       Title
  * @param    string      up          Uri to up button or false
  * @param    string      play        Uri to play button or false
  * @param    bool        sort        Sort buttons active
  * @param    bool        numbers     Show numbers button active
  */
 protected function head($title, $up = false, $play = false, $sort = false, $numbers = false)
 {
     echo parent::head($title);
     // initialize tool tips
     $this->tool_tips = new tool_tips();
     $g = new xml_gen();
     // generate menu xml
     // up button
     $menu_xml[] = $up ? $g->a_img($up, 'images/up.png', "alt='Up one level' title='Up one level'", 'images/up-c.png') : $g->img('images/up-g.png');
     // play button
     $menu_xml[] = $play ? $g->a_img("./?action=play&location={$play}", 'images/play.png', "alt='Play all tracks' title='Play all tracks'", 'images/play-c.png') : $g->img('images/play-g.png');
     // spacer
     $menu_xml[] = $g->space();
     // search button
     $menu_xml[] = $g->a_img("./?action=search", 'images/search.png', "alt='Search Metadata' title='Search Metadata'", 'images/search-c.png');
     // stats button
     $menu_xml[] = $g->a_img("./?action=stats", 'images/stats.png', "alt='Statictics' title='Statictics'", 'images/stats-c.png');
     // config button
     $menu_xml[] = $g->a_img('./?action=config', 'images/config.png', "alt='Configuration' title='Configuration'", 'images/config-c.png');
     // all music link artist search
     $amg_link = $this->action != 'toc' ? "javascript:document.forms.AMG.submit()" : "http://www.allmusic.com/";
     $menu_xml[] = $g->a_img($amg_link, 'images/amg.png', "alt='All Music Guide' title='All Music Guide'", 'images/amg-c.png');
     // google image search
     $goo_link = $this->action != 'toc' ? "javascript:google()" : "http://www.google.com/";
     $menu_xml[] = $g->a_img($goo_link, 'images/google.png', "alt='Google Image Search' title='Google Image Search'", 'images/google-c.png');
     // spacer
     $menu_xml[] = $g->space();
     // numbers button
     $img = @$_COOKIE['show_numbers'] ? 'numb' : 'num0';
     $menu_xml[] = $numbers ? $g->a_img($_SERVER['REQUEST_URI'] . '&set_show_numbers=1', "images/{$img}.png", "alt='Toggle track numbers' title='Toggle track numbers'", "images/{$img}-c.png") : $g->img("images/{$img}-g.png");
     // playing time button
     $img = @$_COOKIE['show_playtime'] ? 'time' : 'time0';
     $menu_xml[] = $sort ? $g->a_img($_SERVER['REQUEST_URI'] . '&set_show_playtime=1', "images/{$img}.png", "alt='Toggle playing time' title='Toggle playing time'", "images/{$img}-c.png") : $g->img("images/{$img}-g.png");
     // sort alpha button
     $img = $this->get_sort_mode();
     $menu_xml[] = $sort ? $g->a_img($_SERVER['REQUEST_URI'] . '&set_sort_alpha=1', "images/{$img}.png", "alt='Toggle sort moder' title='Toggle sort mode'", "images/{$img}-c.png") : $g->img("images/{$img}-g.png");
     // sort desc button
     $img = $this->get_sort_direction();
     $menu_xml[] = $sort ? $g->a_img($_SERVER['REQUEST_URI'] . "&set_sort_mode=1", "images/{$img}.png", "alt='Toggle sort direction' title='Toggle sort direction'", "images/{$img}-c.png") : $g->img("images/{$img}-g.png");
     // output menu and title in main table
     $this->t = new table(2, "id='main'");
     $this->t->data(null, "id='menu'");
     $t = new table(1);
     foreach ($menu_xml as $xml) {
         $t->data($xml);
     }
     $t->done();
     $this->t->data($g->h1($title), "id='body'");
     // all music guide code
     $search_string = ereg("^[#@!\\+]?([^:]+)", $title, $regs) ? $regs[1] : "";
     // first part of title - split by :, remove special chars
     echo "\n            <form action='http://www.allmusic.com/cg/amg.dll' method='post' target='AMG' name='AMG'>\n            <input type='hidden' name='P'   value='amg' />\n            <input type='hidden' name='uid' value='SEARCH' />\n            <input type='hidden' name='sql' value=\"{$search_string}\" />\n            <input type='hidden' id='buttons' name='opt1' value='1' />\n            </form>\n        ";
     // google image search code
     $search_string = urlencode(utf8_decode(str_replace(":", '', $title)));
     echo "\n            <script type='text/javascript'>\n            <!--\n            function google()\n            {\n                window.open('http://images.google.com/images?as_q={$search_string}&svnum=10&hl=en&imgsz=medium|large|xlarge&safe=off',  'google2', 'resizable,scrollbars,menubar,status,toolbar,location')\n                window.open('http://images.google.com/images?as_q={$search_string}&svnum=10&hl=en&imgsz=xxlarge&safe=off',              'google1', 'resizable,scrollbars,menubar,status,toolbar,location')\n            }\n            //-->\n            </script>\n        ";
     // maximize browser window?
     if ($this->browser_behaviour == 'maximize') {
         echo "\n                <script type='text/javascript'>\n                <!--\n                self.moveTo(0,0);\n                self.resizeTo(screen.availWidth, screen.availHeight);\n                // -->\n                </script>\n            ";
     }
 }