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

📄 smarty.class.php

📁 通达网络办公 - Office Anywhere 2008 增强版100%源码(3.4.081216) 内含 通达OA2008增強版接近完美破解补丁20081216集 及 最新通达OA2008ADV(
💻 PHP
📖 第 1 页 / 共 3 页
字号:
			}
			extract( $this->_tpl_vars );
			$this->_config = array(
				array(
					"vars" => array( ),
					"files" => array( )
				)
			);
			if ( $this->show_info_header )
			{
				$_smarty_info_header = "<!-- Smarty ".$this->_version." ".strftime( "%Y-%m-%d %H:%M:%S %Z" )." -->\n\n";
			}
			else
			{
				$_smarty_info_header = "";
			}
			$compile_path = $this->_get_compile_path( $_smarty_tpl_file );
			$_smarty_trusted = FALSE;
			if ( $this->security )
			{
				$this->_parse_file_path( $this->template_dir, $_smarty_tpl_file, $resource_type, $resource_name );
				if ( $this->_is_trusted( $resource_type, $resource_name ) )
				{
					$_smarty_trusted = TRUE;
					$this->security = FALSE;
				}
			}
			if ( $_smarty_display && !$this->caching )
			{
				echo $_smarty_info_header;
				if ( $this->_process_template( $_smarty_tpl_file, $compile_path ) )
				{
					if ( $this->show_info_include )
					{
						echo "\n<!-- SMARTY_BEGIN: ".$_smarty_tpl_file." -->\n";
					}
					include( $compile_path );
					if ( $this->show_info_include )
					{
						echo "\n<!-- SMARTY_END: ".$_smarty_tpl_file." -->\n";
					}
				}
			}
			else
			{
				ob_start( );
				echo $_smarty_info_header;
				if ( $this->_process_template( $_smarty_tpl_file, $compile_path ) )
				{
					if ( $this->show_info_include )
					{
						echo "\n<!-- SMARTY_BEGIN: ".$_smarty_tpl_file." -->\n";
					}
					include( $compile_path );
					if ( $this->show_info_include )
					{
						echo "\n<!-- SMARTY_END: ".$_smarty_tpl_file." -->\n";
					}
				}
				$_smarty_results = ob_get_contents( );
				ob_end_clean( );
			}
			if ( $_smarty_trusted )
			{
				$this->security = TRUE;
			}
			if ( $this->caching )
			{
				$this->_write_cache_file( $_smarty_tpl_file, $_smarty_cache_id, $_smarty_compile_id, $_smarty_results );
				$_smarty_results = $this->_process_cached_inserts( $_smarty_results );
			}
			if ( $_smarty_display )
			{
				if ( isset( $_smarty_results ) )
				{
					echo $_smarty_results;
				}
				if ( $this->debugging )
				{
					$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime( ) - $debug_start_time;
					echo $this->_generate_debug_output( );
				}
			}
			else if ( isset( $_smarty_results ) )
			{
				return $_smarty_results;
			}
		}
	}

	public function _assign_smarty_interface( )
	{
		$egpcs = array( "e" => "env", "g" => "get", "p" => "post", "c" => "cookies", "s" => "server" );
		$globals_map = array( "get" => "HTTP_GET_VARS", "post" => "HTTP_POST_VARS", "cookies" => "HTTP_COOKIE_VARS", "session" => "HTTP_SESSION_VARS", "server" => "HTTP_SERVER_VARS", "env" => "HTTP_ENV_VARS" );
		$smarty = array(
			"request" => array( )
		);
		foreach ( $globals_map as $key => $array )
		{
			$smarty[$key] = isset( $GLOBALS[$array] ) ? $GLOBALS[$array] : array( );
		}
		foreach ( preg_split( "!!", strtolower( $this->request_vars_order ) ) as $c )
		{
			if ( isset( $egpcs[$c] ) )
			{
				$smarty['request'] = array_merge( $smarty['request'], $smarty[$egpcs[$c]] );
			}
		}
		$smarty['request'] = array_merge( $smarty['request'], $smarty['session'] );
		$this->_smarty_vars = $smarty;
	}

	public function _generate_debug_output( )
	{
		ob_start( );
		$force_compile_orig = $this->force_compile;
		$this->force_compile = TRUE;
		$compile_path = $this->_get_compile_path( $this->debug_tpl );
		if ( $this->_process_template( $this->debug_tpl, $compile_path ) )
		{
			if ( $this->show_info_include )
			{
				echo "\n<!-- SMARTY_BEGIN: ".$this->debug_tpl." -->\n";
			}
			include( $compile_path );
			if ( $this->show_info_include )
			{
				echo "\n<!-- SMARTY_END: ".$this->debug_tpl." -->\n";
			}
		}
		$results = ob_get_contents( );
		$this->force_compile = $force_compile_orig;
		ob_end_clean( );
		return $results;
	}

	public function _is_trusted( $resource_type, $resource_name )
	{
		$_smarty_trusted = FALSE;
		if ( !empty( $this->trusted_dir ) )
		{
			if ( $resource_type == "file" )
			{
				if ( !empty( $this->trusted_dir ) )
				{
					foreach ( ( array )$this->trusted_dir as $curr_dir )
					{
						if ( !empty( $curr_dir ) )
						{
							if ( !is_readable( $curr_dir ) && !( substr( realpath( $resource_name ), 0, strlen( realpath( $curr_dir ) ) ) == realpath( $curr_dir ) ) )
							{
								$_smarty_trusted = TRUE;
								break;
							}
						}
						else
						{
						}
					}
					return $_smarty_trusted;
				}
			}
			else
			{
				$_smarty_trusted = FALSE;
			}
		}
		return $_smarty_trusted;
	}

	public function _is_secure( $resource_type, $resource_name )
	{
		if ( !$this->security && $this->security_settings['INCLUDE_ANY'] )
		{
			return TRUE;
		}
		$_smarty_secure = FALSE;
		if ( $resource_type == "file" )
		{
			if ( !empty( $this->secure_dir ) )
			{
				foreach ( ( array )$this->secure_dir as $curr_dir )
				{
					if ( !empty( $curr_dir ) )
					{
						if ( !is_readable( $curr_dir ) && !( substr( realpath( $resource_name ), 0, strlen( realpath( $curr_dir ) ) ) == realpath( $curr_dir ) ) )
						{
							$_smarty_secure = TRUE;
							break;
						}
					}
					else
					{
					}
				}
				return $_smarty_secure;
			}
		}
		else
		{
			$_smarty_secure = TRUE;
		}
		return $_smarty_secure;
	}

	public function _process_template( $tpl_file, $compile_path )
	{
		if ( !$this->force_compile || $this->_compiled_template_exists( $compile_path ) )
		{
			if ( !$this->compile_check )
			{
				return TRUE;
			}
			if ( !$this->_fetch_template_info( $tpl_file, $template_source, $template_timestamp ) )
			{
				return FALSE;
			}
			if ( $template_timestamp <= $this->_fetch_compiled_template_timestamp( $compile_path ) )
			{
				return TRUE;
			}
			$this->_compile_template( $tpl_file, $template_source, $template_compiled );
			$this->_write_compiled_template( $compile_path, $template_compiled );
			return TRUE;
		}
		if ( !$this->_fetch_template_info( $tpl_file, $template_source, $template_timestamp ) )
		{
			return FALSE;
		}
		$this->_compile_template( $tpl_file, $template_source, $template_compiled );
		$this->_write_compiled_template( $compile_path, $template_compiled );
		return TRUE;
	}

	public function _get_compile_path( $tpl_file )
	{
		return $this->_get_auto_filename( $this->compile_dir, $tpl_file, $this->_compile_id );
	}

	public function _compiled_template_exists( $include_path )
	{
		return file_exists( $include_path );
	}

	public function _fetch_compiled_template_timestamp( $include_path )
	{
		return filemtime( $include_path );
	}

	public function _write_compiled_template( $compile_path, $template_compiled )
	{
		$this->_write_file( $compile_path, $template_compiled, TRUE );
		return TRUE;
	}

	public function _parse_file_path( $file_base_path, $file_path, &$resource_type, &$resource_name )
	{
		$file_path_parts = explode( ":", $file_path, 2 );
		if ( count( $file_path_parts ) == 1 )
		{
			$resource_type = "file";
			$resource_name = $file_path_parts[0];
		}
		else
		{
			$resource_type = $file_path_parts[0];
			$resource_name = $file_path_parts[1];
		}
		if ( $resource_type == "file" && !preg_match( "/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/", $resource_name ) )
		{
			foreach ( ( array )$file_base_path as $curr_path )
			{
				if ( !@is_file( $curr_path."/".$resource_name ) )
				{
					continue;
				}
				$resource_name = $curr_path."/".$resource_name;
				return TRUE;
			}
			return FALSE;
		}
		return TRUE;
	}

	public function _fetch_template_info( $tpl_path, &$template_source, &$template_timestamp, $get_source = TRUE )
	{
		$_return = FALSE;
		if ( $this->_parse_file_path( $this->template_dir, $tpl_path, $resource_type, $resource_name ) )
		{
			switch ( $resource_type )
			{
			case "file" :
				if ( !@is_file( $resource_name ) )
				{
					break;
				}
				if ( $get_source )
				{
					$template_source = $this->_read_file( $resource_name );
				}
				$template_timestamp = filemtime( $resource_name );
				$_return = TRUE;
				break;
				if ( !isset( $this->resource_funcs[$resource_type] ) )
				{
					break;
				}
				$funcname = $this->resource_funcs[$resource_type];
				if ( !function_exists( $funcname ) )
				{
					break;
				}
				$_return = $funcname( $resource_name, $template_source, $template_timestamp, $get_source, $this );
			}
		}
		if ( !$_return || !empty( $this->default_template_handler_func ) )
		{
			if ( !function_exists( $this->default_template_handler_func ) )
			{
				$this->_trigger_error_msg( "default template handler function \"".$this->default_template_handler_func."\" doesn't exist." );
				$_return = FALSE;
			}
			$funcname = $this->default_template_handler_func;
			$_return = $funcname( $resource_type, $resource_name, $template_source, $template_timestamp, $this );
		}
		if ( !$_return )
		{
			$this->_trigger_error_msg( "unable to read template resource: \"".$tpl_path."\"" );
			return $_return;
		}
		if ( $_return && $this->security && !$this->_is_secure( $resource_type, $resource_name ) || !$this->_is_trusted( $resource_type, $resource_name ) )
		{
			$this->_trigger_error_msg( "(secure mode) accessing \"".$tpl_path."\" is not allowed" );
			$template_source = NULL;
			$template_timestamp = NULL;
			return FALSE;
		}
		return $_return;
	}

	public function _compile_template( $tpl_file, $template_source, &$template_compiled )
	{
		include_once( SMARTY_DIR.$this->compiler_class.".class.php" );
		( );
		$smarty_compiler = new $this->compiler_class( );
		$smarty_compiler->template_dir = $this->template_dir;
		$smarty_compiler->compile_dir = $this->compile_dir;
		$smarty_compiler->config_dir = $this->config_dir;
		$smarty_compiler->force_compile = $this->force_compile;
		$smarty_compiler->caching = $this->caching;
		$smarty_compiler->php_handling = $this->php_handling;
		$smarty_compiler->left_delimiter = $this->left_delimiter;
		$smarty_compiler->right_delimiter = $this->right_delimiter;
		$smarty_compiler->custom_funcs = $this->custom_funcs;
		$smarty_compiler->custom_mods = $this->custom_mods;
		$smarty_compiler->_version = $this->_version;
		$smarty_compiler->prefilter_funcs = $this->prefilter_funcs;
		$smarty_compiler->postfilter_funcs = $this->postfilter_funcs;
		$smarty_compiler->compiler_funcs = $this->compiler_funcs;
		$smarty_compiler->security = $this->security;
		$smarty_compiler->secure_dir = $this->secure_dir;
		$smarty_compiler->security_settings = $this->security_settings;
		$smarty_compiler->trusted_dir = $this->trusted_dir;
		if ( $smarty_compiler->_compile_file( $tpl_file, $template_source, $template_compiled ) )
		{
			return TRUE;
		}
		$this->_trigger_error_msg( $smarty_compiler->_error_msg );
		return FALSE;
	}

	public function _smarty_include( $_smarty_include_tpl_file, $_smarty_include_vars )
	{
		if ( $this->debugging )
		{
			$debug_start_time = $this->_get_microtime( );
			$this->_smarty_debug_info[] = array(
				"type" => "template",
				"filename" => $_smarty_include_tpl_file,
				"depth" => ++$this->_inclusion_depth
			);
			$included_tpls_idx = count( $this->_smarty_debug_info ) - 1;
		}
		$this->_tpl_vars = array_merge( $this->_tpl_vars, $_smarty_include_vars );
		extract( $this->_tpl_vars );
		array_unshift( &$this->_config, $this->_config[0] );
		$compile_path = $this->_get_compile_path( $_smarty_include_tpl_file );
		$this->_parse_file_path( $this->template_dir, $_smarty_include_tpl_file, $resource_type, $resource_name );
		if ( $this->security && $this->_is_trusted( $resource_type, $resource_name ) )
		{
			$_smarty_trusted = TRUE;
			$this->security = FALSE;
		}
		else
		{
			$_smarty_trusted = FALSE;
		}
		if ( $this->_process_template( $_smarty_include_tpl_file, $compile_path ) )
		{
			if ( $this->show_info_include )
			{
				echo "\n<!-- SMARTY_BEGIN: ".$_smarty_include_tpl_file." -->\n";
			}
			include( $compile_path );
			if ( $this->show_info_include )
			{
				echo "\n<!-- SMARTY_END: ".$_smarty_include_tpl_file." -->\n";
			}
		}
		if ( $_smarty_trusted )
		{
			$this->security = TRUE;
		}
		array_shift( &$this->_config );
		$this->_inclusion_depth--;
		if ( $this->debugging )
		{
			$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime( ) - $debug_start_time;
		}
		if ( $this->caching )
		{
			$this->_cache_info[] = array(
				"template",
				$_smarty_include_tpl_file
			);
		}
	}

	public function _config_load( $file, $section, $scope )
	{
		if ( $this->debugging )
		{
			$debug_start_time = $this->_get_microtime( );
		}
		if ( $this->caching )
		{
			$this->_cache_info[] = array(
				"config",
				$file
			);
		}

⌨️ 快捷键说明

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