/*
**
** File name : usepages.php
**
** Author : Carl Friis-Hansen cjfh@carl-fh.com
**
** Version : 1.0.1 per 07th September 2002
**
** Description: By including this in a php web page, certain information is inserted
** into a MySQL $table. Certain addresses can be exemt from insertion by
** including those addresses in the NySQL $tableCtrl.
** A certain amount of intelligens is build into the recording stragegy
** so that clients refreshing pages doesn't trigger a new insert.
** This is made as a kind of function and thus not as a class. It would
** not make any sense to me to do so.
** This module should be placed in a safe directory, because the password
** for your database is written in this file.
** You are always welcome to view your tables with my online MySQL browser
** at: http://carl-fh.com/myUniSQL/myUniSQL.php
**
*/
if( isset( $up_pagename ) && isset( $f_user ) ) {
putIntoUsePages( $up_pagename, $f_user );
} else if( isset( $up_pagename ) ) {
putIntoUsePages( $up_pagename );
} else if( isset( $f_user ) ) {
$up_pagename="";
putIntoUsePages( $up_pagename, $f_user );
} else {
putIntoUsePages();
}
function putIntoUsePages( $up_pagename="", $f_user="" ) {
//print "\r\n
".$_SERVER["SERVER_ADDR"];
switch( $_SERVER["SERVER_ADDR"] ) {
case "213.84.144.19": // cjfh
$myHost = "213.84.144.19"; // cjfh
$myDatabase = "edlab";
$myUser = "web";
$myPass = "hemmelig";
break;
case "66.226.94.123": // APlus
case "66.226.64.4":
$myHost = "cfriisha.web.aplus.net"; // cjfh
$myDatabase = "cfriisha";
$myUser = "cfriisha";
$myPass = "hemmelig";
break;
case "66.216.34.97": // FeaturePrice
$myHost = "213.84.144.19"; // cjfh
$myDatabase = "edlab";
$myUser = "web";
$myPass = "hemmelig";
break;
return;
}
/*
$myHost = "213.84.144.19";
$myUser = "web";
$myPass = "hemmelig";
$myDatabase = "edlab";
*/
$table = "usepages";
$tableCtrl = "usepagesctrl";
////////////////////////////////////
//
// Inserts the following variables into edlab.usepages@213.84.144.19:
// IPaddress like "213.84.144.19" automatic assignment
// $up_pagename like "/miau/index.php" automatic or manual assignment
// timestamp like "20020821132404" automatic assignment
// [$f_user like "Mary"] Manual asignment before include
// [$REMOTE_USER like "Mary"] Loged in user - automatic assignment
//
// Certain addresses can be barred from insertion. Such addresses
// must then appear in table $tableCtrl.
//
//print "\r\n
mysql_connect($myHost, $myUser, $myPass))";
if($dbLink = @mysql_connect($myHost, $myUser, $myPass, 6))
{
if(@mysql_select_db($myDatabase, $dbLink))
{
$Query = "select lastRecID from $tableCtrl where RecID=1";
$dbResult = @mysql_query($Query, $dbLink);
$row = @mysql_fetch_row($dbResult);
$lastRecID=$row[0]-1;
$Query = "select disable from $tableCtrl where IPaddress='".$_SERVER["REMOTE_ADDR"]."'";
$dbResult = @mysql_query($Query, $dbLink);
if( $row = @mysql_fetch_row($dbResult) )
{
if( $row[0] == "No" )
{
go_do_insert_into_table( $dbLink, $table, $tableCtrl, $lastRecID, $up_pagename, $f_user );
}
} else {
go_do_insert_into_table( $dbLink,$table, $tableCtrl, $lastRecID, $up_pagename, $f_user );
}
}
@mysql_close( $dbLink );
} // if($dbLink...
} // putIntoUsePages(...)
function go_do_insert_into_table( $dbLink, $table, $tableCtrl, $lastRecID, $up_pagename, $f_user )
{
////////////////////////////////////
//
// Table dependent variables.
//
$pagenameMaxLength = 20; // This is the default size of the 'PageName' column
//
// If no specific page name provided, then set this to $SCRIPT_NAME
//
if(!$up_pagename)
{
$up_pagename = $_SERVER["SCRIPT_NAME"];
}
//
// Cut a tail of max $pagenameMaxLength (20) chars of the $up_pagename to suit the column size.
//
if(strlen($up_pagename) > $pagenameMaxLength)
{
$up_pagename = substr($up_pagename, -$pagenameMaxLength);
}
//
// This query ensures that a client's refresh is not inserted in the database.
//
$Query = "select RecID from $table where IPaddress='".$_SERVER["REMOTE_ADDR"]."' and RecID>=$lastRecID and pageName='$up_pagename' order by RecID desc limit 1";
$dbResult = @mysql_query( $Query, $dbLink );
if( !($row = @mysql_fetch_row( $dbResult) ) )
{
$Query = "insert into $table values( NULL, '".$_SERVER["REMOTE_ADDR"]."', '$up_pagename', ";
if( isset( $f_user ) )
{
$Query .= "'$f_user'";
} else if( isset( $_SERVER["REMOTE_USER"] ) ) {
$Query .= "'".$_SERVER["REMOTE_USER"]."'";
} else {
$Query .= "''";
}
if( ! isset( $_SERVER["REMOTE_HOST"] ) ) {
$_SERVER["REMOTE_HOST"] = "Not resolved";
}
$Query .= ", NULL, '".$_SERVER["REMOTE_PORT"]."', '".$_SERVER["SERVER_NAME"]."', '".$_SERVER["REMOTE_HOST"]."' )";
$dbResult = @mysql_query($Query, $dbLink);
//
// Update the control table's first record to hold the new RecID.
//
$Query = "update $tableCtrl set lastRecID=LAST_INSERT_ID() where RecID=1";
$dbResult = @mysql_query($Query, $dbLink);
}
} // go_do_insert_into_table()
?>
Code pages for The
Bible Prophecy Decoder are provided to give immediate
access
to crossword search and thus the prophecies. The code pages are contained in the *.RSL files. Download by right-click on the RSL-file. |
. |
Keyword___ |
Remarks____________________________ |
Code pages___ |