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

📄 smarty.addons.php

📁 极限网络智能办公系统—MYOA26—100%—源程序。
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		$i = 0;
		for ( ;	$i < count( $all_seconds );	$i += $second_interval	)
		{
			$seconds[] = sprintf( "%02d", $all_seconds[$i] );
		}
		$selected = intval( floor( strftime( "%S", $time ) / $second_interval ) * $second_interval );
		$html_result .= "<select name=";
		if ( null !== $field_array )
		{
			$html_result .= "\"".$field_array."[".$prefix."Second]\">"."\n";
		}
		else
		{
			$html_result .= "\"".$prefix."Second\">"."\n";
		}
		$html_result .= smarty_func_html_options( array(
			"output" => $seconds,
			"values" => $seconds,
			"selected" => $selected,
			"print_result" => false
		) );
		$html_result .= "</select>\n";
	}
	if ( $display_meridian && !$use_24_hours )
	{
		$html_result .= "<select name=";
		if ( null !== $field_array )
		{
			$html_result .= "\"".$field_array."[".$prefix."Meridian]\">"."\n";
		}
		else
		{
			$html_result .= "\"".$prefix."Meridian\">"."\n";
		}
		$html_result .= smarty_func_html_options( array(
			"output" => array( "AM", "PM" ),
			"values" => array( "am", "pm" ),
			"selected" => strtolower( strftime( "%p", $time ) ),
			"print_result" => false
		) );
		$html_result .= "</select>\n";
	}
	print $html_result;
}

function smarty_func_math( $args, &$smarty_obj )
{
	if ( empty( $args['equation'] ) )
	{
		$smarty_obj->_trigger_error_msg( "math: missing equation parameter" );
	}
	else
	{
		$equation = $args['equation'];
		if ( substr_count( $equation, "(" ) != substr_count( $equation, ")" ) )
		{
			$smarty_obj->_trigger_error_msg( "math: unbalanced parenthesis" );
		}
		else
		{
			preg_match_all( "![a-zA-Z][a-zA-Z0-9]*!", $equation, $match );
			$allowed_funcs = array( "int", "abs", "ceil", "cos", "exp", "floor", "log", "log10", "max", "min", "pi", "pow", "rand", "round", "sin", "sqrt", "srand", "tan" );
			foreach ( $match[0] as $curr_var )
			{
				if ( !in_array( $curr_var, array_keys( $args ) ) && !in_array( $curr_var, $allowed_funcs ) )
				{
					$smarty_obj->_trigger_error_msg( "math: parameter {$curr_var} not passed as argument" );
					return;
				}
			}
			foreach ( $args as $key => $val )
			{
				if ( $key != "equation" && $key != "format" && $key != "assign" )
				{
					if ( strlen( $val ) == 0 )
					{
						$smarty_obj->_trigger_error_msg( "math: parameter {$key} is empty" );
					}
					else if ( !is_numeric( $val ) )
					{
						$smarty_obj->_trigger_error_msg( "math: parameter {$key}: is not numeric" );
					}
					else
					{
						$equation = preg_replace( "/\\b{$key}\\b/", $val, $equation );
					}
				}
			}
			eval( "\$smarty_math_result = ".$equation.";" );
			if ( empty( $args['format'] ) )
			{
				if ( empty( $args['assign'] ) )
				{
					echo $smarty_math_result;
				}
				else
				{
					$smarty_obj->assign( $args['assign'], $smarty_math_result );
				}
			}
			else if ( empty( $args['assign'] ) )
			{
				printf( $args['format'], $smarty_math_result );
			}
			else
			{
				$smarty_obj->assign( $assign, sprintf( $args['format'], $smarty_math_result ) );
			}
		}
	}
}

function smarty_func_fetch( $args, &$smarty_obj )
{
	extract( $args );
	if ( empty( $file ) )
	{
		$smarty_obj->_trigger_error_msg( "parameter 'file' cannot be empty" );
	}
	else
	{
		if ( $smarty_obj->security && !preg_match( "!^(http|ftp)://!", $file ) )
		{
			foreach ( $smarty_obj->secure_dir as $curr_dir )
			{
				if ( substr( realpath( $file ), 0, strlen( realpath( $curr_dir ) ) ) == realpath( $curr_dir ) )
				{
					$resource_is_secure = true;
					break;
				}
			}
			if ( !$resource_is_secure )
			{
				$smarty_obj->_trigger_error_msg( "(secure mode) fetch '{$file}' is not allowed" );
			}
			else if ( !is_readable( $file ) )
			{
				$smarty_obj->_trigger_error_msg( "fetch cannot read file '{$file}'" );
				return;
			}
		}
		if ( !empty( $assign ) )
		{
			ob_start( );
			readfile( $file );
			$smarty_obj->assign( $assign, ob_get_contents( ) );
			ob_end_clean( );
		}
		else
		{
			readfile( $file );
		}
	}
}

