$sql = 'DELETE FROM ' . $tbl;
    $db->Execute($sql);
    $sql = 'SELECT * FROM ' . $tbl;
    $rs = $db->Execute($sql);
    outputnow('Cleaning ' . $tbl . ' table... ', false);
    outputnow($rs->RecordCount > 0 ? 'Failed' : 'OK');
}
$filename = $_GET['f'];
$filepath = GEDCOM_DIR . $filename;
//$maxtime = ini_get('max_execution_time') - 5;
$maxtime = 30;
$stime = time();
# initialize gedcom parser
outputnow('Initializing gedcom parser...');
require_once CORE_PATH . 'gedcom.class.php';
$gedcom = new GedcomParser();
$gedcom->Open($filepath);
# Set the file offset and set the factkey if needed
if (isset($_GET['offset']) and $_GET['offset'] > 0) {
    $offset = $_GET['offset'];
    # we need to set the factkey to the highest already in the database
    # in case we are not starting from the beginning of the file
    $sql = 'SELECT factkey FROM ' . TBL_FACT;
    $rs = $db->Execute($sql);
    $factkey = 0;
    while ($row = $rs->FetchRow()) {
        if ($row['factkey'] > $factkey) {
            $factkey = $row['factkey'];
        }
    }
    $gedcom->factkey = $factkey;
</style>
<span class="log">
<?php 
# helper function
function outputnow($s)
{
    echo $s . '<br />';
    ob_flush();
    flush();
}
$filename = $_GET['f'];
$filepath = GEDCOM_DIR . $filename;
# initialize gedcom parser
outputnow('Initializing gedcom parser...');
require_once CORE_PATH . 'gedcom.class.php';
$gedcom = new GedcomParser();
# analyze gedcom
outputnow('Analyzing ' . $filename . '...');
$gedcom->Open($filepath);
$gedcom->GetStatistics();
#display results of analysis
outputnow('');
outputnow('Size: ' . filesize_format($gedcom->fsize));
outputnow('Lines: ' . number_format($gedcom->lines));
outputnow('Individuals: ' . number_format($gedcom->individual_count));
outputnow('Families: ' . number_format($gedcom->family_count));
outputnow('Sources: ' . number_format($gedcom->source_count));
outputnow('Notes: ' . number_format($gedcom->note_count));
outputnow('');
$yes = '<a href="' . $_SERVER['PHP_SELF'] . '?m=gedcom_process&f=' . $filename . '">Yes</a>';
$no = '<a href="' . BASE_SCRIPT . '?m=gedcom" target="_parent">No</a>';