當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PEAR::errorMessage方法代碼示例

本文整理匯總了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;
 }
開發者ID:HaldunA,項目名稱:phpwebsite,代碼行數:101,代碼來源:Remote.php

示例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;
 }
開發者ID:BackupTheBerlios,項目名稱:wcms,代碼行數:101,代碼來源:Remote.php


注:本文中的PEAR::errorMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。