Ejemplo n.º 1
0
 function call($get, $post)
 {
     $args = [];
     foreach ($this->get as $name => $param) {
         if (isset($param->domains) and isset($get[$name])) {
             if (($value = security::unwrap($get[$name], $param->domains)) !== null) {
                 $get[$name] = $value;
             } else {
                 unset($get[$name]);
             }
         }
         $value = isset($get[$name]) ? $get[$name] : (isset($param->default) ? $param->default : ($param->required ? backend_error('bad_input', "Missing GET parameter: {$name}") : null));
         if (!is_null($value)) {
             $min = isset($param->min) ? $param->min : null;
             $max = isset($param->max) ? $param->max : null;
             !isset($param->type) or datatype::assert($param->type, $value, $min, $max);
             $args[$name] = $value;
         }
     }
     foreach ($this->post as $name => $param) {
         if (isset($param->domains) and isset($post[$name])) {
             if (($value = security::unwrap($post[$name], $param->domains)) !== null) {
                 $post[$name] = $value;
             } else {
                 unset($post[$name]);
             }
         }
         $value = isset($post[$name]) ? $post[$name] : (isset($param->default) ? $param->default : ($param->required ? backend_error('bad_input', "Missing POST parameter: {$name}") : null));
         if (!is_null($value)) {
             $min = isset($param->min) ? $param->min : null;
             $max = isset($param->max) ? $param->max : null;
             !isset($param->type) or datatype::assert($param->type, $value, $min, $max);
             $args[$name] = $value;
         }
     }
     if ($this->access and !$this->www->parse_query($this->access, $args)) {
         return [false, null];
     }
     if ($this->body) {
         return [true, $this->body->query_direct($args)];
     } else {
         $procedure = $this->procedure;
         return [true, $this->www->{$procedure}($args)];
     }
 }