This commit is contained in:
wangjinlei
2022-04-06 18:24:31 +08:00
parent e0e66e5abe
commit a9bdce100c
557 changed files with 153341 additions and 6448 deletions

View File

@@ -0,0 +1,86 @@
<?php
/*
* @author:administrator
* @createTime:2016-07-03
*/
class ArrayList
{
public $length;
public $name;
public $my_array;
function __construct()
{
$this->my_array=Array();
}
public function Add($element)
{
array_push($this->my_array, $element);
}
public function get_Length()
{
$this->length=count($this->my_array);
return $this->length;
}
public function get($key)
{
if(array_key_exists($key, $this->my_array))
{
echo $this->my_array[$key];
}
else
{
echo "û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>";
}
}
public function list_array()
{
foreach ($this->my_array as $value)
{
echo $value;
echo "<br/>";
}
}
public function Delete($key)
{
if(array_key_exists($key, $this->my_array))
{
$this->my_array[$key]=null;
}
else
{
echo "û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>";
}
}
public function erase_number()
{
$pattern="/[0-9]/";
foreach ($this->my_array as $value)
{
if(eregi($pattern, $value))
{
$value="";
}
}
foreach ($this->my_array as $value)
{
echo $value;
echo"<br/>";
}
}
public function erase_char()
{
$pattern='/a-zA-Z/';
for($i=0;$i<count($this->my_array)-1;$i++)
{
if(eregi($pattern, $this->my_array[$i]))
{
$this->my_array[$i]=null;
}
}
foreach ($this->my_array as $value)
{
echo $value;
echo "<br/>";
}
}
}

View File

@@ -0,0 +1,238 @@
<?php
/*
* @author:administrator
* @createTime:2016-07-03
*/
class DoiRegResult {
/**
* 查询结果
*/
var $queryMsg;
/**
* 用户名
*/
var $userName;
/**
* 用户上传的文件名
*/
var $oldFileName;
/**
* 上传以后系统换成的文件名
*/
var $newFileName;
/**
* 提交时间
*/
var $date;
/**
* 类型
*/
var $type;
/**
* 状态
*/
var $state;
/**
* 完成时间
*/
var $completeDate;
/**
* 结果文件地址
*/
var $resultFileUrl;
/**
* 结果文件内容
*/
var $resultFileText;
/**
* 取得查询结果
*
* @return 查询结果
*/
function getQueryMsg() {
return $this->queryMsg;
}
/**
* 设置查询结果
*
* @param 查询结果
*/
function setQueryMsg( $queryMsg) {
$this->queryMsg = $queryMsg;
}
/**
* 取得用户名
*
* @return 用户名
*/
function getUserName() {
return $this->userName;
}
/**
* 设置用户名
*
* @param 用户名
*/
function setUserName( $userName) {
$this->userName = $userName;
}
/**
* 取得用户上传的文件名
*
* @return 用户上传的文件名
*/
function getOldFileName() {
return $this->oldFileName;
}
/**
* 设置用户上传的文件名
*
* @param 用户上传的文件名
*/
function setOldFileName( $oldFileName) {
$this->oldFileName = $oldFileName;
}
/**
* 取得上传以后系统换成的文件名
*
* @return 上传以后系统换成的文件名
*/
function getNewFileName() {
return $this->newFileName;
}
/**
* 设置上传以后系统换成的文件名
*
* @param 上传以后系统换成的文件名
*/
function setNewFileName( $newFileName) {
$this->newFileName = $newFileName;
}
/**
* 取得提交时间
*
* @return 提交时间
*/
function getDate() {
return $this->date;
}
/**
* 设置提交时间
*
* @param 提交时间
*/
function setDate( $date) {
$this->date = $date;
}
/**
* 取得类型
*
* @return 类型
*/
function getType() {
return $this->type;
}
/**
* 设置类型
*
* @param 类型
*/
function setType( $type) {
$this->type = $type;
}
/**
* 取得状态
*
* @return 状态
*/
function getState() {
return $this->state;
}
/**
* 设置状态
*
* @param 状态
*/
function setState( $state) {
$this->state = $state;
}
/**
* 取得完成时间
*
* @return 完成时间
*/
function getCompleteDate() {
return $this->completeDate;
}
/**
* 设置完成时间
*
* @param 完成时间
*/
function setCompleteDate( $completeDate) {
$this->completeDate = $completeDate;
}
/**
* 取得结果文件地址
*
* @return 结果文件地址
*/
function getResultFileUrl() {
return $this->resultFileUrl;
}
/**
* 设置结果文件地址
*
* @param 结果文件地址
*/
function setResultFileUrl( $resultFileUrl) {
$this->resultFileUrl = $resultFileUrl;
}
/**
* 取得结果文件内容
*
* @return 结果文件内容
*/
function getResultFileText() {
return $this->resultFileText;
}
/**
* 设置结果文件内容
*
* @param 结果文件内容
*/
function setResultFileText( $resultFileText) {
$this->resultFileText = $resultFileText;
}
}

