function determine_action($request = null)
  {
    if($request === null)
      $request =& request :: instance();

    if (!$action = $request->get_attribute('action'))
      $action = $this->_default_action;

    if (!$this->action_exists($action))
    {
      debug :: write_warning(
        'action not found',
        __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__,
        array(
          'class' => get_class($this),
          'action' => $action,
          'default_action' => $this->_default_action
        ));
      return false;
    }

    $this->_current_action = $action;

    return $this->_current_action;
  }
 function determine_action()
 {
     if (isset($_REQUEST['action'])) {
         $action = $_REQUEST['action'];
     } else {
         $action = $this->_default_action;
     }
     if (!$this->action_exists($action)) {
         debug::write_warning('action not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('class' => get_class($this), 'action' => $action, 'default_action' => $this->_default_action));
         return false;
     }
     $this->_current_action = $action;
     return $this->_current_action;
 }
Ejemplo n.º 3
0
 function parse_address_list($address = null, $default_domain = null, $nest_groups = null, $validate_atoms = null, $limit = null)
 {
     if (!isset($this->_called_via_object)) {
         $obj = new rfc822($address, $default_domain, $nest_groups, $validate, $limit);
         return $obj->parse_address_list();
     }
     $this->set_params($address, $default_domain, $nest_groups, $validate_atoms, $limit);
     while ($this->_address = $this->_split_addresses($this->_address)) {
         continue;
     }
     if ($this->_address === false || isset($this->_error)) {
         return debug::write_warning($this->_error, __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     for ($i = 0; $i < count($this->_addresses); $i++) {
         if (($return = $this->_validate_address($this->_addresses[$i])) === false || isset($this->_error)) {
             return debug::write_warning($this->_error, __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
         }
         if (!$this->_nest_groups) {
             $this->_structure = array_merge($this->_structure, $return);
         } else {
             $this->_structure[] = $return;
         }
     }
     return $this->_structure;
 }
	function set_value($value)
	{
		$form_component =& $this->find_parent_by_class('form_component');
    
    $dataspace =& dataspace_registry :: get($form_component->attributes['name']);

		if(!isset($this->attributes['name']))
			debug :: write_warning("form element 'name' attribute not set:" . $this->get_server_id());
		
		$dataspace->set_by_index_string($this->_make_index_name($this->attributes['name']), $value);
	}
Ejemplo n.º 5
0
 function accumulator_stop($key)
 {
     if (!debug::is_debug_enabled()) {
         return;
     }
     $debug =& debug::instance();
     $stop_time = $debug->_time_to_float(microtime());
     if (!array_key_exists($key, $debug->time_accumulator_list)) {
         debug::write_warning('Accumulator $key does not exists, run debug::accumulator_start first', 'debug::accumulator_stop');
         return;
     }
     $accumulator =& $debug->time_accumulator_list[$key];
     $diffTime = $stop_time - $accumulator['temp_time'];
     $accumulator['time'] = $accumulator['time'] + $diffTime;
     ++$accumulator['count'];
 }
	function _decode($headers, $body, $default_ctype = 'text/plain')
	{
	    $result = new stdClass;
	    $headers = $this->_parse_headers($headers);

	    foreach ($headers as $value)
	    {
	      $value_name = strtolower($value['name']);
	      if (isset($result->headers[$value_name]))
	      {
		      if (!is_array( $result->headers[$value_name] ))
		        $result->headers[$value_name] = array($result->headers[$value_name]);

	      	$result->headers[$value_name][] = $value['value'];
	      }
				else
	      	$result->headers[$value_name] = $value['value'];
	    }
	
	    reset($headers);
	    while (list($key, $value) = each($headers))
	    {
	      $headers[$key]['name'] = strtolower($headers[$key]['name']);
	      switch ($headers[$key]['name'])
	      {
	        case 'content-type':
	          $content_type = $this->_parse_header_value($headers[$key]['value']);

	          if (preg_match('/([0-9a-z+.-]+)\/([0-9a-z+.-]+)/i', $content_type['value'], $regs)) 
	          {
              $result->ctype_primary   = $regs[1];
              $result->ctype_secondary = $regs[2];
	          }
	
	          if (isset($content_type['other']))
	            while (list($p_name, $p_value) = each($content_type['other']))
	            	$result->ctype_parameters[$p_name] = $p_value;

	          break;

	        case 'content-disposition':
            $content_disposition = $this->_parse_header_value($headers[$key]['value']);
            $result->disposition   = $content_disposition['value'];
            if (isset($content_disposition['other']))
                while (list($p_name, $p_value) = each($content_disposition['other']))
                    $result->d_parameters[$p_name] = $p_value;
            break;

	        case 'content-transfer-encoding':
            $content_transfer_encoding = $this->_parse_header_value($headers[$key]['value']);
            break;
	      }
	    }
	
	    if (isset($content_type)) 
	    {
        switch (strtolower($content_type['value']))
        {
          case 'multipart/parallel':
          case 'multipart/report': // RFC1892
          case 'multipart/signed': // PGP
          case 'multipart/digest':
          case 'multipart/alternative':
          case 'multipart/related':
          case 'multipart/mixed':
            if(!isset($content_type['other']['boundary']))
            {
              $this->_error = 'No boundary found for ' . $content_type['value'] . ' part';
              debug :: write_warning($this->_error);
              return false;
            }

            $default_ctype = (strtolower($content_type['value']) === 'multipart/digest') ? 'message/rfc822' : 'text/plain';

            $parts = $this->_split_by_boundary($body, $content_type['other']['boundary']);
            for ($i = 0; $i < count($parts); $i++)
            {
              list($part_header, $part_body) = $this->_split_body_header($parts[$i]);
              $part = $this->_decode($part_header, $part_body, $default_ctype);
              if($part === false)
                debug :: write_warning($this->_error);
              $result->parts[] = $part;
            }
            break;

          case 'message/rfc822':
            $obj = &new mime_decode($body);
            $result->parts[] = $obj->decode(array('include_bodies' => $this->_include_bodies));
            unset($obj);
            break;

          case 'text/plain':
          case 'text/html':
          default:
            $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
            $this->_include_bodies ? $result->body = ($this->_decode_bodies ? $this->_decode_body($body, $encoding) : $body) : null;
            break;
        }
	    }
	    else
	    {
	        $ctype = explode('/', $default_ctype);
	        $result->ctype_primary   = $ctype[0];
	        $result->ctype_secondary = $ctype[1];
	        $this->_include_bodies ? $result->body = ($this->_decode_bodies ? $this->_decode_body($body) : $body) : null;
	    }
	
	    return $result;
	}
 /**
  * Returns the value of the form element
  * (the contents of the value attribute)
  * 
  * @return string 
  * @access public 
  */
 function get_value()
 {
     $form_component =& $this->find_parent_by_class('form_component');
     $dataspace = dataspace::instance($form_component->attributes['name']);
     if (!isset($this->attributes['name'])) {
         debug::write_warning("form element 'name' attribute not set:" . $this->get_server_id());
     }
     return $dataspace->get_by_index_string($this->_make_index_name($this->attributes['name']));
 }