"); ******/ //????R?[?h?? mb_internal_encoding("SJIS"); mb_language("Japanese"); $internal_enc = mb_internal_encoding(); //mb_http_output("UTF-8");//?e?X?g?T?[?o?[??N/???T?[?o?[OFF(UTF-8) //print("internal_enc=".$internal_enc."
"); //print("mb_http_output=".mb_http_output()."
"); //?????C?u?????C???N???[?h require_once( "cmnlib.php" ); //?????` define("DEF_MB_LANG", "ja"); define("DEF_MB_ENC", "SJIS"); define("SMTP_SERVER", "192.168.1.21"); //?e?X?g?p?iSMTP??T?[?o?[??????P?A?h???X) define("ITEM_SEC","[Item]"); define("ADDR_SEC","[MailAddress]"); define("CFG_FILE","mailformphp.csv"); define("MF_HTML","mailform.html"); define("CONF_HTML","confirm.html"); define("FN_HTML","finish.html"); define("MNG_TXT","mng.txt"); define("USER_TXT","user.txt"); define("FAMILYNAME", "familyname");//???[?U?????t?B?[???h? define("ERRSENDMAILTO","srvman@mediarium.jp"); define("LOGLIMIT",100); define("MNG"," MNG"); define("USER","USER"); define("PHP_VER", "4"); //PHP??o?[?W?????i5??~?????A5????j //csv?t?@?C????????p?????` $aFieldName = array(); $aItemName = array(); $aLength = array(); $aAttribute = array(); $aRequire = array(); $aDefaultValue = array(); $data_array = array(); $data = array(); $aMailItem = array(); $aMailAddress = array(); $aCCArray = array(); $aBCCArray = array(); $mdata_array = array(); $mdata = array(); //?G???[???b?Z?[?W?????` $Msg = array(); //???M?p?????` $m_Subject =""; $mMain = ""; $u_Subject = ""; $uMain = ""; $m_Main = ""; $u_Main = ""; /*****csv?t?@?C????????****/ $file_name = CFG_FILE; //?t?@?C??????????[?h??J? $file = fopen($file_name, "r") or die("OPEN?G???[ $file_name"); $fItem = false; $line_no = 0; if(PHP_VER == "5"){ /***PHP5??~??SV??????????@******/ while (!feof($file)) { $data_array = fgetcsv_reg($file); $_enc_to=mb_internal_encoding(); $_enc_from=mb_detect_order(); mb_convert_variables($_enc_to,$_enc_from,$data_array); $data = $data_array[0]; if($fItem == false){ //?s??Item]??????? if(stristr($data,ITEM_SEC) != false){ $fItem = true; } }else{ //?s??//"??n??????X?L?b?v if(substr($data,0,2) == "//"){ continue; } //?s???????????[?v???? if(strlen($data) == 0 ){ break; } //?e?J??????z???i?[ //?t?B?[???h???z???i?[ $aFieldName[$line_no] = $data_array[0]; //??????z???i?[ $aItemName[$line_no] = $data_array[1]; //?????????z???i?[ $aLength[$line_no] = $data_array[2]; //???????z???i?[ $aAttribute[$line_no] = $data_array[3]; //?K?{?????z???i?[ $aRequire[$line_no] = $data_array[4]; //??l??z???i?[ $aDefaultValue[$line_no] = $data_array[5]; $line_no++; //?s???J?E???g } } fclose($file); }else{ while(!feof($file)){ //1?s??????? $data_array = fgetcsv($file, 1000, ","); $data = $data_array[0]; if($fItem == false){ //?s??Item]??????? if(stristr($data,ITEM_SEC) != false){ $fItem = true; } }else{ //?s??//"??n??????X?L?b?v if(substr($data,0,2) == "//"){ continue; } //?s???????????[?v???? if(strlen($data) == 0 ){ break; } //?e?J??????z???i?[ //?t?B?[???h???z???i?[ $aFieldName[$line_no] = $data_array[0]; //??????z???i?[ $aItemName[$line_no] = $data_array[1]; //?????????z???i?[ $aLength[$line_no] = $data_array[2]; //???????z???i?[ $aAttribute[$line_no] = $data_array[3]; //?K?{?????z???i?[ $aRequire[$line_no] = $data_array[4]; //??l??z???i?[ $aDefaultValue[$line_no] = $data_array[5]; $line_no++; //?s???J?E???g } } //?t?@?C?????? fclose($file); } /*****?t?B?[???h??????`*****/ $aDataName = array(); //PHP?o?[?W?????? $ver = preg_replace("/(\d).(\d).(\d).*/","$1$2$3",phpversion()); if($ver < 410){ // 4.1.0??O????? for ($i = 0; $i < $line_no; $i++){ //$sFieldName??t?B?[???h??i?[ $sFieldName = $aFieldName[$i]; $aDataName[$i] = $HTTP_POST_VARS[$sFieldName]; //$aDataName[$i] = mb_convert_encoding($HTTP_POST_VARS[$sFieldName],DEF_MB_ENC,$internal_enc); $aDataName[$i] = ChangeTxtData($aDataName[$i],$internal_enc); $Value[$i] = GetItemValue($aFieldName[$i]);//HTML?\?p } //???[?h?????` $Mode = $HTTP_POST_VARS["mode"]; }else{ // 4.1.0 ??~????? for ($i = 0; $i < $line_no; $i++){ //$sFieldName??t?B?[???h??i?[ $sFieldName = $aFieldName[$i]; $aDataName[$i] = $_POST[$sFieldName]; //print("aDataName1".$aDataName[$i]."
"); $aDataName[$i] = mb_convert_encoding($_POST[$sFieldName],DEF_MB_ENC,"EUC-JP"); //print("aDataName2".$aDataName[$i]."
"); $aDataName[$i] = ChangeTxtData($aDataName[$i],$internal_enc); //print("aDataName3".$aDataName[$i]."
"); $Value[$i] = GetItemValue($aFieldName[$i]);//HTML?\?p } //???[?h?????` $Mode = $_POST["mode"]; } /*****?m?F???\*****/ if($Mode == conf){ //?G???[????????M?{?^????\ $Errflg = false; //?G???[?`?F?b?N for ($i = 0; $i < $line_no; $i++){ //?f?[?^?????l???v?????s?E?X?y?[?X????????? //if($aDataName[$i] == $aDefaultValue[$i] || RePlace($aDataName[$i]) == ""){ if(RePlace($aDataName[$i]) == ""){ //?f?[?^????? $aDataName[$i] = ""; } //?K?{???????????CheckBox"?????? if($aRequire[$i] == "1" && $aAttribute[$i] != "CheckBox"){ $Msg[$i] = RequiredCheck($aDataName[$i],"$aItemName[$i]"); }else if($aRequire[$i] == "2" && $aAttribute[$i] != "CheckBox"){ $count = 0; for($check =$i;$check < $line_no;$check++){ $aDataName[$check] = ChangeStrToBlank($aDataName[$check]); //?f?[?^???????? if($aDataName[$check] == ""){ $count++; } //?t?B?[???h??????__"??????? if(substr($aFieldName[$check],-2) == "__"){ break; } } $Msg[$i] = RequiredAllCheck($count,"$aItemName[$i]"); }else if($aRequire[$i] == "3" && $aAttribute[$i] != "CheckBox"){ $count = 0; for($check =$i;$check < $line_no;$check++){ $aDataName[$check] = ChangeStrToBlank($aDataName[$check]); //?f?[?^??????????? if($aDataName[$check] != ""){ $count++; } //?t?B?[???h??????__"??????? if(substr($aFieldName[$check],-2) == "__"){ break; } } $Msg[$i] = RequiredOneCheck($count,"$aItemName[$i]"); } //?K?{?`?F?b?N????G???[???????? if($Msg[$i] == ""){ //???????Text"????TextArea"???? if($aAttribute[$i] == "Text" || $aAttribute[$i] == "TextArea"){ //????????`?F?b?N $Msg[$i] = MaxCheck($aDataName[$i],$aLength[$i],"$aLength[$i]"); } //???????Num"???? if($aAttribute[$i] == "Num"){ //??p????`?F?b?N $Msg[$i] = NumCheck($aDataName[$i]); //??p????`?F?b?N??G???[???????? if($Msg[$i] == ""){ //????????`?F?b?N $Msg[$i] = MaxCheck($aDataName[$i],$aLength[$i],"$aLength[$i]"); } //???????NumHyphen"???? }else if($aAttribute[$i] == "NumHyphen"){ //?d?b????`?F?b?N $Msg[$i] = NumHyphenCheck($aDataName[$i]); //?d?b????`?F?b?N??G???[???????? if($Msg[$i] == ""){ //????????`?F?b?N $Msg[$i] = MaxCheck($aDataName[$i],$aLength[$i],"$aLength[$i]"); } //???????UrlAddr"???? }else if($aAttribute[$i] == "UrlAddr"){ //Url?A?h???X?`?F?b?N $Msg[$i] = UrlCheck($aDataName[$i],"$aItemName[$i]"); //???????MailAddrCnf"???? }else if($aAttribute[$i] == "MailAddrCnf"){ //???[???A?h???X?`?F?b?N $Msg[$i] = MailCheck($aDataName[$i],"$aItemName[$i]"); //???[???A?h???X?`?F?b?N??G???[?????? if($Msg[$i] == ""){ //????????`?F?b?N $Msg[$i] = MaxCheck($aDataName[$i],$aLength[$i],"$aLength[$i]"); } //???????MailAddr"???? }else if($aAttribute[$i] == "MailAddr"){ //???[???A?h???X?`?F?b?N $Msg[$i] = MailCheck($aDataName[$i],"$aItemName[$i]"); //???[???A?h???X?`?F?b?N??G???[?????? if($Msg[$i] == ""){ //????????`?F?b?N $Msg[$i] = MaxCheck($aDataName[$i],$aLength[$i],"$aLength[$i]"); //????????`?F?b?N??G???[?????? if($Msg[$i] == ""){ //?m?F???[???A?h???X??? $Mcnf = false; for($k=$k+1; $k < $line_no; $k++){ //????m?F???[???A?h???X????j????? if($aAttribute[$k] == "MailAddrCnf"){ $j = $k; $Mcnf = true; break; } } //?m?F???[???A?h???X?????????? if($Mcnf == true){ //???[???A?h???X?E?m?F???[???A?h???X??v?`?F?b?N $Msg[$i] = EqualCheck($aDataName[$i],$aDataName[$j],$aItemName[$i]); } } //????????`?F?b?N??G???[?????? } //???[???A?h???X?E?m?F???[???A?h???X?`?F?b?N??G???[?????? } //??????[???A?h???X???? } //?K?{?`?F?b?N??G???[???????? //?K?{?`?F?b?N??G???[???????? else{ //?f?[?^????? $aDataName[$i] = ""; } //?K?{???????????CheckBox"???? if($aRequire[$i] == "1" && $aAttribute[$i] == "CheckBox"){ $count = 0; for($check =$i;$check < $line_no;$check++){ //?`?F?b?N????????? if($aDataName[$check] != ""){ $count++; } //?t?B?[???h??????__"??????? if(substr($aFieldName[$check],-2) == "__"){ break; } } $Msg[$i] = CheckCount($count,$aLength[$i],$aItemName[$i]); } //?G???[??????? if($Msg[$i] != ""){ $Errflg = true; //??{?^?????\ } } //for require(CONF_HTML); /*****?m?F????????????****/ }else if($Mode == back){ require(MF_HTML); /*****???M???\*****/ }else if($Mode == send){ //CSV?t?@?C??????????[?h??J? $file = fopen($file_name, "r") or die("OPEN?G???[ $file_name"); $fMailAddress = false; $mline_no = 0; while(!feof($file)){ //1?s??????? $mdata_array = fgetcsv($file, 1000, ","); $mdata = $mdata_array[0]; if($fMailAddress == false){ //?s??MailAddress]??????? if(stristr($mdata,ADDR_SEC) != false){ $fMailAddress = true; } }else{ //?s??//"??n??????X?L?b?v if(substr($mdata,0,2) == "//"){ continue; } //?s???????????[?v?????I? if(strlen($mdata) == 0 ){ break; } //?e?J??????z???i?[ //?????z???i?[ $aMailItem[$mline_no] = $mdata_array[0]; //???[???A?h???X??z???i?[ $aMailAddress[$mline_no] = $mdata_array[1]; //?????M??w??CC) if($aMailItem[$mline_no] == "CC"){ $ct = count($mdata_array); for($i = 1; $i < $ct; $i++){ //?f?[?^???????????[?v???? if($mdata_array[$i] == ""){ break; } //???[???A?h???X??z???i?[ $aCCArray[$i-1] = $mdata_array[$i]; } } //???J?????M??w??BCC) if($aMailItem[$mline_no] == "BCC"){ for($i = 1; $i < $ct; $i++){ //?f?[?^???????????[?v???? if($mdata_array[$i] == ""){ break; } //???[???A?h???X??z???i?[ $aBCCArray[$i-1] = $mdata_array[$i]; } } $mline_no++; //?s???J?E???g } } //?t?@?C?????? fclose($file); for ($j = 0; $j< $line_no; $j++){ //???[?U?[???A?h???X?????????[?????M???? if($aAttribute[$j] == "MailAddr"){ //?S?p???p?@'08.03.03? $mailFrom = ConvNum($aDataName[$j]); break; } } /* //???[?U???O(????? for ($j = 0; $j< $line_no; $j++){ if($aFieldName[$j] == FAMILYNAME){ $mailName = $aDataName[$j]; break; } } */ //???[???A?h???X?? for ($i = 0; $i < $mline_no; $i++){ //????????[?????M(From:??q?l To:?? MODE:0) //???[?U??A?h???X??????????? if($mailFrom == ""){ //???M??A?h???X?? if($aMailItem[$i] == "From"){ $mailFrom = $aMailAddress[$i]; } } //????????M??A?h???X?? if($aMailItem[$i] == "ToManager"){ //???M???A?h???X?????????? if($aMailAddress[$i] != ""){ //???M???? $mailTo = $aMailAddress[$i]; //??????e?L?X?g?t?@?C??????? LoadMailTmpFile(MNG_TXT, $m_Subject, $mMain); //?????u??? $m_Main = TxtReplace($mMain); $ret = SendMail($mailTo, $mailFrom, $m_Subject, $m_Main); //???[?????M CreateLog($mailFrom,$mailTo,$ret,MNG); //SenduMail($mailTo, $mailFrom, $aCCArray, $aBCCArray, $m_Subject, $m_Main); //print("ret=".$ret."
"); //print("????l?????[?????M?B"."
"); } } //???[?U?[???m?F???[?????M(From:???ATo:??q?l?ABCC:???CC?p?A?h???X MODE:1) //???[?U?[?????M??A?h???X?? if($aMailItem[$i] == "From"){ $u_mailFrom = $aMailAddress[$i]; } //???[?U?[?????M???? if($aMailItem[$i] == "FromName"){ $u_mailFromName = $aMailAddress[$i]; } //???[?U?[?????[?????M??A?h???X?? if($aMailItem[$i] == "ToUser"){ //???M?????????????[?????M if($aMailAddress[$i] == ""){ for ($j = 0; $j< $line_no; $j++){ //???[?U?[???A?h???X????M???w? if($aAttribute[$j] == "MailAddr"){ $u_mailTo = ConvNum($aDataName[$j]); break; } } //???[?U?[???e?L?X?g?t?@?C??????? LoadMailTmpFile(USER_TXT, $u_Subject, $uMain); //?????u??? $u_Main = TxtReplace($uMain); //???M??????????????M if($u_mailTo != ""){ //$ret = SendMail($u_mailTo, $u_mailFrom, $u_Subject, $u_Main); //???[?????M $ret = SenduMail($u_mailTo, $u_mailFrom, $aCCArray, $aBCCArray, $u_Subject, $u_Main,$u_mailFromName); CreateLog($u_mailFrom,$u_mailTo,$ret,USER); //print("ret=".$ret."
"); //print("???[?U??????[?????M?B"."
"); } //???M???0"????????[??????M??? }else if($aMailAddress[$i] == 0){ continue; } } //???[?U?[?????[?????M??A?h???X?? }//for /* print("u_mailTo=".$u_mailTo."
"); print("u_mailFrom=".$u_mailFrom."
"); print("mailName".$mailName."
"); print("$u_Main".$u_Main."
"); */ /* print("mailTo=".$u_mailTo."
"); print("mailFrom=".$u_mailFrom."
"); print("$m_Main".$m_Main."
"); */ require(FN_HTML); }else{ require(MF_HTML); } //print("POST_convert18=".i18n_convert($_POST["company"], "SJIS")."
"); //print("POST_convert_encoding=".mb_convert_encoding($_POST["company"], DEF_MB_ENC, $internal_enc)."
"); //print("REQUEST_convert_encoding=".mb_convert_encoding($_REQUEST["company"], DEF_MB_ENC, $internal_enc)."
"); //print("REQUEST_convert18=".i18n_convert($_REQUEST["company"], "SJIS")."
"); //print("REQUEST=".$_REQUEST["companykana"]."
"); //print("aDataName=". $aDataName[0]."
"); //?e?L?X?g?t?@?C???????u??????\?b?h function TxtReplace($Text) { global $line_no,$aFieldName,$aDataName,$aItemName; //?e?L?X?g?t?@?C???{??????u??? //?{???????X $sRet = ""; $ReplaceData = "Anser"; $ReplaceItem = "Item"; for ($i = 0; $i < $line_no; $i++){ $DataWord = $ReplaceData.$i; $ItemWord = $ReplaceItem.$i; //$Text = ReplaceString($Text, $aFieldName[$i], $aDataName[$i]); $Text = ReplaceString($Text, $DataWord, $aDataName[$i]); $Text = ReplaceString($Text, $ItemWord, $aItemName[$i]); } //???[?U?[??????u??? $IPAddr = getenv('REMOTE_ADDR'); $HosNamet = getenv('REMOTE_HOST'); $UserAgent = getenv('HTTP_USER_AGENT'); $Text = ReplaceString($Text,"REMOTE_ADDR",$IPAddr); $Text = ReplaceString($Text,"REMOTE_HOST",$HosNamet); $Text = ReplaceString($Text,"HTTP_USER_AGENT",$UserAgent); $sRet = $Text; return $sRet; } //value?????\?b?h function GetItemValueRow($sFieldName) { global $line_no,$aFieldName,$aDataName,$aDefaultValue,$Mode; //$sFieldName??t?B?[???h???????""??? $sRet = ""; for ($i = 0; $i < $line_no; $i++){ //$sFieldName??t?B?[???h????v????? if($aFieldName[$i] == $sFieldName){ //?m?F???\??????? if($Mode != conf){ //?f?[?^??????????l??? if($aDataName[$i] == ""){ if($aDefaultValue[$i] != ""){ $sRet = $aDefaultValue[$i]; break; } } } $sRet = $aDataName[$i]; break; } } return $sRet; } //value?????\?b?h(HTML?e?L?X?g?\?p) function GetItemValue($sFieldName) { global $ver; $sRet =""; if($sFieldName != ""){ $name = GetItemValueRow($sFieldName); if($ver < 410){ // 4.1.0??O????? $sRet = htmlspecialchars($name, ENT_QUOTES); }else{ // 4.1.0??~????? $sRet = htmlspecialchars($name, ENT_QUOTES,DEF_MB_ENC); } } return $sRet; } //?Z???N?g?{?b?N?Xselected?????\?b?h function GetSelected($sFieldName,$Value) { global $line_no,$aFieldName,$aDataName,$aDefaultValue,$Mode; //$sFieldName??t?B?[???h???????""??? $sRet = ""; for ($i = 0; $i < $line_no; $i++){ //$sFieldName??t?B?[???h????v????? if($aFieldName[$i] == $sFieldName){ if($aDataName[$i] == $Value){ $sRet = "selected"; } //??\?????@'07.08.03?? if($Mode != conf){ if($aDataName[$i] == ""){ //??l??? if($aDefaultValue[$i] == $Value){ $sRet = "selected"; } } } break; } } return $sRet; } //???W?I?{?^???E?`?F?b?N?{?^??checked?????\?b?h function GetChecked($sFieldName,$Value) { global $line_no,$aFieldName,$aDataName,$aDefaultValue,$Mode; //$sFieldName??t?B?[???h???????""??? $sRet = ""; for ($i = 0; $i < $line_no; $i++){ //$sFieldName??t?B?[???h????v????? if($aFieldName[$i] == $sFieldName){ if($aDataName[$i] == $Value){ $sRet = "checked"; } //??\?????@'07.08.03?? if($Mode != conf){ if($aDataName[$i] == ""){ //??l??? if($aDefaultValue[$i] == $Value){ $sRet = "checked"; } } } break; } } return $sRet; } //?G???[???b?Z?[?W?????\?b?h function GetErrMessage($sFieldName) { global $line_no,$aFieldName,$Msg; //$sFieldName??t?B?[???h???????err?????? $sRet = "err"; for ($i = 0; $i < $line_no; $i++){ //$sFieldName??t?B?[???h????v????? if($aFieldName[$i] == $sFieldName){ $sRet = $Msg[$i]; break; } } return $sRet; } //?t?H?[?????Z?b?g??????????\?b?h //??l????????????????l????radio,checkbox??O) function GetFormClear(){ global $line_no,$aFieldName,$aAttribute,$aDefaultValue; $sRet = "function FormClear(){"; for ($i=0;$i < $line_no;$i++){ if($aAttribute[$i] == "CheckBox"){ $sRet .= "document.formnew.".$aFieldName[$i].".checked =false;"."\n"; }else if($aAttribute[$i] == "Radio"){ $sRet .= "for(i=0;i< document.formnew.".$aFieldName[$i].".length;i++){"."\n". "document.formnew.".$aFieldName[$i]."[i].checked=false;}"."\n"; }else{ if($aDefaultValue[$i] != ""){ $sRet .= "document.formnew.".$aFieldName[$i].".value = \"".$aDefaultValue[$i]."\";"."\n"; }else{ $sRet .= "document.formnew.".$aFieldName[$i].".value = \"\";"."\n"; } } } $sRet .="}"; return $sRet; } //POST???????f?[?^?? function ChangeTxtData($Str,$internal_enc){ if($internal_enc == "SJIS" || $internal_enc == "UTF-8"){ //?o?b?N?X???b?V??????? //$Str = stripslashes($Str); } if($internal_enc == "EUC-JP"){ //??p?_?u???E?V???O???N?H?[?g?E\?}?[?N??S?p??? $Str = ConvHanToZen($Str); } //??p?_?u???E?V???O???N?H?[?g?E\?}?[?N??S?p??? $Str = ConvHanToZen($Str); //??p?J?i??S?p?J?i??? $Str = KanaHanToZen($Str); //?~??u???v????i?\??????????????j'08.07.17?? $Str = KakeruToX($Str); //$Str = izonReplace($Str); return $Str; } //?N?Z???N?g(?????N?`?????N) function CreateYearSelect($Name,$Value,$Firstyear,$LastYear){ $Ret = ""; return $Ret; } //??Z???N?g(?P?`?P?Q?? function CreateMonthSelect($Name,$Value){ $Ret = ""; return $Ret; } //??Z???N?g(?P?`?R?P?? function CreateDaySelect($Name,$Value){ $Ret = ""; return $Ret; } /*** SENDMAIL????O????? * [?????e?f?B???N?g????p?[?~?b?V??????0777]or[0775] * ????????B ***/ function CreateLog($from,$to,$flg,$per){ $ret = true; $logfile = "mailform.log"; $today = date("Y-m-d H:i:s"); if($flg){ $logString = "$per DATE[$today] FROM[$from] TO[$to]"; }else{ $logString = "SENDERR!! $per DATE[$today] FROM[$from] TO[$to]"; } if(!$flg){ $logString2 = $logString."\nPATH[".realpath("./")."]\n"; $ret = SendMail(ERRSENDMAILTO, ERRSENDMAILTO, "MailFormERR!!", $logString2); } if(!file_exists($logfile)){ touch($logfile); chmod($logfile,0606); } $fd = file($logfile); $cut = count($fd); if($cut>LOGLIMIT){ $fp = fopen($logfile, "r"); $allline = array(); $i=0; while(!feof($fp)) { $line = fgets($fp,4096); array_push($allline,$line); } fclose($fp); $fp = fopen($logfile, "w"); $i=2; while($line = $allline[$i]){ fwrite($fp, $line); $i++; } fclose($fp); } if($fp = fopen($logfile, "a")){ fputs($fp,$logString."\n"); fclose($fp); }else{ $ret = false; } return $ret; } /** * ?t?@?C???|?C???^???s?????ACSV?t?B?[???h????????iPHP5????????p?j * @param resource handle * @param int length * @param string delimiter * @param string enclosure * @return ?t?@?C????I?[??B?????????A?G???[???ALSE??????B */ function fgetcsv_reg (&$handle, $length = null, $d = ',', $e = '"') { $d = preg_quote($d); $e = preg_quote($e); $_line = ""; while ($eof != true) { $_line .= (empty($length) ? fgets($handle) : fgets($handle, $length)); $itemcnt = preg_match_all('/'.$e.'/', $_line, $dummy); if ($itemcnt % 2 == 0) $eof = true; } $_csv_line = preg_replace('/(?:\r\n|[\r\n])?$/', $d, trim($_line)); $_csv_pattern = '/('.$e.'[^'.$e.']*(?:'.$e.$e.'[^'.$e.']*)*'.$e.'|[^'.$d.']*)'.$d.'/'; preg_match_all($_csv_pattern, $_csv_line, $_csv_matches); $_csv_data = $_csv_matches[1]; for($_csv_i=0;$_csv_i