Server IP : 180.180.241.3 / Your IP : 216.73.216.127 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/AppServ/www/umedia3/inc/ |
Upload File : |
<? function marc_importfromfile($filex) { if (!function_exists("thisecho")) { function thisecho($t) { $a=0; if ($a==1) { echo $t; } } } global $addimportid; global $dcrs; global $getonly; global $IMPORTCOUNT; global $droppedgetonly; if ($getonly=="") { $s=tmq("select * from bkedit",false); $getonly=","; while ($r=tmq_fetch_array($s)) { $getonly="$getonly,$r[fid]"; } $getonly=str_replace("tag","",$getonly); thisecho ("<B>getonly = $getonly <BR></B>"); } $IMPORTCOUNT=0; sleep(1); $importid=date("s:i:H d/m/Y") . "::$addimportid"; $filename = "$dcrs/_input/$filex"; if (!$fd = fopen($filename, 'rb')) { echo "Cannot open file ($filename)"; exit; } while (!feof($fd)) { $reclength = fread ($fd, 5); //echo "[$reclength]<BR>"; $LEADER=fread ($fd, 7); $indexlength = fread ($fd, 5); $tmp1=fread ($fd, 3); $len_len=fread ($fd, 1); $start_len=fread ($fd, 1); $tmp2=fread ($fd, 2); $FULLLEADER="$reclength$LEADER$indexlength$tmp1$len_len$start_len$tmp2"; thisecho ("[FULLLEADER=$reclength$LEADER($indexlength)$tmp1$len_len$start_len$tmp2]<BR>"); $indexlength=$indexlength-24; if ($indexlength>0) { thisecho( "reclen = $reclength /indexlength =$indexlength<BR> "); $index = fread ($fd, $indexlength); thisecho( "<B>index= $index </B><BR>"); thisecho( "<U>($reclength-(7+5+5+$indexlength+3+1+1+2</U>="); thisecho( "[[" . ($reclength-(7+5+5+$indexlength+3+1+1+2)) . "]]<BR>"); if ( $tmp = fread ($fd, ($reclength-(7+5+5+$indexlength+3+1+1+2))) ) { $p2 = $tmp; $canclestag="no"; // do nothing } else { $canclestag="yes"; $p2=""; } /*$tmp=strpos($p2,"eng d"); echo "<H1>" .$tmp. "</H1>"; $tmp=substr($p2,$tmp+5,1); echo "<H1>" .$tmp. "1</H1>"; $tmp=ord($tmp); echo "<H1><U>" .$tmp. "</U></H1>"; $p2= str_replace(chr(31),"",$p2); $p2= str_replace(chr(30),"_",$p2);*/ //////////////////////////////////////////////////////// if ($cancelstag=="yes") { continue; } $leftstr = $index; $addindi=0; $s="insert into media set \nleader='$FULLLEADER' , \n"; //echo " [" . ($index)."]<BR>"; //echo " alldata=[" . ($p2)."]<BR>"; $getonced=""; while (strlen($leftstr) >=4 &&strlen($p2)>20) { //loop แต่ละแท็ก ในรายการนี้ $addindi=$addindi; $usestr = substr($leftstr,0,12); $leftstr = substr($leftstr,12); thisecho( "use=$usestr/left=$leftstr <BR>"); $f_id = substr($usestr,0,3); $f_length = substr($usestr,3,$len_len); $f_start = substr($usestr,3+$len_len,$start_len); thisecho( "field=$f_id / len = $f_length / start = $f_start<BR>"); $f_dat = substr($p2,$f_start+$addindi,$f_length); $subf=chr(31); $f_usedat=str_replace($subf,"^",$f_dat); $subfe=chr(30); $f_usedat=str_replace($subfe,"<<",$f_usedat); //$f_usedat = substr($f_usedat,2); $f_usedat = substr($f_usedat,0,-2); $f_usedat = iconvth($f_usedat); $f_usedat = addslashes($f_usedat); thisecho("dat=[$f_usedat] (add $addindi)<BR><BR>"); if (strpos($getonly,$f_id)===false) { thisecho ("<FONT COLOR=red><BR>DROPBY getonly $f_id<BR></FONT>"); $droppedgetonly.=",$f_id"; //ไม่ทำอะไร } else { if ($getonced[$f_id]!="yes") { $s="$s tag$f_id='$f_usedat',\n"; $getonced[$f_id]="yes"; } else { $s=str_replace("tag$f_id='","tag$f_id='$f_usedat\n",$s); thisecho ("<FONT COLOR=orange><BR>RE-ADD by getonced $f_id<BR></FONT>"); } thisecho ("<FONT COLOR=orange><BR>ADD $f_id<BR></FONT>"); //echo "<B>$f_id=$getonced[$f_id] </B>"; } } $s = "$s importid='$importid' ;;;;"; //use ;;;; to seperate records $s = trim($s,","); //////////////////////////////////////////////////////// thisecho( " <U>data=$p2</U> <HR>"); thisecho( "<B><PRE>[$s]</PRE></B>"); //echo $s; //tmq($s); $fp = fopen("$dcrs/_output/marc.sql","a"); $string = "$s\n"; // escape the slash from being magically // being transformed into a newline fwrite($fp, $string); $IMPORTCOUNT++; thisecho( " <HR>"); } //if indexlength >0 } //while not feof fclose ($fd); } ?>