function smarty_mod_count_characters( $string, $include_spaces = false )
{
	if ( $include_spaces )
	{
		return strlen( $string );
	}
	return preg_match_all( "/[^\\s]/", $string, $match );
}

function smarty_mod_count_words( $string )
{
	$split_array = preg_split( "/\\s+/", $string );
	$word_count = preg_grep( "/[a-zA-Z0-9]/", $split_array );
	return count( $word_count );
}

function smarty_mod_count_sentences( $string, $include_spaces = false )
{
	return preg_match_all( "/[^\\s]\\.(?!\\w)/", $string, $match );
}

function smarty_mod_count_paragraphs( $string, $include_spaces = false )
{
	return count( preg_split( "/[\r\n]+/", $string ) );
}

function smarty_func_counter( $args, &$smarty_obj )
{
	static $count = array( );
	static $skipval = array( );
	static $dir = array( );
	static $id = "default";
	static $printval = array( );
	static $assign = "";
	extract( $args );
	if ( !isset( $id ) )
	{
		$id = "default";
	}
	if ( isset( $start ) )
	{
		$count[$id] = $start;
	}
	else if ( !isset( $count[$id] ) )
	{
		$count[$id] = 1;
	}
	if ( !isset( $print ) )
	{
		$printval[$id] = true;
	}
	else
	{
		$printval[$id] = $print;
	}
	if ( !empty( $assign ) )
	{
		$printval[$id] = false;
		$smarty_obj->assign( $assign, $count[$id] );
	}
	if ( $printval[$id] )
	{
		echo $count[$id];
	}
	if ( isset( $skip ) )
	{
		$skipval[$id] = $skip;
	}
	else if ( empty( $skipval[$id] ) )
	{
		$skipval[$id] = 1;
	}
	if ( isset( $direction ) )
	{
		$dir[$id] = $direction;
	}
	else if ( !isset( $dir[$id] ) )
	{
		$dir[$id] = "up";
	}
	if ( $dir[$id] == "down" )
	{
		$count[$id] -= $skipval[$id];
	}
	else
	{
		$count[$id] += $skipval[$id];
	}
	return true;
}

function smarty_func_assign_debug_info( $args, &$smarty_obj )
{
	$assigned_vars = $smarty_obj->_tpl_vars;
	ksort( $assigned_vars );
	if ( is_array( $smarty_obj->_config[0] ) )
	{
		$config_vars = $smarty_obj->_config[0];
		ksort( $config_vars );
		$smarty_obj->assign( "_debug_config_keys", array_keys( $config_vars ) );
		$smarty_obj->assign( "_debug_config_vals", array_values( $config_vars ) );
	}
	$included_templates = $smarty_obj->_smarty_debug_info;
	$smarty_obj->assign( "_debug_keys", array_keys( $assigned_vars ) );
	$smarty_obj->assign( "_debug_vals", array_values( $assigned_vars ) );
	$smarty_obj->assign( "_debug_tpls", $included_templates );
	return true;
}

function smarty_mod_debug_print_var( $var, $depth = 0, $length = 40 )
{
	if ( is_array( $var ) )
	{
		$results = "<b>Array (".count( $var ).")</b>";
		foreach ( $var as $curr_key => $curr_val )
		{
			$return = smarty_mod_debug_print_var( $curr_val, $depth + 1 );
			$results .= "<br>\\r".str_repeat( "&nbsp;", $depth * 2 )."<b>{$curr_key}</b> =&gt; {$return}";
		}
		return $results;
	}
	else
	{
		if ( empty( $var ) )
		{
			return "<i>empty</i>";
		}
		if ( $length < strlen( $var ) )
		{
			$results = substr( $var, 0, $length - 3 )."...";
		}
		else
		{
			$results = $var;
		}
		$results = preg_replace( "![\r\t\n]!", " ", $results );
		$results = htmlspecialchars( htmlspecialchars( $results ) );
		return $results;
	}
}

function smarty_func_overlib_init( $args, &$smarty_obj )
{
	echo "<DIV ID=\"overDiv\" STYLE=\"position:absolute; visibility:hidden; z-index:1000;\"></DIV>\n<SCRIPT LANGUAGE=javascript>\n<!--\n";
	readfile( SMARTY_DIR."overlib.js", 1 );
	echo "// -->\n</SCRIPT>\n";
	return;
}

