<?php
/**
 * Filename: divestats.php
 * Function: This file displays the dive statistics for phpDivingLog.
 * Version:  phpDivingLog v1.9 2007-03-07
 * Last Modified: 2007-03-07
 * /***************************************************************************
 * 
 * phpDivingLog
 * Copyright (C) 2006 Lloyd Borrett - http://www.borrett.id.au
 * 
 * Adapted from code by Olaf van Zandwijk - http://enschede.vanzandwijk.net
 * 
 * For use with Diving Log by Sven Knoch - http://www.divinglog.de
 * 
 * This file and all dependant and otherwise related files are part of phpDivingLog.
 * 
 * phpDivingLog is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * phpDivingLog is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * /**************************************************************************
 */

// include_once misc file
$misc_filename = "includes/misc.inc.php";
if (!file_exists($misc_filename)) {
    print "<p>Misc file '" . $misc_filename . "' not found.</p>";
    exit;
} 
include_once ($misc_filename);

// Display the Dive List

// Get the page header
$pagetitle = $_lang['dive_stats'];
include($_config['header']);

// Dive Statistics

// Get number of dives
$count = parse_mysql_query('divecount.sql');
$end = $count[0]['COUNT(*)'];

// Get the Min and Max values
$divestats = parse_mysql_query('divestats.sql');

// echo "<hr>\n<b>Result:</b><br>\n<code>\n";
// print_r($divestats);
// echo "</code>\n<br>\n<hr>\n";

// Get the number of shore dives
$globals['stats'] = "Entry = 1";
$divestatsother = parse_mysql_query('divestatsother.sql');
$shoredives = $divestatsother[0]['Count'];

// Get the number of boat dives
$globals['stats'] = "Entry = 2";
$divestatsother = parse_mysql_query('divestatsother.sql');
$boatdives = $divestatsother[0]['Count'];

// Get the number of night dives
$globals['stats'] = "Divetype = '3' OR Divetype LIKE '%,3' OR Divetype LIKE '%,3,%' OR Divetype LIKE '3,%'";
$divestatsother = parse_mysql_query('divestatsother.sql');
$nightdives = $divestatsother[0]['Count'];

// Get the number of drift dives
$globals['stats'] = "Divetype = '4' OR Divetype LIKE '%,4' OR Divetype LIKE '%,4,%' OR Divetype LIKE '4,%'";
$divestatsother = parse_mysql_query('divestatsother.sql');
$driftdives = $divestatsother[0]['Count'];

// Get the number of deep dives
$globals['stats'] = "Divetype = '5' OR Divetype LIKE '%,5' OR Divetype LIKE '%,5,%' OR Divetype LIKE '5,%'";
$divestatsother = parse_mysql_query('divestatsother.sql');
$deepdives = $divestatsother[0]['Count'];

// Get the number of cave dives
$globals['stats'] = "Divetype = '6' OR Divetype LIKE '%,6' OR Divetype LIKE '%,6,%' OR Divetype LIKE '6,%'";
$divestatsother = parse_mysql_query('divestatsother.sql');
$cavedives = $divestatsother[0]['Count'];

// Get the number of wreck dives
$globals['stats'] = "Divetype = '7' OR Divetype LIKE '%,7' OR Divetype LIKE '%,7,%' OR Divetype LIKE '7,%'";
$divestatsother = parse_mysql_query('divestatsother.sql');
$wreckdives = $divestatsother[0]['Count'];

// Get the number of photo dives
$globals['stats'] = "Divetype = '8' OR Divetype LIKE '%,8' OR Divetype LIKE '%,8,%' OR Divetype LIKE '8,%'";
$divestatsother = parse_mysql_query('divestatsother.sql');
$photodives = $divestatsother[0]['Count'];

// Get the number of saltwater dives
$globals['stats'] = "Water = 1";
$divestatsother = parse_mysql_query('divestatsother.sql');
$saltwaterdives = $divestatsother[0]['Count'];

// Get the number of freshwater dives
$globals['stats'] = "Water = 2";
$divestatsother = parse_mysql_query('divestatsother.sql');
$freshwaterdives = $divestatsother[0]['Count'];

// Get the number of brackish dives
$globals['stats'] = "Water = 3";
$divestatsother = parse_mysql_query('divestatsother.sql');
$brackishdives = $divestatsother[0]['Count'];

