Beispiel #1
0
 /**
  * POST Request
  *
  * @return Mixed data retrieved from Request
  **/
 function _post(&$Model, $params = array())
 {
     $postHeaders = array('Host' => $this->_host, 'Connection' => 'Close', 'Content-Length' => strlen($this->_data));
     $params['headers'] = array_merge($params['headers'], $postHeaders);
     if (!isset($params['headers']['Content-Type'])) {
         $params['headers']['Content-Type'] = 'application/x-www-form-urlencoded';
     }
     $this->_formatHeaders($params['headers']);
     $request = "POST {$this->_path} HTTP/1.0\r\n";
     $request .= $this->_headers . "\r\n";
     $request .= "\r\n";
     $request .= $this->_data;
     $this->__setInfo('requestHeaders', $request);
     $this->Socket->write($request);
     $response = '';
     while ($data = $this->Socket->read()) {
         $response .= $data;
     }
     $this->_parseResponse($response);
     if ($this->__settings[$Model->name]['followRedirect'] && array_key_exists('Location', $this->response['headers'])) {
         $this->serviceConnect($Model, $this->response['headers']['Location'], $params);
         $this->_data = null;
         $this->_get($Model, $params);
     }
     return $this->response['body'];
 }
Beispiel #2
0
 /**
  * Write log
  *
  * @return void
  */
 public function write()
 {
     if ($this->Model->name == 'Log') {
         return true;
     }
     $this->Log->id = null;
     $this->Log->save(array('Log' => array('authuser_id' => $this->Session->read('Usuario.id'), 'model' => $this->Model->name, 'action' => $this->_action, 'old_data' => $this->_oldData, 'new_data' => $this->_newData)));
 }
Beispiel #3
0
 /**
  * Opens an interactive shell if not done already and transmits commands and returns output.
  *
  * @access public
  * @param string $command Command to execute
  * @param string $expect String of output to expect and remove from output.
  * @param bool $expectregex Switches string expectation to regular expressions.
  * @returns bool|string
  */
 public function iexec($command, $expect = "", $expectregex = false)
 {
     trim($command, "\n");
     if ($this->sshobject->write($command . "\n")) {
         return $this->sshobject->read($expect, $expectregex ? NET_SSH . $this->protocol . _READ_REGEX : NET_SSH . $this->protocol . _READ_SIMPLE);
     } else {
         return false;
     }
 }
 /**
  * モデル登録用メソッド
  * 
  * @param Controller $Controller
  */
 public function modelInitializer($Controller)
 {
     if (ClassRegistry::isKeySet('PetitBlogCustomField.PetitBlogCustomFieldConfig')) {
         $this->PetitBlogCustomFieldConfigModel = ClassRegistry::getObject('PetitBlogCustomField.PetitBlogCustomFieldConfig');
     } else {
         $this->PetitBlogCustomFieldConfigModel = ClassRegistry::init('PetitBlogCustomField.PetitBlogCustomFieldConfig');
     }
     $this->petitBlogCustomFieldConfigs = $this->PetitBlogCustomFieldConfigModel->read(null, $Controller->BlogContent->id);
     $this->PetitBlogCustomFieldModel = ClassRegistry::init('PetitBlogCustomField.PetitBlogCustomField');
 }
 public function fetchAll($params = array())
 {
     $this->params = BatchValidator::combine($params, $this->params);
     if ($this->isFiltered()) {
         $results = $this->gateway->read($this->collectionUrl(), $this->params);
     } elseif ($this->getLast) {
         $results = $this->collection->fetchLastInCollection($this->gateway, $this->collectionUrl(), $this->params);
         $this->getLast = false;
     } elseif ($this->getIncrement) {
         $results = $this->collection->fetchIncrement($this->gateway, $this->collectionUrl(), $this->params);
         $this->getIncrement = false;
     } else {
         $results = $this->collection->fetchCollection($this->gateway, $this->collectionUrl(), $this->params);
     }
     return $results;
 }
