From 4e69b9089a0b7a98ed86d76a91a9682c2bb05d6d Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Thu, 9 Jan 2025 09:25:19 +0800 Subject: [PATCH] 1 --- application/api/controller/Article.php | 1 + application/common.php | 3 ++ application/master/controller/Datebase.php | 59 +++++++++++++++++++++- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index 62cc36b..c73b1a2 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -142,6 +142,7 @@ class Article extends Controller { $article_info['publication'] = date('Y/m/d', strtotime($article_info['pub_date'])); //修改keywords $article_info['keywords'] = str_replace(',', '    ', $article_info['keywords']); + $article_info['has_html'] = hasHtml($article_info['article_id']); //更改适应期刊改名后的期刊名称 $journal_info['title'] = choiseti1($article_info['article_id'],$journal_info['title']); //返回数据 diff --git a/application/common.php b/application/common.php index 7546111..6bab626 100644 --- a/application/common.php +++ b/application/common.php @@ -268,6 +268,9 @@ function getAuthor($article) { } + + + function pushSFTPForScopus($file,$pdf_file,$stage_info) { $host = 'sftp-opsbank2.elsevier.com'; diff --git a/application/master/controller/Datebase.php b/application/master/controller/Datebase.php index d957a2e..74450b8 100644 --- a/application/master/controller/Datebase.php +++ b/application/master/controller/Datebase.php @@ -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) {