// Get the number of deco dives
$globals['stats'] = "Deco = True";
$divestatsother = parse_mysql_query('divestatsother.sql');
$decodives = $divestatsother[0]['Count'];

// Get the number of rep dives
$globals['stats'] = "Rep = True";
$divestatsother = parse_mysql_query('divestatsother.sql');
$repdives = $divestatsother[0]['Count'];

// Get dive number for first dive
$globals['stats'] = "Divedate = '" . $divestats[0]['DivedateMin'] . "'";
$divestatsnr = parse_mysql_query('divestatsnr.sql');
$DivedateMinNr = $divestatsnr[0]['Number'];

// Get dive number for last dive
$globals['stats'] = "Divedate = '" . $divestats[0]['DivedateMax'] . "'";
$divestatsnr = parse_mysql_query('divestatsnr.sql');
$DivedateMaxNr = $divestatsnr[count($divestatsnr)-1]['Number'];

// Get dive number for sortest dive
$globals['stats'] = "Divetime = '" . $divestats[0]['DivetimeMin'] . "'";
$divestatsnr = parse_mysql_query('divestatsnr.sql');
$DivetimeMinNr = $divestatsnr[0]['Number'];

// Get dive number for deepest dive
$globals['stats'] = "Divetime = '" . $divestats[0]['DivetimeMax'] . "'";
$divestatsnr = parse_mysql_query('divestatsnr.sql');
$DivetimeMaxNr = $divestatsnr[0]['Number'];

// Get dive number for shallowest dive
$globals['stats'] = "Depth = '" . $divestats[0]['DepthMin'] . "'";
$divestatsnr = parse_mysql_query('divestatsnr.sql');
$DepthMinNr = $divestatsnr[0]['Number'];

// Get dive number for deepest dive
$globals['stats'] = "Depth = '" . $divestats[0]['DepthMax'] . "'";
$divestatsnr = parse_mysql_query('divestatsnr.sql');
$DepthMaxNr = $divestatsnr[0]['Number'];

// Get dive number for coldest dive
$globals['stats'] = "Watertemp = '" . $divestats[0]['WatertempMin'] . "'";
$divestatsnr = parse_mysql_query('divestatsnr.sql');
$WatertempMinNr = $divestatsnr[0]['Number'];

// Get dive number for warmest dive
$globals['stats'] = "Watertemp = '" . $divestats[0]['WatertempMax'] . "'";
$divestatsnr = parse_mysql_query('divestatsnr.sql');
$WatertempMaxNr = $divestatsnr[0]['Number'];

// Get the number of 1st depth range dives
$globals['stats'] = "Depth <= 18";
$divestatsother = parse_mysql_query('divestatsother.sql');
$depthrange1 = $divestatsother[0]['Count'];

// Get the number of 2nd depth range dives
$globals['stats'] = "Depth > 18 AND Depth <= 30";
$divestatsother = parse_mysql_query('divestatsother.sql');
$depthrange2 = $divestatsother[0]['Count'];

// Get the number of 3rd depth range dives
$globals['stats'] = "Depth > 30 AND Depth <= 40";
$divestatsother = parse_mysql_query('divestatsother.sql');
$depthrange3 = $divestatsother[0]['Count'];

// Get the number of 4th depth range dives
$globals['stats'] = "Depth > 40 AND Depth <= 55";
$divestatsother = parse_mysql_query('divestatsother.sql');
$depthrange4 = $divestatsother[0]['Count'];

// Get the number of 5th depth range dives
$globals['stats'] = "Depth > 55";
$divestatsother = parse_mysql_query('divestatsother.sql');
$depthrange5 = $divestatsother[0]['Count'];

echo "<table class=\"divetable\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";

// Links to Dive Log, Dive Sites
$links = " <tr>\n";
$links .= "  <td colspan=\"4\" align=\"center\">\n";
$links .= "   <div class=\"divelogcrumbs\">\n";
$links .= "    <a href=\"index.php\" class=\"divelogcrumbs\"\n";
$links .= "     title=\"";
$links .= $_lang['dive_log_linktitle'] . "\">" . $_lang['dive_log'] . "</a> |\n";
$links .= "    <a href=\"divesite.php\" class=\"divelogcrumbs\"\n";
$links .= "     title=\"";
$links .= $_lang['dive_sites_linktitle'] . "\">" . $_lang['dive_sites'] . "</a> | \n";
$links .= "    <a href=\"equipment.php\" class=\"divelogcrumbs\"\n";
$links .= "     title=\"";
$links .= $_lang['dive_equip_linktitle'] . "\">" . $_lang['dive_equip'] . "</a>\n";
$links .= "   </div>\n";
$links .= "  </td>\n";
$links .= " </tr>\n";
echo $links;