View File

@@ -0,0 +1,340 @@
<?php
/*
* * @author:administrator
* @createTime:2016-07-03
*/
class HttpClient {
// Request vars
var $host;
var $port;
var $path;
var $method;
var $postdata = '';
var $cookies = array();
var $referer;
var $accept = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*';
var $accept_encoding = 'gzip';
var $accept_language = 'en-us';
var $user_agent = 'Incutio HttpClient v0.9';
// Options
var $timeout = 20;
var $use_gzip = true;
var $persist_cookies = true; // If true, received cookies are placed in the $this->cookies array ready for the next request
// Note: This currently ignores the cookie path (and time) completely. Time is not important,
// but path could possibly lead to security problems.
var $persist_referers = true; // For each request, sends path of last request as referer
var $debug = false;
var $handle_redirects = true; // Auaomtically redirect if Location or URI header is found
var $max_redirects = 5;
var $headers_only = false; // If true, stops receiving once headers have been read.
// Basic authorization variables
var $username;
var $password;
// Response vars
var $status;
var $headers = array();
var $content = '';
var $errormsg;
// Tracker variables
var $redirect_count = 0;
var $cookie_host = '';
function HttpClient($host, $port=80) {
$this->host = $host;
$this->port = $port;
}
function get($path, $data = false) {
$this->path = $path;
$this->method = 'GET';
if ($data) {
$this->path .= '?'.$this->buildQueryString($data);
}
return $this->doRequest();
}
function post($path, $data) {
$this->path = $path;
$this->method = 'POST';
$this->postdata = $this->buildQueryString($data);
return $this->doRequest();
}
function buildQueryString($data) {
$querystring = '';
if (is_array($data)) {
// Change data in to postable data
foreach ($data as $key => $val) {
if (is_array($val)) {
foreach ($val as $val2) {
$querystring .= urlencode($key).'='.urlencode($val2).'&';
}
} else {
$querystring .= urlencode($key).'='.urlencode($val).'&';
}
}
$querystring = substr($querystring, 0, -1); // Eliminate unnecessary &
} else {
$querystring = $data;
}
return $querystring;
}
function doRequest() {
// Performs the actual HTTP request, returning true or false depending on outcome
if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) {
// Set error message
switch($errno) {
case -3:
$this->errormsg = 'Socket creation failed (-3)';
case -4:
$this->errormsg = 'DNS lookup failure (-4)';
case -5:
$this->errormsg = 'Connection refused or timed out (-5)';
default:
$this->errormsg = 'Connection failed ('.$errno.')';
$this->errormsg .= ' '.$errstr;
$this->debug($this->errormsg);
}
return false;
}
socket_set_timeout($fp, $this->timeout);
$request = $this->buildRequest();
$this->debug('Request', $request);
fwrite($fp, $request);
// Reset all the variables that should not persist between requests
$this->headers = array();
$this->content = '';
$this->errormsg = '';
// Set a couple of flags
$inHeaders = true;
$atStart = true;
// Now start reading back the response
while (!feof($fp)) {
$line = fgets($fp, 4096);
if ($atStart) {
// Deal with first line of returned data
$atStart = false;
if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) {
$this->errormsg = "Status code line invalid: ".htmlentities($line);
$this->debug($this->errormsg);
return false;
}
$http_version = $m[1]; // not used
$this->status = $m[2];
$status_string = $m[3]; // not used
$this->debug(trim($line));
continue;
}
if ($inHeaders) {
if (trim($line) == '') {
$inHeaders = false;
$this->debug('Received Headers', $this->headers);
if ($this->headers_only) {
break; // Skip the rest of the input
}
continue;
}
if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) {
// Skip to the next header
continue;
}
$key = strtolower(trim($m[1]));
$val = trim($m[2]);
// Deal with the possibility of multiple headers of same name
if (isset($this->headers[$key])) {
if (is_array($this->headers[$key])) {
$this->headers[$key][] = $val;
} else {
$this->headers[$key] = array($this->headers[$key], $val);
}
} else {
$this->headers[$key] = $val;
}
continue;
}
// We're not in the headers, so append the line to the contents
$this->content .= $line;
}
fclose($fp);
// If data is compressed, uncompress it
if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') {
$this->debug('Content is gzip encoded, unzipping it');
$this->content = substr($this->content, 10); // See http://www.php.net/manual/en/function.gzencode.php
$this->content = gzinflate($this->content);
}
// If $persist_cookies, deal with any cookies
if ($this->persist_cookies && isset($this->headers['set-cookie']) && $this->host == $this->cookie_host) {
$cookies = $this->headers['set-cookie'];
if (!is_array($cookies)) {
$cookies = array($cookies);
}
foreach ($cookies as $cookie) {
if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) {
$this->cookies[$m[1]] = $m[2];
}
}
// Record domain of cookies for security reasons
$this->cookie_host = $this->host;
}
// If $persist_referers, set the referer ready for the next request
if ($this->persist_referers) {
$this->debug('Persisting referer: '.$this->getRequestURL());
$this->referer = $this->getRequestURL();
}
// Finally, if handle_redirects and a redirect is sent, do that
if ($this->handle_redirects) {
if (++$this->redirect_count >= $this->max_redirects) {
$this->errormsg = 'Number of redirects exceeded maximum ('.$this->max_redirects.')';
$this->debug($this->errormsg);
$this->redirect_count = 0;
return false;
}
$location = isset($this->headers['location']) ? $this->headers['location'] : '';
$uri = isset($this->headers['uri']) ? $this->headers['uri'] : '';
if ($location || $uri) {
$url = parse_url($location.$uri);
// This will FAIL if redirect is to a different site
return $this->get($url['path']);
}
}
return true;
}
function buildRequest() {
$headers = array();
$headers[] = "{$this->method} {$this->path} HTTP/1.0"; // Using 1.1 leads to all manner of problems, such as "chunked" encoding
$headers[] = "Host: {$this->host}";
$headers[] = "User-Agent: {$this->user_agent}";
$headers[] = "Accept: {$this->accept}";
if ($this->use_gzip) {
$headers[] = "Accept-encoding: {$this->accept_encoding}";
}
$headers[] = "Accept-language: {$this->accept_language}";
if ($this->referer) {
$headers[] = "Referer: {$this->referer}";
}
// Cookies
if ($this->cookies) {
$cookie = 'Cookie: ';
foreach ($this->cookies as $key => $value) {
$cookie .= "$key=$value; ";
}
$headers[] = $cookie;
}
// Basic authentication
if ($this->username && $this->password) {
$headers[] = 'Authorization: BASIC '.base64_encode($this->username.':'.$this->password);
}
// If this is a POST, set the content type and length
if ($this->postdata) {
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'Content-Length: '.strlen($this->postdata);
}
$request = implode("\r\n", $headers)."\r\n\r\n".$this->postdata;
return $request;
}
function getStatus() {
return $this->status;
}
function getContent() {
return $this->content;
}
function getHeaders() {
return $this->headers;
}
function getHeader($header) {
$header = strtolower($header);
if (isset($this->headers[$header])) {
return $this->headers[$header];
} else {
return false;
}
}
function getError() {
return $this->errormsg;
}
function getCookies() {
return $this->cookies;
}
function getRequestURL() {
$url = 'http://'.$this->host;
if ($this->port != 80) {
$url .= ':'.$this->port;
}
$url .= $this->path;
return $url;
}
// Setter methods
function setUserAgent($string) {
$this->user_agent = $string;
}
function setAuthorization($username, $password) {
$this->username = $username;
$this->password = $password;
}
function setCookies($array) {
$this->cookies = $array;
}
// Option setting methods
function useGzip($boolean) {
$this->use_gzip = $boolean;
}
function setPersistCookies($boolean) {
$this->persist_cookies = $boolean;
}
function setPersistReferers($boolean) {
$this->persist_referers = $boolean;
}
function setHandleRedirects($boolean) {
$this->handle_redirects = $boolean;
}
function setMaxRedirects($num) {
$this->max_redirects = $num;
}
function setHeadersOnly($boolean) {
$this->headers_only = $boolean;
}
function setDebug($boolean) {
$this->debug = $boolean;
}
// "Quick" static methods
function quickGet($url) {
$bits = parse_url($url);
$host = $bits['host'];
$port = isset($bits['port']) ? $bits['port'] : 80;
$path = isset($bits['path']) ? $bits['path'] : '/';
if (isset($bits['query'])) {
$path .= '?'.$bits['query'];
}
$client = new HttpClient($host, $port);
if (!$client->get($path)) {
return false;
} else {
return $client->getContent();
}
}
function quickPost($url, $data) {
$bits = parse_url($url);
$host = $bits['host'];
$port = isset($bits['port']) ? $bits['port'] : 80;
$path = isset($bits['path']) ? $bits['path'] : '/';
$client = new HttpClient($host, $port);
if (!$client->post($path, $data)) {
return false;
} else {
return $client->getContent();
}
}
function debug($msg, $object = false) {
if ($this->debug) {
print '<div style="border: 1px solid red; padding: 0.5em; margin: 0.5em;"><strong>HttpClient Debug:</strong> '.$msg;
if ($object) {
ob_start();
print_r($object);
$content = htmlentities(ob_get_contents());
ob_end_clean();
print '<pre>'.$content.'</pre>';
}
print '</div>';
}
}
}
?>

