コード例 #1
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;
 }
コード例 #2
0
 * @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);
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("request", $request);
$smarty->assign("type", $type);
$smarty->assign("content", $content);
$smarty->display("inc_vw_request_cluster.tpl");