echo " <tr><td colspan=\"4\" class=\"spacing\">&nbsp;</td></tr>\n";

echo " <tr class=\"divesection\">\n";
echo "  <td colspan=\"4\">" . $_lang['stats_sect_stats'] . "</td>\n";
echo " </tr>\n";

// Show overall details
echo " <tr class=\"divetitle\">\n";
echo "  <td>" . $_lang['stats_totaldives'] . "</td>\n";
echo "  <td>" . $_lang['stats_divedatemax'] . "</td>\n";
echo "  <td>" . $_lang['stats_divedatemin'] . "</td>\n";
echo "  <td>&nbsp;</td>\n";
echo " </tr>\n";

echo " <tr class=\"divecontent\">";
echo "  <td>" . $end . "</td>\n";
echo "  <td>" . date($_lang['logbook_divedate_format'], strtotime($divestats[0]['DivedateMax']));
echo "&nbsp;&nbsp;[<a\n";
echo "   href=\"index.php?nr=" . $DivedateMaxNr . "\"\n";
echo "   title=\"" . $_lang['dlog_number_title'] . $DivedateMaxNr;
echo "\">" . $DivedateMaxNr . "</a>]</td>\n";
echo "  <td>" . date($_lang['logbook_divedate_format'], strtotime($divestats[0]['DivedateMin']));
echo "&nbsp;&nbsp;[<a\n";
echo "   href=\"index.php?nr=" . $DivedateMinNr . "\"\n";
echo "   title=\"" . $_lang['dlog_number_title'] . $DivedateMinNr;
echo "\">" . $DivedateMinNr . "</a>]</td>\n";
echo "  <td>&nbsp;</td>\n";
echo " </tr>\n";

// Show dive length details
echo " <tr class=\"divetitle\">\n";
echo "  <td>" . $_lang['stats_totaltime'] . "</td>\n";
echo "  <td>" . $_lang['stats_divetimemax'] . "</td>\n";
echo "  <td>" . $_lang['stats_divetimemin'] . "</td>\n";
echo "  <td>" . $_lang['stats_divetimeavg'] . "</td>\n";
echo " </tr>\n";

echo " <tr class=\"divecontent\">";
echo "  <td>" . floor($divestats[0]['BottomTime'] / 60) . ":" . sprintf("%02d",($divestats[0]['BottomTime'] % 60)) . " " . $_lang['stats_totaltime_units'] . "</td>\n";
echo "  <td>" . $divestats[0]['DivetimeMax'] . "&nbsp;" . $_lang['unit_time'];
echo "&nbsp;&nbsp;[<a\n";
echo "   href=\"index.php?nr=" . $DivetimeMaxNr . "\"\n";
echo "   title=\"" . $_lang['dlog_number_title'] . $DivetimeMaxNr;
echo "\">" . $DivetimeMaxNr . "</a>]</td>\n";
echo "  <td>" . $divestats[0]['DivetimeMin'] . "&nbsp;" . $_lang['unit_time'];
echo "&nbsp;&nbsp;[<a\n";
echo "   href=\"index.php?nr=" . $DivetimeMinNr . "\"\n";
echo "   title=\"" . $_lang['dlog_number_title'] . $DivetimeMinNr;
echo "\">" . $DivetimeMinNr . "</a>]</td>\n";
echo "  <td>" . round($divestats[0]['DivetimeAvg'], 0) . "&nbsp;" . $_lang['unit_time'] . "</td>\n";
echo " </tr>\n";

// Show dive depth details
echo " <tr class=\"divetitle\">\n";
echo "  <td>&nbsp;</td>\n";
echo "  <td>" . $_lang['stats_depthmax'] . "</td>\n";
echo "  <td>" . $_lang['stats_depthmin'] . "</td>\n";
echo "  <td>" . $_lang['stats_depthavg'] . "</td>\n";
echo " </tr>\n";

