関数の標準化

  COMMON.PHP



  
<?
header( "Content-Type: text/html; Charset=shift_jis" );

# **********************************************************
# 環境
# **********************************************************
define( 'COMMON_CLIENT_PATH', '/localweb/skeleton/require/' );
$CLIENT_FONT = 'MS Pゴシック';

# **********************************************************
# キャラクタセットを指定するMETAタグ文字列作成関数
# **********************************************************
function HtmlCharset( $Target ) {

	$strRet = '<META';
	$strRet .= ' http-equiv="Content-type"';
	$strRet .= " content=\"text/html; charset=$Target\">";

	return $strRet;

}

# **********************************************************
# 挟み込み関数
# **********************************************************
function Enclose( $strValue, $Chr, $Type, $Option="" ) {

	$strRet = "";

	switch( $Type ) {
		# 単純挟み込み
		case 0:
			$strRet = $Chr . $strValue . $Chr;
			break;
		# HTML挟み込み
		case 1:
			$strRet = "<" . $Chr . " " . $Option . ">";
			$strRet .= $strValue;
			$strRet .= "</" . $Chr . ">";
			break;
	}

	return $strRet;

}

# **********************************************************
# ' 挟み込み関数
# **********************************************************
function Ss( $strValue ) {

	return Enclose( $strValue, "'", 0 );

}

# **********************************************************
# " 挟み込み関数
# **********************************************************
function Dd( $strValue ) {

	return Enclose( $strValue, "\"", 0 );

}

# **********************************************************
# <TH> 挟み込み関数
# **********************************************************
function Th( $strValue, $Option="" ) {

	return Enclose( $strValue, "TH", 1, $Option );

}

# **********************************************************
# <TD> 挟み込み関数
# **********************************************************
function Td( $strValue, $Option="" ) {

	return Enclose( $strValue, "TD", 1, $Option );

}

# **********************************************************
# <A href> 挟み込み関数
# **********************************************************
function Alink( $Url, $strValue, $Option="" ) {

	return Enclose( $strValue, "A", 1, "href=" . Dd($Url) . " " . $Option );

}

# **********************************************************
# <DIV> 挟み込み関数
# **********************************************************
function Div( $strValue, $Option="" ) {

	return Enclose( $strValue, "DIV", 1, $Option );

}

# **********************************************************
# 改行付表示関数
# **********************************************************
function OutCr( $strValue ) {

	print $strValue . "\n";

}

# **********************************************************
# タイトル表示関数
# **********************************************************
function DispTitle( $strTitle ) {

	$strValue = Div( $strTitle, "style='margin-top:5'" );
	$strValue = Div( $strValue, "class=SYSTEM_TITLE" );

	OutCr( $strValue );

}

# **********************************************************
# ウインドウ最大化JavaScript出力関数
# **********************************************************
function MaxWindow( ) {

	OutCr( '<!-- ' . str_repeat("*", 75) );
	OutCr( ' ページロード時の初期処理' );
	OutCr( str_repeat("*", 76) . ' -->' );
	OutCr( '<SCRIPT FOR=window EVENT=onload LANGUAGE=JavaScript>' );
	OutCr( '' );
	OutCr( '	window.focus();' );
	OutCr( '	top.moveTo( 0, 0 );' );
	OutCr( '	top.resizeTo( screen.width, screen.height - 32 );' );
	OutCr( '' );
	OutCr( '</SCRIPT>' );

}

# **********************************************************
# デバッグ用情報表示関数
# **********************************************************
function DispHash( &$Hash, $strTitle="" ) {

	$Class = "class=DEBUG_TITLE";

	OutCr( "<TABLE border=4 cellpadding=5 bgcolor=WHITE style='border-style:ridge'>" );
	OutCr( Th( "$strTitle 名称", $Class ) );
	OutCr( Th( 内容, $Class ) );
	foreach( $Hash as $Key => $Value ) {
		OutCr( "<TR>" );
		OutCr( Td( $Key ) );
		if ( $Value == "" ) {
			OutCr( Td( "&nbsp;" ) );
		}
		else {
			OutCr( Td( $Value ) );
		}
		OutCr( "</TR>" );
	}
	OutCr( "</TABLE>" );

}

