コード例 #1
0
 /**
  * Méthode permettant de tester si le service d'extraction Tika est actif
  *
  * @return string
  */
 function loadTikaInfos()
 {
     $conf_host = trim(CAppUI::conf("search tika_host"));
     $conf_port = trim(CAppUI::conf("search tika_port"));
     $client = new CHTTPClient("http://{$conf_host}:{$conf_port}/tika");
     return $client->get();
 }
コード例 #2
0
 * $Id$
 *  
 * @category Search
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 * @link     http://www.mediboard.org */
CCanDo::checkAdmin();
$request = CValue::get("request");
$type = CValue::get("type_request");
$content = "";
if ($request && !strripos($request, "delete")) {
    $client = new CHTTPClient($request);
    switch ($type) {
        case "get":
            $content = $client->get();
            break;
        case "put":
            $content = $client->putFile($request);
            break;
        case "post":
            $content = $client->post($request);
            break;
        default:
            $content = $client->get();
    }
}
$content = json_decode($content, true);
if (!$content) {
    CAppUI::stepAjax("{$request} est invalide", UI_MSG_ERROR);
}
コード例 #3
0
ファイル: CApp.class.php プロジェクト: fbone/mediboard4
 /**
  * Send the request on the server
  *
  * @param String   $url  URL
  * @param String[] $post Parameters POST
  *
  * @return bool|string
  */
 static function serverCall($url, $post = null)
 {
     CSessionHandler::writeClose();
     global $rootName, $version;
     $session_name = preg_replace("/[^a-z0-9]/i", "", $rootName);
     $cookie = CValue::cookie($session_name);
     $result = array("code" => "", "body" => "");
     try {
         $http_client = new CHTTPClient($url);
         $http_client->setCookie("{$session_name}={$cookie}");
         $http_client->setUserAgent("Mediboard-" . $version["version"]);
         $http_client->setOption(CURLOPT_FOLLOWLOCATION, true);
         if ($post) {
             $request = $http_client->post(http_build_query($post));
         } else {
             $request = $http_client->get();
         }
     } catch (Exception $e) {
         CSessionHandler::start();
         $result["body"] = $e->getMessage();
         return $result;
     }
     CSessionHandler::start();
     $result["code"] = $http_client->last_information["http_code"];
     $result["body"] = $request;
     return $result;
 }
コード例 #4
0
 /**
  * Check the URL disponibility
  *
  * @param String   $url         URL site
  * @param String[] $option      Option array
  * @param Boolean  $return_body Return the content of the page
  *
  * @return bool|int
  */
 static function checkUrl($url, $option = null, $return_body = false)
 {
     try {
         $http_client = new CHTTPClient($url);
         if ($option) {
             if (CMbArray::get($option, "ca_cert")) {
                 $http_client->setSSLPeer($option["ca_cert"]);
             }
             if (CMbArray::get($option, "username") || CMbArray::get($option, "password")) {
                 $http_client->setHTTPAuthentification($option["username"], $option["password"]);
             }
             if (CMbArray::get($option, "local_cert")) {
                 $http_client->setSSLAuthentification($option["local_cert"], $option["passphrase"]);
             }
         }
         $http_client->setOption(CURLOPT_HEADER, true);
         $result = $http_client->get();
     } catch (Exception $e) {
         return false;
     }
     if ($return_body) {
         return $result;
     }
     return preg_match("|200|", $result);
 }