Graffiti!
";
//Open Connection
$connection = odbc_connect("graffiti","","");
$query= "Select * From Viewers WHERE IMName = '$n' ";
$result = odbc_do($connection, $query) or die('The SQL query could not be completed at this time (1).');
if(odbc_fetch_row($result))
{
$sqlstmt="Update Viewers SET TimeAccessed=now, IP='$REMOTE_ADDR' WHERE IMName = '$n'";
$result = odbc_do($connection, $sqlstmt) or die('The SQL statement could not be completed at this time (2).');
}
else
{
$sqlstmt="INSERT INTO Viewers (IMName, TimeAccessed, IP) VALUES ('$n', now, '$REMOTE_ADDR')";
$result = odbc_do($connection, $sqlstmt) or die('The SQL statement could not be completed at this time (3).');
}
//If Searching for something...
if (isset($Searchfor))
{
$Searchfor = str_replace("'","''",$Searchfor);
$query = "Select * From messages WHERE quote LIKE '%$Searchfor%'";
}
else
{
$query = "Select * From stats";
}
$result = odbc_do($connection, $query) or die('The SQL query could not be completed at this time (4).');
//Get the total number of quotes (highest ID), and any other stats
$i=0;
$j=1;
$fCount = odbc_num_fields($result);
while ($i < $fCount)
{
$i++;
$fName = odbc_field_name($result, $i);
$job[$fName] = odbc_result($result, $i);
}
$j=$j+1;
$i=0;
//Do the math to get max and min messages
$numberviews=$job["Views"];
$totalmsgs=$job["total"];
$getxmsgs=20; //Change this to the number of recent messages you want to display
$maxmsgs=$totalmsgs+1;
$minmsgs=$totalmsgs-$getxmsgs;
if ($minmsgs<0) {$minmsgs=0;} //Make sure minimum is 0
//Update number of times viewed
$numberviews++;
$stmt = "update stats set Views=$numberviews";
$result = odbc_do($connection, $stmt) or die('The SQL statement could not be completed at this time (5).');
//Go get the messages
$query = "Select * From wall where ID<$maxmsgs AND ID>$minmsgs ORDER BY ID DESC";
//echo $query;
$result = odbc_do($connection, $query) or die('The SQL query could not be completed at this time (6).');
$i=0;
$j=1;
$fCount = odbc_num_fields($result);
while(odbc_fetch_row($result))
{
while ($i < $fCount)
{
$i++;
$fName = odbc_field_name($result, $i);
$job[$fName] = odbc_result($result, $i);
}
$j=$j+1;
$i=0;
$message = str_replace("\'","'",$job["Message"]);
$message = str_replace('\"','"',$message);
%>
<% if ($job["Name"]=="kpxhunnie"){echo "";}%><% echo $job["Name"]; %>: <% echo $message; %>
<%
} //End of while loop
odbc_close($connection);
%>
Write on the wall, <% echo $n %>!
Who's been here?
Viewed <% echo $numberviews %> times.
PHP Scripts by Plocmstart
http://www.plocmstart.com