$tilkobling = mysql_pconnect("mysql.stud.ntnu.no", "pirum", "mona");
mysql_select_db("pirum_db",$tilkobling);
function time_ago($when){
$time = time();
$time_ago = $time - $when;
if( $time_ago > 86400 ) {
$days = floor($time_ago / 86400);
$hours = floor( ( $time_ago - ( $days * 86400 ) ) / 3600 );
$last_seen_text = $days.' dager, '.$hours.' timer siden ';
} else {
$hours = floor($time_ago / 3600);
$minutes = floor( ( $time_ago - ( $hours * 3600 ) ) / 60 );
$last_seen_text = $hours.' timer, '.$minutes.' minutter siden ';
}
return $last_seen_text;
}
function alfabytte($text){
$text = ereg_replace("@","[at]",$text);
$text = ereg_replace("\[at\]","[at]",$text);
$text = ereg_replace("\(at\)","[at]",$text);
return $text;
}
function smilyfilter($text){
$text = ereg_replace("java","jaava",$text);
$text = ereg_replace("Java","jaava",$text);
$text = ereg_replace("JAVA","jaava",$text);
$text = ereg_replace("javA","jaava",$text);
$text = ereg_replace("jAVa","jaava",$text);
$text = ereg_replace("jAVA","jaava",$text);
$text = ereg_replace("<","<",$text);
$text = ereg_replace(">",">",$text);
$text = ereg_replace("\n","
",$text);
$text = ereg_replace("\'","`",$text);
$text = ereg_replace("\"","''",$text);
$text = ereg_replace("æ","æ",$text);
$text = ereg_replace("å","å",$text);
$text = ereg_replace("ø","ø",$text);
$text = preg_replace("/\[b\](.+?)\[\/b\]/", '$1', $text);
$text = preg_replace("/\[i\](.+?)\[\/i\]/", '$1', $text);
$text = preg_replace("/\[u\](.+?)\[\/u\]/", '$1', $text);
$text = preg_replace("/\[center\](.+?)\[\/center\]/", '$1', $text);
$text = ereg_replace("\^\^","",$text);
$text = ereg_replace(":P","",$text);
$text = ereg_replace(":p","",$text);
$text = ereg_replace(":))","",$text);
$text = ereg_replace(":)","",$text);
$text = ereg_replace(":D","",$text);
$text = ereg_replace(":@","",$text);
$text = ereg_replace(">\;:\(","",$text);
$text = ereg_replace(":S","",$text);
$text = ereg_replace(":s","",$text);
$text = ereg_replace("\(a\)","",$text);
$text = ereg_replace("\(A\)","",$text);
$text = ereg_replace("\(l\)","",$text);
$text = ereg_replace("\(L\)","",$text);
$text = ereg_replace("<3","",$text);
$text = ereg_replace(";)","",$text);
$text = ereg_replace(":\(","",$text);
$text = ereg_replace("XD","",$text);
$text = ereg_replace("\:-\/","",$text);
$text = stripslashes($text);
return $text;
}
$time = time();
if($_POST['new_entry'] && $_SESSION['somekindawoman']){
if(!$tag){
$name = mysql_real_escape_string($_POST['name']);
} else {
$name = $tag;
}
$ip_block = array(
'66.232.118.183'
,'222.66.48.253'
,'66.79.85.140'
,'201.210.181.5'
,'58.147.4.20'
,'85.214.25.228'
,'202.141.41.53'
,'210.210.220.241'
,'217.20.175.100'
);
$hilsen = mysql_real_escape_string($_POST['hylsensz']);
$epost = mysql_real_escape_string($_POST['epost']);
$ip = $_SERVER['REMOTE_ADDR'];
$stops = mysql_fetch_array(mysql_query("SELECT id FROM gjestebok WHERE ip LIKE '$ip' AND timestamp > '".(time()-(60*15))."'"));
if($stops['id']){
print'
Cannot add entry within 15 minutes of previous entry
';
} else
if($name && $hilsen && !in_array($ip,$ip_block) && $_SESSION['somekindawoman']
&& !ereg('
$query = mysql_query("SELECT * FROM `gjestebok` ORDER BY id DESC");
while($row = mysql_fetch_array($query)){
?>