<?
// This is a console mode program!!!!!
// It expect you have Internet access to access a database on port 3306
include("class.columns.php");
define("SERVER", "213.84.144.19" ); // You are wellcome to select data from this database server
define("USERNAME", "friend" ); // There are currently three databases you can access:
define("PASSWORD", "friendly" ); // cdx, gps and photo
// You are only given Select priviledges.
if($argc < 4)
{
print "\r\nThis program is GPL and copyright 2002 by Carl Friis-Hansen\r\n\r\n" .
"USAGE:\r\n" .
" PHP $argv[0] COS110|COS111|COS129|COS136 from to [FULL [HTML]]\r\n\r\n" .
"from on the form YYYYMMDD\r\n" .
"to on the form YYYYMMDD\r\n\r\n" .
"The program interrogates cdx.logcdx and summes the column COS???.\r\n" .
"The result is a tab delimited line with number of calls and the total cost.\r\n";
exit();
}
// resource mysql_connect (string [server], string [username], string [password])
if($dbf = @mysql_connect(SERVER, USERNAME, PASSWORD))
{
// print SERVER . "/" . USERNAME . " is connected\r\n--------------------------------\r\n";
} else {
exit("Error: " . SERVER . "/" . USERNAME . " is NOT connected\r\n--------------------------------\r\n");
}
function doQuery($Query="")
{
global $dbf;
global $dbResult;
if($Query != "")
{
$dbResult = mysql_query($Query, $dbf);
}
$result = mysql_fetch_row($dbResult);
return $result;
} // doQuery()
if($argv[4] == "FULL" or $argv[4] == "full")
{
$psc = new printSimpelColumns();
$psc->setColumnDefinition(0, "EndDate" ,"%-8s | ");
$psc->setColumnDefinition(1, "EndTime" ,"%-8s | ");
$psc->setColumnDefinition(2, "Duration" ,"%-8s | ");
$psc->setColumnDefinition(3, "Price" ,"%7s | ");
$psc->setColumnDefinition(4, "Name" ,"%-8s | ");
$psc->setColumnDefinition(5, "Digits" ,"%-17s\r\n");
if($argv[5] == "HTML" or $argv[5] == "html")
{
print "<pre>\r\n";
}
print $psc->getHeaderLine();
$a = doQuery( "select EndDate, EndTime, DurationT, $argv[1], AlarmC, Digits" .
" from cdx.logcdx" .
" where EndDate >= $argv[2]" .
" && EndDate <= $argv[3]" .
" && $argv[1] <> ''" .
" order by RecID ASC" );
print $psc->getDataLine($a);
while($a = doQuery())
{
print $psc->getDataLine($a);
}
if($argv[5] == "HTML" or $argv[5] == "html")
{
print "</pre>\r\n";
}
} else {
$a = doQuery( "select count(*), sum($argv[1])" .
" from cdx.logcdx" .
" where EndDate >= $argv[2]" .
" && EndDate <= $argv[3]" .
" && $argv[1] <> ''" .
" order by RecID ASC" );
print "Number of calls: " . $a[0] . " for a total of EUR " . $a[1] . "\r\n";
}
mysql_close($dbf);
?>
|