Code:.php" ); return new $name(); } } } else { //----------------------------------------- // We're using safe mode skins, yippee // Load the data from the DB //----------------------------------------- $skin_global = ""; $other_skin = ""; $ibforums->skin['_type'] = 'Database Skins'; if ( $ibforums->skin_global == "" and $name != 'skin_global') { //----------------------------------------- // Skin global not loaded... //----------------------------------------- $ibforums->loaded_templates[] = $name; $ibforums->loaded_templates[] = 'skin_global'; $DB->simple_construct( array( 'select' => '*', 'from' => 'skin_templates_cache', 'where' => "template_set_id=".$ibforums->skin['_skincacheid']." AND template_group_name IN ('skin_global', '$name')" ) ); $DB->simple_exec(); while ( $r = $DB->fetch_row() ) { if ( $r['template_group_name'] == 'skin_global' ) { $skin_global = $r['template_group_content']; } else { $other_skin = $r['template_group_content']; } } eval($skin_global); $ibforums->skin_global = new skin_global(); } else { //----------------------------------------- // Skin global is loaded.. //----------------------------------------- if ( $name == 'skin_global' and in_array( 'skin_global', $ibforums->loaded_templates ) ) { return; } //----------------------------------------- // Load the skin, man //----------------------------------------- $ibforums->loaded_templates[] = $name; $DB->simple_construct( array( 'select' => '*', 'from' => 'skin_templates_cache', 'where' => "template_set_id=".$ibforums->skin['_skincacheid']." AND template_group_name='$name'" ) ); $DB->simple_exec(); $r = $DB->fetch_row(); $other_skin = $r['template_group_content']; } eval($other_skin); if ( $name == 'skin_global' ) { $ibforums->skin_global = new skin_global(); } else { return new $name(); } } } /*-------------------------------------------------------------------------*/ // SKIN, sort out the skin stuff /*-------------------------------------------------------------------------*/ function load_skin() { global $ibforums, $DB; $id = -1; $skin_set = 0; $from_forum = 0; $ibforums->input['skinid'] = intval($ibforums->input['skinid']); $ibforums->member['skin'] = intval($ibforums->member['skin']); //----------------------------------------- // Do we have a cache? //----------------------------------------- if ( ! is_array( $ibforums->cache['skin_id_cache'] ) ) { define ( 'IN_ACP', 1 ); require_once( ROOT_PATH.'sources/admin/admin_cache_functions.php' ); $admin = new admin_cache_functions(); $ibforums->cache['skin_id_cache'] = $admin->_rebuild_skin_id_cache(); } //----------------------------------------- // Search bot? //----------------------------------------- if ( ( $ibforums->is_bot == 1 ) and ($ibforums->vars['spider_suit'] != "") ) { $skin_set = 1; $id = $ibforums->vars['spider_suit']; } else { //----------------------------------------- // Do we have a skin for a particular forum? //----------------------------------------- if ($ibforums->input['f'] and $ibforums->input['act'] != 'UserCP') { if ( $ibforums->cache['forum_cache'][ $ibforums->input['f'] ]['skin_id'] > 0 ) { $id = $ibforums->cache['forum_cache'][ $ibforums->input['f'] ]['skin_id']; $skin_set = 1; $from_forum = 1; } } //----------------------------------------- // Are we allowing user chooseable skins? //----------------------------------------- if ($skin_set != 1 and $ibforums->vars['allow_skins'] == 1) { if ( $ibforums->input['skinid'] ) { $id = $ibforums->input['skinid']; $skin_set = 1; } else if ( $ibforums->member['skin'] ) { $id = $ibforums->member['skin']; $skin_set = 1; } } } //----------------------------------------- // Nothing set / hidden and not admin? Choose the default //----------------------------------------- if ( $ibforums->cache['skin_id_cache'][ $id ]['set_hidden'] ) { if ( $from_forum ) { $skin_set = 1; } else if ( $ibforums->member['g_access_cp'] ) { $skin_set = 1; } else { $skin_set = 0; } } if ( ! $id OR ! $skin_set OR ! is_array($ibforums->cache['skin_id_cache'][ $id ]) ) { foreach( $ibforums->cache['skin_id_cache'] as $sid => $data ) { if ( $data['set_default'] ) { $id = $data['set_skin_set_id']; $skin_set = 1; } } } //----------------------------------------- // Get the skin //----------------------------------------- $db_skin = $DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => 'set_skin_set_id='.$id ) ); $ibforums->skin['_css'] = $db_skin['set_cache_css']; $ibforums->skin['_wrapper'] = $db_skin['set_cache_wrapper']; $ibforums->skin['_macro'] = $db_skin['set_cache_macro']; $ibforums->skin['_skincacheid'] = IN_DEV ? 1 : $db_skin['set_skin_set_id']; $ibforums->skin['_csscacheid'] = IN_DEV ? 1 : $db_skin['set_skin_set_id']; $ibforums->skin['_imagedir'] = $db_skin['set_image_dir']; $ibforums->skin['_emodir'] = $db_skin['set_emoticon_folder']; $ibforums->skin['_setid'] = $db_skin['set_skin_set_id']; $ibforums->skin['_setname'] = $db_skin['set_name']; $ibforums->skin['_usecsscache'] = $db_skin['set_css_method'] ? 1 : 0; //----------------------------------------- // Setting the skin? //----------------------------------------- if ( ($ibforums->input['setskin']) and ($ibforums->member['id']) ) { $DB->simple_construct( array( 'update' => 'members', 'set' => "skin=".intval($id), 'where' => "id=".$ibforums->member['id'] ) ); $DB->simple_exec(); $ibforums->member['skin'] = $id; } return $row; } /*-------------------------------------------------------------------------*/ // Require, parse and return an array containing the language stuff /*-------------------------------------------------------------------------*/ function load_words($current_lang_array, $area, $lang_type) { require ROOT_PATH."lang/".$lang_type."/".$area.".php"; foreach ($lang as $k => $v) { $current_lang_array[$k] = stripslashes($v); } unset($lang); return $current_lang_array; } /*-------------------------------------------------------------------------*/ // Truncate text string /*-------------------------------------------------------------------------*/ function txt_truncate($text, $limit=30) { global $ibforums; if (strlen($text) > $limit) { $text = substr($text,0, $limit - 3) . "..."; $text = preg_replace( "/&(#(\d+;?)?)?\.\.\.$/", '...', $text ); } else { $text = preg_replace( "/&(#(\d+?)?)?$/", '', $text ); } return $text; } /*-------------------------------------------------------------------------*/ // Get new PM notification window /*-------------------------------------------------------------------------*/ function get_new_pm_notification() { global $DB, $ibforums, $skin_universal; //----------------------------------------- // posty parsery //----------------------------------------- require_once( ROOT_PATH.'sources/lib/post_parser.php' ); $parser = new post_parser(); //----------------------------------------- // Get last PM details //----------------------------------------- $DB->cache_add_query( 'msg_get_new_pm_notification', array( 'mid' => $ibforums->member['id'] ) ); $DB->simple_exec(); $msg = $DB->fetch_row(); if ( ! $msg['msg_id'] and ! $msg['mt_id'] and ! $msg['id'] ) { return ''; } $msg['msg_post'] = $parser->strip_all_tags( $msg['msg_post'] ); if ( strlen( $msg['msg_post'] ) > 120 ) { $msg['msg_post'] = substr( $msg['msg_post'], 0, 117 ) . '...'; $msg['msg_post'] = preg_replace( "/&(#(\d+;?)?)?\.\.\.$/", '...', $msg['msg_post'] ); } if ( ! is_array( $ibforums->cache['badwords'] ) ) { $ibforums->cache['badwords'] = array(); $DB->simple_construct( array( 'select' => 'type,swop,m_exact', 'from' => 'badwords' ) ); $bbcode = $DB->simple_exec(); while ( $r = $DB->fetch_row($bbcode) ) { $ibforums->cache['badwords'][] = $r; } } $msg['msg_post'] = $parser->bad_words( $msg['msg_post'] ); if ( $msg['mt_hasattach'] ) { $msg['attach_img'] = '<{ATTACH_ICON}> '; } $msg['avatar'] = $this->get_avatar($msg['avatar_location'], 1, $msg['avatar_size'], $msg['avatar_type']); return $ibforums->skin_global->msg_get_new_pm_notification( $msg ); } /*-------------------------------------------------------------------------*/ // expire_subscription // ------------------ // Remove member's subscription /*-------------------------------------------------------------------------*/ function expire_subscription() { global $DB, $ibforums; $query = "sub_end=0"; // Get subscription details... $DB->simple_construct( array( 'select' => '*', 'from' => 'subscription_trans', 'where' => "subtrans_state='paid' AND subtrans_member_id={$ibforums->member['id']}" ) ); $DB->simple_exec(); if ( $row = $DB->fetch_row() ) { if ( $row['subtrans_old_group'] > 0 ) { $DB->simple_construct( array( 'select' => 'g_id', 'from' => 'groups', 'where' => "g_id={$row['subtrans_old_group']}" ) ); $DB->simple_exec(); if ( $group = $DB->fetch_row() ) { $query .= ", mgroup={$row['subtrans_old_group']}"; } else { // Group has been deleted, reset back to base member group $query .= ", mgroup={$ibforums->vars['member_group']}"; } } $DB->simple_construct( array( 'update' => 'subscription_trans', 'set' => "subtrans_state='expired'", 'where' => "subtrans_id={$row['subtrans_id']}" ) ); $DB->simple_exec(); } $DB->simple_construct( array( 'update' => 'members', 'set' => $query, 'where' => "id={$ibforums->member['id']}" ) ); $DB->simple_exec(); } /*-------------------------------------------------------------------------*/ // txt_stripslashes // ------------------ // Make Big5 safe - only strip if not already... /*-------------------------------------------------------------------------*/ function txt_stripslashes($t) { if ( $this->get_magic_quotes ) { $t = stripslashes($t); } return $t; } /*-------------------------------------------------------------------------*/ // txt_raw2form // ------------------ // makes _POST text safe for text areas /*-------------------------------------------------------------------------*/ function txt_raw2form($t="") { $t = str_replace( '$', "$", $t); if ( get_magic_quotes_gpc() ) { $t = stripslashes($t); } $t = preg_replace( "/\\\(?!&#|\?#)/", "\", $t ); return $t; } /*-------------------------------------------------------------------------*/ // Safe Slashes - ensures slashes are saved correctly /*-------------------------------------------------------------------------*/ function txt_safeslashes($t="") { return str_replace( '\\', "\\\\", $this->txt_stripslashes($t)); } /*-------------------------------------------------------------------------*/ // txt_htmlspecialchars // ------------------ // Custom version of htmlspecialchars to take into account mb chars /*-------------------------------------------------------------------------*/ function txt_htmlspecialchars($t="") { // Use forward look up to only convert & not { $t = preg_replace("/&(?!#[0-9]+;)/s", '&', $t ); $t = str_replace( "<", "<" , $t ); $t = str_replace( ">", ">" , $t ); $t = str_replace( '"', """, $t ); $t = str_replace( "'", ''', $t ); return $t; // A nice cup of? } /*-------------------------------------------------------------------------*/ // txt_UNhtmlspecialchars // ------------------ // Undoes what the above function does. Yes. /*-------------------------------------------------------------------------*/ function txt_UNhtmlspecialchars($t="") { $t = str_replace( "&" , "&", $t ); $t = str_replace( "<" , "<", $t ); $t = str_replace( ">" , ">", $t ); $t = str_replace( """, '"', $t ); $t = str_replace( "'", "'", $t ); return $t; } /*-------------------------------------------------------------------------*/ // txt_wintounix // ------------------ // Converts \r\n to \n /*-------------------------------------------------------------------------*/ function txt_windowstounix($t="") { // windows $t = str_replace( "\r\n" , "\n", $t ); // Mac OS 9 $t = str_replace( "\r" , "\n", $t ); return $t; } /*-------------------------------------------------------------------------*/ // return_md5_check // ------------------ // md5 hash for server side validation of form / link stuff /*-------------------------------------------------------------------------*/ function return_md5_check() { global $ibforums; if ( $ibforums->member['id'] ) { return md5($ibforums->member['email'].'&'.$ibforums->member['member_login_key'].'&'.$ibforums->member['joined']); } else { return md5("this is only here to prevent it breaking on guests"); } } /*-------------------------------------------------------------------------*/ // C.O.C.S (clean old comma-delimeted strings) // ------------------ // <> /*-------------------------------------------------------------------------*/ function trim_leading_comma($t) { return preg_replace( "/^,/", "", $t ); } function trim_trailing_comma($t) { return preg_replace( "/,$/", "", $t ); } function clean_comma($t) { return preg_replace( "/,{2,}/", ",", $t ); } function clean_perm_string($t) { $t = $this->clean_comma($t); $t = $this->trim_leading_comma($t); $t = $this->trim_trailing_comma($t); return $t; } /*-------------------------------------------------------------------------*/ // size_format // ------------------ // Give it a byte to eat and it'll return nice stuff! /*-------------------------------------------------------------------------*/ function size_format($bytes="") { global $ibforums; $retval = ""; if ($bytes >= 1048576) { $retval = round($bytes / 1048576 * 100 ) / 100 . $ibforums->lang['sf_mb']; } else if ($bytes >= 1024) { $retval = round($bytes / 1024 * 100 ) / 100 . $ibforums->lang['sf_k']; } else { $retval = $bytes . $ibforums->lang['sf_bytes']; } return $retval; } /*-------------------------------------------------------------------------*/ // print_forum_rules // ------------------ // Checks and prints forum rules (if required) /*-------------------------------------------------------------------------*/ function print_forum_rules($forum) { global $ibforums, $DB; $ruleshtml = ""; $rules['fid'] = $forum['id']; if ($forum['show_rules']) { if ( $forum['show_rules'] == 2 ) { if ( $ibforums->vars['forum_cache_minimum'] ) { $tmp = $DB->simple_exec_query( array( 'select' => 'rules_title, rules_text', 'from' => 'forums', 'where' => "id=".$forum['id']) ); $rules['title'] = $tmp['rules_title']; $rules['body'] = $tmp['rules_text']; } else { $tmp = $DB->simple_exec_query( array( 'select' => 'rules_text', 'from' => 'forums', 'where' => "id=".$forum['id']) ); $rules['body'] = $tmp['rules_text']; $rules['title'] = $forum['rules_title']; } $ruleshtml = $ibforums->skin_global->forum_show_rules_full($rules); } else { if ( $ibforums->vars['forum_cache_minimum'] ) { $tmp = $DB->simple_exec_query( array( 'select' => 'rules_title', 'from' => 'forums', 'where' => "id=".$forum['id']) ); $rules['title'] = $tmp['rules_title']; } else { $rules['title'] = $forum['rules_title']; } $ruleshtml = $ibforums->skin_global->forum_show_rules_link($rules); } } return $ruleshtml; } /*-------------------------------------------------------------------------*/ // // hdl_ban_line() : Get / set ban info // Returns array on get and string on "set" // /*-------------------------------------------------------------------------*/ function hdl_ban_line($bline) { global $ibforums; if ( is_array( $bline ) ) { // Set ( 'timespan' 'unit' ) $factor = $bline['unit'] == 'd' ? 86400 : 3600; $date_end = time() + ( $bline['timespan'] * $factor ); return time() . ':' . $date_end . ':' . $bline['timespan'] . ':' . $bline['unit']; } else { $arr = array(); list( $arr['date_start'], $arr['date_end'], $arr['timespan'], $arr['unit'] ) = explode( ":", $bline ); return $arr; } } /*-------------------------------------------------------------------------*/ // // check_perms() : Nice little sub to check perms // Returns TRUE if access is allowed, FALSE if not. // /*-------------------------------------------------------------------------*/ function check_perms($forum_perm="") { global $ibforums; if ( ! is_array( $ibforums->perm_id_array ) ) { return FALSE; } if ( $forum_perm == "" ) { return FALSE; } else if ( $forum_perm == '*' ) { return TRUE; } else { $forum_perm_array = explode( ",", $forum_perm ); foreach( $ibforums->perm_id_array as $u_id ) { if ( in_array( $u_id, $forum_perm_array ) ) { return TRUE; } } // Still here? Not a match then. return FALSE; } } /*-------------------------------------------------------------------------*/ // // do_number_format() : Nice little sub to handle common stuff // /*-------------------------------------------------------------------------*/ function do_number_format($number) { global $ibforums; if ($ibforums->vars['number_format'] != 'none') { return number_format($number , 0, '', $this->num_format); } else { return $number; } } /*-------------------------------------------------------------------------*/ // // hdl_forum_read_cookie() // /*-------------------------------------------------------------------------*/ function hdl_forum_read_cookie($set="") { global $ibforums; if ( $set == "" ) { // Get cookie and return array... if ( $fread = $this->my_getcookie('forum_read') ) { $farray = unserialize(stripslashes($fread)); if ( is_array($farray) and count($farray) > 0 ) { foreach( $farray as $id => $stamp ) { $ibforums->forum_read[$id] = $stamp; } } } return TRUE; } else { // Set cookie... $fread = addslashes(serialize($ibforums->forum_read)); $this->my_setcookie('forum_read', $fread); return TRUE; } } /*-------------------------------------------------------------------------*/ // // Return scaled down image // /*-------------------------------------------------------------------------*/ function scale_image($arg) { // max_width, max_height, cur_width, cur_height $ret = array( 'img_width' => $arg['cur_width'], 'img_height' => $arg['cur_height'] ); if ( $arg['cur_width'] > $arg['max_width'] ) { $ret['img_width'] = $arg['max_width']; $ret['img_height'] = ceil( ( $arg['cur_height'] * ( ( $arg['max_width'] * 100 ) / $arg['cur_width'] ) ) / 100 ); $arg['cur_height'] = $ret['img_height']; $arg['cur_width'] = $ret['img_width']; } if ( $arg['cur_height'] > $arg['max_height'] ) { $ret['img_height'] = $arg['max_height']; $ret['img_width'] = ceil( ( $arg['cur_width'] * ( ( $arg['max_height'] * 100 ) / $arg['cur_height'] ) ) / 100 ); } return $ret; } /*-------------------------------------------------------------------------*/ // // Show NORMAL created security image(s)... // /*-------------------------------------------------------------------------*/ function show_gif_img($this_number="") {
|