⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functions.php

📁 泛微协同办公系统标准版E-office V5.5的源代码内含泛微办公系统V5.5自动注册文件。
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?php

class func
{

	var $time_formats = array( );
	var $time_options = array( );
	var $offset = "";
	var $offset_set = 0;

	function func( )
	{
		global $INFO;
		$this->time_options = array(
			"JOINED" => $INFO['clock_joined'],
			"SHORT" => $INFO['clock_short'],
			"LONG" => $INFO['clock_long'],
			"LASTV" => $INFO['clock_lastvisit'],
			"ANN" => "Y-m-d"
		);
	}

	function load_template( $name, $id = "" )
	{
		global $ibforums;
		global $DB;
		global $root_path;
		$tags = 1;
		if ( $ibforums->vars['safe_mode_skins'] == 0 )
		{
			require( $root_path."Skin/".$ibforums->skin_id."/{$name}.php" );
			return new $name( );
		}
		else
		{
			$DB->query( "SELECT func_name, func_data, section_content FROM ibf_skin_templates WHERE set_id='".$ibforums->skin_rid."' AND group_name='{$name}'" );
			if ( !$DB->get_num_rows( ) )
			{
				fatal_error( "无法从数据库获取模板文件信息。模板文件 {$name}, ID {$ibforums->skin_rid}" );
			}
			else
			{
				$new_class = "class {$name} {\n";
				while ( $row = $DB->fetch_row( ) )
				{
					if ( $tags == 1 )
					{
						$comment = "<!--TEMPLATE: {$name} -- 主题部分:".$row['func_name']."-->\n";
					}
					$new_class .= "function ".$row['func_name']."(".$row['func_data'].") {\n";
					$new_class .= "global \$ibforums;\n";
					$new_class .= "return <<<EOF\n".$comment.$row['section_content']."\nEOF;\n}\n";
				}
				$new_class .= "}\n";
				eval( $new_class );
				return new $name( );
			}
		}
	}

	function make_profile_link( $name, $id = "" )
	{
		global $ibforums;
		if ( 0 < $id )
		{
			return "<a href='{$ibforums->base_url}&act=Profile&MID={$id}'>{$name}</a>";
		}
		else
		{
			return $name;
		}
	}

	function boink_it( $url )
	{
		global $ibforums;
		if ( $ibforums->vars['header_redirect'] == "refresh" )
		{
			@header( "Refresh: 0;url=".$url );
		}
		else if ( $ibforums->vars['header_redirect'] == "html" )
		{
			@flush( );
			echo "<html><head><meta http-equiv='refresh' content='0; url={$url}'></head><body></body></html>";
			exit( );
		}
		else
		{
			@header( "Location: ".$url );
		}
		exit( );
	}

