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

📄 functions.php

📁 国外非常不错的论坛
💻 PHP
📖 第 1 页 / 共 4 页
字号:
			'+5.5' => '+5:30',			'+6' => '+6:00',			'+7' => '+7:00',			'+8' => '+8:00',			'+9' => '+9:00',			'+9.5' => '+9:30',			'+10' => '+10:00',			'+11' => '+11:00',			'+12' => '+12:00',		);				if ( $action == 'get_zones' ) {						return $timezones;					} elseif ( $action == 'check_existance' ) {						if ( !empty($timezones[$param]) )				return true;			else				return false;					}			}	//	// Make a user's profile link	//	function make_profile_link($user_id, $username, $level) {				switch ( $level ) {						case 3:				$levelclass = ' class="administrator"';				break;			case 2:				$levelclass = ' class="moderator"';				break;			case 1:				$levelclass = '';				break;					}				return '<a href="'.$this->make_url('profile.php', array('id' => $user_id)).'"'.$levelclass.'>'.unhtml(stripslashes($username)).'</a>';			}		//	// Create a forum statistics box like on the forum index	//	function forum_stats_box() {				global $db, $template, $lang, $session;				if ( $this->get_config('enable_forum_stats_box') && $this->get_user_level() >= $this->get_config('view_forum_stats_box_min_level') ) {						//			// Timestamp for defining last updated sessions			//			$min_updated = time() - ( $this->get_config('online_min_updated') * 60 );						//			// Get the session and user information			//			$result = $db->query("SELECT u.displayed_name, u.level, u.hide_from_online_list, s.user_id AS id, s.ip_addr FROM ( ".TABLE_PREFIX."sessions s LEFT JOIN ".TABLE_PREFIX."members u ON s.user_id = u.id ) WHERE s.updated > ".$min_updated." ORDER BY s.updated DESC");						//			// Arrays for holding a list of online guests and members.			//			$count = array(				'total_members' => 0,				'hidden_members' => 0,				'guests' => 0			);			$list = array(				'members' => array(),				'guests' => array()			);			$memberlist = array();						while ( $onlinedata = $db->fetch_result($result) ) {								if ( !$onlinedata['id'] ) {										//					// This is a guest					// Guests will only be counted per IP address					//					if ( !in_array($onlinedata['ip_addr'], $list['guests']) ) {												$count['guests']++;						$list['guests'][] = $onlinedata['ip_addr'];											}									} else {										//					// This is a member					//					if ( !in_array($onlinedata['id'], $list['members']) ) {												if ( !$onlinedata['hide_from_online_list'] ) {														$memberlist[] = $this->make_profile_link($onlinedata['id'], $onlinedata['displayed_name'], $onlinedata['level']);													} else {														if ( $this->get_user_level() == LEVEL_ADMIN )								$memberlist[] = '<em>'.$this->make_profile_link($onlinedata['id'], $onlinedata['displayed_name'], $onlinedata['level']).'</em>';														$count['hidden_members']++;													}												$count['total_members']++;						$list['members'][] = $onlinedata['id'];											}									}							}						$latest_member = $this->get_stats('latest_member');						if ( $count['total_members'] === 1 && $count['guests'] === 1 )				$users_online = $lang['MemberGuestOnline'];			elseif ( $count['total_members'] !== 1 && $count['guests'] === 1 )				$users_online = $lang['MembersGuestOnline'];			elseif ( $count['total_members'] === 1 && $count['guests'] !== 1 )				$users_online = $lang['MemberGuestsOnline'];			else				$users_online = $lang['MembersGuestsOnline'];						//			// Parse the online box			//			$template->parse('forum_stats_box', 'various', array(				'small_stats' => sprintf($lang['IndexStats'], $this->get_stats('posts'), $this->get_stats('topics'), $this->get_stats('members')),				'newest_member' => ( !$this->get_stats('members') ) ? '' : ' '.sprintf($lang['NewestMemberExtended'], '<a href="'.$this->make_url('profile.php', array('id' => $latest_member['id'])).'">'.unhtml(stripslashes($latest_member['displayed_name'])).'</a>'),				'users_online' => sprintf($users_online, $this->get_config('online_min_updated'), $count['total_members'], $count['hidden_members'], $count['guests']),				'members_online' => ( count($memberlist) ) ? join(', ', $memberlist) : '',				'detailed_list_link' => ( $this->get_config('enable_detailed_online_list') && $this->get_user_level() >= $this->get_config('view_detailed_online_list_min_level') ) ? '<a href="'.$this->make_url('online.php').'">'.$lang['Detailed'].'</a>' : ''			));					}			}		//	// Get the server's load avarage value	//	function get_server_load() {				$found_load = false;				if ( strstr(PHP_OS, 'WIN') !== false ) {						//			// Afaik we can't get this on Windows			//			return false;					} else {						if ( file_exists('/proc/loadavg') && is_readable('/proc/loadavg') ) {								//				// We use the Linux method of getting the 3 average load				// values of the server. This only works on Linux afaik...				//				$fh = fopen('/proc/loadavg', 'r');				$out = fread($fh, 14);				fclose($fh);				if ( preg_match('#([0-9]+\.[0-9]{2}) ([0-9]+\.[0-9]{2}) ([0-9]+\.[0-9]{2})#', $out, $match) )					return $match[1]; // we use the load average value of the past 1 minute				else					$found_load = false;							}						if ( !$found_load ) {								//				// Another way is running the uptime command and using its				// output. This should also work on FreeBSD. The var $tmp				// is unnecessary at this moment.				//				$out = @exec('uptime', $tmp, $retval);								if ( !$retval ) {										//					// $retval contains the exit code 0 when ran successfully...					//					if ( preg_match('#([0-9]+\.[0-9]{2}), ([0-9]+\.[0-9]{2}), ([0-9]+\.[0-9]{2})#', $out, $match) )						return $match[1]; // we use the load average value of the past 1 minute					else						return false;									} else {										//					// We can't determine the server load... The server can't access					// /proc/loadavg, can't run uptime or is running an unsupported OS					//					return false;									}							}					}			}		//	// Define the icon for forums	//	function forum_icon($id, $open, $post_time) {				global $db, $session, $template, $lang;				if ( $session->sess_info['user_id'] && !is_array($this->updated_forums) ) {						$result = $db->query("SELECT t.id, t.forum_id, p.post_time FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."posts p WHERE p.id = t.last_post_id AND p.post_time > ".$_SESSION['previous_visit']);			$this->updated_forums = array();			while ( $topicsdata = $db->fetch_result($result) ) {								if ( !in_array($topicsdata['forum_id'], $this->updated_forums) && ( !array_key_exists($topicsdata['id'], $_SESSION['viewed_topics']) || $_SESSION['viewed_topics'][$topicsdata['id']] < $topicsdata['post_time'] ) )					$this->updated_forums[] = $topicsdata['forum_id'];							}					}				if ( $session->sess_info['user_id'] && in_array($id, $this->updated_forums) ) {						if ( $open ) {								$forum_icon = $template->get_config('open_newposts_icon');				$forum_status = $lang['NewPosts'];							} else {								$forum_icon = $template->get_config('closed_newposts_icon');				$forum_status = $lang['LockedNewPosts'];							}					} else {						if ( $open ) {								$forum_icon = $template->get_config('open_nonewposts_icon');				$forum_status = $lang['NoNewPosts'];							} else {								$forum_icon = $template->get_config('closed_nonewposts_icon');				$forum_status = $lang['LockedNoNewPosts'];							}					}				return array($forum_icon, $forum_status);			}		//	// Define the icon for topics	//	function topic_icon($id, $locked, $post_time) {				global $session, $template, $lang;				if ( $session->sess_info['user_id'] && $_SESSION['previous_visit'] < $post_time && ( !array_key_exists($id, $_SESSION['viewed_topics']) || $_SESSION['viewed_topics'][$id] < $post_time ) ) {						if ( !$locked ) {								$topic_icon = $template->get_config('open_newposts_icon');				$topic_status = $lang['NewPosts'];							} else {								$topic_icon = $template->get_config('closed_newposts_icon');				$topic_status = $lang['LockedNewPosts'];							}					} else {						if ( !$locked ) {								$topic_icon = $template->get_config('open_nonewposts_icon');				$topic_status = $lang['NoNewPosts'];							} else {								$topic_icon = $template->get_config('closed_nonewposts_icon');				$topic_status = $lang['LockedNoNewPosts'];							}					}				return array($topic_icon, $topic_status);			}		//	// Calculate the age of a person based on a birthday date	//	function calculate_age($birthday) {				$month = intval(substr($birthday, 4, 2));		$day = intval(substr($birthday, 6, 2));		$year = intval(substr($birthday, 0, 4));				//		// Because Windows doesn't allow dates before 1970 with mktime(),		// we perform a trick to calculate dates before 1970.		//		if ( $year < 1970 ) {						$years_before_unix_epoch = 1970 - $year;			$false_year = $year + ( $years_before_unix_epoch * 2 );			$timestamp = mktime(0, 0, 0, $month, $day, $false_year);			$timestamp -= ( $years_before_unix_epoch * 31556926 * 2 );					} else {						$timestamp = mktime(0, 0, 0, $month, $day, $year);					}				return floor((time()-$timestamp)/31556926);			}		//	// Get a list of template sets	//	function get_template_sets() {				if ( !count($this->available['templates']) ) {						$handle = opendir(ROOT_PATH.'templates');			while ( false !== ( $template_name = readdir($handle) ) ) {								if ( preg_match('#^[^\.]#', $template_name) && file_exists('./templates/'.$template_name.'/global.tpl.php') )					$this->available['templates'][] = $template_name;							}			closedir($handle);			sort($this->available['templates']);			reset($this->available['templates']);					}				return $this->available['templates'];			}		//	// Get a list of language packs	//	function get_language_packs() {				if ( !count($this->available['languages']) ) {						$handle = opendir(ROOT_PATH.'languages');			while ( false !== ( $language_name = readdir($handle) ) ) {								if ( preg_match('#^lang_(.+)\.php$#', $language_name, $language_name) )					$this->available['languages'][] = $language_name[1];							}			closedir($handle);			sort($this->available['languages']);			reset($this->available['languages']);					}				return $this->available['languages'];			}		//	// Return the sql tables with the table prefix	//	function get_usebb_tables() {				global $db;				$tables = array();		$result = $db->query("SHOW TABLES LIKE '".TABLE_PREFIX."%'");		while ( $out = $db->fetch_result($result) )			$tables[] = current($out);		return $tables;			}		//	// Redirect the user to a certain location within UseBB	//	function redirect($page, $vars=array(), $anchor='') {				$goto = $this->get_config('board_url').$this->make_url($page, $vars, false);		if ( !empty($anchor) )			$goto .= '#'.$anchor;		$this->raw_redirect($goto);			}		//	// Redirect with a predefined URL	//	function raw_redirect($url) {				@header('Location: '.$url);		die('<meta http-equiv="refresh" content="0;URL='.$url.'" />');			}	}?>

⌨️ 快捷键说明

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