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

📄 functions_phpbb20.php

📁 通过基于Windows的图形化界面
💻 PHP
📖 第 1 页 / 共 3 页
字号:
*/function phpbb_convert_group_name($group_name){	$default_groups = array(		'GUESTS',		'REGISTERED',		'REGISTERED_COPPA',		'GLOBAL_MODERATORS',		'ADMINISTRATORS',		'BOTS',	);	if (in_array(strtoupper($group_name), $default_groups))	{		return 'phpBB2 - ' . $group_name;	}	return phpbb_set_encoding($group_name, false);}/*** Convert the group type constants*/function phpbb_convert_group_type($group_type){	switch ($group_type)	{		case 0:			return GROUP_OPEN;		break;		case 1:			return GROUP_CLOSED;		break;		case 2:			return GROUP_HIDDEN;		break;	}	return GROUP_SPECIAL;}/*** Convert the topic type constants*/function phpbb_convert_topic_type($topic_type){	switch ($topic_type)	{		case 0:			return POST_NORMAL;		break;		case 1:			return POST_STICKY;		break;		case 2:			return POST_ANNOUNCE;		break;		case 3:			return POST_GLOBAL;		break;	}	return POST_NORMAL;}/*** Reparse the message stripping out the bbcode_uid values and adding new ones and setting the bitfield* @todo What do we want to do about HTML in messages - currently it gets converted to the entities, but there may be some objections to this*/function phpbb_prepare_message($message){	global $phpbb_root_path, $phpEx, $db, $convert, $user, $config, $cache, $convert_row, $message_parser;	if (!$message)	{		$convert->row['mp_bbcode_bitfield'] = $convert_row['mp_bbcode_bitfield'] = 0;		return '';	}	// Decode phpBB 2.0.x Message	if (isset($convert->row['old_bbcode_uid']) && $convert->row['old_bbcode_uid'] != '')	{		$message = preg_replace('/\:(([a-z0-9]:)?)' . $convert->row['old_bbcode_uid'] . '/s', '', $message);	}	if (strpos($message, '[quote=') !== false)	{		$message = preg_replace('/\[quote="(.*?)"\]/s', '[quote=&quot;\1&quot;]', $message);	}	$user_id = $convert->row['poster_id'];	$message = str_replace('<', '&lt;', $message);	$message = str_replace('>', '&gt;', $message);	$message = str_replace('<br />', "\n", $message);	// make the post UTF-8	$message = phpbb_set_encoding($message);	$message_parser->warn_msg = array(); // Reset the errors from the previous message	$message_parser->bbcode_uid = make_uid($convert->row['post_time']);	$message_parser->message = $message;	unset($message);	// Make sure options are set.//	$enable_html = (!isset($row['enable_html'])) ? false : $row['enable_html'];	$enable_bbcode = (!isset($convert->row['enable_bbcode'])) ? true : $convert->row['enable_bbcode'];	$enable_smilies = (!isset($convert->row['enable_smilies'])) ? true : $convert->row['enable_smilies'];	$enable_magic_url = (!isset($convert->row['enable_magic_url'])) ? true : $convert->row['enable_magic_url'];	// parse($allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $update_this_message = true, $mode = 'post')	$message_parser->parse($enable_bbcode, $enable_magic_url, $enable_smilies);		if (sizeof($message_parser->warn_msg))	{		$msg_id = isset($convert->row['post_id']) ? $convert->row['post_id'] : $convert->row['privmsgs_id'];		$convert->p_master->error('<span style="color:red">' . $user->lang['POST_ID'] . ': ' . $msg_id . ' ' . $user->lang['CONV_ERROR_MESSAGE_PARSER'] . ': <br /><br />' . implode('<br />', $message_parser->warn_msg), __LINE__, __FILE__, true);	}	$convert->row['mp_bbcode_bitfield'] = $convert_row['mp_bbcode_bitfield'] = $message_parser->bbcode_bitfield;	$message = $message_parser->message;	unset($message_parser->message);	return $message;}/*** Return the bitfield calculated by the previous function*/function get_bbcode_bitfield(){	global $convert_row;	return $convert_row['mp_bbcode_bitfield'];}/*** Determine the last user to edit a post* In practice we only tracked edits by the original poster in 2.0.x so this will only be set if they had edited their own post*/function phpbb_post_edit_user(){	global $convert_row, $config;	if (isset($convert_row['post_edit_count']))	{		return phpbb_user_id($convert_row['poster_id']);	}	return 0;}/*** Obtain the path to uploaded files on the 2.0.x forum* This is only used if the Attachment MOD was installed*/function phpbb_get_files_dir(){	if (!defined('MOD_ATTACHMENT'))	{		return;	}	global $db, $convert, $user, $config, $cache;	$sql = 'SELECT config_value AS upload_dir		FROM ' . $convert->src_table_prefix . "attachments_config		WHERE config_name = 'upload_dir'";	$result = $db->sql_query($sql);	$upload_path = $db->sql_fetchfield('upload_dir');	$db->sql_freeresult($result);	$sql = 'SELECT config_value AS ftp_upload		FROM ' . $convert->src_table_prefix . "attachments_config		WHERE config_name = 'allow_ftp_upload'";	$result = $db->sql_query($sql);	$ftp_upload = (int) $db->sql_fetchfield('ftp_upload');	$db->sql_freeresult($result);	if ($ftp_upload)	{		$convert->p_master->error($user->lang['CONV_ERROR_ATTACH_FTP_DIR'], __LINE__, __FILE__);	}	return $upload_path;}/*** Copy thumbnails of uploaded images from the 2.0.x forum* This is only used if the Attachment MOD was installed*/function phpbb_copy_thumbnails(){	global $db, $convert, $user, $config, $cache, $phpbb_root_path;	$src_path = $convert->options['forum_path'] . '/' . phpbb_get_files_dir() . '/thumbs/';		if ($handle = @opendir($src_path))	{		while ($entry = readdir($handle))		{			if ($entry[0] == '.')			{				continue;			}			if (is_dir($src_path . $entry))			{				continue;			}			else			{				copy_file($src_path . $entry, $config['upload_path'] . '/' . preg_replace('/^t_/', 'thumb_', $entry));				@unlink($phpbb_root_path . $config['upload_path'] . '/thumbs/' . $entry);			}		}		closedir($handle);	}}/*** Convert the attachment category constants* This is only used if the Attachment MOD was installed*/function phpbb_attachment_category($cat_id){	switch ($cat_id)	{		case 1:			return ATTACHMENT_CATEGORY_IMAGE;		break;		case 2:			return ATTACHMENT_CATEGORY_WM;		break;		case 3:			return ATTACHMENT_CATEGORY_FLASH;		break;	}	return ATTACHMENT_CATEGORY_NONE;}/*** Obtain list of forums in which different attachment categories can be used*/function phpbb_attachment_forum_perms($forum_permissions){	if (empty($forum_permissions))	{		return '';	}	// Decode forum permissions	$forum_ids = array();	$one_char_encoding = '#';	$two_char_encoding = '.';	$auth_len = 1;	for ($pos = 0; $pos < strlen($forum_permissions); $pos += $auth_len)	{		$forum_auth = substr($forum_permissions, $pos, 1);		if ($forum_auth == $one_char_encoding)		{			$auth_len = 1;			continue;		}		else if ($forum_auth == $two_char_encoding)		{			$auth_len = 2;			$pos--;			continue;		}				$forum_auth = substr($forum_permissions, $pos, $auth_len);		$forum_id = base64_unpack($forum_auth);		$forum_ids[] = (int) $forum_id;	}		if (sizeof($forum_ids))	{		return attachment_forum_perms($forum_ids);	}	return '';}/*** Convert the avatar type constants*/function phpbb_avatar_type($type){	switch ($type)	{		case 1:			return AVATAR_UPLOAD;		break;		case 2:			return AVATAR_REMOTE;		break;		case 3:			return AVATAR_GALLERY;		break;	}	return 0;}/*** Transfer avatars, copying the image if it was uploaded*/function phpbb_import_avatar($user_avatar){	global $convert_row;	if (!$convert_row['user_avatar_type'])	{		return '';	}	else if ($convert_row['user_avatar_type'] == 1)	{		// Uploaded avatar		return import_avatar($user_avatar);	}	else if ($convert_row['user_avatar_type'] == 2)	{		// Remote avatar		return $user_avatar;	}	else if ($convert_row['user_avatar_type'] == 3)	{		// Gallery avatar		return $user_avatar;	}	return '';}/*** Calculate the correct to_address field for private messages*/function phpbb_privmsgs_to_userid($to_userid){	global $config;	return 'u_' . phpbb_user_id($to_userid);}/*** Calculate whether a private message was unread using the bitfield*/function phpbb_unread_pm($pm_type){	return ($pm_type == 5) ? 1 : 0;}/*** Calculate whether a private message was new using the bitfield*/function phpbb_new_pm($pm_type){	return ($pm_type == 1) ? 1 : 0;}/*** Obtain the folder_id for the custom folder created to replace the savebox from 2.0.x (used to store saved private messages)*/function phpbb_get_savebox_id($user_id){	global $db;	$user_id = phpbb_user_id($user_id);	// Only one custom folder, check only one	$sql = 'SELECT folder_id		FROM ' . PRIVMSGS_FOLDER_TABLE . '		WHERE user_id = ' . $user_id;	$result = $db->sql_query_limit($sql, 1);	$folder_id = (int) $db->sql_fetchfield('folder_id');	$db->sql_freeresult($result);	return $folder_id;}/*** Transfer attachment specific configuration options* These were not stored in the main config table on 2.0.x* This is only used if the Attachment MOD was installed*/function phpbb_import_attach_config(){	global $db, $convert, $config;	$sql = 'SELECT *		FROM ' . $convert->src_table_prefix . 'attachments_config';	$result = $db->sql_query($sql);	$attach_config = array();	while ($row = $db->sql_fetchrow($result))	{		$attach_config[$row['config_name']] = $row['config_value'];	}	$db->sql_freeresult($result);	set_config('allow_attachments', 1);	// old attachment mod? Must be very old if this entry do not exist...	if (!empty($attach_config['display_order']))	{		set_config('display_order', $attach_config['display_order']);	}	set_config('max_filesize', $attach_config['max_filesize']);	set_config('max_filesize_pm', $attach_config['max_filesize_pm']);	set_config('attachment_quota', $attach_config['attachment_quota']);	set_config('max_attachments', $attach_config['max_attachments']);	set_config('max_attachments_pm', $attach_config['max_attachments_pm']);	set_config('allow_pm_attach', $attach_config['allow_pm_attach']);	set_config('img_display_inlined', $attach_config['img_display_inlined']);	set_config('img_max_width', $attach_config['img_max_width']);	set_config('img_max_height', $attach_config['img_max_height']);	set_config('img_link_width', $attach_config['img_link_width']);	set_config('img_link_height', $attach_config['img_link_height']);	set_config('img_create_thumbnail', $attach_config['img_create_thumbnail']);	set_config('img_max_thumb_width', 400);	set_config('img_min_thumb_filesize', $attach_config['img_min_thumb_filesize']);	set_config('img_imagick', $attach_config['img_imagick']);}/*** Calculate the date a user became inactive*/function phpbb_inactive_time(){	global $convert_row;	if ($convert_row['user_active'])	{		return 0;	}	if ($convert_row['user_lastvisit'])	{		return $convert_row['user_lastvisit'];	}	return $convert_row['user_regdate'];}/*** Calculate the reason a user became inactive* We can't actually tell the difference between a manual deactivation and one for profile changes* from the data available to assume the latter*/function phpbb_inactive_reason(){	global $convert_row;	if ($convert_row['user_active'])	{		return 0;	}	if ($convert_row['user_lastvisit'])	{		return INACTIVE_PROFILE;	}	return INACTIVE_REGISTER;}?>

⌨️ 快捷键说明

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