echo " <tr class=\"divecontent\">";
echo "  <td>&nbsp;</td>\n";
if ($_config['length']) {
    echo "  <td>" . MetreToFeet($divestats[0]['DepthMax'], 0) . "&nbsp;" . $_lang['unit_length_short_imp'];
} else {
    echo "  <td>" . $divestats[0]['DepthMax'] . "&nbsp;" . $_lang['unit_length'];
} 
echo "&nbsp;&nbsp;[<a\n";
echo "   href=\"index.php?nr=" . $DepthMaxNr . "\"\n";
echo "   title=\"" . $_lang['dlog_number_title'] . $DepthMaxNr;
echo "\">" . $DepthMaxNr . "</a>]</td>\n";
if ($_config['length']) {
    echo "  <td>" . MetreToFeet($divestats[0]['DepthMin'], 0) . "&nbsp;" . $_lang['unit_length_short_imp'];
} else {
    echo "  <td>" . $divestats[0]['DepthMin'] . "&nbsp;" . $_lang['unit_length'];
} 
echo "&nbsp;&nbsp;[<a\n";
echo "   href=\"index.php?nr=" . $DepthMinNr . "\"\n";
echo "   title=\"" . $_lang['dlog_number_title'] . $DepthMinNr;
echo "\">" . $DepthMinNr . "</a>]</td>\n";
if ($_config['length']) {
    echo "  <td>" . MetreToFeet($divestats[0]['DepthAvg'], 0) . "&nbsp;" . $_lang['unit_length_short_imp'];
} else {
    echo "  <td>" . round($divestats[0]['DepthAvg'], 1) . "&nbsp;" . $_lang['unit_length'];
} 
echo "</td>\n";
echo " </tr>\n";

// Show dive depth table
echo " <tr class=\"divecontent\">\n";
echo "  <td>&nbsp;</td>\n";
echo "  <td align=\"right\">" . ($_config['length'] ? $_lang['stats_depth1i'] : $_lang['stats_depth1m']) . "&nbsp;&nbsp;</td>\n";
echo "  <td>" . $depthrange1 . " (" . round(($depthrange1 / $end) * 100) . "%)</td>\n";
echo "  <td>&nbsp;</td>\n";
echo " </tr>\n";
echo " <tr class=\"divecontent\">\n";
echo "  <td>&nbsp;</td>\n";
echo "  <td align=\"right\">" . ($_config['length'] ? $_lang['stats_depth2i'] : $_lang['stats_depth2m']) . "&nbsp;&nbsp;</td>\n";
echo "  <td>" . $depthrange2 . " (" . round(($depthrange2 / $end) * 100) . "%)</td>\n";
echo "  <td>&nbsp;</td>\n";
echo " </tr>\n";
echo " <tr class=\"divecontent\">\n";
echo "  <td>&nbsp;</td>\n";
echo "  <td align=\"right\">" . ($_config['length'] ? $_lang['stats_depth3i'] : $_lang['stats_depth3m']) . "&nbsp;&nbsp;</td>\n";
echo "  <td>" . $depthrange3 . " (" . round(($depthrange3 / $end) * 100) . "%)</td>\n";
echo "  <td>&nbsp;</td>\n";
echo " </tr>\n";
echo " <tr class=\"divecontent\">\n";
echo "  <td>&nbsp;</td>\n";
echo "  <td align=\"right\">" . ($_config['length'] ? $_lang['stats_depth4i'] : $_lang['stats_depth4m']) . "&nbsp;&nbsp;</td>\n";
echo "  <td>" . $depthrange4 . " (" . round(($depthrange4 / $end) * 100) . "%)</td>\n";
echo "  <td>&nbsp;</td>\n";
echo " </tr>\n";
echo " <tr class=\"divecontent\">\n";
echo "  <td>&nbsp;</td>\n";
echo "  <td align=\"right\">" . ($_config['length'] ? $_lang['stats_depth5i'] : $_lang['stats_depth5m']) . "&nbsp;&nbsp;</td>\n";
echo "  <td>" . $depthrange5 . " (" . round(($depthrange5 / $end) * 100) . "%)</td>\n";
echo "  <td>&nbsp;</td>\n";
echo " </tr>\n";

// Show water temp, deco and rep details
echo " <tr class=\"divetitle\">\n";
echo "  <td>" . $_lang['stats_watertempmin'] . "</td>\n";
echo "  <td>" . $_lang['stats_watertempmax'] . "</td>\n";
echo "  <td>" . $_lang['stats_decodives'] . "</td>\n";
echo "  <td>" . $_lang['stats_repdives'] . "</td>\n";
echo " </tr>\n";

