theme && file_exists($themes[$user->theme][0])) { include $themes[$user->theme][0]; } else { include $themes[key($themes)][0]; } return new Theme(); } function discussion_score($comment) { $value = ($comment->votes) ? ($comment->score / $comment->votes) : (($comment->score) ? $comment->score : 0); return (strpos($value, ".")) ? substr($value ."00", 0, 4) : $value .".00"; } function check_field($message) { return str_replace("\"", """, stripslashes($message)); } function check_input($message) { global $allowed_html, $submission_size; return strip_tags(addslashes(substr($message, 0, $submission_size)), $allowed_html); } function check_output($message, $nl2br = 0) { global $allowed_html; if ($nl2br == 1) return nl2br(strip_tags(stripslashes($message), $allowed_html)); else return strip_tags(stripslashes($message), $allowed_html); } function discussion_num_replies($id, $count = 0) { $result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = $id"); return ($result) ? db_result($result, 0) : 0; } function discussion_num_filtered($sid, $pid) { global $user; $threshold = ($user->id) ? $user->threshold : "0"; $pid = ($pid) ? $pid : 0; $result = db_query("SELECT COUNT(cid) FROM comments WHERE sid = $sid AND pid = $pid AND (votes != 0 AND score / votes < $threshold)"); return ($result) ? db_result($result, 0) : 0; } function format_plural($count, $singular, $plural) { return ($count == 1) ? "$count $singular" : "$count $plural"; } function format_date($timestamp, $type = "medium") { global $user; $timestamp += ($user->timezone) ? $user->timezone - date("Z") : 0; switch ($type) { case "small": $date = date("D, m/d/y - H:i", $timestamp); break; case "medium": $date = date("l, m/d/Y - H:i", $timestamp); break; case "large": $date = date("D, M d, Y - H:i", $timestamp); break; case "extra large": $date = date("l, F dS, Y - H:i", $timestamp); break; default: $date = date("D, M d, Y - H:i", $timestamp); } return $date; } function format_data($field, $replacement = "na") { return ($field) ? $field : $replacement; } function format_username($username, $admin = 0) { if ($username) return ($admin) ? "$username" : "$username"; else { global $anonymous; return $anonymous; } } function format_email($address) { return ($address) ? "$address" : format_data($address); } function format_url($address, $description = "") { // POSSIBLE EXTENSIONS: // 1. add `http://' in case it's missing. // 2. add a trailing `/' in case it's missing. // 3. remove any parameters in the URI. $description = ($description) ? $description : $address; return ($address) ? "$description" : format_data($address); } ?>