Esempio n. 1
0
 public function action()
 {
     if (!current_user_can('edit_products')) {
         die(-1);
     }
     if (!isset($_POST['method'])) {
         die(-1);
     }
     $method = $_POST['method'];
     if (!in_array($method, array('DELETE', 'GET', 'POST'), true)) {
         die(-1);
     }
     if (!isset($_POST['path'])) {
         die(-1);
     }
     $path = $_POST['path'];
     if (!isset($_POST['data'])) {
         $data = null;
     } else {
         $data = json_decode(stripslashes_deep($_POST['data']), true);
     }
     try {
         $response = $this->client->request($method, $path, $data);
     } catch (Aplazame_Exception $e) {
         http_send_status(402);
         $response = $e->get_body();
     }
     wp_send_json($response);
 }
Esempio n. 2
0
function get_roi_boxes($image_pid, $nothing, $workflow_id)
{
    global $user;
    $returnBoxes = "";
    if (Workflow_Users::doesWorkflowHaveUserName($workflow_id, $user->name) && Workflow_Permission::doesWorkflowHavePermission($workflow_id, "canAnalyzeSpecimen")) {
        $roi_pids = AP_Image::getROIListForImage($image_pid);
        foreach ($roi_pids as $roi_pid) {
            $roiMetadata_record = AP_ROI::getroiMetadata_record($roi_pid);
            $returnBoxes[] = array("y" => $roiMetadata_record['y'], "h" => $roiMetadata_record['h'], "x" => $roiMetadata_record['x'], "w" => $roiMetadata_record['w'], "type" => $roiMetadata_record['roiType'], "pid" => $roi_pid);
        }
        echo json_encode($returnBoxes);
    } else {
        http_send_status(401);
        echo "You do not have sufficient permission";
    }
}
Esempio n. 3
0
 /**
  * Send the response headers and body.
  * @return void
  */
 public function send()
 {
     // don't send more than once
     if (static::$sent) {
         return;
     }
     // (maybe) start output buffering
     if (2 > ob_get_level()) {
         #if (! $this->gzip_body || ! ob_start('ob_gzhandler'))
         ob_start();
     }
     // send at least some cache header
     if (!isset($this->headers['Cache-Control'])) {
         $this->nocache();
     }
     // send Status header
     if (!isset($this->status)) {
         if (isset($GLOBALS['HTTP_RESPONSE_CODE'])) {
             $this->status = $GLOBALS['HTTP_RESPONSE_CODE'];
         } else {
             if (isset($this->headers['Location'])) {
                 $this->status = 302;
             } else {
                 $this->status = 200;
             }
         }
     }
     http_send_status($this->status);
     // send Content-Type header
     if (!isset($this->content_type)) {
         $this->content_type = static::DEFAULT_CONTENT_TYPE;
     }
     http_send_content_type($this->content_type, $this->getCharset());
     // send other headers
     foreach ($this->headers as $name => $value) {
         header(sprintf("%s: %s", $name, $value), true);
     }
     // output the body
     if ($this->send_body) {
         echo $this->body;
         ob_end_flush();
     }
     static::$sent = true;
     exit;
 }
/**
 * Test Http functions.
 */
function test_functions()
{
    http_cache_last_modified();
    http_chunked_decode();
    http_deflate();
    http_inflate();
    http_build_cookie();
    http_date();
    http_get_request_body_stream();
    http_get_request_body();
    http_get_request_headers();
    http_match_etag();
    http_match_modified();
    http_match_request_header();
    http_support();
    http_negotiate_charset();
    http_negotiate_content_type();
    http_negotiate_language();
    ob_deflatehandler();
    ob_etaghandler();
    ob_inflatehandler();
    http_parse_cookie();
    http_parse_headers();
    http_parse_message();
    http_parse_params();
    http_persistent_handles_clean();
    http_persistent_handles_count();
    http_persistent_handles_ident();
    http_get();
    http_head();
    http_post_data();
    http_post_fields();
    http_put_data();
    http_put_file();
    http_put_stream();
    http_request_body_encode();
    http_request_method_exists();
    http_request_method_name();
    http_request_method_register();
    http_request_method_unregister();
    http_request();
    http_redirect();
    http_send_content_disposition();
    http_send_content_type();
    http_send_data();
    http_send_file();
    http_send_last_modified();
    http_send_status();
    http_send_stream();
    http_throttle();
    http_build_str();
    http_build_url();
}