echo " <tr class=\"divecontent\">";
if ($_config['temp']) {
    echo "  <td>" . CelsiusToFahrenh($divestats[0]['WatertempMin'], 0) . "&nbsp;" . $_lang['unit_temp_imp'];
} else {
    echo "  <td>" . $divestats[0]['WatertempMin'] . "&nbsp;" . $_lang['unit_temp'];
} 
echo "&nbsp;&nbsp;[<a\n";
echo "   href=\"index.php?nr=" . $WatertempMinNr . "\"\n";
echo "   title=\"" . $_lang['dlog_number_title'] . $WatertempMinNr;
echo "\">" . $WatertempMinNr . "</a>]</td>\n";
if ($_config['temp']) {
    echo "  <td>" . CelsiusToFahrenh($divestats[0]['WatertempMax'], 0) . "&nbsp;" . $_lang['unit_temp_imp'];
} else {
    echo "  <td>" . $divestats[0]['WatertempMax'] . "&nbsp;" . $_lang['unit_temp'];
} 
echo "&nbsp;&nbsp;[<a\n";
echo "   href=\"index.php?nr=" . $WatertempMaxNr . "\"\n";
echo "   title=\"" . $_lang['dlog_number_title'] . $WatertempMaxNr;
echo "\">" . $WatertempMaxNr . "</a>]</td>\n";
echo "  <td>" . $decodives . " (" . round(($decodives / $end) * 100) . "%)</td>\n";
echo "  <td>" . $repdives . " (" . round(($repdives / $end) * 100) . "%)</td>\n";
echo " </tr>\n";

// Show water type details
echo " <tr class=\"divetitle\">\n";
echo "  <td>" . $_lang['stats_saltwaterdives'] . "</td>\n";
echo "  <td>" . $_lang['stats_freshwaterdives'] . "</td>\n";
echo "  <td>" . $_lang['stats_brackishdives'] . "</td>\n";
echo "  <td>&nbsp;</td>\n";
echo " </tr>\n";

echo " <tr class=\"divecontent\">";
echo "  <td>" . $saltwaterdives . " (" . round(($saltwaterdives / $end) * 100) . "%)</td>\n";
echo "  <td>" . $freshwaterdives . " (" . round(($freshwaterdives / $end) * 100) . "%)</td>\n";
echo "  <td>" . $brackishdives . " (" . round(($brackishdives / $end) * 100) . "%)</td>\n";
echo "  <td>&nbsp;</td>\n";
echo " </tr>\n";

// Show dive type details
echo " <tr class=\"divetitle\">\n";
echo "  <td>" . $_lang['stats_shoredives'] . "</td>\n";
echo "  <td>" . $_lang['stats_boatdives'] . "</td>\n";
echo "  <td>" . $_lang['stats_nightdives'] . "</td>\n";
echo "  <td>" . $_lang['stats_driftdives'] . "</td>\n";
echo " </tr>\n";

echo " <tr class=\"divecontent\">";
echo "  <td>" . $shoredives . " (" . round(($shoredives / $end) * 100) . "%)</td>\n";
echo "  <td>" . $boatdives . " (" . round(($boatdives / $end) * 100) . "%)</td>\n";
echo "  <td>" . $nightdives . " (" . round(($nightdives / $end) * 100) . "%)</td>\n";
echo "  <td>" . $driftdives . " (" . round(($driftdives / $end) * 100) . "%)</td>\n";
echo " </tr>\n";

// Show more dive type details
echo " <tr class=\"divetitle\">\n";
echo "  <td>" . $_lang['stats_deepdives'] . "</td>\n";
echo "  <td>" . $_lang['stats_cavedives'] . "</td>\n";
echo "  <td>" . $_lang['stats_wreckdives'] . "</td>\n";
echo "  <td>" . $_lang['stats_photodives'] . "</td>\n";
echo " </tr>\n";

echo " <tr class=\"divecontent\">";
echo "  <td>" . $deepdives . " (" . round(($deepdives / $end) * 100) . "%)</td>\n";
echo "  <td>" . $cavedives . " (" . round(($cavedives / $end) * 100) . "%)</td>\n";
echo "  <td>" . $wreckdives . " (" . round(($wreckdives / $end) * 100) . "%)</td>\n";
echo "  <td>" . $photodives . " (" . round(($photodives / $end) * 100) . "%)</td>\n";
echo " </tr>\n";

echo "</table>\n";

// Dive Certifications

