- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name: Billy
Subject: Re: how to show  1

Below is a perl script I wrote that would be a good starter page, with the 
number of pages indexed, etc.  I used the sql statements above, and some of the 
html code off the page referenced above..
Hope that is okay.. :)


---- start ----------------------------------------
#!/usr/bin/perl

use DBI;

print "Content-type: text/html\n\n";

$db='mydb';
$userid='myuserid';
$password='mypassword';

$dbh = DBI->connect('dbi:mysql:$db',$userid,$password);

($doc_count, $size)=&get_num_docs_and_size($dbh);
$num_sites=&get_number_of_sites($dbh);

&print_page($doc_count, $num_sites, $size);

$dbh->disconnect;

exit;


sub get_num_docs_and_size {
  my ($dbh)[EMAIL PROTECTED];

  #get number of documents indexed and size
  my $query="SELECT count(*), sum(docsize)
             FROM url
             WHERE status in (200,206,304)";

  my $sth = $dbh->prepare($query);

  $sth->execute ||
           die "Could not execute SQL statement ... maybe invalid?";

  #output database results
  my ($count, $size)=$sth->fetchrow_array;

  $sth->finish;

  return ($count, $size);
}

sub get_number_of_sites {
   my ($dbh)[EMAIL PROTECTED];
   my $query="SELECT count(*)
              FROM server
              WHERE command='S' AND parent > 0";

   my $sth = $dbh->prepare($query);

   $sth->execute ||
             die "Could not execute SQL statement ... maybe invalid?";

   my $num=$sth->fetchrow_array;

   $sth->finish;
   return $num;
}


sub print_page {
  my ($doc_count, $num_sites, $size)[EMAIL PROTECTED];

  $size=int($size/(1024*1024));

  $size=&format_number($size);
  $doc_count=&format_number($doc_count);
  $num_sites=&format_number($num_sites);

print <<EOF;
<html>
<center>
<head>
    <title>Findit</title>
    <link href="/css/therm2.css" rel="stylesheet" type="text/css">
</head>
<body>
<img src='/findit.png'>
<table bgcolor=#EEEEEE border="0" cellpadding="2" cellspacing="0">
<!--
<table bgcolor=#EEEEEE width=100%>
<table border="0" cellpadding="2" cellspacing="0">
-->
                    <tr>
                      <td>
<div>
<p>
<form id="s" method="GET" action="/cgi-bin/search.cgi" 
enctype="application/x-www-form-urlencoded">


                                &nbsp;<b>&nbsp;Search:</b> <input  type="text" 
name="q" size="68" value=""><input type="submit" value="&gt;&gt;&gt;">&nbsp;
                </form>
                            <div align="right">&nbsp;</div>
<b>
  <b></b>

</b>
</div>

                      </td>
                    </tr>
                </table>
&nbsp;&nbsp;
<small>$doc_count pages,  $num_sites sites, $size MBytes indexed.</small>

              </td>
            </tr>
        </table>
<p>
</center>
</div>
</center>
</body>
</html>
EOF

}


sub format_number {
  my ($number)[EMAIL PROTECTED];

    my $text = reverse $number;
    $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
    return scalar reverse $text;
}

- - - - - - - - - - - - - - - - - - - - - - - - - - - -

Read the full topic here:
http://www.dataparksearch.org/cgi-bin/simpleforum.cgi?fid=02;topic_id=1164998266

Reply via email to