Skip to content

Commit

Permalink
Correção na função de chamadas ao WXIS por POST
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusandrade committed Aug 24, 2017
1 parent 2b6ec7a commit 5f81a81
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions htdocs/isis-oai-provider/lib/ISISDb.php
Expand Up @@ -8,21 +8,21 @@ class ISISDb{

function ISISDb($dbname) {
global $CONFIG, $DATABASES;

$this->wxis_host = $_SERVER['HTTP_HOST'];
$this->dbname = $dbname;
$this->dbpath = $DATABASES[$dbname]['path'];
$this->wxis_action = $CONFIG['ENVIRONMENT']['CGI-BIN_DIRECTORY'] .
$this->wxis_action = $CONFIG['ENVIRONMENT']['CGI-BIN_DIRECTORY'] .
$CONFIG['ENVIRONMENT']['DIRECTORY'] . 'wxis.exe/' . $CONFIG['ENVIRONMENT']['DIRECTORY'] . 'wxis/';
$this->app_path = APPLICATION_PATH;

}


function get_list($params){
return wxis_list($params);
}

function getrecord($params, $key_length){
return utf8_encode ($this->wxis_document_get( $this->wxis_url("getrecord.xis", $params, $key_length) ));
}
Expand All @@ -34,11 +34,11 @@ function getidentifiers($params, $key_length){
function gettotal($params, $key_length){
return $this->wxis_document_post( $this->wxis_url("gettotal.xis",$params, $key_length) );
}

function index($params){
return wxis_index($params);
}

function wxis_document_get($url){
return file_get_contents($url);

Expand All @@ -52,22 +52,22 @@ function wxis_url ( $IsisScript, $params, $key_length = '1030' ) {
}

$request = "http://" . $this->wxis_host . $wxis_action . "?" . "IsisScript=" . $IsisScript . "&app_path=" . $this->app_path;


foreach ($params as $key => $value){
$request .= "&" . $key . "=" . $value;
}
return $request;

}

function wxis_document_post( $url, $content = "" ){
function wxis_document_post( $url, $content = "" ){
$content = str_replace("\\\"","\"",$content);
$content = str_replace("\n","",$content);
$content = str_replace("\r","",$content);
$content = str_replace("\\\\","\\",$content);

// Strip URL
// Strip URL
$url_parts = parse_url($url);
$host = $url_parts["host"];
$port = ($url_parts["port"]) ? $url_parts["port"] : 80;
Expand All @@ -79,32 +79,32 @@ function wxis_document_post( $url, $content = "" ){
}
$timeout = 10;
$contentLength = strlen($query);
// Generate the request header
$ReqHeader =
"POST $path HTTP/1.0\n".
"Host: $host\n".
"User-Agent: PostIt\n".
"Content-Type: application/x-www-form-urlencoded\n".
"Content-Length: $contentLength\n\n".
"$query\n";
// Open the connection to the host

// Generate the request header
$ReqHeader =
"POST $path HTTP/1.1\r\n".
"Host: $host\r\n".
"User-Agent: PostIt\r\n".
"Content-Type: application/x-www-form-urlencoded\r\n".
"Content-Length: $contentLength\r\n\r\n".
"$query\r\n";

// Open the connection to the host
$fp = fsockopen($host, $port, $errno, $errstr, $timeout);
fputs( $fp, $ReqHeader );

fputs( $fp, $ReqHeader );
if ($fp) {
while (!feof($fp)){
$result .= fgets($fp, 4096);
}
}

$response = strstr($result,"\n\r");
$response = trim($response);

return $response;
return $response;
}

}

?>
?>

0 comments on commit 5f81a81

Please sign in to comment.