This commit is contained in:
wangjinlei
2025-01-09 09:25:19 +08:00
parent d6bfe3dce6
commit 4e69b9089a
3 changed files with 62 additions and 1 deletions

View File

@@ -245,7 +245,7 @@ class Datebase extends Controller
$file = ROOT_PATH."public/articleXML/".substr($article_info['doi'],strpos($article_info['doi'],"/")+1).".xml";
if(is_file($file)){
return ;
return $file;
}
@@ -392,6 +392,7 @@ class Datebase extends Controller
file_put_contents($file, $x);
return $file;
}
@@ -819,10 +820,43 @@ class Datebase extends Controller
if($journal_info['journal_id']==1){
$this->scopusPushXML($data["journal_stage_id"]);//scopus数据库
}
if(in_array($journal_info["journal_id"],[2,8,20,15,9,10,3,1])){//ep数据库
$this->pushXmlToEp($data["journal_stage_id"]);
}
return jsonSuccess([]);
}
public function Eptest(){
$data = $this->request->post();
$rule = new Validate([
"stage_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$this->pushXmlToEp($data['stage_id']);
}
public function pushXmlToEp($stage_id){
$stage_info = $this->journal_stage_obj->where("journal_stage_id",$stage_id)->find();
$list = $this->article_obj->where("journal_stage_id",$stage_id)->select();
$journal_info = $this->journal_obj->where("journal_id",$stage_info['journal_id'])->find();
foreach ($list as $v){
$local_file = $this->xmlCreateForArticle($v['article_id']);
$file = substr($v['doi'],strpos($v['doi'],"/")+1).".xml";
$remote_file = "/".$journal_info['title']."/".$stage_info['stage_year']."v".$stage_info['stage_vol']."n".$stage_info['stage_no']."-".$file;
$this->pushFtpForEp($remote_file,$local_file);
$localPdf = ROOT_PATH."public/articlePDF/".$v['file_pdf'];
$remotePdf = "/".$journal_info['title']."/".$stage_info['stage_year']."v".$stage_info['stage_vol']."n".$stage_info['stage_no']."-".substr($v['doi'],strpos($v['doi'],"/")+1).".pdf";
$this->pushFtpForEp($remotePdf,$localPdf);
}
}
public function dataPushForLx(){
$data = $this->request->post();
$rule = new Validate([
@@ -1129,6 +1163,29 @@ class Datebase extends Controller
phpinfo();
}
private function pushFtpForEp($remote_file,$local_file){
$ftp = [
'server' => 'ftp.epnet.com',
'user' => '56704',
'pass' => 'o3Mys"(S'
];
$con = ftp_connect($ftp['server']);
$res = ftp_login($con, $ftp['user'], $ftp['pass']);
if (!$res) { //连接失败
exit('连接失败');
}
ftp_pasv($con, true);
$data = ftp_put($con, $remote_file,$local_file, FTP_BINARY);
if (!$data) { // 上传失败
exit('上传失败');
}
ftp_close($con);
}
// 连接ftp
private function sendFtp($url, $title)
{