Viewing file: downloadDocAgain.php (5.47 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php set_time_limit(0); include_once("../../class/clsConnection.php"); include_once("../../class/clsDB.php"); include_once "../global.php"; include_once "../class/clsSendReceive.php"; include_once "../class/clsCollegeDetail.php"; include_once "../class/clsCollegeDetail.php"; include_once "functdownload.php";
$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EOFFICE'], $GLOBALS['DBUSER_EOFFICE'], $GLOBALS['DBPASS_EOFFICE']);
$oTsr = new sendreceive($oC); $oTsr2 = new sendreceive($oC); $oTsr3 = new sendreceive($oC); $oTsr4 = new sendreceive($oC); $oCd = new collegedetail($oC);
//----select doc status = r2 start download $oTsr->SearchByKey($tsr_id);
while($oTsr->GetRecord()){ $tsr_id =$oTsr->tsr_id; $tsr_docid =$oTsr->tsr_docid; $tsr_doc_url=$oTsr->tsr_doc_url; $tsr_doc_chksum=$oTsr->tsr_doc_chksum; $tsr_fr_node=$oTsr->tsr_fr_node; $tsr_docname=$oTsr->tsr_docname; $tsr_statusDocAtt=$oTsr->tsr_statusDocAtt;
$oCd->SearchByKey($oTsr->tsr_fr_node); $oCd->GetRecord(); //---download each Doc $i=0; //echo $tsr_doc_url."GGGG"; exit; while($tsr_doc_url!=''){ list($downloadurl,$tsr_doc_url)=preg_split('[,]',$tsr_doc_url,2); list($downloadfilename,$tsr_docname)=preg_split('[,]',$tsr_docname,2); list($downloadchksum,$tsr_doc_chksum)=preg_split('[,]',$tsr_doc_chksum,2); //echo $downloadurl; exit; $checktsr_statusDocAtt.='Y'; $i++;
$count=strlen($tsr_statusDocAtt); if($count!=$i){ $statusDoc = substr($tsr_statusDocAtt,$i-1,-($count-1-($i-1))); }else{ $statusDoc = substr($tsr_statusDocAtt,$count-1); } //if($statusDoc=='N'){ //Array ( [scheme] => http [host] => administer.pi.ac.th [path] => /mispbri/eoffice/documents/20170216_105657-354-fa53285dca6ba8b8d70f8cdb2b20595a.pdf ) $_url = parse_url($downloadurl); $_url_path = explode("/", $_url['path']); $_url_full = $_url['scheme']."://".$_url['host']."/".$_url_path[1]."/".$_url_path[2]; //print_r($_url_full); exit; //http://administer.pi.ac.th/mispbri/eoffice/admin/admin_json.php?mod=getDocAttatchList&DocID=609031 //echo $_url_full."/admin/admin_json.php?mod=getDocAttatchList&DocID={$tsr_docid}"; $_json_data = file_get_contents($_url_full."/admin/admin_json.php?mod=getDocAttatchList&DocID={$tsr_docid}"); $_arr_data = json_decode($_json_data); $_doc_list = iconv("utf-8", "tis-620", $_arr_data->filelist); // aust //echo $_doc_list; exit; //print_r($_arr_data); exit; //echo $_url_full."/admin/admin_json.php?mod=getDocAttatchList&DocID={$tsr_docid}"; exit; //print_r($_arr_data->filelist); exit; //$_doc_list = $_arr_data->filelist; if(downloadRemoteFile($tsr_fr_node,$downloadurl, $GLOBALS['path_upload_documentsTmp'])==true){ $file_name = basename($downloadurl); $file_name_write=$file_name; $filename_=''; $filetype_=''; list($filename_,$filetype_)=preg_split("/\./",$file_name_write); $filewrite=$filename_.'-'.$tsr_fr_node.'.'.$filetype_; $fileN=substr(strrchr($downloadurl, '/'),1); $pathfile=$GLOBALS['path_upload_documentsTmp'].$filewrite; //echo " ==> $checksum==$downloadchksum<br>"; $checksum=md5_file($pathfile); $c=0; if($downloadchksum==""){ $c=1; } if(($checksum==$downloadchksum) || $c==1){ //--update tsr_statusDocAtt $count=strlen($tsr_statusDocAtt); if($count!=$i){ $tsr_statusDocAtt = substr_replace($tsr_statusDocAtt, "Y", $i-1,-($count-1-($i-1))); }else{ $tsr_statusDocAtt = substr_replace($tsr_statusDocAtt, "Y", $count-1); } $oTsr2->SearchByKey($oTsr->tsr_id); $oTsr2->GetRecord(); $oTsr2->Edit(); $oTsr2->tsr_statusDocAtt=$tsr_statusDocAtt; $oTsr2->tsr_docname=$_doc_list; $oTsr2->tsr_receive=($oTsr2->tsr_docname!="")?"Y":"N";
//$oTsr2->tsr_receive="Y"; //$oTsr2->tsr_status="r3"; $YY = date('Y')+543; $_tsr_receivedate=date("{$YY}-m-t G:i:s"); $oTsr2->tsr_receivedate=$_tsr_receivedate; //echo "<pre>"; print_r($oTsr2); exit; //$_SESSION['buff']['tsr_docname']=$_doc_list;
//echo $oTsr2->tsr_statusDocAtt." => "; $oTsr2->Save(); $oTsr2->Close(); file_get_contents($_url_full."/admin/admin_json.php?mod=updateStatusDocument&DocID={$tsr_docid}"); //echo "<tr><td align=\"left\"> >>>>> ดาวน์โหลดเอกสารสมบูรณ์ <<<<<</td></tr>"; }else{ //echo "<tr><td align=\"left\"> >>>>> เอกสารที่ดาวน์โหลดมาไม่สมบูรณ์ <<<<<</td></tr>"; } }else{ //echo "<tr><td align=\"left\"> >>>>> ไม่สามารถดาวน์โหลดเอกสารได้ <<<<<</td></tr>"; } //} //check N only } //split tsr_doc_url } //exit; echo "<meta http-equiv='refresh' content='0; URL=showDetailReceiveDocSRshow.php?page_id=$page_id&tsr_id=$tsr_id&selectcID=$selectcID&selectcID2=$selectcID2'>"; //Header("Location: showDetailReceiveDocSRshow.php?page_id=$page_id&tsr_id=$tsr_id&selectcID=$selectcID&selectcID2=$selectcID2"); ?>
|