	function make_password( )
	{
		$pass = "";
		$chars = array( "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "A", "b", "B", "c", "C", "d", "D", "e", "E", "f", "F", "g", "G", "h", "H", "i", "I", "j", "J", "k", "K", "l", "L", "m", "M", "n", "N", "o", "O", "p", "P", "q", "Q", "r", "R", "s", "S", "t", "T", "u", "U", "v", "V", "w", "W", "x", "X", "y", "Y", "z", "Z" );
		$count = count( $chars ) - 1;
		srand( ( double )microtime( ) * 1000000 );
		$i = 0;
		for ( ;	$i < 8;	++$i	)
		{
			$pass .= $chars[rand( 0, $count )];
		}
		return $pass;
	}

	function forum_new_posts( $forum_data, $sub = 0 )
	{
		global $ibforums;
		global $std;
		$rtime = $ibforums->input['last_visit'];
		$fid = $forum_data['fid'] == "" ? $forum_data['id'] : $forum_data['fid'];
		if ( $ftime = $std->my_getcookie( "fread_".$fid ) )
		{
			$rtime = $rtime < $ftime ? $ftime : $rtime;
		}
		if ( $sub == 0 )
		{
			if ( !$forum_data['status'] )
			{
				return "<{C_LOCKED}>";
			}
			$sub_cat_img = "";
		}
		else
		{
			$sub_cat_img = "_CAT";
		}
		if ( $forum_data['password'] && $sub == 0 )
		{
			return $rtime < $forum_data['last_post'] ? "<{C_ON_RES}>" : "<{C_OFF_RES}>";
		}
		return $rtime < $forum_data['last_post'] ? "<{C_ON".$sub_cat_img."}>" : "<{C_OFF".$sub_cat_img."}>";
	}

	function folder_icon( $topic, $dot = "", $last_time = -1 )
	{
		global $ibforums;
		$last_time = $ibforums->input['last_visit'] < $last_time ? $last_time : $ibforums->input['last_visit'];
		if ( $dot != "" )
		{
			$dot = "_DOT";
		}
		if ( $topic['state'] == "closed" )
		{
			return "<{B_LOCKED}>";
		}
		if ( $topic['poll_state'] )
		{
			if ( !$ibforums->member['id'] )
			{
				return "<{B_POLL".$dot."}>";
			}
			if ( $topic['last_vote'] < $topic['last_post'] )
			{
				$topic['last_vote'] = $topic['last_post'];
			}
			if ( $last_time && $last_time < $topic['last_vote'] )
			{
				return "<{B_POLL".$dot."}>";
			}
			if ( $last_time && $topic['last_vote'] < $last_time )
			{
				return "<{B_POLL_NN".$dot."}>";
			}
			return "<{B_POLL}>";
		}
		if ( $topic['state'] == "moved" || $topic['state'] == "link" )
		{
			return "<{B_MOVED}>";
		}
		if ( !$ibforums->member['id'] )
		{
			return "<{B_NORM".$dot."}>";
		}
		if ( $ibforums->vars['hot_topic'] <= $topic['posts'] + 1 && ( isset( $last_time ) && $topic['last_post'] <= $last_time ) )
		{
			return "<{B_HOT_NN".$dot."}>";
		}
		if ( $ibforums->vars['hot_topic'] <= $topic['posts'] + 1 )
		{
			return "<{B_HOT".$dot."}>";
		}
		if ( $last_time && $last_time < $topic['last_post'] )
		{
			return "<{B_NEW".$dot."}>";
		}
		return "<{B_NORM".$dot."}>";
	}

	function text_tidy( $txt = "" )
	{
		$trans = get_html_translation_table( HTML_ENTITIES );
		$trans = array_flip( $trans );
		$txt = strtr( $txt, $trans );
		$txt = preg_replace( "/\\s{2}/", "&nbsp; ", $txt );
		$txt = preg_replace( "/\r/", "\n", $txt );
		$txt = preg_replace( "/\t/", "&nbsp;&nbsp;", $txt );
		return $txt;
	}

	function compile_db_string( $data )
	{
		$field_names = "";
		$field_values = "";
		foreach ( $data as $k => $v )
		{
			$v = preg_replace( "/'/", "\\'", $v );
			$field_names .= "{$k},";
			$field_values .= "'{$v}',";
		}
		$field_names = preg_replace( "/,\$/", "", $field_names );
		$field_values = preg_replace( "/,\$/", "", $field_values );
		return array(
			"FIELD_NAMES" => $field_names,
			"FIELD_VALUES" => $field_values
		);
	}

	function build_pagelinks( $data )
	{
		global $ibforums;
		$work = array( );
		$section = 2;
		$work['pages'] = 1;
		if ( $data['TOTAL_POSS'] % $data['PER_PAGE'] == 0 )
		{
			$work['pages'] = $data['TOTAL_POSS'] / $data['PER_PAGE'];
		}
		else
		{
			$number = $data['TOTAL_POSS'] / $data['PER_PAGE'];
			$work['pages'] = ceil( $number );
		}
		$work['total_page'] = $work['pages'];
		$work['current_page'] = 0 < $data['CUR_ST_VAL'] ? $data['CUR_ST_VAL'] / $data['PER_PAGE'] + 1 : 1;
		if ( 1 < $work['pages'] )
		{
			$work['first_page'] = "{$data['L_MULTI']} ({$work['pages']})";
			$i = 0;
			for ( ;	$i <= $work['pages'] - 1;	++$i	)
			{
				$RealNo = $i * $data['PER_PAGE'];
				$PageNo = $i + 1;
				if ( $RealNo == $data['CUR_ST_VAL'] )
				{
					$work['page_span'] .= "&nbsp;<b>[{$PageNo}]</b>";
				}
				else if ( $PageNo < $work['current_page'] - $section )
				{
					$work['st_dots'] = "&nbsp;<a href='{$data['BASE_URL']}&st=0' title='{$ibforums->lang['ps_page']} 1'>&laquo; {$ibforums->lang['ps_first']}</a>&nbsp;...";
				}
				else if ( $work['current_page'] + $section < $PageNo )
				{
					$work['end_dots'] = "...&nbsp;<a href='{$data['BASE_URL']}&st=".( $work['pages'] - 1 ) * $data['PER_PAGE']."' title='{$ibforums->lang['ps_page']} {$work['pages']}'>{$ibforums->lang['ps_last']} &raquo;</a>";
				}
				else
				{
					$work['page_span'] .= "&nbsp;<a href='{$data['BASE_URL']}&st={$RealNo}'>{$PageNo}</a>";
				}
			}
			$work['return'] = $work['first_page'].$work['st_dots'].$work['page_span']."&nbsp;".$work['end_dots'];
		}
		else
		{
			$work['return'] = $data['L_SINGLE'];
		}
		return $work['return'];
	}

	function build_forum_jump( $html = 1, $override = 0 )
	{
		global $INFO;
		global $DB;
		global $ibforums;
		$last_cat_id = -1;
		$DB->query( "SELECT f.id as forum_id, f.parent_id, f.subwrap, f.sub_can_post, f.name as forum_name, f.position, f.read_perms, c.id as cat_id, c.name\n\t\t\t\t    FROM ibf_forums f\n\t\t\t\t     LEFT JOIN ibf_categories c ON (c.id=f.category)\n\t\t\t\t    ORDER BY c.position, f.position" );
		if ( $html == 1 )
		{
			$the_html = "<form onSubmit=\"if(document.jumpmenu.f.value == -1){return false;}\" action='{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}&act=SF' method='GET' name='jumpmenu'>"."<input type='hidden' name='act' value='SF'>\n<input type='hidden' name='s' value='{$ibforums->session_id}'>"."<select name='f' onChange=\"if(this.options[this.selectedIndex].value != -1){ document.jumpmenu.submit() }\" class='forminput'>"."<option value='-1'>#Forum Jump#"."<option value='-1'>------------";
		}
		$forum_keys = array( );
		$cat_keys = array( );
		$children = array( );
		$subs = array( );
		if ( $html == 0 || $override == 1 )
		{
			$ibforums->vars['short_forum_jump'] = 0;
		}
		while ( $i = $DB->fetch_row( ) )
		{
			$selected = "";
			if ( ( $html == 1 || $override == 1 ) && $ibforums->input['f'] && $ibforums->input['f'] == $i['forum_id'] )
			{
				$selected = " selected";
			}
			if ( $i['subwrap'] == 1 && $i['sub_can_post'] != 1 )
			{
				$forum_keys[$i['cat_id']][$i['forum_id']] = "<option value=\"{$i['forum_id']}\"".$selected.">&nbsp;&nbsp;- {$i['forum_name']}</option>\n";
			}
			else
			{
				if ( $i['read_perms'] == "*" )
				{
					if ( 0 < $i['parent_id'] )
					{
						$children[$i['parent_id']][] = "<option value=\"{$i['forum_id']}\"".$selected.">&nbsp;&nbsp;---- {$i['forum_name']}</option>\n";
					}
					else
					{
						$forum_keys[$i['cat_id']][$i['forum_id']] = "<option value=\"{$i['forum_id']}\"".$selected.">&nbsp;&nbsp;- {$i['forum_name']}</option><!--fx:{$i['forum_id']}-->\n";
					}
				}
				else if ( preg_match( "/(^|,)".$ibforums->member[mgroup]."(,|\$)/", $i['read_perms'] ) )
				{
					if ( 0 < $i['parent_id'] )
					{
						$children[$i['parent_id']][] = "<option value=\"{$i['forum_id']}\"".$selected.">&nbsp;&nbsp;---- {$i['forum_name']}</option>\n";
					}
					else
					{
						$forum_keys[$i['cat_id']][$i['forum_id']] = "<option value=\"{$i['forum_id']}\"".$selected.">&nbsp;&nbsp;- {$i['forum_name']}</option><!--fx:{$i['forum_id']}-->\n";
					}
				}
			}
			if ( $last_cat_id != $i['cat_id'] )
			{
				$cat_keys[$i['cat_id']] = "<option value='-1'>{$i['name']}</option>\n";
				$last_cat_id = $i['cat_id'];
			}
		}
		foreach ( $cat_keys as $cat_id => $cat_text )
		{
			if ( is_array( $forum_keys[$cat_id] ) && 0 < count( $forum_keys[$cat_id] ) )
			{
				$the_html .= $cat_text;
				foreach ( $forum_keys[$cat_id] as $idx => $forum_text )
				{
					$the_html .= $forum_text;
					if ( 0 < count( $children[$idx] ) )
					{
						if ( $ibforums->vars['short_forum_jump'] != 1 )
						{
							foreach ( $children[$idx] as $ii => $tt )
							{
								$the_html .= $tt;
							}
						}
						else
						{
							$the_html = str_replace( "</option><!--fx:{$idx}-->", " (+".count( $children[$idx] )." {$ibforums->lang['fj_subforums']})</option>", $the_html );
						}
					}
				}
			}
		}
		if ( $html == 1 )
		{
			$the_html .= "</select>&nbsp;<input type='submit' value='{$ibforums->lang['jmp_go']}' class='forminput'></form>";
		}
		return $the_html;
	}

	function clean_email( $email = "" )
	{
		$email = preg_replace( "#[\n\r\\*\\'\"<>&\\%\\!\\(\\)\\{\\}\\[\\]\\?\\/]#", "", $email );
		if ( preg_match( "/^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,4})(\\]?)\$/", $email ) )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -