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

📄 functions.php

📁 国外非常不错的论坛
💻 PHP
📖 第 1 页 / 共 4 页
字号:
		);		$min_level = intval($auth_int[$actions[$action]]);				//		// If the user level is equal or greater than the		// auth integer, return a true, otherwise return a false.		//		if ( $userlevel >= $min_level )			return true;		else			return false;			}		//	// Return a list of moderators, clickable and seperated with commas	//	function get_mods_list($forum, $listarray=false) {				global $db, $lang;				$forum_moderators = array();				if ( is_array($listarray) && count($listarray) ) {						foreach ( $listarray as $modsdata ) {								if ( $modsdata['forum_id'] == $forum )					$forum_moderators[] = $this->make_profile_link($modsdata['id'], $modsdata['displayed_name'], $modsdata['level']);							}						if ( !count($forum_moderators) ) {								return $lang['Nobody'];							}					} else {						$result = $db->query("SELECT u.id, u.displayed_name, u.level FROM ".TABLE_PREFIX."members u, ".TABLE_PREFIX."moderators m WHERE m.forum_id = ".$forum." AND m.user_id = u.id ORDER BY u.displayed_name");			while ( $modsdata = $db->fetch_result($result) )				$forum_moderators[] = $this->make_profile_link($modsdata['id'], $modsdata['displayed_name'], $modsdata['level']);							if ( !count($forum_moderators) ) {								return $lang['Nobody'];							}					}				//		// Join all values in the array		//		return join(', ', $forum_moderators);			}		//	// Return a clickable list of pages	//	function make_page_links($pages_number, $current_page, $items_number, $items_per_page, $page_name, $page_id_val=NULL, $back_forward_links=true, $url_vars=array()) {				global $lang;				if ( intval($items_number) > intval($items_per_page) ) {						$page_links = array();			$page_links_groups_length = 4;						if ( !$current_page ) {								$current_page = $pages_number+1;				$page_links_groups_length++;							}						for ( $i = 1; $i <= $pages_number; $i++ ) {								if ( $current_page != $i ) {										if ( $i+$page_links_groups_length >= $current_page && $i-$page_links_groups_length <= $current_page ) {												if ( valid_int($page_id_val) )							$url_vars['id'] = $page_id_val;						$url_vars['page'] = $i;						$page_links[] = '<a href="'.$this->make_url($page_name, $url_vars).'">'.$i.'</a>';											} else {												if ( end($page_links) != '...' )							$page_links[] = '...';											}									} else {										$page_links[] = '<strong>'.$i.'</strong>';									}							}						$page_links = join(' ',$page_links);						if ( $back_forward_links ) {								if ( valid_int($page_id_val) )					$url_vars['id'] = $page_id_val;								if ( $current_page > 1 ) {										$url_vars['page'] = $current_page-1;					$page_links = '<a href="'.$this->make_url($page_name, $url_vars).'">&lt;</a> '.$page_links;									}				if ( $current_page < $pages_number ) {										$url_vars['page'] = $current_page+1;					$page_links .= ' <a href="'.$this->make_url($page_name, $url_vars).'">&gt;</a>';									}				if ( $current_page > 2 ) {										$url_vars['page'] = 1;					$page_links = '<a href="'.$this->make_url($page_name, $url_vars).'">&laquo;</a> '.$page_links;									}				if ( $current_page+1 < $pages_number ) {										$url_vars['page'] = $pages_number;					$page_links .= ' <a href="'.$this->make_url($page_name, $url_vars).'">&raquo;</a>';									}							}						$page_links = sprintf($lang['PageLinks'], $page_links);					} else {						$page_links = sprintf($lang['PageLinks'], '1');					}				return $page_links;			}		//	// Apply BBCode and smilies to a string	//	function markup($string, $bbcode=true, $smilies=true, $html=false) {				global $db, $template, $lang;				$string = preg_replace('#(script|about|applet|activex|chrome):#is', '\\1&#058;', $string);				//		// Needed by some BBCode regexps and smilies		//		$string = ' '.$string.' ';				if ( !$html )			$string = unhtml($string);				if ( $smilies ) {						foreach ( $template->get_config('smilies') as $pattern => $img )				$string = preg_replace('#([\s\]\[])'.preg_quote(unhtml($pattern), '#').'([\s\]\[])#', '\\1<img src="templates/'.$this->get_config('template').'/smilies/'.$img.'" alt="'.unhtml($pattern).'" />\\2', $string);					}				if ( $bbcode ) {						$target_blank = ( $this->get_config('target_blank') ) ? ' target="_blank"' : '';			$rel_nofollow = ( $this->get_config('rel_nofollow') ) ? ' rel="nofollow"' : '';						//			// Difficult parsing of code tags			//			if ( preg_match('#\[code\](.*?)\[/code\]#is', $string) ) {								$string_parts = preg_split('#(\[code\])#is', $string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);				$new_string_parts = array();				foreach ( $string_parts as $string_part ) {										if ( preg_match_all('#(\[/code\])#is', $string_part, $matches) ) {												$end_tags_count = count($matches[0]);						$string_parts2 = preg_split('#(\[/code\])#is', $string_part, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);						$i = 1;						$string_part = '';						foreach ( $string_parts2 as $string_part2 ) {														if ( preg_match('#\[/code\]#is', $string_part2) ) {																if ( $i < $end_tags_count ) {																		$string_part .= preg_replace('#<img src="(.*?)" alt="(.*?)" />#', '\\2', preg_replace(array('#\[#', '#\]#'), array('&#91;', '&#93;'), $string_part2));																	} else {																		$string_part .= $string_part2;																	}								$i++;															} else {																if ( $i === $end_tags_count ) {																		$string_part .= preg_replace('#<img src="(.*?)" alt="(.*?)" />#', '\\2', preg_replace(array('#\[#', '#\]#'), array('&#91;', '&#93;'), $string_part2));																	} else {																		$string_part .= $string_part2;																	}															}													}											}					$new_string_parts[] = $string_part;									}				$string = join('', $new_string_parts);				preg_match_all("#\[code\](.*?)\[/code\]#is", $string, $matches);								foreach ( $matches[1] as $oldpart ) {										$newpart = preg_replace(array('#\[#', '#\]#', "#\n#", "#\r#"), array('&#91;', '&#93;', '<br />', ''), $oldpart);					$string = str_replace($oldpart, $newpart, $string);									}				$string = preg_replace("#\[code\](.*?)\[/code\]#is", sprintf($template->get_config('code_format'), '\\1'), $string);							}						//			// Parse URL's and e-mail addresses			//			$ignore_chars = "^a-z0-9"; # warning, rawly included in regex!			$string = preg_replace(array(				"#([\s][".$ignore_chars."]*?)([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*?)([".$ignore_chars."]*?[\s])#is",				"#([\s][".$ignore_chars."]*?)([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)([".$ignore_chars."]*?[\s])#is"			), array(				'\\1<a href="\\2"'.$target_blank.$rel_nofollow.'>\\2</a>\\3',				'\\1<a href="mailto:\\2">\\2</a>\\4'			), $string);						//			// All kinds of BBCode regexps			//			$regexps = array(				// [b]text[/b]					"#\[b\](.*?)\[/b\]#is" => '<strong>\\1</strong>',				// [i]text[/i]					"#\[i\](.*?)\[/i\]#is" => '<em>\\1</em>',				// [u]text[/u]					"#\[u\](.*?)\[/u\]#is" => '<u>\\1</u>',				// [s]text[/s]					"#\[s\](.*?)\[/s\]#is" => '<del>\\1</del>',				// [img]image[/img]					"#\[img\]([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*?)\.(gif|png|jpe?g)\[/img\]#is" => '<img src="\\1.\\2" alt="'.$lang['UserPostedImage'].'" />',				// [url]http://www.usebb.net[/url]					"#\[url\]([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*?)\[/url\]#is" => '<a href="\\1"'.$target_blank.$rel_nofollow.'>\\1</a>',				// [url=http://www.usebb.net]UseBB[/url]					"#\[url=([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*?)\](.*?)\[/url\]#is" => '<a href="\\1"'.$target_blank.$rel_nofollow.'>\\2</a>',				// [mailto]somebody@nonexistent.com[/mailto]					"#\[mailto\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/mailto\]#is" => '<a href="mailto:\\1">\\1</a>',				// [mailto=somebody@nonexistent.com]mail me[/mailto]					"#\[mailto=([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\](.*?)\[/mailto\]#is" => '<a href="mailto:\\1">\\3</a>',				// [color=red]text[/color]					"#\[color=([\#a-z0-9]+)\](.*?)\[/color\]#is" => '<span style="color:\\1">\\2</span>',				// [size=999]too big text[/size]					"#\[size=([0-9]{3,})\](.*?)\[/size\]#is" => '\\2',				// [size=14]text[/size]					"#\[size=([0-9]*?)\](.*?)\[/size\]#is" => '<span style="font-size:\\1pt">\\2</span>',				// [google=keyword]text[/google]					"#\[google=(.*?)\](.*?)\[/google\]#is" => '<a href="http://www.google.com/search?q=\\1"'.$target_blank.$rel_nofollow.'>\\2</a>',			);						//			// Now parse those regexps			//			foreach ( $regexps as $find => $replace )				$string = preg_replace($find, $replace, $string);						//			// Now parse quote tags			//			while ( preg_match("#\[quote\](.*?)\[/quote\]#is", $string) )				$string = preg_replace("#\[quote\](.*?)\[/quote\]#is", sprintf($template->get_config('quote_format'), $lang['Quote'], '\\1'), $string);			while ( preg_match("#\[quote=(.*?)\](.*?)\[/quote\]#is", $string) )				$string = preg_replace("#\[quote=(.*?)\](.*?)\[/quote\]#is", sprintf($template->get_config('quote_format'), sprintf($lang['Wrote'], '\\1'), '\\2'), $string);					}				if ( !$html ) {						$string = str_replace("\n", "<br />\n", $string);			$string = str_replace("\r", "", $string);					}				return trim($string);			}		//	// Return the BBCode control buttons	//	function get_bbcode_controls() {				global $lang, $template;				$controls = array(			array('[b]', '[/b]', 'B', 'font-weight: bold'),			array('[i]', '[/i]', 'I', 'font-style: italic'),			array('[u]', '[/u]', 'U', 'text-decoration: underline'),			array('[s]', '[/s]', 'S', 'text-decoration: line-through'),			array('[quote]', '[/quote]', $lang['Quote'], ''),			array('[code]', '[/code]', $lang['Code'], ''),			array('[img]', '[/img]', $lang['Img'], ''),			array('[url=http://www.example.com]', '[/url]', $lang['URL'], ''),			array('[color=red]', '[/color]', $lang['Color'], ''),			array('[size=14]', '[/size]', $lang['Size'], '')		);				$out = array();		foreach ( $controls as $data ) {						$out[] = '<a href="javascript:insert_tags(\''.$data[0].'\', \''.$data[1].'\')" style="'.$data[3].'">'.$data[2].'</a>';					}				return join($template->get_config('post_form_bbcode_seperator'), $out);			}		//	// Return the smiley control graphics	//	function get_smiley_controls() {				global $template;				$smilies = $template->get_config('smilies');		$smilies = array_unique($smilies);		$out = array();		foreach ( $smilies as $pattern => $img ) {						$out[] = '<a href="javascript:insert_smiley(\''.addslashes(unhtml($pattern)).'\')"><img src="templates/'.$this->get_config('template').'/smilies/'.$img.'" alt="'.unhtml($pattern).'" /></a>';					}				return join($template->get_config('post_form_smiley_seperator'), $out);			}		function replace_badwords($string) {				global $db;				if ( !isset($this->badwords) ) {						$result = $db->query("SELECT word, replacement FROM ".TABLE_PREFIX."badwords ORDER BY word ASC");			$this->badwords = array();			while ( $data = $db->fetch_result($result) )				$this->badwords['#\b(' . str_replace('\*', '\w*?', preg_quote(stripslashes($data['word']), '#')) . ')\b#i'] = stripslashes($data['replacement']);					}				foreach ( $this->badwords as $badword => $replacement )			$string = preg_replace($badword, $replacement, $string);				return $string;			}		//	// Replace all whitespace by a space except in <textarea /> and <pre />	//	function compress_sourcecode($string) {				$matches = array();		preg_match_all("#<textarea.*?>(.*?)</textarea>#is", $string, $matches[0]);		preg_match_all("#<pre.*?>(.*?)</pre>#is", $string, $matches[1]);		preg_match_all("#<script.*?>(.*?)</script>#is", $string, $matches[2]);		$matches = array_merge($matches[0][0], $matches[1][0], $matches[2][0]);		foreach ( $matches as $oldpart ) {						$newpart = str_replace("\n", "\0", $oldpart);			$string = str_replace($oldpart, $newpart, $string);					}		$string = str_replace("\r", "", $string);		$string = preg_replace("#\s+#", ' ', $string);		$string = str_replace("\0", "\n", $string);		return $string;			}		//	// Timezone handling	//	function timezone_handler($action, $param=NULL) {				$timezones = array(			'-12' => '-12:00',			'-11' => '-11:00',			'-10' => '-10:00',			'-9' => '-9:00',			'-8' => '-8:00',			'-7' => '-7:00',			'-6' => '-6:00',			'-5' => '-5:00',			'-4' => '-4:00',			'-3.5' => '-3:30',			'-3' => '-3:00',			'-2' => '-2:00',			'-1' => '-1:00',			'0' => '+0:00',			'+1' => '+1:00',			'+2' => '+2:00',			'+3' => '+3:00',			'+3.5' => '+3:30',			'+4' => '+4:00',			'+4.5' => '+4:30',			'+5' => '+5:00',

⌨️ 快捷键说明

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