1
This commit is contained in:
@@ -242,6 +242,13 @@ class Datebase extends Controller
|
||||
|
||||
$article_info = $this->article_obj->where("article_id",$article_id)->find();
|
||||
$journal_info = $this->journal_obj->where("journal_id",$article_info['journal_id'])->find();
|
||||
|
||||
$file = ROOT_PATH."public/articleXML/".substr($article_info['doi'],strpos($article_info['doi'],"/")+1).".xml";
|
||||
if(is_file($file)){
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
$xml = new \SimpleXMLElement('<article/>');
|
||||
// 设置命名空间
|
||||
$xml->addAttribute('xmlns:mml', 'http://www.w3.org/1998/Math/MathML');
|
||||
@@ -383,7 +390,7 @@ class Datebase extends Controller
|
||||
// echo $xml->asXML(); // 或者保存到文件,例如 $xml->asXML('output.xml');
|
||||
$x = $xml->asXML();
|
||||
|
||||
$file = ROOT_PATH."public/articleXML/".substr($article_info['doi'],strpos($article_info['doi'],"/")+1).".xml";
|
||||
|
||||
file_put_contents($file, $x);
|
||||
|
||||
}
|
||||
@@ -447,6 +454,71 @@ class Datebase extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function EBSCOtest(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"article_id"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$this->EBSCOPushXml($data['article_id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function EBSCOPushXml($article_id){
|
||||
$article_info = $this->article_obj->where("article_id",$article_id)->find();
|
||||
$journal_info = $this->journal_obj->where("journal_id",$article_info['journal_id'])->find();
|
||||
$this->xmlCreateForArticle($article_id);
|
||||
|
||||
|
||||
$file = substr($article_info['doi'],strpos($article_info['doi'],"/")+1).".xml";;
|
||||
$pdf_file = $article_info['file_pdf'];
|
||||
$stage_info = $this->journal_stage_obj->where("journal_stage_id",$article_info['journal_stage_id'])->find();
|
||||
|
||||
// 创建 SFTP 连接
|
||||
$ftp_host = 'ftp.epnet.com'; // FTP 服务器地址
|
||||
$ftp_user = '56704'; // FTP 用户名
|
||||
$ftp_pass = 'o3Mys"(S'; // FTP 密码
|
||||
$ftp_port = 21; // FTP 端口(默认 21)
|
||||
$local_file = ROOT_PATH."public/articleXML/".$file;//'path/to/local/file.txt'; // 本地文件路径
|
||||
$remote_file = '/'.$journal_info['title'].'/'.$stage_info['stage_year']."v".$stage_info['stage_vol']."n".$stage_info['stage_no']."-".$file; // 远程文件路径
|
||||
|
||||
$localPdf = ROOT_PATH."public/articlePDF/".$pdf_file;
|
||||
$remoteFilePdf = '/'.$journal_info['title'].'/'.$stage_info['stage_year']."v".$stage_info['stage_vol']."n".$stage_info['stage_no']."-".str_replace(".xml",".pdf",$file);
|
||||
// 建立 FTP 连接
|
||||
$ftp_conn = ftp_connect($ftp_host, $ftp_port);
|
||||
|
||||
if (!$ftp_conn) {
|
||||
return 'FTP 连接失败';
|
||||
}
|
||||
|
||||
// 登录 FTP 服务器
|
||||
$login_result = ftp_login($ftp_conn, $ftp_user, $ftp_pass);
|
||||
|
||||
if (!$login_result) {
|
||||
ftp_close($ftp_conn);
|
||||
return 'FTP 登录失败';
|
||||
}
|
||||
|
||||
ftp_pasv($ftp_conn, true);
|
||||
|
||||
// 上传文件
|
||||
ftp_put($ftp_conn, $remote_file, $local_file, FTP_ASCII);
|
||||
ftp_put($ftp_conn, $remoteFilePdf, $localPdf, FTP_BINARY);
|
||||
|
||||
// if ($upload) {
|
||||
// $result = '文件上传成功';
|
||||
// } else {
|
||||
// $result = '文件上传失败';
|
||||
// }
|
||||
|
||||
// 关闭连接
|
||||
ftp_close($ftp_conn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送邮件至青年科学家
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user