View File

@@ -0,0 +1,109 @@
<?php
/**
* @className:LoginResult.php
* @classDescription:系统登录结果类
* @author:administrator
* @createTime:2016-07-03
*/
class LoginResult {
/**
* cookie信息
*/
var $cookies;
/**
* 用户ID
*/
var $userId;
/**
* 用户类型
*/
var $companyType;
/**
* 登录状态
*/
var $loginState;
/**
* 取得cookie信息
*
* @return cookie信息
*/
function __construct()
{
}
function getCookies() {
return $this->cookies;
}
/**
* 设置cookie信息
*
* @param cookie信息
*/
function setCookies($cookies) {
$this->cookies = $cookies;
}
/**
* 取得用户ID
*
* @return 用户ID
*/
function getUserId() {
return $this->userId;
}
/**
* 设置用户ID
*
* @param 用户ID
*/
function setUserId( $userId) {
$this->userId = $userId;
}
/**
* 取得用户类型
*
* @return 用户类型
*/
function getCompanyType() {
return $this->companyType;
}
/**
* 设置用户类型
*
* @param 用户类型
*/
function setCompanyType( $companyType) {
$this->companyType = $companyType;
}
/**
* 取得登录状态
*
* @return 登录状态
*/
function getLoginState() {
return $this->loginState;
}
/**
* 设置登录状态
*
* @param 登录状态
*/
function setLoginState( $loginState) {
$this->loginState = $loginState;
}
}

