ini_set("output_buffering",6000); header("Expires: -1"); include "config.php"; mysql_pconnect($db_hostname,$db_username,$db_password); mysql_select_db($db_dbname); function barf($message) { include_once "top.php"; echo $message; include_once "bottom.php"; exit; } function abort_if_mysql_error() { if (mysql_error()) { barf("
Oops! Fatal database error:
" . htmlspecialchars(mysql_error()) . "
"); } } function mysql_query_wrapper($q) { $ret = mysql_query($q); abort_if_mysql_error(); return $ret; } function mysql_query_one_value($sql) { $q = mysql_query_wrapper($sql); $row = mysql_fetch_row($q); return $row[0]; } function editable_if_admin ($value, $inputname, $size=32, $maxlength=128) { global $user; if ($user->user_is_admin) { $html = ""; $html .= ''; return $html; } else { return htmlspecialchars($value) . " "; } } function strtrunc ($s, $max) { if (strlen($s) <= $max) return $s; else return substr($s,0,$max-3) . '...'; } function hyperlinkurls ($s) { /* if ($_ENV[REMOTE_ADDR] != '24.67.192.68') return $s; */ return preg_replace("|(https?://[-_0-9a-zA-Z][-_0-9a-zA-Z\\.]+[-_0-9a-zA-Z](/([^\\s<>]*[^\\s<>&\\.,\\?\\)])?)?)|", "\\1", $s); } function oneorzero ($postvar) { return $_POST[$postvar] ? 1 : 0; } function is_spam () { $m = "From: $_POST[author_name] <$_POST[author_email]>\nTo: root@kics.bc.ca\nSubject: ticket\n\n"; foreach ($_POST as $k => $v) { $m .= $v; $m .= "\n"; } $p = popen("spamc -t 10 -d spamd.tomclegg.net >/dev/null 2>/dev/null", "w"); fwrite ($p, $m); $ret = pclose ($p); return ($ret != 0); } if ($_COOKIE['session']) { $s = split (",", $_COOKIE['session']); $user = mysql_fetch_object(mysql_query_wrapper("select * from users where user_id='$s[0]' and user_auth='$s[1]'")); } ?>