// Get the certification details
$divecert = parse_mysql_query('brevetlist.sql');
$count = count($divecert);
if ($count != 0) {
    echo "<table class=\"divetable\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";

    echo " <tr><td colspan=\"4\" class=\"spacing\">&nbsp;</td></tr>\n";

    echo " <tr class=\"divesection\">\n";
    echo "  <td colspan=\"5\">" . $_lang['stats_sect_certs'] . "</td>\n";
    echo " </tr>\n"; 

    // Show dive certification titles
    echo " <tr class=\"divetitle\">\n";
    echo "  <td>" . $_lang['cert_brevet'] . "</td>\n";
    echo "  <td>" . $_lang['cert_org'] . "</td>\n";
    echo "  <td>" . $_lang['cert_certdate'] . "</td>\n";
    echo "  <td>" . $_lang['cert_number'] . "</td>\n";
    echo "  <td>" . $_lang['cert_instructor'] . "</td>\n";
    echo " </tr>\n";

    for ($i = 0; $i < count($divecert); $i++) {
        echo " <tr class=\"divecontent\">\n";
        if ($divecert[$i]['Brevet'] == "") {
            echo "   <td>-</td>\n";
        } else {
            echo "  <td>" . $divecert[$i]['Brevet'] . "</td>\n";
        } 
        if ($divecert[$i]['Org'] == "") {
            echo "   <td>-</td>\n";
        } else {
            echo "  <td>" . $divecert[$i]['Org'] . "</td>\n";
        } 
        if ($divecert[$i]['CertDate'] == "") {
            echo "   <td>-</td>\n";
        } else {
            echo "  <td>" . date($_lang['logbook_divedate_format'], strtotime($divecert[$i]['CertDate'])) . "</td>\n";
        } 
        if ($divecert[$i]['Number'] == "") {
            echo "   <td>-</td>\n";
        } else {
            echo "  <td>" . $divecert[$i]['Number'] . "</td>\n";
        } 
        if ($divecert[$i]['Instructor'] == "") {
            echo "   <td>-</td>\n";
        } else {
            echo "  <td>" . $divecert[$i]['Instructor'] . "</td>\n";
        } 
        echo " </tr>\n";
        if (($divecert[$i]['Scan1Path'] != "") || ($divecert[$i]['Scan1Path'] != "")) {
            echo " <tr class=\"divecontent\">\n";
            echo "  <td colspan=\"5\" align=\"center\">";
            $title = $divecert[$i]['Org'] . " " . $divecert[$i]['Brevet'];
            if ($divecert[$i]['Scan1Path'] != "") {
                echo "\n   <img src=\"" . $_config['userpath_web'] . $divecert[$i]['Scan1Path'] . "\"\n";
                echo "    title=\"" . $title . " " . $_lang['cert_scan_front'] . "\"\n";
                echo "    alt=\"" . $title . " " . $_lang['cert_scan_front'] . "\">";
            } 
            if ($divecert[$i]['Scan2Path'] != "") {
                echo "\n   <img src=\"" . $_config['userpath_web'] . $divecert[$i]['Scan2Path'] . "\"\n";
                echo "    title=\"" . $title . " " . $_lang['cert_scan_back'] . "\"\n";
                echo "    alt=\"" . $title . " " . $_lang['cert_scan_back'] . "\">";
            } 
            echo "<br>\n";
            echo "   &nbsp;</td>\n";
            echo " </tr>\n";
        } 
    } 

    echo "</table>\n";
} 

// Program Details

// Get the program details
$dbinfo = parse_mysql_query('dbinfo.sql');

echo "<table class=\"divetable\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";

echo " <tr><td class=\"spacing\">&nbsp;</td></tr>\n";

echo " <tr class=\"divetitle\">\n";
echo "  <td>" . $_lang['poweredby'] . "\n";
echo "   <a href=\"http://www.divinglog.de/\" target=\"_blank\"\n";
echo "   title=\"Diving Log web site\">" . $dbinfo[0]['PrgName'] . "</a>\n";
echo "   " . $dbinfo[0]['DBVersion'] . $_lang['and'] . "\n";
echo "   <a href=\"http://www.borrett.id.au/interests/phpdivinglog.htm\"\n";
echo "   target=\"_blank\"\n";
echo "   title=\"phpDivingLog web site\">" . $_config['app_name'] . "</a> ";
echo $_config['app_version'] . "</td>\n";
echo " </tr>\n";

echo "</table>\n";

// Get the page footer
include ($_config['footer_divestats']);

?>