107
vendor/chinadoi/include/LoginResult.php vendored Normal file
View File

@@ -0,0 +1,107 @@
<?php
/**
* @className:LoginResult.php
* @classDescription:系统登录结果类
* @author:administrator
* @createTime:2016-07-03
*/
class LoginResult {
/**
* cookie信息
*/
var $cookies;
/**
* 用户ID
*/
var $userId;
/**
* 用户类型
*/
var $companyType;
/**
* 登录状态
*/
var $loginState;
/**
* 取得cookie信息
*
* @return cookie信息
*/
function __construct() {
}
function getCookies() {
return $this->cookies;
}
/**
* 设置cookie信息
*
* @param cookie信息
*/
function setCookies($cookies) {
$this->cookies = $cookies;
}
/**
* 取得用户ID
*
* @return 用户ID
*/
function getUserId() {
return $this->userId;
}
/**
* 设置用户ID
*
* @param 用户ID
*/
function setUserId($userId) {
$this->userId = $userId;
}
/**
* 取得用户类型
*
* @return 用户类型
*/
function getCompanyType() {
return $this->companyType;
}
/**
* 设置用户类型
*
* @param 用户类型
*/
function setCompanyType($companyType) {
$this->companyType = $companyType;
}
/**
* 取得登录状态
*
* @return 登录状态
*/
function getLoginState() {
return $this->loginState;
}
/**
* 设置登录状态
*
* @param 登录状态
*/
function setLoginState($loginState) {
$this->loginState = $loginState;
}
}

