T_RESULT USE /************************************************************ '* 文字列長さ取得 '***********************************************************/ function LenA($str){ $len = strlen($str); for ($i=1;$i<=$len; $i++) { $nA = ord($str); if(0<=$nA && nA <256 ) { $nLen = $nLen +1; } else { $nLen = $nLen +2; } } $LenA = $nLen; return $LenA; } /************************************************************ '* 文字列処理 '***********************************************************/ function dfstr($inStr){ if(is_null($inStr) || $inStr == ""){ return "''"; } // $strWork = ereg_replace("", "."".",$inStr); // $strWork = ereg_replace("'", "''",$inStr); $strWork = htmlspecialchars($inStr); $strWork = "'$strWork'"; $dfstr = $strWork; return $dfstr; } /************************************************************ '* Ji.M.K '***********************************************************/ function dfdate_compare($indate){ if (datecheck($indate)) { exit(); } $stmp = ":00"; $strWork = date("YmdHi'$stmp'"); //just a moment ..think } /************************************************************ '* 日付処理 '***********************************************************/ function dfdate($indate){ $tmp = explode("/", $indate); $Ydate = $tmp[0]; $Mdate = $tmp[1]; $Ddate = substr($tmp[2],0,2); if(!checkdate($Mdate, $Ddate, $Ydate)){ exit(); } $indate = mktime(0,0,0,$Mdate,$Ddate,$Ydate); $strWork = date(Y, $indate)."/".date(m, $indate)."/".date(d, $indate); $strWork = $strWork." ".date(H, $indate).":".date(i, $indate).":00"; $strWork = "'".$strWork."'"; //SQL Server return $strWork; } /************************************************************ '* 数字処理 '***********************************************************/ function dfNumber($indata,$inKeta,$inShosuKeta){ if(!is_numeric($indata)){ return false; exit(); } if(!is_numeric($inKeta)){ return false; exit(); } $inShosKeta = intval($inShosKeta); if(!is_numeric($inShosKeta)){ return false; exit(); } //数値変換する $strWork = $indata * 1; //整数部と小数部に分ける $strWork = explode(".", $strWork); // if ubound(strWork) > 0 then // strRet = Right(String(inKeta,"0") & strWork(0),inKeta) & "." & _ // Right(String(Len(strWork(1)),"0") & strWork(1),Len(strWork(1))) // else // strRet = Right(String(inKeta,"0") & strWork(0),inKeta) // end if //整数部の左側にゼロ埋めをする if(count($strWork) > 1){ $strRet = substr(str_repeat("0", $inKeta).$strWork[0], -($inKeta)).".".substr(str_repeat("0", strlen($strWork[1])).$strWork[1], -(strlen($strWork[1]))); }else{ $strRet = substr(str_repeat("0", $inKeta).$strWork[0], -($inKeta)); } return $strRet; } /************************************************************ '* 半角化処理 '***********************************************************/ function ZenToHan($indata) { define("csSplit","|"); $ZenToHan = $indata; if(is_null($indata)) { return false; exit; } if(trim($indata)=="") { return false; exit; } // '前後のスペースを除去する $indata = Trim($indata); if((strlen($indata) == 2) && (bin2hex($indata) == 8140)) { $ZenToHan = ""; return $ZenToHan; } //'数値変換する $strWork = explode(csSplit,$indata); for ($i=0;$i0 ) { $strWork[$i] = ereg_Replace($temp,$temp1,$strWork[$i]); } } $strRet = $strRet.$strWork[$i].csSplit; } // '最後の区切り文字を除去する if(substr($strRet,-1) == csSplit) { $len = strlen($strRet); $strRet=(substr($strRet,0,$len-1)); } $ZenToHan =$strRet; return $ZenToHan; } /************************************************************ '* 半角カタカナ→全角カタカナ '* 半角化処理(英数字記号) '* 半角化処理(英数字) '***********************************************************/ function RE_ZENtoHAN_SJIS($str_ZEN) { $kana_sjis = array( 0x00A7,0x00B1,0x00A8,0x00B2,0x00A9,0x00B3,0x00AA,0x00B4,0x00AB,0x00B5, 0x00B6,0xB6DE,0x00B7,0xB7DE,0x00B8,0xB8DE,0x00B9,0xB9DE,0x00BA,0xBADE, 0x00BB,0xBBDE,0x00BC,0xBCDE,0x00BD,0xBDDE,0x00BE,0xBEDE,0x00BF,0xBFDE, 0x00C0,0xC0DE,0x00C1,0xC1DE,0x00AF,0x00C2,0xC2DE,0x00C3,0xC3DE,0x00C4, 0xC4DE,0x00C5,0x00C6,0x00C7,0x00C8,0x00C9,0x00CA,0xCADE,0xCADF,0x00CB, 0xCBDE,0xCBDF,0x00CC,0xCCDE,0xCCDF,0x00CD,0xCDDE,0xCDDF,0x00CE,0xCEDE, 0xCEDF,0x00CF,0x00D0,0x0000,0x00D1,0x00D2,0x00D3,0x00AC,0x00D4,0x00AD, 0x00D5,0x00AE,0x00D6,0x00D7,0x00D8,0x00D9,0x00DA,0x00DB,0x0000,0x00DC, 0x0000,0x0000,0x00A6,0x00DD,0xB3DE,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 ); $sym_sjis = array( 0x20,0xA4,0xA1,0x00,0x2E,0xA5,0x00,0x00,0x00,0x00,0xDE,0xDF,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28, 0x29,0x00,0x00,0x5B,0x5D,0x00,0x00,0x00,0x00,0x00,0x00,0xA2,0xA3,0x00, 0x00,0x00,0x00,0x2B,0x2D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x2A,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ); $str_HAN = ''; $b = unpack("C*", $str_ZEN); $n = count($b); for ($i = 1; $i <= $n; $i++) { $b1 = $b[$i]; if ($b1 >= 0x80) { $b2 = $b[$i+1]; if ($b1 == 0x83 // Katakanaは そのまま && (0x3F < $b2 && $b2 < 0x9F)) { $str_HAN .= chr($b1).chr($b2); } elseif ($b1 == 0x81 // Symbol && (0x3F < $b2 && $b2 < 0x9F)) { $c1 = $sym_sjis[ $b2 - 0x40 ]; if ($c1 == 0x00) { $str_HAN .= chr($b1).chr($b2); } else { $str_HAN .= chr($c1); } } elseif ($b1 == 0x82 // Alphabet & Number && (0x3F < $b2 && $b2 < 0x9F)) { if ($b[$i+1] < 0x80) { $str_HAN .= chr($b2 - 0x1F); } else { $str_HAN .= chr($b2 - 0x20); } } else { // Rest of Zenkaku $str_HAN .= chr($b1).chr($b2); } $i++; } else { // ASCII $str_HAN .= chr($b1); } } return $str_HAN; } /************************************************************ '* 文字長カウント処理 '***********************************************************/ function GetLen($inStr){ $nLen = strlen($inStr); $nResult = 0 ; for( $nP=0 ;$nP < $nLen; $i++); { $Tarray = array($inStr); $md = $Tarray[$nP]; $nA = ord($md); if(($nA>=0) && ($nA <256)) { $nResult = $nResult +1; } else { $nResult = $nResult +2; } } return $nResult; } /************************************************************ '* 英字省略化処理 '***********************************************************/ function LegularToOmit($inStr){ $strWork; $strWork = $inStr; $strWork = ereg_Replace("That is","That's",$strWork); $strWork = ereg_Replace("is not","isn't",$strWork); $strWork = ereg_Replace("What is","What's",$strWork); $strWork = ereg_Replace("It is","It's",$strWork); $strWork = ereg_Replace("I am","I'm",$strWork); $strWork = ereg_Replace("you are","you're",$strWork); $strWork = ereg_Replace("are not","aren't",$strWork); $strWork = ereg_Replace("He is","He's",$strWork); $strWork = ereg_Replace("She is","She's",$strWork); $strWork = ereg_Replace("Who is","Who's",$strWork); $strWork = ereg_Replace("can not","can't",$strWork); $strWork = ereg_Replace("was not","wasn't",$strWork); $strWork = ereg_Replace("were not","weren't",$strWork); $strWork = ereg_Replace("They are","They're",$strWork); $strWork = ereg_Replace("We are","We're",$strWork); $strWork = ereg_Replace("have not","haven't",$strWork); $strWork = ereg_Replace("has not","hasn't",$strWork); $strWork = ereg_Replace("do not","don't",$strWork); $strWork = ereg_Replace("does not","doesn't",$strWork); $strWork = ereg_Replace("did not","didn't",$strWork); $strWork = ereg_Replace("I will","I'll",$strWork); $strWork = ereg_Replace("will not","won't",$strWork); $strWork = ereg_Replace("could not","couldn't",$strWork); $strWork = ereg_Replace("would not","wouldn't",$strWork); $strWork = ereg_Replace("should not","shouldn't",$strWork); $strWork = ereg_Replace("Let us","Let's",$strWork); $strWork = ereg_Replace("let us","let's",$strWork); // $strWork = ereg_Replace(" .",".",$strWork); // $strWork = ereg_Replace(". ",".",$strWork); $strWork = ereg_Replace(" ,",",",$strWork); $strWork = ereg_Replace(", ",",",$strWork); $strWork = ereg_Replace(" ?","?",$strWork); $strWork = ereg_Replace("? ","?",$strWork); $strWork = ereg_Replace(" !","!",$strWork); $strWork = ereg_Replace("! ","!",$strWork); return $strWork; } /************************************************************ '* 英字正式化処理 '***********************************************************/ function OmitToLegular($inStr){ $strWork; $strWork = $inStr; $strWork = ereg_Replace("That's","That is",$strWork); $strWork = ereg_Replace("isn't","is not",$strWork); $strWork = ereg_Replace("What's","What is",$strWork); $strWork = ereg_Replace("It's","It is",$strWork); $strWork = ereg_Replace("I'm","I am",$strWork); $strWork = ereg_Replace("You're","You are",$strWork); $strWork = ereg_Replace("aren't","are not",$strWork); $strWork = ereg_Replace("He's","He is",$strWork); $strWork = ereg_Replace("She's","She is",$strWork); $strWork = ereg_Replace("Who's","Who is",$strWork); $strWork = ereg_Replace("can't","can not",$strWork); $strWork = ereg_Replace("cannot","can not",$strWork); $strWork = ereg_Replace("wasn't","was not",$strWork); $strWork = ereg_Replace("weren't","were not",$strWork); $strWork = ereg_Replace("They're","They are",$strWork); $strWork = ereg_Replace("We're","We are",$strWork); $strWork = ereg_Replace("haven't","have not",$strWork); $strWork = ereg_Replace("hasn't","has not",$strWork); $strWork = ereg_Replace("don't","do not",$strWork); $strWork = ereg_Replace("doesn't","does not",$strWork); $strWork = ereg_Replace("didn't","did not",$strWork); $strWork = ereg_Replace("I'll","I will",$strWork); $strWork = ereg_Replace("won't","will not",$strWork); $strWork = ereg_Replace("couldn't","could not",$strWork); $strWork = ereg_Replace("wouldn't","would not",$strWork); $strWork = ereg_Replace("shouldn't","should not",$strWork); $strWork = ereg_Replace("Let's","Let us",$strWork); $strWork = ereg_Replace("let's","let us",$strWork); // $strWork = ereg_Replace(" .",".",$strWork); // $strWork = ereg_Replace(". ",".",$strWork); $strWork = ereg_Replace(" ,",",",$strWork); $strWork = ereg_Replace(", ",",",$strWork); // $strWork = ereg_Replace(" ?","?",$strWork); // $strWork = ereg_Replace("? ","?",$strWork); $strWork = ereg_Replace(" !","!",$strWork); $strWork = ereg_Replace("! ","!",$strWork); return $strWork; } /************************************************************ '* 区切り指定文字列を??トして、重複を削除した区切り文字列を返す not yet '**********************************************************/ function ArrayUniq($indata,$inKugiri) { $ArrayUniq = $indata; if($indata == "" ) { return false; exit; } if($inKugiri == "") { return false; exit; } $aryData = explode($inKugiri,$indata); //$result = array_unique($aryData); // 02.10.4 revised //$strWork = $result[0]; // 02.10.4 revised $strWork = $aryData[0]; for ($i =1; $i < count($aryData);$i++) { //if ($aryData[$i-1] != $aryData[$i]) { // 02.10.4 revised $strWork = $strWork . $inKugiri . $aryData[$i]; //} } $ArrayUniq = $strWork; return $ArrayUniq; } /************************************************************ '* 採点の登録 '************************************************************/ function SetResult($inID,$inQNO,$inUSERID,$inRESULT,$inTABLE,$inTABLE_ANSWER,$inTABLE_RESULT,$DBSet) { $csExt = ".txt"; $csSplit = "|"; $csSENTAKU = "s"; $ANS_CNT = array_pad(array(),100,0); $ANS_VAL = array_pad(array(),100,0); $RESULT = array_pad(array(),100,0); global $m; //'初期値設定 $SetResult = ""; //'引数のチェック if (!Is_Numeric($inID)) {return false; exit;} if (Is_Null($inQNO)) {return false; exit;} if (!Is_Numeric($inUSERID)) {return false; exit;} if (!Is_Array($inRESULT)) {return false; exit;} if ($inTABLE_ANSWER == "") {return false; exit;} if ($inTABLE_RESULT == "") {return false; exit;} $T_ANS = $inTABLE_ANSWER; $T_RES = $inTABLE_RESULT; $strSQL = "SELECT FILE_URL FROM ". $inTABLE . " WHERE ID = ". $inID . " AND DELETE_FLG = 0"; $DBSet->parse($strSQL); $nRowCnt = $DBSet->RecordCount; if($nRowCnt > 0) { $PATH = $DBSet->fieldbyName("FILE_URL"); $PATH = GetFile($PATH); }else { return false; } // echo "path:".$PATH."
"; // echo "qno:".$inQNO."
"; // echo "table:".$inTABLE."
"; $rtnFile = SetResult_GetPath($PATH,$inQNO,$inTABLE); if($rtnFile == "") { return false; } $strAnswerValue = SetResult_GetAnswerValue($rtnFile); if($strAnswerValue == false ) { return false; } for($i=0; $i ------------------------------------ // '正解の取得 // $strSQL = "SELECT Q_CNT,A001 FROM " . $T_ANS . " WHERE ID = " . $inID . // " AND QNO = " . dfstr($inQNO) . // " AND DELETE_FLG = 0" . // " ORDER BY Q_CNT"; // " AND DELETE_FLG = 0" . // 03.01.22 add // $DBSet->parse($strSQL); // $ncnt = 1; // while($ncnt <= $DBSet->RecordCount) { // $i = round($DBSet->fieldbyname("Q_CNT"),0); // $i = $i -1; // $ANS_CNT[$i] = round(substr($DBSet->fieldbyname("A001"),0,2),0); // $ANS_VAL[$i] = substr($DBSet->fieldbyname("A001"),3); // $DBSet->Next(); // $ncnt++; // } // $COUNT = $i +1; //---------------------- 03.04.14 delete < end > ------------------------------------ //'採点 if (strtolower(substr($inQNO,4,1)) == $csSENTAKU ) { //'選択式の時、問題数分のループ処理で採点する for ($i = 0;$i < $COUNT;$i++) { $RESULT[$i] = 0; $nCount = 0 ; //'解答と正解が入っているものを採点対象にする if (($inRESULT[$i] <> "") && ($ANS_VAL[$i] <> "")) { //'正解の配列化 $strWork = explode($csSplit,$ANS_VAL[$i]); $inRESULT[$i] = OmitToLegular($inRESULT[$i]); //'英字(省略化→正規) // 2003.5.20 M.Hamasaki // 英語問題のスペース対策 $pat = array( "/\s+/", "/(^\s+|\s+$)/", "/\s\./", "/\s\?/", "/\s,/" ); $rep = array( " ", "", ".", "?", "," ); $inRESULT[$i] = preg_replace( $pat, $rep, $inRESULT[$i] ); //'正解の配列数分のループ処理 for ($j = 0;$j ------------------------------------ // if (Is_Numeric($strWork[$j])) { // $strWork[$j] = $strWork[$j] * 1; // }else { //---------------------- 03.04.14 delete < end > ------------------------------------ // $strWork[$j] = ZenToHan($strWork[$j]); // } if ($ANS_CNT[$i] == 1 ) { //'正解が1つの時は、完全一致とする if ($strWork[$j] == $inRESULT[$i]) { $nCount = $nCount + 1; } }else { //'正解が2つ以上の時は、存在すればOKとする if(stristr($inRESULT[$i],$strWork[$j])) { // 03.04.14 stristr() add $nCount = $nCount + 1; } } }// the end of for if ($nCount >= $ANS_CNT[$i]) { $RESULT[$i] = 1; } }// the end of if } //'正解数の算出 $SEIKAI_CNT = 0; for ($i = 0;$i < $COUNT;$i++) { $SEIKAI_CNT = $SEIKAI_CNT + $RESULT[$i]; } }else { $SEIKAI_CNT = 0; //'記述式の時採点しない } $strSQL = "SELECT COUNT(*) AS CNT FROM " . $T_RES . " WHERE ID = " . $inID . " AND QNO = " . dfstr($inQNO) . " AND USERID = " . $inUSERID; " AND DELETE_FLG = 0"; // " AND DELETE_FLG = 0"; // 03.01.22 add $DBSet->parse($strSQL); //------------------------- 03.01.23 add -------------------------------------- if ($T_RES == "T_RESULT") { if (round($DBSet->fieldbyname("CNT"),0) == 0 ) { //'採点の登録 $strSQL = "INSERT INTO " . $T_RES . "(ID,QNO,USERID,Q_CNT,SEIKAI_CNT"; if (strtolower(substr($inQNO,4,1)) == $csSENTAKU ) { for ($i = 1;$i <= $COUNT;$i++) { $strSQL = $strSQL . ",A" . substr("00" . $i,-3); } } $strSQL = $strSQL . ",CREATEDATE, SEQ_NO,UPDATEDATE) VALUES" . "(" . $inID . "," . dfstr($inQNO) . "," . $inUSERID . "," . $COUNT . "," . $SEIKAI_CNT; if (strtolower(substr($inQNO,4,1)) == $csSENTAKU ) { for ($i = 0;$i< $COUNT;$i++) { $strSQL = $strSQL . "," . $RESULT[$i]; } } $strSQL = $strSQL .",". dfstr(GetNow()) ; $strSQL = $strSQL .",". $m ; $strSQL = $strSQL .",". dfstr(GetNow()).")"; // 03.04.22 UPDATEDATE add }else { //'採点の更新 $strSQL = "UPDATE " . $T_RES . " SET" . " Q_CNT = " . $COUNT . ",SEIKAI_CNT = " . $SEIKAI_CNT . ",UPDATEDATE = " . dfstr(GetNow()); if (strtolower(substr($inQNO,4,1)) == $csSENTAKU ) { for ($i = 1;$i<= $COUNT;$i++) { $strSQL = $strSQL . ",A" . substr("00" . $i,-3); $i = $i -1; $strSQL = $strSQL . " = " . $RESULT[$i]; $i = $i +1; } } $strSQL = $strSQL . " WHERE ID = " . $inID . " AND QNO = " . dfstr($inQNO) . " AND USERID = " . $inUSERID; } $m = $m + 1; }else { //------------------------- 03.01.23 add -------------------------------------- if (round($DBSet->fieldbyname("CNT"),0) == 0 ) { //'採点の登録 $strSQL = "INSERT INTO " . $T_RES . "(ID,QNO,USERID,Q_CNT,SEIKAI_CNT"; if (strtolower(substr($inQNO,4,1)) == $csSENTAKU ) { for ($i = 1;$i <= $COUNT;$i++) { $strSQL = $strSQL . ",A" . substr("00" . $i,-3); } } $strSQL = $strSQL . ",CREATEDATE,UPDATEDATE) VALUES" . "(" . $inID . "," . dfstr($inQNO) . "," . $inUSERID . "," . $COUNT . "," . $SEIKAI_CNT; if (strtolower(substr($inQNO,4,1)) == $csSENTAKU ) { for ($i = 0;$i< $COUNT;$i++) { $strSQL = $strSQL . "," . $RESULT[$i]; } } $strSQL = $strSQL .",". dfstr(GetNow()) ; $strSQL = $strSQL .",". dfstr(GetNow()).")"; // 03.04.22 UPDATEDATE add }else { //'採点の更新 $strSQL = "UPDATE " . $T_RES . " SET" . " Q_CNT = " . $COUNT . ",SEIKAI_CNT = " . $SEIKAI_CNT . ",UPDATEDATE = " . dfstr(GetNow()); if (strtolower(substr($inQNO,4,1)) == $csSENTAKU ) { for ($i = 1;$i<= $COUNT;$i++) { $strSQL = $strSQL . ",A" . substr("00" . $i,-3); $i = $i -1; $strSQL = $strSQL . " = " . $RESULT[$i]; $i = $i +1; } } $strSQL = $strSQL . " WHERE ID = " . $inID . " AND QNO = " . dfstr($inQNO) . " AND USERID = " . $inUSERID; } } $DBSet->parse($strSQL); $DBSet->Close(); return true; } //////////////////////////////////////////////////////////////////////// // user Function // // Seperate date function Date_Se($date) { $Se_date[0] = substr($date,0,4); $Se_date[1] = substr($date,4,2); $Se_date[2] = substr($date,6,2); $Se_date[3] = substr($date,8,2); $Se_date[4] = substr($date,10,2); $Se_date[5] = substr($date,12,2); $SetValue = $Se_date[0]."/".$Se_date[1]."/".$Se_date[2]." ".$Se_date[3].":".$Se_date[4].":".$Se_date[5]; return $SetValue; } //////////////////////////////////////////////// // // NOW // // /////////////////////////////////////////////// function GetNow(){ $date = date("Y/m/d H:i:s"); return $date; } /////////////////////////////////////////////////// function Date_SeYMD($date) { $Se_date[0] = substr($date,0,4); $Se_date[1] = substr($date,4,2); $Se_date[2] = substr($date,6,2); $SetValue = $Se_date[0]."/".$Se_date[1]."/".$Se_date[2]; return $SetValue; } ////////////////////////////////////////////////////////////////////// // SetMaxCount ////////////////////////////////////////////////////////////////////// function SetMaxCount($T_NAME,$TEMP,$DBSet){ $strSQL = "select MAXNO from ".$TEMP." where TNAME = '$T_NAME'"; $DBSet->parse($strSQL); $tmp = $DBSet ->fieldbyname("MAXNO"); $temp100 = $tmp + 1; if($tmp <>""){ $strSQL = "update ".$TEMP." set MAXNO=".$temp100." where TNAME='$T_NAME'"; $DBSet -> parse($strSQL); } else { $strSQL = "insert into ".$TEMP."(TNAME,MAXNO) values ('$T_NAME',$temp100)"; $DBSet -> parse($strSQL); } return $temp100; exit(); } function Ut_ChgStrSlachTo2WD($arg){ $RtnStr = Ut_ChgStrOneChar($arg, "5c", "¥"); return $RtnStr; } //************************************************** //機 能:文字列の中の特定なコードを特定な文字に変換する //入 力:$arg  =変換元の文字列 // :$OrgCode =変換元コード // :$ChgCh =変換先文字 //戻り値: // 正常:変換された文字列 // 異常:NULL //************************************************** function Ut_ChgStrOneChar($arg, $OrgCode, $ChgCh){ $strlen = strlen($arg); $tmpStr = ""; $i = 0; while($i <= $strlen){ $temp = substr($arg, $i, 1); $ch = bin2hex($temp); if($ch == $OrgCode){ $temp = $ChgCh; } $i = $i + 1; $tmpStr = $tmpStr.$temp; } return $tmpStr; } function TextReplace($text1,$text2,$word) { $count =0; $word = strval($word); $strRtn = ""; $flg = true; while ($flg == true) { $pos = strpos($word,$text1); if($pos == 0){ $Str_Cut = substr($word,0,strlen($text1)); if($Str_Cut == $text1){ $strRtn = $strRtn.substr($word,0,$pos); $strRtn = $strRtn.$text2; $word = substr($word,($pos + strlen($text1))); } } else{ $strRtn = $strRtn.substr($word,0,$pos); $strRtn = $strRtn.$text2; $word = substr($word,($pos + strlen($text1))); } if($pos == 0 && $count >0 ){ $flg = false; } $count = $count +1; } $strRtn = $strRtn.$word; return $strRtn; } ////////////////////////////////////////////// // // F5 or Reload check // // 02/10/07 //////////////////////////////////////////// function reload_check($USERID,$inTITLE,$inTABLE,$DBSet) { $strSQL = "Select MAX(ID) AS CNT FROM ". $inTABLE ." WHERE USERID =".$USERID; $DBSet->parse($strSQL); $CNT = $DBSet->FieldbyName("CNT"); $strSQL = ""; $strSQL = "Select TITLE,CREATEDATE,USERID FROM ".$inTABLE. " WHERE ID = ".$CNT; $DBSet->parse($strSQL); $tmpNow = date("YmdHis"); $cTime = $DBSet->FieldbyName("CREATEDATE"); $cTitle = $DBSet->FieldbyName("TITLE"); $cTime_t =date("YmdHis", mktime(intval(substr($cTime,11,2)),intval(substr($cTime,14,2)+1),intval(substr($cTime,17,2)),intval(substr($cTime,5,2)),intval(substr($cTime,8,2)),intval(substr($cTime,0,4)))); if(($DBSet->FieldbyName("USERID") == $USERID) && ($tmpNow < $cTime_t) && ($inTITLE == $cTitle)){ $strError = "既に登録されでいます。"; // echo HTML_ErrorPage($GROUPNAME,$strError); return false; exit; } return true; } ////////////////////////////////////// // // 02/10/05 update Security // ////////////////////////////////////// Function PUBLIC_PHP5($ID,$TABLE_NAME,$DBSet) { $strSQL =""; $strSQL = "SELECT ID,PUB_FLG FROM ".$TABLE_NAME ." WHERE ID = ".$ID; $DBSet->parse($strSQL); $Rcount = $DBSet->RecordCount; $Pub_Flg = ""; $k = 1; if($Rcount != 0){ $Pub_Flg = ""."\n"; $k= $k+1; } } return $Pub_Flg; } ///////////////////////////////////////////// // // Name : db_NullCheck() // // input : string // output : Boolean // /////////////////////////////////////////////// function db_NullCheck($inStr) { $outStr = $inStr; $len1 = strlen(trim($inStr)); $outStr = str_replace(" ","",trim($outStr)); $outStr = str_replace(" ","",trim($outStr)); $len2 = strlen($outStr); if(trim($outStr) == ""){ return true; } else{ return false; } /* if($len1 == $len2){ return false; } else{ return true; } */ } ////////////////////////////////////////////////// // // Name : Trans_FileName() // Input : String // OutPut : String // //////////////////////////////////////////////////// Function Trans_FileName($strFile) { if($strFile ==""){ return false; } $attached = str_replace(" ","",$strFile); $slash_pos = strrpos($attached, "\\"); if ($slash_pos) { $attached = substr($attached, $slash_pos + 1); } $splited = split("\.", $attached, 2); $Random = microtime(); $tmpFile = md5($Random).".".$splited[1]; $T1 = $tmpFile; $FILENAME = $tmpFile; return $tmpFile; } Function inMeta2OutString($inStr) { // $inStr = str_replace(""","\"",$inStr); // $inStr = str_replace("<","<",$inStr); // $inStr = str_replace(">",">",$inStr); // $inStr = str_replace("&","&",$inStr); // $inStr = str_replace("'","'",$inStr); $inStr = str_replace("&","&",$inStr); $inStr = str_replace("quot;","'",$inStr); $inStr = str_replace("|","|",$inStr); $inStr = str_replace("<","<",$inStr); $inStr = str_replace(">",">",$inStr); // $inStr = str_replace("
","\n",$inStr); return $inStr; } /************************************************************ '* 半角化処理(英数字記号) '* 半角化処理(英数字) '* revised by Moon Il Joong 2003.04.12 '***********************************************************/ function ZENtoHAN_SJIS2($str_ZEN, $kana = 1, $alph = 1, $sym = 1) { $kana_sjis = array( 0x00A7,0x00B1,0x00A8,0x00B2,0x00A9,0x00B3,0x00AA,0x00B4,0x00AB,0x00B5, 0x00B6,0xB6DE,0x00B7,0xB7DE,0x00B8,0xB8DE,0x00B9,0xB9DE,0x00BA,0xBADE, 0x00BB,0xBBDE,0x00BC,0xBCDE,0x00BD,0xBDDE,0x00BE,0xBEDE,0x00BF,0xBFDE, 0x00C0,0xC0DE,0x00C1,0xC1DE,0x00AF,0x00C2,0xC2DE,0x00C3,0xC3DE,0x00C4, 0xC4DE,0x00C5,0x00C6,0x00C7,0x00C8,0x00C9,0x00CA,0xCADE,0xCADF,0x00CB, 0xCBDE,0xCBDF,0x00CC,0xCCDE,0xCCDF,0x00CD,0xCDDE,0xCDDF,0x00CE,0xCEDE, 0xCEDF,0x00CF,0x00D0,0x0000,0x00D1,0x00D2,0x00D3,0x00AC,0x00D4,0x00AD, 0x00D5,0x00AE,0x00D6,0x00D7,0x00D8,0x00D9,0x00DA,0x00DB,0x0000,0x00DC, 0x0000,0x0000,0x00A6,0x00DD,0xB3DE,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 ); // 20030603 modify y.ono $table_han2zen_sjis = array(0x8142,0x8175,0x8176,0x8141,0x8145,0x8392, 0x8340,0x8342,0x8344,0x8346,0x8348,0x8383,0x8385,0x8387,0x8362,0x835B, 0x8341,0x8343,0x8345,0x8347,0x8349,0x834A,0x834C,0x834E,0x8350,0x8352, 0x8354,0x8356,0x8358,0x835A,0x835C,0x835E,0x8360,0x8363,0x8365,0x8367, 0x8369,0x836A,0x836B,0x836C,0x836D,0x836E,0x8371,0x8374,0x8377,0x837A, 0x837D,0x837E,0x8380,0x8381,0x8382,0x8384,0x8386,0x8388,0x8389,0x838A, 0x838B,0x838C,0x838D,0x838F,0x8393,0x814A,0x814B); $sym_sjis = array( 0x20,0xA4,0xA1,0x2C,0x2E,0xA5,0x3A,0x3B,0x3F,0x21,0xDE,0xDF,0x00,0x00, 0x00,0x5E,0x00,0x5F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB0, 0x00,0x00,0x2F,0x00,0x00,0x00,0x7C,0x00,0x00,0x60,0x27,0x00,0x22,0x28, 0x29,0x00,0x00,0x5B,0x5D,0x7B,0x7D,0x00,0x00,0x00,0x00,0xA2,0xA3,0x00, 0x00,0x00,0x00,0x2B,0x2D,0x00,0x00,0x00,0x00,0x3E,0x00,0x3C,0x3D,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5C,0x24,0x00,0x00,0x25, 0x23,0x26,0x2A,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ); $str_HAN = ''; $b = unpack('C*', $str_ZEN); $n = count($b); for ($i = 1; $i <= $n; ++$i) { $b1 = $b[$i]; if ($b1 >= 0x80) { $b2 = $b[++$i]; if ($kana == 1 && $b1 == 0x83 // Katakana && (0x3F < $b2 && $b2 < 0x9F)) { $c = $b2 - 0x40; // 1 $c1 = ($kana_sjis[$c] & 0xFF00) >> 8; // 0 // $c2 = $kana_sjis[$c] & 0x00FF; // 177 => hankaku $c2 = $kana_sjis[$c] & 0xFF00; // 0 if ($c1 == 0x00) { if ($c2 == 0x00) { $str_HAN .= chr($b1).chr($b2); } else { $str_HAN .= chr($c2); } } else { $c = $b2 - 0x40; $c1 = ($table_han2zen_sjis[$c] & 0xFF00) >> 8; $str_HAN .= chr($c1).chr($b2); // $str_HAN .= chr($c1).chr($c2); } } elseif ($sym == 1 && $b1 == 0x81 // Symbol && (0x3F < $b2 && $b2 < 0x9F)) { $c1 = $sym_sjis[ $b2 - 0x40 ]; // 0 64 -> 40 if ($c1 == 0x00) { $str_HAN .= chr($b1).chr($b2); } else { $str_HAN .= chr($c1); } } elseif ($alph == 1 && $b1 == 0x82 // Alphabet & Number && (0x3F < $b2 && $b2 < 0x9F)) { if ($b2 < 0x80) { // 0x827A $str_HAN .= chr($b2 - 0x1F); } else { $str_HAN .= chr($b2 - 0x20); } } else { // Rest of Zenkaku $str_HAN .= chr($b1).chr($b2); } } else { // ASCII $str_HAN .= chr($b1); } } return $str_HAN; } function SetResult_GetPath($inPATH,$inQNO,$inTABLE) { if($inPATH == "") { return false; } if($inQNO == "") { return false; } $strFile = ""; $tmpPATH = explode("|",$inPATH); if(count($tmpPATH) > 1) { for($k=0;$k 0) { for($i=0;$i < count($strPATH);$i++) { $strWork = $strPATH[$i]; $tmpFile = explode("/",$strWork); if(substr($tmpFile[count($tmpFile) -1],0,1) == "q") { if($inTABLE == "T_QST") { $strQNO = substr($tmpFile[count($tmpFile) -1],0,5). str_replace("-","",$tmpFile[count($tmpFile) -3]) . str_replace("-","",$tmpFile[count($tmpFile) -2]); }else { $strQNO = substr($tmpFile[count($tmpFile) -1],0,5); } if($strQNO == $inQNO) { $strFile = EUCtoSJIS($strWork); } }else { if($inTABLE == "T_QST") { $strQNO = substr($tmpFile[count($tmpFile)-1],0,strlen($tmpFile[count($tmpFile)-1])-4). str_replace("-","",$tmpFile[count($tmpFile)-4]) . str_replace("-","",$tmpFile[count($tmpFile)-3]); }else { $strQNO = substr($tmpFile[count($tmpFile) -1],0,5); } if($strQNO == $inQNO) { $strFile = EUCtoSJIS($strWork); } } // end if } // end for } } }else { $strPATH = explode(",",$inPATH); if(count($strPATH) >0) { for($i=0;$i < count($strPATH);$i++) { $strWork = $strPATH[$i]; $tmpFile = explode("/",$strWork); if(substr($tmpFile[count($tmpFile)-1],0,1) == "q") { if($inTABLE == "T_QST") { $strQNO = substr($tmpFile[count($tmpFile)-1],0,5). str_replace("-","",$tmpFile[count($tmpFile)-3]) . str_replace("-","",$tmpFile[count($tmpFile)-2]); }else { $strQNO = substr($tmpFile[count($tmpFile) -1],0,5); } if($strQNO == $inQNO) { $strFile = EUCtoSJIS($strWork); } }else { if($inTABLE == "T_QST") { $strQNO = substr($tmpFile[count($tmpFile)-1],0,strlen($tmpFile[count($tmpFile)-1])-4). str_replace("-","",$tmpFile[count($tmpFile)-4]) . str_replace("-","",$tmpFile[count($tmpFile)-3]); }else { $strQNO = substr($tmpFile[count($tmpFile) -1],0,5); } if($strQNO == $inQNO) { $strFile = EUCtoSJIS($strWork); } } } } }// end if return $strFile; } function SetResult_GetAnswerValue($inFile) { $strAnswerValue = ""; if($inFile == "") { return false; } $strBODY = GetFile($inFile); if ($strBODY == "" ) { return false; } //'BODY部の取得 $strBODY = HTML_GetBody($strBODY); //'VALUE値の取得 $RetValue = HTML_GetInputValues($strBODY,$VALUE); //'VALUE値のチェック&整形 $strRet = CheckValue($RetValue); if (substr($strRet,0,5) == "Error" ) { return false; } return $strRet; } ?> database selection error