function smarty_func_overlib( $args, &$smarty_obj )
{
	extract( $args );
	if ( empty( $text ) )
	{
		$smarty_obj->_trigger_error_msg( "overlib: attribute 'text' required" );
		return false;
	}
	if ( empty( $trigger ) )
	{
		$trigger = "onMouseOver";
	}
	echo $trigger."=\"return overlib('".str_replace( "'", "\\'", $text )."'";
	if ( $sticky )
	{
		echo ",STICKY";
	}
	if ( !empty( $caption ) )
	{
		echo ",CAPTION,'".str_replace( "'", "\\'", $caption )."'";
	}
	if ( !empty( $fgcolor ) )
	{
		echo ",FGCOLOR,'{$fgcolor}'";
	}
	if ( !empty( $bgcolor ) )
	{
		echo ",BGCOLOR,'{$bgcolor}'";
	}
	if ( !empty( $textcolor ) )
	{
		echo ",TEXTCOLOR,'{$textcolor}'";
	}
	if ( !empty( $capcolor ) )
	{
		echo ",CAPCOLOR,'{$capcolor}'";
	}
	if ( !empty( $closecolor ) )
	{
		echo ",CLOSECOLOR,'{$closecolor}'";
	}
	if ( !empty( $textfont ) )
	{
		echo ",TEXTFONT,'{$textfont}'";
	}
	if ( !empty( $captionfont ) )
	{
		echo ",CAPTIONFONT,'{$captionfont}'";
	}
	if ( !empty( $closefont ) )
	{
		echo ",CLOSEFONT,'{$closefont}'";
	}
	if ( !empty( $textsize ) )
	{
		echo ",TEXTSIZE,'{$textsize}'";
	}
	if ( !empty( $captionsize ) )
	{
		echo ",CAPTIONSIZE,'{$captionsize}'";
	}
	if ( !empty( $closesize ) )
	{
		echo ",CLOSESIZE,'{$closesize}'";
	}
	if ( !empty( $width ) )
	{
		echo ",WIDTH,'{$width}'";
	}
	if ( !empty( $height ) )
	{
		echo ",HEIGHT,'{$height}'";
	}
	if ( !empty( $left ) )
	{
		echo ",LEFT";
	}
	if ( !empty( $right ) )
	{
		echo ",RIGHT";
	}
	if ( !empty( $center ) )
	{
		echo ",CENTER";
	}
	if ( !empty( $above ) )
	{
		echo ",ABOVE";
	}
	if ( !empty( $below ) )
	{
		echo ",BELOW";
	}
	if ( !empty( $border ) )
	{
		echo ",BORDER,'{$border}'";
	}
	if ( !empty( $offsetx ) )
	{
		echo ",OFFSETX,'{$offsetx}'";
	}
	if ( !empty( $offsety ) )
	{
		echo ",OFFSETY,'{$offsetxy}'";
	}
	if ( !empty( $fgbackground ) )
	{
		echo ",FGBACKGROUND,'{$fgbackground}'";
	}
	if ( !empty( $bgbackground ) )
	{
		echo ",BGBACKGROUND,'{$bgbackground}'";
	}
	if ( !empty( $closetext ) )
	{
		echo ",CLOSETEXT,'".str_replace( "'", "\\'", $closetext )."'";
	}
	if ( !empty( $noclose ) )
	{
		echo ",NOCLOSE";
	}
	if ( !empty( $status ) )
	{
		echo ",STATUS,'".str_replace( "'", "\\'", $status )."'";
	}
	if ( !empty( $autostatus ) )
	{
		echo ",AUTOSTATUS";
	}
	if ( !empty( $autostatuscap ) )
	{
		echo ",AUTOSTATUSCAP";
	}
	if ( !empty( $inarray ) )
	{
		echo ",INARRAY,'{$inarray}'";
	}
	if ( !empty( $caparray ) )
	{
		echo ",CAPARRAY,'{$caparray}'";
	}
	if ( !empty( $capicaon ) )
	{
		echo ",CAPICON,'{$capicon}'";
	}
	if ( !empty( $snapx ) )
	{
		echo ",SNAPX,'{$snapx}'";
	}
	if ( !empty( $snapy ) )
	{
		echo ",SNAPY,'{$snapy}'";
	}
	if ( !empty( $fixx ) )
	{
		echo ",FIXX,'{$fixx}'";
	}
	if ( !empty( $fixy ) )
	{
		echo ",FIXY,'{$fixy}'";
	}
	if ( !empty( $background ) )
	{
		echo ",BACKGROUND,'{$background}'";
	}
	if ( !empty( $padx ) )
	{
		echo ",PADX,'{$padx}'";
	}
	if ( !empty( $pady ) )
	{
		echo ",PADY,'{$pady}'";
	}
	if ( !empty( $fullhtml ) )
	{
		echo ",FULLHTML";
	}
	if ( !empty( $frame ) )
	{
		echo ",FRAME,'{$frame}'";
	}
	if ( !empty( $timeout ) )
	{
		echo ",TIMEOUT,'{$timeout}'";
	}
	if ( !empty( $function ) )
	{
		echo ",FUNCTION,'{$function}'";
	}
	if ( !empty( $delay ) )
	{
		echo ",DELAY,'{$delay}'";
	}
	if ( !empty( $hauto ) )
	{
		echo ",HAUTO";
	}
	if ( !empty( $vauto ) )
	{
		echo ",VAUTO";
	}
	echo ");\" onMouseOut=\"nd();\"";
	return;
}

?>

⌨️ 快捷键说明

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