$Value ) { $_POST[$Key] = $_GET[$Key]; } # ********************************************************** # $_GET データを全て $_POST に転送して \' と \" を変換 # ********************************************************** foreach( $_POST as $Key => $Value ) { $_POST[$Key] = str_replace("\\\\", "\\", $Value ); $_POST[$Key] = str_replace("\\'", "'", $_POST[$Key] ); $_POST[$Key] = str_replace("\\\"", "\"", $_POST[$Key] ); } $base_param = "ret={$_POST['ret']}"; $base_param .= "&func={$_POST['func']}"; $base_param .= "&ai={$_POST['ai']}"; $base_param .= "&max={$_POST['max']}"; $base_param .= "&debug={$_POST['debug']}"; $base_param .= "&code={$_POST['code']}"; # ********************************************************** # 環境 # ********************************************************** define( 'COMMON_AUTHOR', 'LIGHTBOX' ); $COMMON_VERSION = '8.0307'; $PHP_VERSION = phpversion(); $HOME_URL = ""; // 戻る場所 $CLIENT_PATH = ""; // 外部スタイルシート等の場所(セットする場合最後に '/') $CLIENT_FONT_SIZE = "12px"; // デフォルトのフォントサイズ # ********************************************************** # 更新データセット # ********************************************************** function SetData( $Value, $Type ) { $ret; if ( trim( $Value ) == "" ) { $ret = "NULL"; } else { if ( $Type == 1 ) { $ret = str_replace( "'", "''", $Value ); $ret = Ss( $ret ); } else { $ret = $Value + 0; } } return $ret; } # ********************************************************** # テキストファイル一括読み込み # ********************************************************** function TxtGetAll( $Path ) { $txt_array = @file( $Path ); if ( $txt_array === FALSE ) { return FALSE; } $len = count( $txt_array ); for( $i = $len - 1; $i >= 0; $i-- ) { if ( substr( $txt_array[$i], 0, 1 ) == ';' ) { array_splice( $txt_array, $i, 1 ); } if ( substr( $txt_array[$i], 0, 2 ) == '--' ) { array_splice( $txt_array, $i, 1 ); } } $txt = implode( "", $txt_array ); return $txt; } function TxtPutAll( $Path, $text, $mode="a" ) { $ret; $handle = fopen( $Path, $mode ); fwrite( $handle, $text ); fclose( $handle ); } # ********************************************************** # 文字列内の PHP 変数を示す文字列のパース # 1) ApplyValue( "文字列" ); # 2) ApplyValue( "ファイルのパス", TRUE ); # ********************************************************** function ApplyValue( $Value, $flg=FALSE ) { if ( $flg ) { $Value = TxtGetAll( $Value ); } $Value = str_replace('"', '\\"', $Value ); eval("\$Value = \"$Value\";"); return $Value; } # ********************************************************** # ディリクトリリスト取得 ( 戻り値 : 配列 ) # ********************************************************** function GetDirList( $Path ) { $ret = array(); if ( $dh = opendir( "$Path" ) ) { while ( ($file = readdir($dh) ) !== false ) { if ( filetype( $Path . "/" . $file ) == 'dir' ) { if ( $file != "." && $file != ".." ) { $ret[] = $file; } } } closedir( $dh ); } return $ret; } # ********************************************************** # ダブルクォート表示用処理 # ********************************************************** function RestoreValue( ) { foreach( $_POST as $Key => $Value ) { $_POST[$Key] = str_replace("\"", """, $_POST[$Key] ); } } # ********************************************************** # クッキーデータの復帰 # ********************************************************** function RestoreCookie( ) { foreach( $_COOKIE as $Key => $Value ) { if ( substr( $Key, 0, 2 ) == 'In' ) { if ( !isset( $_POST[$Key] ) ) { $_POST[$Key] = str_replace("\\\\", "\\", $_COOKIE[$Key] ); $_POST[$Key] = str_replace("\\'", "'", $_POST[$Key] ); $_POST[$Key] = str_replace("\\\"", "\"", $_POST[$Key] ); } } } } # ********************************************************** # エラーメッセージのセット # ********************************************************** function SetError( $Message ) { $GLOBALS['ErrMessage'] = $Message; } # ********************************************************** # 引継ぎ用埋め込みデータの作成 # ********************************************************** function CreateInData( ) { global $InData; $InData = ""; foreach( $_POST as $Key => $Value ) { if ( substr( $Key, 0, 2 ) == "In" ) { if ( substr( $Key, 0, 3 ) != "In2" ) { $InData .= "\n"; } } else { if ( $Key == 'ret' || $Key == 'func' || $Key == 'ai' || $Key == 'debug' ) { $InData .= "\n"; } } } if ( $_POST['focus'] == 'yes' ) { ?> QueryEx( $Query ); $Ret = ""; while ( $Column ) { $Ret .= "\n"; $Column = $SQL->QueryEx( ); } return $Ret; } # ********************************************************** # リダイレクト # ********************************************************** function Redirect( $Target ) { header( "Location: $Target" ); } # ********************************************************** # DB 別挟み込み関数 # 1:MySQL, 2:SQLServer # ********************************************************** function DBEnclose( $strValue, $Type ) { $strRet = ""; switch( $Type ) { case 1: $strRet = Enclose( $strValue, "`", 0 ); break; case 2: $strRet = Enclose( "[", "]", 2, $strValue ); break; case 3: case 5: case 6: # $strRet = Enclose( $strValue, "\"", 0 ); $strRet = $strValue; break; case 4: $strRet = Enclose( "[", "]", 2, $strValue ); break; } return $strRet; } # ********************************************************** # DB 別挟み込み削除関数 # 1:MySQL, 2:SQLServer # ********************************************************** function RemoveDBEnclose( $strValue, $Type ) { $strRet = ''; if ( $GLOBALS['conf_client_charset'] != "" ) { mb_regex_encoding($GLOBALS['conf_client_charset']); } switch( $Type ) { case 1: $strRet = str_replace( "`", "", $strValue ); break; case 2: case 4: $strRet = mb_ereg_replace("[\[\]]", "", $strValue ); break; case 3: case 5: case 6: $strRet = str_replace( "\"", "", $strValue ); break; break; } 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 .= ""; break; # 左右挟み込み case 2: $strRet = $strValue . $Option . $Chr; break; } return $strRet; } # ********************************************************** # ' 挟み込み関数 # ********************************************************** function Ss( $strValue ) { return Enclose( $strValue, "'", 0 ); } # ********************************************************** # " 挟み込み関数 # ********************************************************** function Dd( $strValue ) { return Enclose( $strValue, "\"", 0 ); } # ********************************************************** # 改行付表示関数 # ********************************************************** function OutCr( $strValue ) { print $strValue . "\n"; } # ********************************************************** # デバッグ用情報表示関数 # ********************************************************** function DispHash( &$Hash, $strTitle="" ) { $Option = "bgcolor=white"; OutCr( "" ); OutCr( Th( "$strTitle 名称", "bgcolor=silver" ) ); OutCr( Th( 内容, "bgcolor=silver" ) ); foreach( $Hash as $Key => $Value ) { OutCr( "" ); OutCr( Td( $Key, $Option ) ); OutCr( Td( $Value, $Option ) ); OutCr( "" ); } OutCr( "
" ); } # ********************************************************** # デバッグ用グローバル変数表示関数 # ********************************************************** # ********************************************************** # デバッグ用グローバル変数表示関数 # ********************************************************** function DispGlobal( ) { $Option = "bgcolor=white"; OutCr( "" ); OutCr( Th( "グローバル変数", "bgcolor=silver" ) ); OutCr( Th( 内容, "bgcolor=silver" ) ); $flg = FALSE; foreach( $GLOBALS as $Key => $Value ) { if ( $Key == 'COMMON_VERSION' ) { $flg = TRUE; } if ( $flg ) { if ( substr( $Key, 0, 7 ) != 'OutData' ) { OutCr( "" ); OutCr( Td( $Key, $Option ) ); if ( is_string( $Value ) ) { $Value = str_replace('&', '&', $Value ); $Value = str_replace('<', '<', $Value ); $Value = str_replace('>', '>', $Value ); } if ( is_object($Value) ) { OutCr( Td( "OBJECT:" . get_class($Value) , "bgcolor=skyblue" ) ); } else { OutCr( Td( $Value, $Option ) ); } OutCr( "" ); } } } OutCr( "
" ); } # ********************************************************** # デバッグ用情報表示関数 # ********************************************************** function DispDebug( $strType="MISS" ) { $TableTag = ""; $Err = "デバッグ用情報表示関数への引数が誤っています"; $Option = "bgcolor=white"; switch( $strType ) { case "VER": OutCr( $TableTag ); OutCr( Th( "現在のPHPバージョン", "bgcolor=silver" ) ); OutCr( "" ); OutCr( Td( phpversion(), $Option ) ); OutCr( "" ); OutCr( "
" ); 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, $Option ) ); OutCr( "" ); break; } } # ********************************************************** # 挟み込み関数 # ********************************************************** function Th( $strValue, $Option="" ) { return Enclose( $strValue, "TH", 1, $Option ); } # ********************************************************** # 挟み込み関数 # ********************************************************** function Td( $strValue, $Option="" ) { return Enclose( $strValue, "TD", 1, $Option ); } # ********************************************************** # デバッグ用メッセージの表示 (1) # ********************************************************** function DispData( $actFlg, $flg=TRUE ) { if ( $flg ) { if ( $actFlg ) { DispHash( $_GET, "GET" ); DispHash( $_POST, "POST" ); DispHash( $_COOKIE, "COOKIE" ); if ( isset( $_SESSION ) ) { DispHash( $_SESSION, "SESSION" ); } DispGlobal(); } } } # ********************************************************** # デバッグ用メッセージの表示 (2) # ********************************************************** function DispArray( &$Array ) { OutCr( "
" );
	print_r( $Array );
	OutCr( "
" ); } # ********************************************************** # デバッグ用メッセージの表示 (3) # ********************************************************** function DispDump( &$Var ) { var_dump( $Var ); } # ********************************************************** # DTPicker の value 属性用の値の取得 # 9999/99/99 ????? または 9999-99-99 ????? # という入力文字列を処理する # それ以外の文字列が渡されると当日の文字列を使用する # (時間は切り捨てる) # ********************************************************** function GetDtpValue( $strDate ) { $Base = gregoriantojd(12,30,1899); $Target = gregoriantojd(Date("n"),Date("j"),Date("Y")); $strDelim = "\0"; if ( FALSE !== strpos( $strDate, "/" ) ) { $strDelim = "/"; } if ( FALSE !== strpos( $strDate, "-" ) ) { $strDelim = "-"; } $DatePart = explode( $strDelim, $strDate ); if ( is_array( $DatePart ) ) { $Cnt = count( $DatePart ); if ( $Cnt >= 3 ) { if ( $DatePart[0] < 50 ) { $DatePart[0] += 2000; } if ( $DatePart[0] < 100 ) { $DatePart[0] += 1900; } $DatePart2 = explode( " ", $DatePart[2] ); $Target = gregoriantojd( $DatePart[1], $DatePart2[0], $DatePart[0] ); } } return( $Target - $Base ); } # ********************************************************** # DTPicker が POST した 月/日/年 を 年/月/日 に変換する # (時間は切り捨てる) # ********************************************************** function GetDtpPostValue( $strDate ) { $strDelim = ""; if ( FALSE !== strpos( $strDate, "/" ) ) { $strDelim = "/"; } if ( FALSE !== strpos( $strDate, "-" ) ) { $strDelim = "-"; } $DatePart = explode( $strDelim, $strDate ); $DatePart2 = explode( " ", $DatePart[2] ); if ( $DatePart2[0] < 50 ) { $DatePart2[0] += 2000; } if ( $DatePart2[0] < 100 ) { $DatePart2[0] += 1900; } return $DatePart2[0] . "/" . $DatePart[0] . "/" . $DatePart[1]; } ?>