View File

@@ -0,0 +1,91 @@
<?php
/*
* @author:administrator
* @createTime:2016-07-03
*/
Class MyCookie
{
function ReadCookie($cookiefile="../../tmp.cookie")
{
$cookie_folder = dirname(__FILE__)."/temp";
$lines = file($cookie_folder."/$cookiefile");
$rtn=array();
foreach($lines as $line) {
// if($line[0] != '#' && substr_count($line, "\t") == 6) {
die("--ss-");
$tokens = explode("\t", $line);
$tokens = array_map('trim', $tokens);
$tokens[4] = date('Y-m-d h:i:s', $tokens[4]);
if(strpos($tokens[6], "~")!=false )
{
$tmpary=exploed($tokens[6],"~");
$rtn["userId"]=$tmpary[0];
$rtn["userName"]=$tmpary[1];
$rtn["companyType"]=$tmpary[2];
return $rtn;
}
//}
}
return $rtn;
}
function join_cookie($cook)
{
foreach( $cook as $k=>$v )
{
$d[] =$k."=".$v;
}
$data = implode(";",$d);
return $data;
}
function pase_cookie($cookFile,$encode=true)
{
$cookie = file_get_contents ( $cookFile );
$citem = explode("*\n",$cookie);
foreach( $citem as $c )
{
list($ckey,$cvalue) = explode("\n",$c);
if($ckey!='')$cook[$ckey] = $cvalue;
}
return $cook;
}
}
?>
<?php
////test ...
/*
$MyCookieC=new MyCookie();
$MyCookieC->ReadCookie();
*/
?>

View File

