本文整理汇总了PHP中PEAR::errorMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR::errorMessage方法的具体用法?PHP PEAR::errorMessage怎么用?PHP PEAR::errorMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR
的用法示例。
在下文中一共展示了PEAR::errorMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: call_epi
//.........这里部分代码省略.........
$len = strlen($request);
$req_headers = "Host: {$server_host}:{$server_port}\r\n" . "Content-type: text/xml\r\n" . "Content-length: {$len}\r\n";
$username = $this->config->get('username');
$password = $this->config->get('password');
if ($username && $password) {
$req_headers .= "Cookie: PEAR_USER={$username}; PEAR_PW={$password}\r\n";
$tmp = base64_encode("{$username}:{$password}");
$req_headers .= "Authorization: Basic {$tmp}\r\n";
}
if ($this->cache !== null) {
$maxAge = '?maxAge=' . $this->cache['lastChange'];
} else {
$maxAge = '';
}
if ($use_proxy && $proxy_host != '' && $proxy_user != '') {
$req_headers .= 'Proxy-Authorization: Basic ' . base64_encode($proxy_user . ':' . $proxy_pass) . "\r\n";
}
if ($this->config->get('verbose') > 3) {
print "XMLRPC REQUEST HEADERS:\n";
var_dump($req_headers);
print "XMLRPC REQUEST BODY:\n";
var_dump($request);
}
if ($use_proxy && $proxy_host != '') {
$post_string = "POST http://" . $server_host;
if ($proxy_port > '') {
$post_string .= ':' . $server_port;
}
} else {
$post_string = "POST ";
}
$path = '/' . $channel->getPath('xmlrpc');
fwrite($fp, $post_string . $path . "{$maxAge} HTTP/1.0\r\n{$req_headers}\r\n{$request}");
$response = '';
$line1 = fgets($fp, 2048);
if (!preg_match('!^HTTP/[0-9\\.]+ (\\d+) (.*)!', $line1, $matches)) {
return $this->raiseError("PEAR_Remote: invalid HTTP response from XML-RPC server");
}
switch ($matches[1]) {
case "200":
// OK
break;
case "304":
// Not Modified
return $this->cache['content'];
case "401":
// Unauthorized
if ($username && $password) {
return $this->raiseError("PEAR_Remote ({$server_host}:{$server_port}) " . ": authorization failed", 401);
} else {
return $this->raiseError("PEAR_Remote ({$server_host}:{$server_port}) " . ": authorization required, please log in first", 401);
}
default:
return $this->raiseError("PEAR_Remote ({$server_host}:{$server_port}) : " . "unexpected HTTP response", (int) $matches[1], null, null, "{$matches['1']} {$matches['2']}");
}
while (trim(fgets($fp, 2048)) != '') {
}
// skip rest of headers
while ($chunk = fread($fp, 10240)) {
$response .= $chunk;
}
fclose($fp);
if ($this->config->get('verbose') > 3) {
print "XMLRPC RESPONSE:\n";
var_dump($response);
}
$ret = xmlrpc_decode($response);
if (is_array($ret) && isset($ret['__PEAR_TYPE__'])) {
if ($ret['__PEAR_TYPE__'] == 'error') {
if (isset($ret['__PEAR_CLASS__'])) {
$class = $ret['__PEAR_CLASS__'];
} else {
$class = "PEAR_Error";
}
if ($ret['code'] === '') {
$ret['code'] = null;
}
if ($ret['message'] === '') {
$ret['message'] = null;
}
if ($ret['userinfo'] === '') {
$ret['userinfo'] = null;
}
if (strtolower($class) == 'db_error') {
$ret = $this->raiseError(PEAR::errorMessage($ret['code']), $ret['code'], null, null, $ret['userinfo']);
} else {
$ret = $this->raiseError($ret['message'], $ret['code'], null, null, $ret['userinfo']);
}
}
} elseif (is_array($ret) && sizeof($ret) == 1 && isset($ret[0]) && is_array($ret[0]) && !empty($ret[0]['faultString']) && !empty($ret[0]['faultCode'])) {
extract($ret[0]);
$faultString = "XML-RPC Server Fault: " . str_replace("\n", " ", $faultString);
return $this->raiseError($faultString, $faultCode);
} elseif (is_array($ret) && sizeof($ret) == 2 && !empty($ret['faultString']) && !empty($ret['faultCode'])) {
extract($ret);
$faultString = "XML-RPC Server Fault: " . str_replace("\n", " ", $faultString);
return $this->raiseError($faultString, $faultCode);
}
return $ret;
}
示例2: call_epi
//.........这里部分代码省略.........
if (!$fp && $http_proxy) {
return $this->raiseError("PEAR_Remote::call: fsockopen(`{$proxy_host}', {$proxy_port}) failed");
} elseif (!$fp) {
return $this->raiseError("PEAR_Remote::call: fsockopen(`{$server_host}', {$server_port}) failed");
}
$len = strlen($request);
$req_headers = "Host: {$server_host}:{$server_port}\r\n" . "Content-type: text/xml\r\n" . "Content-length: {$len}\r\n";
$username = $this->config->get('username');
$password = $this->config->get('password');
if ($username && $password) {
$req_headers .= "Cookie: PEAR_USER={$username}; PEAR_PW={$password}\r\n";
$tmp = base64_encode("{$username}:{$password}");
$req_headers .= "Authorization: Basic {$tmp}\r\n";
}
if ($this->cache !== null) {
$maxAge = '?maxAge=' . $this->cache['lastChange'];
} else {
$maxAge = '';
}
if ($use_proxy && $proxy_host != '' && $proxy_user != '') {
$req_headers .= 'Proxy-Authorization: Basic ' . base64_encode($proxy_user . ':' . $proxy_pass) . "\r\n";
}
if ($this->config->get('verbose') > 3) {
print "XMLRPC REQUEST HEADERS:\n";
var_dump($req_headers);
print "XMLRPC REQUEST BODY:\n";
var_dump($request);
}
if ($use_proxy && $proxy_host != '') {
$post_string = "POST http://" . $server_host;
if ($proxy_port > '') {
$post_string .= ':' . $server_port;
}
} else {
$post_string = "POST ";
}
fwrite($fp, $post_string . "/xmlrpc.php{$maxAge} HTTP/1.0\r\n{$req_headers}\r\n{$request}");
$response = '';
$line1 = fgets($fp, 2048);
if (!preg_match('!^HTTP/[0-9\\.]+ (\\d+) (.*)!', $line1, $matches)) {
return $this->raiseError("PEAR_Remote: invalid HTTP response from XML-RPC server");
}
switch ($matches[1]) {
case "200":
// OK
break;
case "304":
// Not Modified
return $this->cache['content'];
case "401":
// Unauthorized
if ($username && $password) {
return $this->raiseError("PEAR_Remote: authorization failed", 401);
} else {
return $this->raiseError("PEAR_Remote: authorization required, please log in first", 401);
}
default:
return $this->raiseError("PEAR_Remote: unexpected HTTP response", (int) $matches[1], null, null, "{$matches['1']} {$matches['2']}");
}
while (trim(fgets($fp, 2048)) != '') {
}
// skip rest of headers
while ($chunk = fread($fp, 10240)) {
$response .= $chunk;
}
fclose($fp);
if ($this->config->get('verbose') > 3) {
print "XMLRPC RESPONSE:\n";
var_dump($response);
}
$ret = xmlrpc_decode($response);
if (is_array($ret) && isset($ret['__PEAR_TYPE__'])) {
if ($ret['__PEAR_TYPE__'] == 'error') {
if (isset($ret['__PEAR_CLASS__'])) {
$class = $ret['__PEAR_CLASS__'];
} else {
$class = "PEAR_Error";
}
if ($ret['code'] === '') {
$ret['code'] = null;
}
if ($ret['message'] === '') {
$ret['message'] = null;
}
if ($ret['userinfo'] === '') {
$ret['userinfo'] = null;
}
if (strtolower($class) == 'db_error') {
$ret = $this->raiseError(PEAR::errorMessage($ret['code']), $ret['code'], null, null, $ret['userinfo']);
} else {
$ret = $this->raiseError($ret['message'], $ret['code'], null, null, $ret['userinfo']);
}
}
} elseif (is_array($ret) && sizeof($ret) == 1 && isset($ret[0]) && is_array($ret[0]) && !empty($ret[0]['faultString']) && !empty($ret[0]['faultCode'])) {
extract($ret[0]);
$faultString = "XML-RPC Server Fault: " . str_replace("\n", " ", $faultString);
return $this->raiseError($faultString, $faultCode);
}
return $ret;
}