# **********************************************************
# デバッグ用情報表示関数
# **********************************************************
function DispDebug( $strType="MISS" ) {

	$TableTag = "<TABLE border=4 cellpadding=5 bgcolor=WHITE style='border-style:ridge'>";
	$Err = "デバッグ用情報表示関数への引数が誤っています";
	$Class = "class=DEBUG_TITLE";

	switch( $strType ) {
		case "VER":
			OutCr( $TableTag );
			OutCr( Th( "現在のPHPバージョン", $Class ) );
			OutCr( "<TR>" );
			OutCr( Td( phpversion() ) );
			OutCr( "</TR>" );
			OutCr( "</TABLE>" );
			break;

		case "POST":
			DispHash( $_POST, "POST" );
			break;

		case "GET":
			DispHash( $_GET, "GET" );
			break;

		case "SESSION":
			if ( isset( $_SESSION ) ) {
				DispHash( $_SESSION, "SESSION" );
			}
			break;

		case "ENV":
			DispHash( $_ENV, "ENV" );
			break;

		case "SERVER":
			DispHash( $_SERVER, "SERVER" );
			break;

		case "COOKIE":
			DispHash( $_COOKIE, "COOKIE" );
			break;

		case "REQUEST":
			DispHash( $_REQUEST, "REQUEST" );
			break;

		default:
			OutCr( $TableTag );
			OutCr( Th( $Err, $Class ) );
			OutCr( "</TABLE>" );
			break;
	}

}

# **********************************************************
# デバッグ用メッセージの表示
# **********************************************************
function DispData() {

	DispHash( $_GET, "GET" );
	DispHash( $_POST, "POST" );
	if ( isset( $_SESSION ) ) {
		DispHash( $_SESSION, "SESSION" );
	}

}

# **********************************************************
# デバッグ用メッセージの表示
# **********************************************************
function DispArray( &$Array ) {

	OutCr( "<PRE>" );
	print_r( $Array );
	OutCr( "</PRE>" );

}

# **********************************************************
# プロテクト関数
# **********************************************************
function SetProtect( $nMode ){

	global $DisPass,$DisType,$Dis;

	if ( $nMode != 3 ) {
		foreach( $DisPass as $Key => $Value ) {
			if ( $Value == 1 ) {
				$Dis[$Key] = $DisType[$Key];
			}
			if ( $Value == 2 ) {
				$Dis[$Key] = '';
			}
		}
	}
	else {
		foreach( $DisPass as $Key => $Value ) {
			if ( $Key == 'Update' ) {
				$Dis[$Key] = '';
			}
			else {
				$Dis[$Key] = $DisType[$Key];
			}
		}
	}
}

# **********************************************************
# 隠しフィールド作成関数
# **********************************************************
function SetHidden( $strField ){

	global $Option ;

	$Option .= '<INPUT type=hidden name=' . $strField . ' value=';
	$Option .= Dd( $_POST[ $strField ] );
	$Option .= '>';

}

# **********************************************************
# メッセージ表示関数
# **********************************************************
function SetMessage( $strMes ){

	global $Option ;
	$Option .= $strMes;

}

# **********************************************************
# データ処理関数(PASS グループ,プロテクトタイプ,初期プロテクトの設定)
# **********************************************************
function SetPassData( $fileName ){

	global $DisPass,$DisType,$Dis;

		$fp = fopen( $fileName, "r" );

			while( 1 ) {

				$buffer = fgets( $fp );

				if ( feof( $fp ) ) {
					break;
				}
					$buffer = rtrim ( $buffer,"\n\r" );

					list($Field,$Pass,$Type,$Init) = explode("\t",$buffer);

# $Passの値 1or2を PASSグループに代入。

					$DisPass[ $Field ] = $Pass;

# $Typeの値 TXT_PROTECTorBTN_PROTECTを プロテクトタイプグループに代入。

					if ( $Type == "TXT_PROTECT" ){
						$DisType[ $Field ] = TXT_PROTECT;
					}
					else {
						$DisType[ $Field ] = BTN_PROTECT;
					}

# $Initの値 TXT_PROTECTorBTN_PROTECTor ""を 初期プロテクトに代入。

					switch ( $Init ) {
						case 'TXT_PROTECT':
							$Dis[ $Field ] = TXT_PROTECT;
							break;
		
						case 'BTN_PROTECT':
							$Dis[ $Field ] = BTN_PROTECT;
							break;
		
						default:
							$Dis[ $Field ] = "";
							break;
					}
			}
			fclose( $fp );
}

?>
  



  STYLE.PHP



  
<STYLE type="text/css">

	.SYSTEM_TITLE {
		background-color:MIDNIGHTBLUE;
		color:WHITE;
		border-style:ridge;
		font-family:'<?=$CLIENT_FONT?>';
		font-size:20;
		font-weight:bold;
		text-align:center;
		height:40;
	}

	.DEBUG_TITLE {
		background-color:FORESTGREEN;
		color:WHITE;
	}

</STYLE>
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