@@ -0,0 +1,377 @@
<?php
/**
* 上传文件
*
* @author:administrator
* @createTime:2016-07-03
*
*/
include_once('UserLoginQ2.class.php');
include_once('UploadResult.class.php');
include_once('DoiRegResult.class.php');
class UploadFileQ2 {
var $filePath;// 源文件路径,要上传的文件的全路径包括文件名
var $userId;// 用户id
var $companyType;// 机构类型
//var $doiurl="127.0.0.1:8080/chinadoi-portal";
var $ip=null;
// 构造方法
function __construct() {
}
/**
*
* @param filePath 源文件路径,要上传的文件的全路径包括文件名
* @param userId 用户id
* @param companyType 机构类型
* @return 上传结果 文件上传成功
文件名、目录名或卷标语法不正确
请输入文件名称
您输入的文件名含有非法字符
已有同名文件夹
文件重命名错误请与管理员联系或者重新上传
插入记录有错误请与管理员联系
文件不存在
服务器连接失败
*/
function upload( $filePath, $username, $password, $oprType){
$CUserLoginO2X=new UserLoginQ2();
if(empty($this->ip)) $this->ip=SERVERIP;
$ip=$this->ip;
$loginresult=$CUserLoginO2X->userlogin($username, $password,$ip);
if($loginresult->loginState!=="登录成功") return $loginresult->loginState;
return $this->uploadX1($filePath, $loginresult->userId, $loginresult->companyType,$oprType);
}
function upload2( $filePath, $username, $password, $oprType){
$CUserLoginO2X=new UserLoginQ2();
if(empty($this->ip)) $this->ip=SERVERIP;
$ip=$this->ip;
$loginresult=$CUserLoginO2X->userlogin($username, $password,$ip);
if($loginresult->loginState!=="登录成功") return $loginresult->loginState;
return $this->uploadX2($filePath, $loginresult->userId, $loginresult->companyType,$oprType);
}
function uploadX1($targetFile, $userId, $companyType, $oprType) {
$rtn="文件上传失败";
$cookie_file = COOKIEFILE;
if(!file_exists($cookie_file))
{
echo "cookie_file is not exists!";
die();
}
$this->userId=$userId;
$this->companyType=$companyType;
$upurl=$this->ip."/chinadoi-manage/manage/doidata-upload.action";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$upurl );
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
//curl_setopt($ch, CURLOPT_URL, _VIRUS_SCAN_URL);
curl_setopt($ch, CURLOPT_POST, true);
$post = array(
"fileForm_upload"=>"@$targetFile",
"upload"=>"@$targetFile",
"OTList"=>"DOI注册",
"userId"=> $this->userId,
"companyType"=> $this->companyType,
"clientState"=> true,
"pageType"=> "clientUpFile",
"mes"=> "",
"allUpSpace"=> "1000",
"upFileSpace"=> "15.0",
"oddSpace"=> "999.96",
"rootPath"=> "E:/chinadoi/backup/UserFiles/552",
"filePath"=> "/待审核的文件/追加数据",
"upFileType"=> "3",
"outputfiletype"=> "2",
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$result = curl_exec($ch);
if(strpos($result, "文件上传成功")!=false )
{
$rtn= $uploadState="文件上传成功";
}
return $rtn;
}
function uploadX2($targetFile, $userId, $companyType, $oprType)
{
$rtn = new UploadResult();
$cookie_file = COOKIEFILE;
$uploadMsg = "服务器连接失败";
$newFileNames = array();
if(!file_exists($cookie_file))
{
//echo "cookie_file is not exists!";
$uploadMsg = $targetFile. "用户未授权";
$rtn->setUploadState($uploadMsg);
return $rtn;
}
if(!file_exists($targetFile)&&!is_dir($dir)){
$uploadMsg = $targetFile. "文件上传失败!文件或目录不存在";
$rtn->setUploadState($uploadMsg);
return $rtn;
}
$checkResult = is_dir($targetFile);
if($checkResult==true){
$filesnames = scandir($targetFile);
foreach ($filesnames as $subfile) {
if($subfile!="." && $subfile!="..")
{
$subfile=$targetFile."/".$subfile;
$uploadresult=new UploadResult();
$uploadresult = $this->uploadX2($subfile, $userId, $companyType,$oprType);
if ("文件上传成功"!=$uploadresult->getUploadState()) {
return $uploadresult;
}
$newFileNames = array_merge((array)$newFileNames, (array)$uploadresult->getNewFileNames());
}
}
$rtn->setUploadState("文件上传成功");
$rtn->setNewFileNames($newFileNames);
return $rtn;
}
/////////////////////////////////////////////////////
$this->userId=$userId;
$this->companyType=$companyType;
if ($oprType == 1) {
// 上传类型
$filePath="/待审核的文件/批量DOI查询";
} else if ($oprType == 2) {
// 上传类型
$filePath="/待审核的文件/批量元数据查询";
} else if ($oprType == 3) {
// 上传类型
$filePath="/待审核的文件/追加数据";
} else if ($oprType == 4) {
// 上传类型
$filePath="/待审核的文件/修改数据";
}
else
{
$filePath="/待审核的文件/追加数据";
}
$post = array(
"upload"=>"@$targetFile",
"userId"=>$this->userId,
"companyType"=>$this->companyType,
"upFileSpace_s"=>filesize($targetFile) ,
"clientState"=> true,
"filePath"=> $filePath,
"upFileType"=> "3",
"pageType"=> "clientUpFile",
);
$upurl=$this->ip."/chinadoi-manage/manage/doidata-upload.action";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$upurl );
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
//curl_setopt($ch, CURLOPT_URL, _VIRUS_SCAN_URL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$result = curl_exec($ch);
$header =null;
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == '200') {
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($result, 0, $headerSize);
}
curl_close($ch);
$state=null;
$newfilename=null;
if(empty($header))
{
$uploadMsg = "服务器连接失败";
}
else
{
$headArr = explode("\n", $header);
foreach ($headArr as $line) {
if(strpos($line, "state") !== false){
$tmpary=explode(":",$line);
$state = trim($tmpary[1]);
}
// 获取新文件名
if(strpos($line, "newFileName") !== false){
$tmpary=explode(":",$line);
$newfilename = trim($tmpary[1]);
}
}
if($state!=null ){
if($state=="upFile1"){
$uploadMsg = "文件上传成功";
} else if($state=="upFile4"){
$uploadMsg = $targetFile. "文件上传失败!文件名、目录名或卷标语法不正确";
} else if($state=="upFile5"){
$uploadMsg = $targetFile. "文件上传失败!请输入文件名称";
} else if($state=="upFile6"){
$uploadMsg = $targetFile. "文件上传失败!您输入的文件名含有非法字符";
} else if($state=="upFile7"){
$uploadMsg = $targetFile. "文件上传失败!已有同名文件夹";
} else if($state=="upFile9"){
$uploadMsg = $targetFile. "文件上传失败!文件重命名错误请与管理员联系或者重新上传";
} else if($state=="upFile10"){
$uploadMsg = $targetFile. "文件上传失败!插入记录有错误请与管理员联系";
}
else
{
$uploadMsg = $targetFile. "文件上传失败!未知原因";
}
$rtn->setNewFileNames($newfilename);
} else {
$uploadMsg = "用户没有分配角色!请与管理员联系";
}
}
$rtn->setUploadState($uploadMsg);
return $rtn;
}
/**
* DOI注册结果查询
*
* @param fileName 系统中的文件名
* @param userName 用户名
* @param password 密码
* @return DOI注册结果类
*/
function getDoiRegResult( $fileName, $userName, $password) {
// 初始化返回结果
$result = null;
$wsdl = DOIQUERYSERVICEURL;
$client = new SoapClient($wsdl);
$param = array('in0'=>$fileName,'in1'=>$userName,'in2'=>$password);
$ret = $client->getDoiRegResult($param);
if ($ret->out){
$result = $ret->out;
}
return $result;
}
}
?>