Beispiel #6
0
    /**
     * Does the actual saving of the Log model. Also adds the special field if possible.
     * 
     * If model field in table, add the Model->alias
     * If action field is NOT in table, remove it from dataset
     * If the userKey field in table, add it to dataset
     * If userData is supplied to model, add it to the title 
     *
     * @param Object $Model
     * @param array $logData
     */
    function _saveLog(&$Model, $logData, $title = null) {  
    	if ($title !== NULL) {
    		$logData['Log']['title'] = $title;
    	} elseif ($Model->displayField == $Model->primaryKey) {
    		$logData['Log']['title'] = $Model->alias . ' ('. $Model->id.')';
    	} elseif (isset($Model->data[$Model->alias][$Model->displayField])) {
    		$logData['Log']['title'] = $Model->data[$Model->alias][$Model->displayField];
    	} else {
    		$Model->recursive = -1;
    		$Model->read(array($Model->displayField));
    		$logData['Log']['title'] = $Model->data[$Model->alias][$Model->displayField];
    	}
    		
    	if (isset($this->Log->_schema['model'])) {
    		$logData['Log']['model'] = $Model->alias;
    	}
    	
    	if (isset($this->Log->_schema['model_id']) && !isset($logData['Log']['model_id'])) {
    		if ($Model->id) {
    			$logData['Log']['model_id'] = $Model->id;
    		} elseif ($Model->insertId) {
    			$logData['Log']['model_id'] = $Model->insertId;
    		}     		
    	}
		
    	if (!isset($this->Log->_schema[ 'action' ])) {
    		unset($logData['Log']['action']);
    	} elseif (isset($Model->logableAction) && !empty($Model->logableAction)) {
    		$logData['Log']['action'] = implode(',',$Model->logableAction); // . ' ' . $logData['Log']['action'];
    		unset($Model->logableAction);
    	}
    	
    	if (isset($this->Log->_schema[ 'version_id' ]) && isset($Model->version_id)) {
    		$logData['Log']['version_id'] = $Model->version_id;
    		unset($Model->version_id);
    	}
    	
    	if (isset($this->Log->_schema[ 'ip' ]) && $this->userIP) {
    		$logData['Log']['ip'] = $this->userIP;
    	}
    	
    	if (isset($this->Log->_schema[ $this->settings[$Model->alias]['userKey'] ]) && $this->user) {
    		$logData['Log'][$this->settings[$Model->alias]['userKey']] = $this->user[$this->UserModel->alias][$this->UserModel->primaryKey];
    	}  	
    	
        if (isset($this->Log->_schema['description'])) {
        	if ($this->user && $this->UserModel) {
        		$logData['Log']['description'] .= ' by '.$this->settings[$Model->alias]['userModel'].' "'.
        				$this->user[$this->UserModel->alias][$this->UserModel->displayField].'"';
        		if ($this->settings[$Model->alias]['description_ids']) {
        			$logData['Log']['description'] .= ' ('.$this->user[$this->UserModel->alias][$this->UserModel->primaryKey].')';
        		}
    										
        	} else { 
        		// UserModel is active, but the data hasnt been set. Assume system action.
        		$logData['Log']['description'] .= ' by System';
        	}
    		$logData['Log']['description'] .= '.';    		
    	} 	
    	$this->Log->create($logData);
    	$this->Log->save(NULL,FALSE);    	
    }
Beispiel #7
0
 /**
  * XML To Associative Array
  * by Sergey Aikinkulov
  *
  * @see: http://www.php.net/manual/en/class.xmlreader.php#83929
  *
  * $xml = new XMLReader();
  * $xml->open([XML file]);
  * $assoc = xml2assoc($xml);
  * $xml->close();
  *
  * @param Object $xml
  * @return array
  * @access private
  */
 private function xml2assoc($xml)
 {
     $assoc = NULL;
     while ($xml->read()) {
         switch ($xml->nodeType) {
             case XMLReader::END_ELEMENT:
                 return $assoc;
             case XMLReader::ELEMENT:
                 $assoc[$xml->name][] = array('value' => $xml->isEmptyElement ? '' : $this->xml2assoc($xml));
                 break;
             case XMLReader::TEXT:
             case XMLReader::CDATA:
                 $assoc .= $xml->value;
         }
     }
     return $assoc;
 }
