'), array('<noscript', 'noscript>'), $array); $output = stripslashes($array); } return $output; } if(get_magic_quotes_gpc()) { $_GET = stripslashes_array($_GET); $_POST = stripslashes_array($_POST); $_COOKIE = stripslashes_array($_COOKIE); } $_SERVER = stripslashes_array($_SERVER); $url = "{$HTTP_SERVER_VARS['SERVER_NAME']}".str_replace(" ", "_+_-_+_", $HTTP_SERVER_VARS['PHP_SELF']); if ($HTTP_SESSION_VARS) {extract($HTTP_SESSION_VARS, EXTR_SKIP); } if ($_SESSION) {extract($_SESSION, EXTR_SKIP); } if ($HTTP_COOKIE_VARS) {extract($HTTP_COOKIE_VARS, EXTR_SKIP); } if ($_COOKIE) {extract($_COOKIE, EXTR_SKIP); } if ($HTTP_POST_VARS) {extract($HTTP_POST_VARS, EXTR_SKIP); } if ($_POST) {extract($_POST, EXTR_SKIP); } if ($HTTP_GET_VARS) {extract($HTTP_GET_VARS, EXTR_SKIP); } if ($_GET) {extract($_GET, EXTR_SKIP); } if ($HTTP_ENV_VARS) {extract($HTTP_ENV_VARS, EXTR_SKIP); } if ($_ENV) {extract($_ENV, EXTR_SKIP); } //////////////////////////////////////////////////////// // Description: Notice fix if(!isset($a)) $a = NULL; // Action fix if(!isset($c)) $c = NULL; // Another Action fix if(!isset($l)) $l = NULL; // Poll Action fix if(!isset($d)) $d = NULL; // Data fix if(!isset($o)) $o = NULL; // Other fix if(!isset($q)) $q = NULL; // Another Other fix if(!isset($k)) $k = NULL; // Another Another Other fix if(!isset($i)) $i = NULL; // Info fix if(!isset($p)) $p = 1; // Pagination fix if(!isset($m)) $m = date('n'); // Calendar fix if(!isset($action)) $action = NULL; if(!isset($template_left)) $template_left = NULL; if(!isset($session_id)) $session_id = session_id(); if(!isset($layout)) $layout = NULL; if(!isset($layout2)) $layout2 = NULL; if(!isset($template_right)) $template_right = NULL; if(!isset($_SERVER['HTTP_REFERER'])) $_SERVER['HTTP_REFERER'] = NULL; if(!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; if(!isset($_SESSION['authorization'])) $_SESSION['authorization'] = 0; //////////////////////////////////////////////////////// // Description: Define Authorizations if($_SESSION['authorization'] == 0) { $is_guest = 1; $is_user = NULL; $is_moderator = NULL; $is_administrator = NULL; $is_webmaster = NULL; } if($_SESSION['authorization'] == 1) { $is_guest = NULL; $is_user = 1; $is_moderator = NULL; $is_administrator = NULL; $is_webmaster = NULL; } if($_SESSION['authorization'] == 2) { $is_guest = NULL; $is_user = NULL; $is_moderator = 1; $is_administrator = NULL; $is_webmaster = NULL; } if($_SESSION['authorization'] == 3) { $is_guest = NULL; $is_user = NULL; $is_moderator = NULL; $is_administrator = 1; $is_webmaster = NULL; } if($_SESSION['authorization'] == 4) { $is_guest = NULL; $is_user = NULL; $is_moderator = NULL; $is_administrator = NULL; $is_webmaster = 1; } //////////////////////////////////////////////////////// // Description: Check see if user is loged in or not if(isset($is_guest)) $is_loged_in = NULL; if(isset($is_user) || isset($is_moderator) || isset($is_administrator) || isset($is_webmaster)) $is_loged_in = 1; //////////////////////////////////////////////////////// // Description: Autoexecute these querys $badwords_db = $db->getTable("SELECT * FROM badwords"); $emoticons_db = $db->getTable("SELECT * FROM emoticons"); //////////////////////////////////////////////////////// // Function: Message Definition // Description: insert messages when called function messagedef($message) { global $config, $i; require "language/{$config['language']}"; if(!isset($output)) $output = NULL; if ($i == 1) $output .="$message {$language['Message desc']}"; elseif ($i == 2) $output .="$message {$language['Message desc2']}"; elseif ($i == 3) $output .="$message {$language['Message desc3']} {$_SESSION['username']}"; elseif ($i == 4) $output .="$message {$language['Message desc4']}"; elseif ($i == 5) $output .="$message {$language['Message desc5']}"; elseif ($i == 6) $output .="$message {$language['Message desc6']}"; elseif ($i == 7) $output .="$message {$language['Message desc7']}"; elseif ($i == 8) $output .="$message {$language['Message desc8']}"; elseif ($i == 9) $output .="$message {$language['Message desc9']}"; elseif ($i == 10) $output .="$message {$language['Message desc10']}"; elseif ($i == 11) $output .="$message {$language['Message desc11']}"; elseif ($i == 12) $output .="$message {$language['Message desc12']}"; elseif ($i == 13) $output .="$message {$language['Message desc13']}"; elseif ($i == 14) $output .="$message {$language['Message desc14']}"; elseif ($i == 15) $output .="$message {$language['Message desc15']}"; elseif ($i == 16) $output .="$message {$language['Message desc16']}"; elseif ($i == 17) $output .="$message {$language['Message desc17']}"; elseif ($i == 18) $output .="$message {$language['Message desc18']}"; elseif ($i == 19) $output .="$message {$language['Message desc19']}"; elseif ($i == 20) $output .="$message {$language['Message desc20']}"; elseif ($i == 21) $output .="$message {$language['Message desc21']}"; elseif ($i == 22) $output .="$message {$language['Message desc22']}"; elseif ($i == 23) $output .="$message {$language['Message desc23']}"; elseif ($i == 24) $output .="$message {$language['Message desc24']}"; elseif ($i == 25) $output .="$message {$language['Message desc25']}"; elseif ($i == 26) $output .="$message {$language['Message desc26']}"; elseif ($i == 27) $output .="$message {$language['Message desc27']}"; elseif ($i == 28) $output .="$message {$language['Message desc28']}"; elseif ($i == 29) $output .="$message {$language['Message desc29']}"; elseif ($i == 30) $output .="$message {$language['Message desc30']}"; elseif ($i == 31) $output .="$message {$language['Message desc31']}"; elseif ($i == 32) $output .="$message {$language['Message desc32']}"; elseif ($i == 33) $output .="$message {$language['Message desc33']}"; elseif ($i == 34) $output .="$message {$language['Message desc34']}"; elseif ($i == 35) $output .="$message {$language['Message desc35']}"; elseif ($i == 36) $output .="$message {$language['Message desc36']}"; elseif ($i == 37) $output .="$message {$language['Message desc37']}"; elseif ($i == 38) $output .="$message {$language['Message desc38']}"; elseif ($i == 39) $output .="$message {$language['Message desc39']}"; elseif ($i == 40) $output .="$message {$language['Message desc40']}"; elseif ($i == 41) $output .="$message {$language['Message desc41']}"; elseif ($i == 42) $output .="$message {$language['Message desc42']}"; elseif ($i == 43) $output .="$message {$language['Message desc43']}"; elseif ($i == 44) $output .="$message {$language['Message desc44']}"; elseif ($i == 45) $output .="$message {$language['Message desc45']}"; elseif ($i == 46) $output .="$message {$language['Message desc46']}"; elseif ($i == 47) $output .="$message {$language['Message desc47']}"; elseif ($i == 48) $output .="$message {$language['Message desc48']}"; elseif ($i == 49) $output .="$message {$language['Message desc49']}"; elseif ($i == 50) $output .="$message {$language['Message desc50']}"; elseif ($i == 51) $output .="$message {$language['Message desc51']}"; elseif ($i == 52) $output .="$message {$language['Message desc52']}"; elseif ($i == 53) $output .="$message {$language['Message desc53']}"; elseif ($i == 54) $output .="$message {$language['Message desc54']}"; elseif ($i == 55) $output .="$message {$language['Message desc55']}"; elseif ($i == 56) $output .="$message {$language['Message desc56']}"; elseif ($i == 57) $output .="$message {$language['Message desc57']}"; elseif ($i == 58) $output .="$message {$language['Message desc58']}"; elseif ($i == 59) $output .="$message {$language['Message desc59']}"; elseif ($i == 60) $output .="$message {$language['Message desc60']}"; elseif ($i == 61) $output .="$message {$language['Message desc61']}"; elseif ($i == 62) $output .="$message {$language['Message desc62']}"; elseif ($i == 63) $output .="$message {$language['Message desc63']}"; elseif ($i == 64) $output .="$message {$language['Message desc64']}"; elseif ($i == 65) $output .="$message {$language['Message desc65']}"; elseif ($i == 66) $output .="$message {$language['Message desc66']}"; elseif ($i == 67) $output .="$message {$language['Message desc67']}"; elseif ($i == 68) $output .="$message {$language['Message desc68']}"; elseif ($i == 69) $output .="$message {$language['Message desc69']}"; elseif ($i == 70) $output .="$message {$language['Message desc70']}"; elseif ($i == 71) $output .="$message {$language['Message desc71']}"; elseif ($i == 72) $output .="$message {$language['Message desc72']}"; elseif ($i == 73) $output .="$message {$language['Message desc73']}"; elseif ($i == 74) $output .="$message {$language['Message desc74']}"; elseif ($i == 75) $output .="$message {$language['Message desc75']}"; elseif ($i == 76) $output .="$message {$language['Message desc76']}"; elseif ($i == 77) $output .="$message {$language['Message desc77']}"; elseif ($i == 78) $output .="$message {$language['Message desc78']}"; elseif ($i == 79) $output .="$message {$language['Message desc79']}"; elseif ($i == 80) $output .="$message {$language['Message desc80']}"; elseif ($i == 81) $output .="$message {$language['Message desc81']}"; elseif ($i == 82) $output .="$message {$language['Message desc82']}"; elseif ($i == 83) $output .="$message {$language['Message desc83']}"; elseif ($i == 84) $output .="$message {$language['Message desc84']}"; elseif ($i == 85) $output .="$message {$language['Message desc85']}"; elseif ($i == 86) $output .="$message {$language['Message desc86']}"; elseif ($i == 87) $output .="$message {$language['Message desc87']}"; elseif ($i == 88) $output .="$message {$language['Message desc88']}"; elseif ($i == 89) $output .="$message {$language['Message desc89']}"; elseif ($i == 91) $output .="$message {$language['Message desc91']}"; elseif ($i == 92) $output .="$message {$language['Message desc92']}"; elseif ($i == 93) $output .="$message {$language['Message desc93']}"; elseif ($i == 94) $output .="$message {$language['Message desc94']}"; elseif ($i == 95) $output .="$message {$language['Message desc95']}"; elseif ($i == 96) $output .="$message {$language['Message desc96']}"; elseif ($i == 97) $output .="$message {$language['Message desc97']}"; elseif ($i == 98) $output .="$message {$language['Message desc98']}"; elseif ($i == 99) $output .="$message {$language['Message desc99']}"; elseif ($i == 100) $output .="$message {$language['Message desc100']}"; elseif ($i == 101) $output .="$message {$language['Message desc101']}"; elseif ($i == 102) $output .="$message {$language['Message desc102']}"; elseif ($i == 103) $output .="$message {$language['Message desc103']}"; elseif ($i == 104) $output .="$message {$language['Message desc104']}"; elseif ($i == 105) $output .="$message {$language['Message desc105']}"; elseif ($i == 106) $output .="$message {$language['Message desc106']}"; elseif ($i == 107) $output .="$message {$language['Message desc107']}"; elseif ($i == 108) $output .="$message {$language['Message desc108']}"; elseif ($i == 109) $output .="$message {$language['Message desc109']}"; elseif ($i == 110) $output .="$message {$language['Message desc110']}"; elseif ($i == 111) $output .="$message {$language['Message desc111']}"; elseif ($i == 112) $output .="$message {$language['Message desc112']}"; elseif ($i == 113) $output .="$message {$language['Message desc113']}"; elseif ($i == 114) $output .="$message {$language['Message desc114']}"; elseif ($i == 115) $output .="$message {$language['Message desc115']}"; elseif ($i == 116) $output .="$message {$language['Message desc116']}"; elseif ($i == 117) $output .="$message {$language['Message desc117']}"; elseif ($i == 118) $output .="$message {$language['Message desc118']}"; elseif ($i == 119) $output .="$message {$language['Message desc119']}"; elseif ($i == 120) $output .="$message {$language['Message desc120']}"; elseif ($i == 121) $output .="$message {$language['Message desc121']}"; elseif ($i == 122) $output .="$message {$language['Message desc122']}"; elseif ($i == 123) $output .="$message {$language['Message desc123']}"; elseif ($i == 124) $output .="$message {$language['Message desc124']}"; elseif ($i == 125) $output .="$message {$language['Message desc125']}"; elseif ($i == 126) $output .="$message {$language['Message desc126']}"; elseif ($i == 127) $output .="$message {$language['Message desc127']}"; elseif ($i == 128) $output .="$message {$language['Message desc128']}"; elseif ($i == 129) $output .="$message {$language['Message desc129']}"; elseif ($i == 130) $output .="$message {$language['Message desc130']}"; elseif ($i == 131) $output .="$message {$language['Message desc131']}"; elseif ($i == 132) $output .="$message {$language['Message desc132']}"; elseif ($i == 133) $output .="$message {$language['Message desc133']}"; elseif ($i == 134) $output .="$message {$language['Message desc134']}"; else $output .="$message {$language['Message desc00']}"; return $output; } //////////////////////////////////////////////////////// // Function: jcm_linebreaks // Description: Convert \r\n and \r to \n function jcm_linebreaks($str){ return str_replace("\r", "\n", str_replace("\r\n", "\n", $str)); } //////////////////////////////////////////////////////// // Function: jcm_stripslashes // Description: Strip slashes function jcm_stripslashes($str){ return (get_magic_quotes_gpc() == 1) ? stripslashes($str) : $str; } //////////////////////////////////////////////////////// // Function: jcm_strlen // Description: A more special strlen() function jcm_strlen($str){ return strlen(preg_replace('/&#([0-9]+);/', '!', $str)); } //////////////////////////////////////////////////////// // Function: jcm_htmlspecialchars // Description: A more special htmlspecialchars() function jcm_htmlspecialchars($str) { $str = preg_replace('/&(?!#[0-9]+;)/s', '&', $str); $str = str_replace(array('<', '>', '"'), array('<', '>', '"'), $str); return $str; } //////////////////////////////////////////////////////// // Function: split_text // Description: Split the message into tokens function split_text($text, $start, $end) { $num_spaces = 4; $tokens = explode($start, $text); $outside[] = $tokens[0]; $num_tokens = count($tokens); for ($i = 1; $i < $num_tokens; ++$i) { $temp = explode($end, $tokens[$i]); $inside[] = $temp[0]; $outside[] = $temp[1]; } if ($num_spaces != 8 && $start == '[code]') { $spaces = str_repeat(' ', $num_spaces); $inside = str_replace("\t", $spaces, $inside); } return array($inside, $outside); } //////////////////////////////////////////////////////// // Function: check_tag_order // Description: Check for [code] and [quote] function check_tag_order($text,$x) { // The maximum allowed quote depth $max_depth = 3; while (true) { $c_start = strpos($text, '[code]'); $c_end = strpos($text, '[/code]'); $q_start = strpos($text, '[quote]'); $q_end = strpos($text, '[/quote]'); if (preg_match('#\[quote=("|"|\'|)(.*)\\1\]#sU', $text, $matches)) $q2_start = strpos($text, $matches[0]); else $q2_start = 65536; if ($c_start === false) $c_start = 65536; if ($c_end === false) $c_end = 65536; if ($q_start === false) $q_start = 65536; if ($q_end === false) $q_end = 65536; if (min($c_start, $c_end, $q_start, $q_end, $q2_start) == 65536) break; $q3_start = ($q_start < $q2_start) ? $q_start : $q2_start; if ($q3_start < min($q_end, $c_start, $c_end)) { $step = ($q_start < $q2_start) ? 7 : strlen($matches[0]); $cur_index += $q3_start + $step; if ($q_depth == $max_depth) $overflow_begin = $cur_index - $step; ++$q_depth; $text = substr($text, $q3_start + $step); } else if ($q_end < min($q_start, $c_start, $c_end)) { if ($q_depth == 0){ return $x = 1; exit; } $q_depth--; $cur_index += $q_end+8; if ($q_depth == $max_depth) $overflow_end = $cur_index; $text = substr($text, $q_end+8); } else if ($c_start < min($c_end, $q_start, $q_end)) { $tmp = strpos($text, '[/code]'); if ($tmp === false){ return $x = 2; exit; } else $text = substr($text, $tmp+7); $cur_index += $tmp+7; } else if ($c_end < min($c_start, $q_start, $q_end)){ return $x = 3; exit; } } if ($q_depth > 0){ return $x = 4; exit; } else if ($q_depth < 0){ return $x = 5; exit; } if (isset($overflow_begin)) return array($overflow_begin, $overflow_end); else return null; } //////////////////////////////////////////////////////// // Function: truncate_url // Description: Takes care of url function truncate_url($url, $link = '') { $full_url = $url; if (strpos($url, 'www.') === 0) $full_url = 'http://'.$full_url; else if (strpos($url, 'ftp.') === 0) $full_url = 'ftp://'.$full_url; else if (strpos($url, 'http://') !== 0) $full_url = 'http://'.$full_url; $link = ($link == '' || $link == $url) ? ((strlen($url) > 55) ? substr($url, 0 , 39).' ... '.substr($url, -10) : $url) : stripslashes($link); return ''.$link.''; } //////////////////////////////////////////////////////// // Function: handle_img_tag // Description: Takes care of the image function handle_img_tag($url) { $img_tag = ''.htmlspecialchars($url).''; return $img_tag; } //////////////////////////////////////////////////////// // Function: do_bbcode // Description: Takes care of bbcode function do_bbcode($message) { $pattern[] = '#\[b\](.*?)\[/b\]#s'; $pattern[] = '#\[i\](.*?)\[/i\]#s'; $pattern[] = '#\[u\](.*?)\[/u\]#s'; $pattern[] = '#\[font=(.*?)\](.*?)\[/font\]#s'; $pattern[] = '#\[size=(.*?)\](.*?)\[/size\]#s'; $pattern[] = '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s'; $pattern[] = '#\[left\](.*?)\[/left\]#s'; $pattern[] = '#\[center\](.*?)\[/center\]#s'; $pattern[] = '#\[right\](.*?)\[/right\]#s'; $pattern[] = '#\[list\]#s'; $pattern[] = '#\[/list\]#s'; $pattern[] = '#\[\*\]#s'; $pattern[] = '#\[image=((ht|f)tps?://)([^\s<"]*?)\\]#e'; $pattern[] = '#\[url\](.*?)\[/url\]#e'; $pattern[] = '#\[url=(.*?)\](.*?)\[/url\]#e'; $pattern[] = '#\[email\](.*?)\[/email\]#'; $pattern[] = '#\[email=(.*?)\](.*?)\[/email\]#'; $replace[] = '$1'; $replace[] = '$1'; $replace[] = '$1'; $replace[] = '$2'; $replace[] = '$2'; $replace[] = '$2'; $replace[] = '
$1
'; $replace[] = '
$1
'; $replace[] = '
$1
'; $replace[] = ''; $replace[] = '
  • '; $replace[] = 'handle_img_tag(\'$1$3\')'; $replace[] = 'truncate_url(\'$1\')'; $replace[] = 'truncate_url(\'$1\', \'$2\')'; $replace[] = '$1'; $replace[] = '$2'; // This thing takes a while! :) $message = preg_replace($pattern, $replace, $message); if (strpos($message, 'quote') !== false) { $message = preg_replace('#\[quote=("|"|\'|)(.*)\\1\]#seU', '"

    ".str_replace(\'[\', \'[\', \'$2\')." wrote:

    "', $message); $message = str_replace('[quote]', '

     

    ', $message); $message = str_replace('[/quote]', '
    ', $message); } return $message; } //////////////////////////////////////////////////////// // Function: do_clickable // Description: Takes care of links function do_clickable($message) { $message = ' '.$message; $message = preg_replace('#([\s\(\)])(https?|ftp|news){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.truncate_url(\'$2://$3\')', $message); $message = preg_replace('#([\s\(\)])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.truncate_url(\'$2.$3\', \'$2.$3\')', $message); return substr($message, 1); } //////////////////////////////////////////////////////// // Function: do_smilies // Description: Takes care of emoticons function do_smilies($message) { global $emoticons_db; if($emoticons_db != FALSE) { $smilies_path = "images/emoticons"; foreach($emoticons_db as $idx=>$emoticons) { $smiley_codes[] = $emoticons['code']; $smiley_files[] = $emoticons['pic']; } $message = ' '.$message.' '; for ($count = 0; $count <= $idx; $count++) $message = preg_replace("#(?<=.\W|\W.|^\W)".preg_quote($smiley_codes[$count], '#')."(?=.\W|\W.|\W$)#m", '$1'.$smiley_codes[$count].'$2', $message); return substr($message, 1, -1); } else return $message; } //////////////////////////////////////////////////////// // Function: do_censor // Description: Takes care of badwords function do_censor($message) { global $config, $badwords_db; if($badwords_db != FALSE) { foreach($badwords_db as $idx=>$badwords) { $badword[] = $badwords['word']; $wordreplacment[] = $badwords['replacement']; } $message = ' '.$message.' '; for ($count = 0; $count <= $idx; $count++) { if($config['badword_mode'] == 1) $message = preg_replace ( '#'.$badword[$count].'#i', ''.$wordreplacment[$count].'', $message ); else $message = preg_replace ( '#'.$badword[$count].'#i', str_pad ( '', strlen ( $badword[$count] ), '*' ), $message ); } return substr($message, 1, -1); } else return $message; } //////////////////////////////////////////////////////// // Function: parse_char // Description: Replaces charactars + adds bb and sm function parse_message($message) { global $config; $message = jcm_htmlspecialchars($message); if (strpos($message, '[url]') !== false && strpos($message, '[/url]') !== false) $message = cuttext($message,115); if (strpos($message, '[code]') !== false && strpos($message, '[/code]') !== false) { list($inside, $outside) = split_text($message, '[code]', '[/code]'); $outside = array_map('trim', $outside); $message = implode('<">', $outside); } if ($config['badwords'] == 1) $message = do_censor($message); $message = do_clickable($message); if ($config['emoticons'] == 1) $message = do_smilies($message); if ($config['bbcode'] == 1 && strpos($message, '[') !== false && strpos($message, ']') !== false) $message = do_bbcode($message); $pattern = array("\n", "\t", ' ', ' '); $replace = array('
    ', '    ', '  ', '  '); $message = str_replace($pattern, $replace, $message); if (isset($inside)) { $outside = explode('<">', $message); $message = ''; $num_tokens = count($outside); for ($i = 0; $i < $num_tokens; $i++) { $message .= $outside[$i]; if (isset($inside[$i])) $message .= '

    Code:

    '.trim($inside[$i]).'
    '; } } return $message; } //////////////////////////////////////////////////////// // Function: dis_bb_em // Description: Status on BBcode and Emoticons Global function dis_bb_em($ex=false) { global $config; require "language/{$config['language']}"; if($config['bbcode'] == 1) $bbcode = "{$language['Enabled']}"; else $bbcode = "{$language['Disabled']}"; if($config['emoticons'] == 1) $emoticons = "{$language['Enabled']}"; else $emoticons = "{$language['Disabled']}"; if($config['badwords'] == 1) $badwords = "{$language['Enabled']}"; else $badwords = "{$language['Disabled']}"; if($ex == "true") $spaces = "





    "; else $spaces = "


    "; $output = "$spaces{$language['BBcode']} > $bbcode
    {$language['Emoticons']} > $emoticons
    {$language['Badwords']} > $badwords"; return $output; } //////////////////////////////////////////////////////// // Function: insertBBcode // Description: insert bbcode function insertBBcode($break_location = FALSE) { global $config; require "language/{$config['language']}"; $bbcodes_path = "templates/{$config['template']}/images/codes"; $bbcode_codes = array("[b]Text[/b]","[i]Text[/i]","[u]Text[/u]","[font=verdana]Text[/font]","[size=2]Text[/size]","[color=red]Text[/color]","[left]text[/left]","[center]text[/center]","[right]text[/right]","[list][*]Text1[*]Text2[/list]","[quote=Name]Text[/quote]","[code]Text[/code]","[image=URL]","[url=URL]Text[/url]","[email=URL]Text[/email]"); $bbcode_files = array("bold.gif","italic.gif","underline.gif","fontface.gif","fontsize.gif","color.gif","fontleft.gif","fontcenter.gif","fontright.gif","list.gif","quote.gif","code.gif","img.gif","url.gif","email.gif"); $bbcode_alt = array($language['BBcode desc'],$language['BBcode desc2'],$language['BBcode desc3'],$language['BBcode desc4'],$language['BBcode desc5'],$language['BBcode desc6'],$language['BBcode desc7'],$language['BBcode desc8'],$language['BBcode desc9'],$language['BBcode desc10'],$language['BBcode desc11'],$language['BBcode desc12'],$language['BBcode desc13'],$language['BBcode desc14'],$language['BBcode desc15']); foreach($bbcode_codes as $idx=>$code) { if(!isset($h)) $h = 1; if(!isset($output)) $output = NULL; if($config['bbcode'] == 1) $output .="\"{$bbcode_alt[$idx]}\""; else $output .="\"{$language['Disabled']}\""; if($h % $break_location == 0 and $break_location) $output .= "
    "; else $output .= ""; $h++; } return $output; } //////////////////////////////////////////////////////// // Function: insertSmilies // Description: insert smilies function insertSmilies($break_location = FALSE) { global $config, $emoticons_db; require "language/{$config['language']}"; $smilies_path = "images/emoticons"; if($emoticons_db != FALSE) { foreach($emoticons_db as $emoticons) { $smiley_codes[] = $emoticons['code']; $smiley_files[] = $emoticons['pic']; } foreach($smiley_codes as $idx=>$code) { if(!isset($h)) $h = 1; if(!isset($output)) $output = NULL; if($config['bbcode'] == 1) $output .="\"{$smiley_codes[$idx]}\""; else $output .="\"{$language['Disabled']}\""; if($h % $break_location == 0 and $break_location) $output .= "
    "; else $output .= ""; $h++; } } else $output = $language['No Emoticons']; return $output; } //////////////////////////////////////////////////////// // Function: find_ip // Description: Shows the ip function find_ip() { if (getenv('HTTP_CLIENT_IP')) $ip = getenv('HTTP_CLIENT_IP'); elseif (getenv('HTTP_X_FORWARDED_FOR')) $ip = getenv('HTTP_X_FORWARDED_FOR'); elseif (getenv('HTTP_X_FORWARDED')) $ip = getenv('HTTP_X_FORWARDED'); elseif (getenv('HTTP_FORWARDED_FOR')) $ip = getenv('HTTP_FORWARDED_FOR'); elseif (getenv('HTTP_FORWARDED')) $ip = getenv('HTTP_FORWARDED'); else $ip = $_SERVER['REMOTE_ADDR']; return $ip; } //////////////////////////////////////////////////////// // Function: find_browser // Description: Shows the browser or bots function find_browser($browser_def) { if (!(strpos($browser_def,'Mozilla') === false)) { if (!(strpos($browser_def,'Opera') === false)) $browser = 'Opera'; elseif (!(strpos($browser_def,'Firefox') === false)) $browser = 'Firefox'; elseif (!(strpos($browser_def,'Netscape') === false)) $browser = 'Netscape'; elseif (!(strpos($browser_def,'MSIE') === false)) $browser = 'Internet Explorer'; else $browser = 'Other browser'; } else { if (!(strpos($browser_def,'Google') === false)) $browser = 'Google Bot'; elseif (!(strpos($browser_def,'msn') === false)) $browser = 'Msn Bot'; else $browser = 'Other bot'; } return $browser; } //////////////////////////////////////////////////////// // Function: generate_code // Description: This function generates a random code function generate_code($length = 8, $seeds = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') { $str = ''; $seeds_count = strlen($seeds); list($usec, $sec) = explode(' ', microtime()); $seed = (float) $sec + ((float) $usec * 100000); mt_srand($seed); for ($i = 0; $length > $i; $i++) $str .= $seeds{mt_rand(0, $seeds_count - 1)}; return $str; } //////////////////////////////////////////////////////// // Function: send_email // Description: This function sends mails to destination function send_email($dat) { global $config, $template; $website_name = $config['website_name']; $website_url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}"; $webmaster_name = $config['webmaster_name']; $webmaster_email = $config['webmaster_email']; switch($dat['reason']) { case 'activate': $subject = "$website_name | Activation"; $body = implode("", file("templates/$template/email/act.php")); $body = str_replace("{username}", $dat['username'], $body); $body = str_replace("{date}", date("l, d F Y - h:i:s",$dat['actime']), $body); $body = str_replace("{link}", $website_url."?n=modules/register&a=2&key=".$dat['multikey'], $body); $body = str_replace("{key}", $dat['multikey'], $body); $body = str_replace("{website_name}", $website_name, $body); $body = str_replace("{webmaster_name}", $webmaster_name, $body); $body = str_replace("{webmaster_email}", $webmaster_email, $body); break; case 'forgot': $subject = "$website_name | Forgotten Password"; $body = implode("", file("templates/$template/email/fpw.php")); $body = str_replace("{username}", $dat['username'], $body); $body = str_replace("{date}", date("l, d F Y - h:i:s",$dat['actime']), $body); $body = str_replace("{link}", $website_url."?n=modules/register&a=3&d=3&key=".$dat['multikey'], $body); $body = str_replace("{website_name}", $website_name, $body); $body = str_replace("{webmaster_name}", $webmaster_name, $body); $body = str_replace("{webmaster_email}", $webmaster_email, $body); break; } $headers =""; $headers.="From: \"".$webmaster_name."\" <".$webmaster_email.">\n"; $headers.="Return-Path: $webmaster_email\n"; $headers.="X-Priority: 3\n"; $headers.="X-Mailer: $website_name Server\n"; // send out the message mail($dat['email'], $subject, $body, $headers); } //////////////////////////////////////////////////////// // Function: cuttext // Description: Cuts a string and adds .. function cuttext($value,$lenght) { if (strlen($value) >= $lenght ) { $limited = substr($value,0,$lenght); $limited .= "..."; } else $limited = $value; return $limited; } //////////////////////////////////////////////////////// // Function: row2color // Description: Shows the results on 2 colors function row2color($id_def) { if ($id_def/2 == round($id_def/2)) $row = "con1"; else $row = "con2"; return $row; } //////////////////////////////////////////////////////// // Function: today_yesterday // Description: Function for Today and Yesterday function today_yesterday($time,$ex=false) { global $config; require "language/{$config['language']}"; $today = date("d/m/y",time()); $yesterday = date("d/m/y",time() - 86400); if($ex == "true") { if ($today == date("d/m/y",$time)) $date = "{$language['Time today']} ".date("h:i:s A", $time).""; elseif ($yesterday == date("d/m/y",$time)) $date = "{$language['Time yesterday']} ".date("h:i:s A", $time).""; else $date = date("d/m/y h:i:s A", $time); } else { if ($today == date("d/m/y",$time)) $date = "{$language['Time today']} - ".date("h:i:s A", $time).""; elseif ($yesterday == date("d/m/y",$time)) $date = "{$language['Time yesterday']} - ".date("h:i:s A", $time).""; else $date = date("d/m/y - h:i:s A", $time); } return $date; } //////////////////////////////////////////////////////// // Function: last_visit // Description: Calculates the last visit function last_visit($time,$regtime=false) { global $config; require "language/{$config['language']}"; if($time == $regtime) $finish = $language['Time Definition Never']; else { $day = date("d",$time); $month = date("m",$time); $year = date("Y",$time); $hours = date("H",$time); $minutes = date("i",$time); $seconds = date("s",$time); $date = time() - mktime($hours, $minutes, $seconds, $month, $day, $year); if (!is_array($date)) { $periods = array ($language['Time Definition Years'] => 31556926,$language['Time Definition Months'] => 2629743,$language['Time Definition Days'] => 86400,$language['Time Definition Hours'] => 3600,$language['Time Definition Minutes'] => 60,$language['Time Definition Seconds'] => 1); $date = (int) $date; foreach ($periods as $period => $value) { $count = floor($date / $value); if ($count == 0) continue; $values[$period] = $count; $date = $date % $value; } if (empty($values)) $values = null; $date = $values; } if (!is_array($date)) return false; foreach ($date as $key => $value) { $segment = $value . ' ' . $key; if ($value == 1) { if($key == $language['Time Definition Years']) $segment = $value . ' ' . $language['Time Definition Year']; if($key == $language['Time Definition Months']) $segment = $value . ' ' . $language['Time Definition Month']; if($key == $language['Time Definition Weeks']) $segment = $value . ' ' . $language['Time Definition Week']; if($key == $language['Time Definition Days']) $segment = $value . ' ' . $language['Time Definition Day']; if($key == $language['Time Definition Hours']) $segment = $value . ' ' . $language['Time Definition Hour']; if($key == $language['Time Definition Minutes']) $segment = $value . ' ' . $language['Time Definition Minute']; if($key == $language['Time Definition Seconds']) $segment = $value . ' ' . $language['Time Definition Second']; } $array[] = $segment; } $result = implode(', ', $array); $finish = $result." {$language['HQ user desc7']}"; } return $finish; } //////////////////////////////////////////////////////// // Function: find_country // Description: insert country for user detalies function find_country($name=false,$type=false) { if(!isset($list)) $list = NULL; $c = array ("none" => "Not Specified","af" => "Afghanistan","al" => "Albania","dz" => "Algeria","ao" => "Angola","ar" => "Argentina","am" => "Armenia","aw" => "Aruba","au" => "Australia","at" => "Austria","az" => "Azerbaijan","bs" => "Bahamas","bh" => "Bahrain","bd" => "Bangladesh","bb" => "Barbados","by" => "Belarus","be" => "Belgium","bz" => "Belize","bj" => "Benin","bm" => "Bermuda","bt" => "Bhutan","bo" => "Bolivia","ba" => "Bosnia And Herzegovina","bw" => "Botswana","br" => "Brazil","bn" => "Brunei Darussalam","bg" => "Bulgaria","bf" => "Burkina Faso","bi" => "Burundi","kh" => "Cambodia","cm" => "Cameroon","ca" => "Canada","cv" => "Cape Verde","ky" => "Cayman Islands","cf" => "Central African Republic","cl" => "Chile","cn" => "China","co" => "Colombia","cg" => "Congo","ck" => "Cook Islands","cr" => "Costa Rica","ci" => "Cote D'Ivoire","hr" => "Croatia","cu" => "Cuba","cy" => "Cyprus","cz" => "Czech Republic","dk" => "Denmark","tp" => "East Timor","ec" => "Ecuador","eg" => "Egypt","er" => "Eritrea","ee" => "Estonia","et" => "Ethiopia","fo" => "Faroe Islands","fj" => "Fiji","fi" => "Finland","fr" => "France","pf" => "French Polynesia","ga" => "Gabon","ge" => "Georgia","de" => "Germany","gi" => "Gibraltar","gr" => "Greece","gl" => "Greenland","gp" => "Guadeloupe","gu" => "Guam","gt" => "Guatemala","gy" => "Guyana","ht" => "Haiti","va" => "Holy See (Vatican City State)","hk" => "Hong Kong","hu" => "Hungary","is" => "Iceland","in" => "India","id" => "Indonesia","ir" => "Iran","iq" => "Iraq","ie" => "Ireland","il" => "Israel","it" => "Italy","jm" => "Jamaica","jp" => "Japan","jo" => "Jordan","kz" => "Kazakstan","ke" => "Kenya","ki" => "Kiribati","kp" => "Korea, Democratic People'S Republic Of","kr" => "Korea, Republic Of","kg" => "Kyrgyzstan","lv" => "Latvia","lb" => "Lebanon","ly" => "Libyan Arab Jamahiriya","lt" => "Lithuania","lu" => "Luxembourg","mo" => "Macau","mk" => "Macedonia","mg" => "Madagascar","my" => "Malaysia","mt" => "Malta","mx" => "Mexico","md" => "Moldova, Republic Of","mc" => "Monaco","mn" => "Mongolia","ms" => "Montserrat","ma" => "Morocco","mz" => "Mozambique","na" => "Namibia","nr" => "Nauru","np" => "Nepal","nl" => "Netherlands","an" => "Netherlands Antilles","nc" => "New Caledonia","nz" => "New Zealand","nf" => "Norfolk Island","mp" => "Northern Mariana Islands","no" => "Norway","om" => "Oman","pk" => "Pakistan","ps" => "Palestinian Territory, Occupied","pa" => "Panama","py" => "Paraguay","pe" => "Peru","ph" => "Philippines","pl" => "Poland","pt" => "Portugal","pr" => "Puerto Rico","qa" => "Qatar","ro" => "Romania","ru" => "Russian Federation","lc" => "Saint Lucia","pm" => "Saint Pierre And Miquelon","ws" => "Samoa","sa" => "Saudi Arabia","sl" => "Sierra Leone","sg" => "Singapore","sk" => "Slovakia","si" => "Slovenia","sb" => "Solomon Islands","so" => "Somalia","za" => "South Africa","es" => "Spain","lk" => "Sri Lanka","sd" => "Sudan","se" => "Sweden","ch" => "Switzerland","sy" => "Syrian Arab Republic","tw" => "Taiwan, Province Of China","tz" => "Tanzania, United Republic Of","th" => "Thailand","tg" => "Togo","to" => "Tonga","tt" => "Trinidad And Tobago","tn" => "Tunisia","tr" => "Turkey","tc" => "Turks And Caicos Islands","tv" => "Tuvalu","ug" => "Uganda","ua" => "Ukraine","uk" => "United Kingdom","us" => "United States","uy" => "Uruguay","ve" => "Venezuela","vn" => "Viet Nam","vg" => "Virgin Islands, British","vi" => "Virgin Islands, U.S.","ye" => "Yemen","yu" => "Yugoslavia","zw" => "Zimbabwe"); if(!$type) { foreach ($c as $k => $v) { if($k == "$name") $selected = "selected"; else $selected = ""; if($k == "none") $v = NULL; $list .= "\n"; } } else foreach ($c as $k => $v) if($k == "$name") $list = $v; return $list; } //////////////////////////////////////////////////////// // Function: find_authorization // Description: Shows the authorization function find_authorization($authorization) { global $config; require "language/{$config['language']}"; switch($authorization) { case 1: $user_authorization = $language['Authorization 1']; break; case 2: $user_authorization = $language['Authorization 2']; break; case 3: $user_authorization = $language['Authorization 3']; break; case 4: $user_authorization = $language['Authorization 4']; break; } return $user_authorization; } //////////////////////////////////////////////////////// // Function: find_age // Description: Find age function find_age($age,$surplus=false) { if(!$age == NULL) { if(!$surplus) $diff = (date("Y") - date("Y",$age)); else $diff = ((date("Y") + $surplus) - date("Y",$age)); if (mktime(0,0,0,date("m",$age),date("j",$age),date("Y")) <= time()) $finish = $diff; else $finish = $diff - 1; } else $finish = NULL; return $finish; } //////////////////////////////////////////////////////// // Function: find_avatar // Description: Shows the avatar function find_avatar($avatar_def) { if(isset($avatar_def)) $avatar = ""; else $avatar = NULL; return $avatar; } //////////////////////////////////////////////////////// // Function: find_flag // Description: Shows the flag function find_flag($flag_def,$location_def,$name=false,$none=false) { if(!$flag_def) $flag = "$location_def"; elseif($flag_def == "none" && $none == true) $flag = NULL; else $flag = "".find_country($flag_def,1).""; if($name == true) { if(!$flag_def) $flag .= " $location_def"; elseif($flag_def == "none" && $none == true) $flag .= NULL; else $flag .= " ".find_country($flag_def,1).""; } return $flag; } //////////////////////////////////////////////////////// // Function: find_status // Description: Shows the status function find_status($status_def) { global $config; require "language/{$config['language']}"; if($status_def == "banned") $status = "{$language['Users view desc3']}"; elseif($status_def == "activate") $status = "{$language['Users view desc2']}"; else $status = "{$language['Users view desc']}"; return $status; } //////////////////////////////////////////////////////// // Function: arrow_legend // Description: Shows the arrows by date function arrow_legend($date_def) { $stat_one = time() - 86400; // a day $stat_two = time() - 259200; // 3 days $stat_three = time() - 604800; // a week if ($date_def > $stat_one) $stat = 1; elseif ($date_def > $stat_two) $stat = 2; elseif ($date_def > $stat_three) $stat = 3; else $stat = 4; return $stat; } //////////////////////////////////////////////////////// // Function: paginate // Description: Display the [ 1 2 3 ] and [1] [2] [3] function paginate($num_pages, $cur_page, $link_to, $forum_type=false) { $pages = array(); $link_to_all = false; if ($num_pages <= 1) { if($forum_type == "true") $pages = array('1'); else $pages = array('1'); } else { if ($cur_page > 3) { if($forum_type == "true") { $pages[] = '1'; if ($cur_page != 4) $pages[] = '…'; } else { $pages[] = '1'; if ($cur_page != 4) $pages[] = '…'; } } for ($current = $cur_page - 2, $stop = $cur_page + 3; $current < $stop; ++$current) { if ($current < 1 || $current > $num_pages) continue; elseif ($current != $cur_page || $link_to_all) { if($forum_type == "true") $pages[] = ''.$current.''; else $pages[] = ''.$current.''; } else { if($forum_type == "true") $pages[] = ''.$current.''; else $pages[] = ''.$current.''; } } if ($cur_page <= ($num_pages-3)) { if($cur_page != ($num_pages-3)) { if($forum_type == "true") $pages[] = '…'; else $pages[] = '…'; } if($forum_type == "true") $pages[] = ''.$num_pages.''; else $pages[] = ''.$num_pages.''; } } if($forum_type == "true") return implode(' ', $pages); else return implode(' ', $pages); } //////////////////////////////////////////////////////// // Function: form_dropdown // Description: dropdown list from directory function form_dropdown($name, $list=array(), $default_val, $slot1, $slot2, $slot3) { if(!isset($output)) $output = NULL; $output .= ""; return $output; } ?>