View File

@@ -0,0 +1,58 @@
<?php
/**
* @className:UploadResult.php
* @classDescription:文件上传结果类
* @author:adminstrator
* @createTime:2016-07-12
*/
class UploadResult {
/**
* 上传状态
*/
var $uploadState;
/**
* 系统中的文件名
*/
var $newFileNames;
/**
* 取得上传状态
*
* @return 上传状态
*/
function getUploadState() {
return $this->uploadState;
}
/**
* 设置上传状态
*
* @param 上传状态
*/
function setUploadState( $uploadState) {
$this->uploadState = $uploadState;
}
/**
* 取得系统中的文件名
*
* @return 系统中的文件名
*/
function getNewFileNames() {
return $this->newFileNames;
}
/**
* 设置系统中的文件名
*
* @param 系统中的文件名
*/
function setNewFileNames( $newFileNames) {
$this->newFileNames = $newFileNames;
}
}

View File

@@ -0,0 +1,179 @@
<?php
/*
* @author:administrator
* @createTime:2016-07-03
*/
header('Content-Type: text/html; charset=utf-8');
//include_once("../config.php");
include_once 'LoginResult.class.php';
//define('SERVERIP','168.160.19.48:8080');
Class UserLoginQ2
{
var $loginurl="chinadoi-manage/manage/login.action?";
var $loginresult=null;
var $ip=null;
function userlogin( $userName, $password,$ip)
{
if(empty($this->ip))
$this->ip=SERVERIP;
$loginState = "服务器连接失败";
/**
* 模拟登录
*/
//初始化变量
$cookie_file = COOKIEFILE;
$loginurl="chinadoi-manage/manage/login.action?";
$login_url = "http://$ip/$loginurl";
$post = "userName=".$userName."&password=".$password;
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_exec($ch);
curl_close($ch);
//带上cookie文件访问需要访问的页面
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$result = curl_exec($ch);
curl_close($ch);
//清理cookie文件
// unlink($cookie_file);
//这一块根据自己抓包获取到的网站上的数据来做判断
$loginresult=new LoginResult();
//echo $result;
if(strpos($result, "user-login!loginOut.action") !== false)
{
$loginState = "登录成功";
$arycookie=ReadCookie();
//print_r($arycookie);
$loginresult->userId=$arycookie["userId"];
$loginresult->companyType=$arycookie["companyType"];
$loginresult->loginState=$loginState;
}else{
$loginresult->loginState= $loginState ;
exit;
}
return $loginresult;
}
}
?>
<?php
function ReadCookie()
{
$rtn=array();
$cookie_file = COOKIEFILE;
//$handle = fopen("c:\\folder\\resource.txt", "w+");
if(!file_exists($cookie_file))
{
return $rtn;
}
$lines = file($cookie_file);
$trows = '';
foreach($lines as $line) {
if($line[0] != '#' && substr_count($line, "\t") == 6) {
$tokens = explode("\t", $line);
$tokens = array_map('trim', $tokens);
$tokens[4] = date('Y-m-d h:i:s', $tokens[4]);
//echo $tokens[6]."<br/>";
if(strpos($tokens[6], "~")!=false )
{
$tmpary=explode("~",$tokens[6]);
$rtn["userId"]=$tmpary[0];
$rtn["userName"]=$tmpary[1];
$rtn["companyType"]=$tmpary[2];
return $rtn;
}
// $trows .= '<tr><td>' . implode('</td><td>', $tokens) . '</td></tr>' . PHP_EOL;
}
}
//echo '<table>'.PHP_EOL.'<tbody>'.PHP_EOL.$trows.'</tbody>'.PHP_EOL.'</table>';
return $rtn;
}
?>
<?php
/////////// test....
/*
$userloginQ2=new UserLoginQ2X();
$loginresult=$userloginQ2->userlogin("test01", "test01", "168.160.19.48:8080");
echo $loginresult->loginState;
echo "<br/>";
echo $loginresult->userId;
*/
?>