Beispiel #8
0
 /**
  * Does the actual saving of the Log model. Also adds the special field if possible.
  *
  * If model field in table, add the Model->alias
  * If action field is NOT in table, remove it from dataset
  * If the userKey field in table, add it to dataset
  * If userData is supplied to model, add it to the title
  *
  * @param Object $Model
  * @param array $logData
  */
 function _saveLog(&$Model, $logData, $title = null)
 {
     if ($title !== null) {
         $logData['Log']['title'] = $title;
     } elseif ($Model->displayField == $Model->primaryKey) {
         $logData['Log']['title'] = $Model->alias . ' (' . $Model->id . ')';
     } elseif (isset($Model->data[$Model->alias][$Model->displayField])) {
         $logData['Log']['title'] = $Model->data[$Model->alias][$Model->displayField];
     } else {
         $Model->recursive = -1;
         $Model->read(array($Model->displayField));
         $logData['Log']['title'] = $Model->data[$Model->alias][$Model->displayField];
     }
     if (isset($this->Log->_schema[$this->settings[$Model->alias]['classField']])) {
         // by miha nahtigal
         $logData['Log'][$this->settings[$Model->alias]['classField']] = $Model->name;
     }
     if (isset($this->Log->_schema[$this->settings[$Model->alias]['foreignKey']]) && !isset($logData['Log'][$this->settings[$Model->alias]['foreignKey']])) {
         if ($Model->id) {
             $logData['Log'][$this->settings[$Model->alias]['foreignKey']] = $Model->id;
         } elseif ($Model->insertId) {
             $logData['Log'][$this->settings[$Model->alias]['foreignKey']] = $Model->insertId;
         }
     }
     if (!isset($this->Log->_schema['action'])) {
         unset($logData['Log']['action']);
     } elseif (isset($Model->logableAction) && !empty($Model->logableAction)) {
         $logData['Log']['action'] = implode(',', $Model->logableAction);
         // . ' ' . $logData['Log']['action'];
         unset($Model->logableAction);
     }
     if (isset($this->Log->_schema['version_id']) && isset($Model->version_id)) {
         $logData['Log']['version_id'] = $Model->version_id;
         unset($Model->version_id);
     }
     if (isset($this->Log->_schema['ip']) && $this->userIP) {
         $logData['Log']['ip'] = $this->userIP;
     }
     if (!isset($this->user[$this->UserModel->alias][$this->UserModel->primaryKey])) {
         return;
     }
     if (isset($this->Log->_schema[$this->settings[$Model->alias]['userKey']]) && $this->user) {
         $logData['Log'][$this->settings[$Model->alias]['userKey']] = $this->user[$this->UserModel->alias][$this->UserModel->primaryKey];
     }
     if (isset($this->Log->_schema['description'])) {
         if ($this->user && $this->UserModel) {
             $logData['Log']['description'] .= ' by ' . $this->settings[$Model->alias]['userModel'] . ' "' . $this->user[$this->UserModel->alias][$this->UserModel->displayField] . '"';
             if ($this->settings[$Model->alias]['description_ids']) {
                 $logData['Log']['description'] .= ' (' . $this->user[$this->UserModel->alias][$this->UserModel->primaryKey] . ')';
             }
         } else {
             // UserModel is active, but the data hasnt been set. Assume system action.
             $logData['Log']['description'] .= ' by System';
         }
         $logData['Log']['description'] .= '.';
     }
     if (!in_array($logData['Log']['model'], $this->ignore)) {
         $this->Log->create($logData);
         $this->Log->save(null, array('validate' => false, 'callbacks' => false));
     }
 }