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

📄 acp_attachments.php

📁 这些都是我以前学习是用到的源码
💻 PHP
📖 第 1 页 / 共 4 页
字号:
		$types = array(			INLINE_LINK		=> $user->lang['MODE_INLINE'],			PHYSICAL_LINK	=> $user->lang['MODE_PHYSICAL']		);				if ($group_id)		{			$sql = "SELECT download_mode				FROM " . EXTENSION_GROUPS_TABLE . "				WHERE group_id = " . (int) $group_id;			$result = $db->sql_query($sql);			$download_mode = (!($row = $db->sql_fetchrow($result))) ? INLINE_LINK : $row['download_mode'];			$db->sql_freeresult($result);		}		else		{			$download_mode = INLINE_LINK;		}		$group_select = '<select name="' . $select_name . '"' . (($key) ? ' id="' . $key . '"' : '') . '>';		foreach ($types as $type => $mode)		{			$selected = ($type == $download_mode) ? ' selected="selected"' : '';			$group_select .= '<option value="' . $type . '"' . $selected . '>' . $mode . '</option>';		}		$group_select .= '</select>';		return $group_select;	}	/**	* Search Imagick	*/	function search_imagemagick()	{		$imagick = '';		$exe = ((defined('PHP_OS')) && (preg_match('#^win#i', PHP_OS))) ? '.exe' : '';		$magic_home = getenv('MAGICK_HOME');		if (empty($magic_home))		{			$locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/');			$path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH'))));				$locations = array_merge($path_locations, $locations);			foreach ($locations as $location)			{				// The path might not end properly, fudge it				if (substr($location, -1, 1) !== '/')				{					$location .= '/';				}				if (@is_readable($location . 'mogrify' . $exe) && @filesize($location . 'mogrify' . $exe) > 3000)				{					$imagick = str_replace('\\', '/', $location);					continue;				}			}		}		else		{			$imagick = str_replace('\\', '/', $magic_home);		}		return $imagick;	}	/**	* Test Settings	*/	function test_upload(&$error, $upload_dir, $create_directory = false)	{		global $user, $phpbb_root_path;		// Does the target directory exist, is it a directory and writeable.		if ($create_directory)		{			if (!file_exists($phpbb_root_path . $upload_dir))			{				@mkdir($phpbb_root_path . $upload_dir, 0777);				@chmod($phpbb_root_path . $upload_dir, 0777);			}		}		if (!file_exists($phpbb_root_path . $upload_dir))		{			$error[] = sprintf($user->lang['NO_UPLOAD_DIR'], $upload_dir);			return;		}		if (!is_dir($phpbb_root_path . $upload_dir))		{			$error[] = sprintf($user->lang['UPLOAD_NOT_DIR'], $upload_dir);			return;		}		if (!is_writable($phpbb_root_path . $upload_dir))		{			$error[] = sprintf($user->lang['NO_WRITE_UPLOAD'], $upload_dir);			return;		}	}	/**	* Perform operations on sites for external linking	*/	function perform_site_list()	{		global $db, $user;		if (isset($_REQUEST['securesubmit']))		{			// Grab the list of entries			$ips = request_var('ips', '');			$ip_list = array_unique(explode("\n", $ips));			$ip_list_log = implode(', ', $ip_list);			$ip_exclude = (!empty($_POST['ipexclude'])) ? 1 : 0;			$iplist = array();			$hostlist = array();			foreach ($ip_list as $item)			{				if (preg_match('#^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$#', trim($item), $ip_range_explode))				{					// Don't ask about all this, just don't ask ... !					$ip_1_counter = $ip_range_explode[1];					$ip_1_end = $ip_range_explode[5];					while ($ip_1_counter <= $ip_1_end)					{						$ip_2_counter = ($ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[2] : 0;						$ip_2_end = ($ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[6];						if ($ip_2_counter == 0 && $ip_2_end == 254)						{							$ip_2_counter = 256;							$ip_2_fragment = 256;							$iplist[] = "'$ip_1_counter.*'";						}						while ($ip_2_counter <= $ip_2_end)						{							$ip_3_counter = ($ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[3] : 0;							$ip_3_end = ($ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[7];							if ($ip_3_counter == 0 && $ip_3_end == 254)							{								$ip_3_counter = 256;								$ip_3_fragment = 256;								$iplist[] = "'$ip_1_counter.$ip_2_counter.*'";							}							while ($ip_3_counter <= $ip_3_end)							{								$ip_4_counter = ($ip_3_counter == $ip_range_explode[3] && $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[4] : 0;								$ip_4_end = ($ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end) ? 254 : $ip_range_explode[8];								if ($ip_4_counter == 0 && $ip_4_end == 254)								{									$ip_4_counter = 256;									$ip_4_fragment = 256;									$iplist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.*'";								}								while ($ip_4_counter <= $ip_4_end)								{									$iplist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter'";									$ip_4_counter++;								}								$ip_3_counter++;							}							$ip_2_counter++;						}						$ip_1_counter++;					}				}				else if (preg_match('#^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$#', trim($item)) || preg_match('#^[a-f0-9:]+\*?$#i', trim($item)))				{					$iplist[] = "'" . trim($item) . "'";				}				else if (preg_match('#^([\w\-_]\.?){2,}$#is', trim($item)))				{					$hostlist[] = "'" . trim($item) . "'";				}				else if (preg_match("#^([a-z0-9\-\*\._/]+?)$#is", trim($item)))				{					$hostlist[] = "'" . trim($item) . "'";				}			}			$sql = 'SELECT site_ip, site_hostname				FROM ' . SITELIST_TABLE . "				WHERE ip_exclude = $ip_exclude";			$result = $db->sql_query($sql);			if ($row = $db->sql_fetchrow($result))			{				$iplist_tmp = array();				$hostlist_tmp = array();				do				{					if ($row['site_ip'])					{						$iplist_tmp[] = "'" . $row['site_ip'] . "'";					}					else if ($row['site_hostname'])					{						$hostlist_tmp[] = "'" . $row['site_hostname'] . "'";					}					// break;				}				while ($row = $db->sql_fetchrow($result));				$iplist = array_unique(array_diff($iplist, $iplist_tmp));				$hostlist = array_unique(array_diff($hostlist, $hostlist_tmp));				unset($iplist_tmp);				unset($hostlist_tmp);			}			$db->sql_freeresult($result);			if (sizeof($iplist))			{				foreach ($iplist as $ip_entry)				{					$sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_ip, ip_exclude)						VALUES ($ip_entry, $ip_exclude)";					$db->sql_query($sql);				}			}			if (sizeof($hostlist))			{				foreach ($hostlist as $host_entry)				{					$sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_hostname, ip_exclude)						VALUES ($host_entry, $ip_exclude)";					$db->sql_query($sql);				}			}						if (!empty($ip_list_log))			{				// Update log				$log_entry = ($ip_exclude) ? 'LOG_DOWNLOAD_EXCLUDE_IP' : 'LOG_DOWNLOAD_IP';				add_log('admin', $log_entry, $ip_list_log);			}			trigger_error($user->lang['SECURE_DOWNLOAD_UPDATE_SUCCESS'] . adm_back_link($this->u_action));		}		else if (isset($_POST['unsecuresubmit']))		{			$unip_sql = array_map('intval', $_POST['unip']);			if (sizeof($unip_sql))			{				$l_unip_list = '';				// Grab details of ips for logging information later				$sql = 'SELECT site_ip, site_hostname					FROM ' . SITELIST_TABLE . '					WHERE ' . $db->sql_in_set('site_id', $unip_sql);				$result = $db->sql_query($sql);				while ($row = $db->sql_fetchrow($result))				{					$l_unip_list .= (($l_unip_list != '') ? ', ' : '') . (($row['site_ip']) ? $row['site_ip'] : $row['site_hostname']);				}				$db->sql_freeresult($result);				$sql = 'DELETE FROM ' . SITELIST_TABLE . '					WHERE ' . $db->sql_in_set('site_id', $unip_sql);				$db->sql_query($sql);				add_log('admin', 'LOG_DOWNLOAD_REMOVE_IP', $l_unip_list);			}			trigger_error($user->lang['SECURE_DOWNLOAD_UPDATE_SUCCESS'] . adm_back_link($this->u_action));		}	}	/**	* Re-Write extensions cache file	*/	function rewrite_extensions()	{		global $db, $cache;		$sql = 'SELECT e.extension, g.*			FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g			WHERE e.group_id = g.group_id				AND g.allow_group = 1';		$result = $db->sql_query($sql);		$extensions = array();		while ($row = $db->sql_fetchrow($result))		{			$extension = $row['extension'];			$extensions[$extension]['display_cat']	= (int) $row['cat_id'];			$extensions[$extension]['download_mode']= (int) $row['download_mode'];			$extensions[$extension]['upload_icon']	= (string) $row['upload_icon'];			$extensions[$extension]['max_filesize']	= (int) $row['max_filesize'];			$allowed_forums = ($row['allowed_forums']) ? unserialize(trim($row['allowed_forums'])) : array();			if ($row['allow_in_pm'])			{				$allowed_forums = array_merge($allowed_forums, array(0));			}			// Store allowed extensions forum wise			$extensions['_allowed_'][$extension] = (!sizeof($allowed_forums)) ? 0 : $allowed_forums;		}		$db->sql_freeresult($result);		$cache->destroy('_extensions');		$cache->put('_extensions', $extensions);	}	/**	* Write display_order config field	*/	function display_order($value, $key = '')	{		$radio_ary = array(0 => 'DESCENDING', 1 => 'ASCENDING');		return h_radio('config[display_order]', $radio_ary, $value, $key);	}	/**	* Adjust all three max_filesize config vars for display	*/	function max_filesize($value, $key = '')	{		// Determine size var and adjust the value accordingly		$size_var = ($value >= 1048576) ? 'mb' : (($value >= 1024) ? 'kb' : 'b');		$value = ($value >= 1048576) ? round($value / 1048576 * 100) / 100 : (($value >= 1024) ? round($value / 1024 * 100) / 100 : $value);		return '<input type="text" id="' . $key . '" size="8" maxlength="15" name="config[' . $key . ']" value="' . $value . '" /> <select name="' . $key . '">' . size_select_options($size_var) . '</select>';	}	/**	* Write secure_allow_deny config field	*/	function select_allow_deny($value, $key = '')	{		$radio_ary = array(1 => 'ORDER_ALLOW_DENY', 0 => 'ORDER_DENY_ALLOW');		return h_radio('config[' . $key . ']', $radio_ary, $value, $key);	}}?>

⌨️ 快捷键说明

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