"; if( strlen($var) == 0 ) return $empty_ret_val; else { if( $do_escape ) return "\"" . mysql_escape_string($var) . "\""; else return "\"" . $var . "\""; } } else if( $type == "n" ) { // apparently this is one way to obtain the string length // of a number. if( strlen( strval($var) ) == 0 ) return $empty_ret_val; else return $var; } else { // If we don't know what to do with the variable, just return it // in hopes that things will continue on fine. return $var; } } //------------------------------------------------------------------------------------------- // defs.php needs to define $HOST, $USER, $PASSWD, $DB, $MYSQL_CON_ERR, and $MYSQL_SELECT_ERR function connect() { global $HOST, $USER, $PASSWD, $DB, $MYSQL_CON_ERR, $MYSQL_SELECT_ERR, $RED; // Connect to database. if ( ! @mysql_connect($HOST, $USER, $PASSWD) ) { $errmsg = "Error connecting to $HOST as $USER: " . mysql_error(); print "
** $errmsg **
"; log_and_mail_error($errmsg); die($MYSQL_CON_ERR); } if( !mysql_select_db($DB) ) { $errmsg = "Error selecting $DB: " . mysql_error(); print "
** $errmsg **
"; log_and_mail_error($errmsg); die($MYSQL_SELECT_ERR); } } function query_error($location, $q, $sys_err_msg) { global $ADMIN_EMAIL, $ADMIN_PHONE, $RED; log_and_mail_error("OCPA Query Error: $location:\nq=$q\n$sys_err_msg"); print "
"; print "** The query produced an error **
\n"; print "----------------- THE PROBLEM -----------------
\n"; print "$sys_err_msg

\n"; print "
"; die(); } // strip bbcode function strip_bbcode($text) { $text = preg_replace('#\[b\](.*?)\[/b\]#si', '\1', $text); $text = preg_replace('#\[i\](.*?)\[/i\]#si', '\1', $text); $text = preg_replace('#\[u\](.*?)\[/u\]#si', '\1', $text); $text = preg_replace('#\[center\](.*?)\[/center\]#si', '\1', $text); $text = preg_replace('#\[url\]([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\";\+]*?)([\r\n]*)\[/url\]#si', '\2\3', $text); $text = preg_replace('#\[url\]([\r\n]*)([^\s\'\";\+]*?)([\r\n]*)\[/url\]#si', '\2', $text); $text = preg_replace('#\[url=([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\";\+]*?)\](.*?)([\r\n]*)\[/url\]#si', '\4', $text); $text = preg_replace('#\[url=([\r\n]*)([^\s\'\";\+]*?)\](.*?)([\r\n]*)\[/url\]#si', '\3', $text); $text = preg_replace('#\[mail\]([\r\n]*)([^\s\'\";:\+]*?)([\r\n]*)\[/mail\]#si', '\2', $text); $text = preg_replace('#\[mail=([\r\n]*)([^\s\'\";:\+]*?)\](.*?)([\r\n]*)\[/mail\]#si', '\2', $text); $text = preg_replace('#\[small\](.*?)\[/small\]#si', '\1', $text); $text = preg_replace('#\[color=(black|blue|brown|cyan|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|violet|white|yellow)\](.*?)\[/color\]#si', '\2', $text); $text = preg_replace('#\[flash width=([0-9]*?) height=([0-9]*?)\]([^\s\'\";:\+]*?)(\.swf)\[/flash\]#si', '', $text); $text = preg_replace("#\[img\]((http|ftp|https|ftps)://)(.*?)(\.(jpg|jpeg|gif|png|JPG|JPEG|GIF|PNG))\[/img\]#sie","\1",$text); $qcount = substr_count($text, "[quote]"); $ccount = substr_count($text, "[code]"); for ($i=0;$i < $qcount;$i++) $text = preg_replace('#\[quote\](.*?)\[/quote\]#si', '\1', $text); for ($i=0;$i < $ccount;$i++) $text = preg_replace('#\[code\](.*?)\[/code\]#si', '\1', $text); return $text; } ?>