Exemplo n.º 1
0
 /**
  * Sanea por el tipo de dato en el modelo
  *
  * @param	string $modelName
  * @param	string $fieldName
  * @param	mixed $value
  */
 public static function saniziteByDataType($modelName, $fieldName, $value)
 {
     $entity = EntityManager::get($modelName);
     if ($entity->hasField($fieldName)) {
         if (get_magic_quotes_gpc() == false) {
             $value = addslashes($value);
         }
         $dataTypes = $entity->getDataTypes();
         $dataType = $dataTypes[$fieldName];
         if ($value === '' || $value === null) {
             return null;
         } else {
             if (strpos($dataType, 'decimal')) {
                 return Filter::bring($value, 'double');
             } else {
                 if (strpos($dataType, 'int')) {
                     return Filter::bring($value, 'int');
                 } else {
                     return Filter::bring($value, 'striptags');
                 }
             }
         }
     } else {
         throw new ActiveRecordException('El campo "' . $fieldName . '" no hace parte de la entidad "' . $modelName . '"');
     }
 }
Exemplo n.º 2
0
 /**
  * Este metodo e usado para fazer uma chamada de servico e retornar uma instancia do mesmo
  * @param string $modulo
  * @param string $servico
  * @param integer $modalidade
  * @return Uma instancia do objeto do servico requisitado
  */
 public function getService($modulo, $servico, $type_service = self::TYPE_SERVICE, $modalidade = self::ZEND_FRAMEWORK)
 {
     $this->modalidade = $modalidade;
     $this->modulo = $modulo;
     $this->servico = $servico;
     $this->type_service = $type_service;
     $this->service_namespace = str_replace('/', '\\', $this->obtemNamespace());
     if (!class_exists($this->service_namespace)) {
         throw new \Exception("Erro ao carregar a classe {$this->service_namespace}, verique se a classe existe ou se os parametros foram passados corretamente!");
     }
     $instancia = null;
     if ($this->modalidade == self::ZEND_FRAMEWORK) {
         if ($this->type_service = self::TYPE_ENTITY) {
             $this->configuraZeDb();
             $instancia = $this->em->get($this->service_namespace);
         } else {
             $instancia = new $this->service_namespace();
         }
     }
     return $instancia;
 }
Exemplo n.º 3
0
function getCaller($sid)
{
    return EntityManager::get()->getRepository('Realms\\Player')->findOneBy(array('sessionId' => $sid));
}
Exemplo n.º 4
0
// The server sends this to the API. A plugin must be written to handle this portion
$requestHandler->respond('POST', '/server/heartbeat', function ($request, $response) {
    if (!isset($request->nplayers)) {
        $response->code(400);
        $response->body('Bad request');
        $response->send();
        return;
    }
    $key = $request->cookies()->get('key');
    if ($key === null) {
        $response->code(401);
        $response->body('key is required');
        $response->send();
        return;
    }
    $server = EntityManager::get()->getRepository('Realms\\Server')->findOneBy(array('key' => $key));
    if ($server === null) {
        $response->code(401);
        $response->body('Invalid key');
        $response->send();
        return;
    }
    // We aren't entirely sure what nplayers entails.
    // We know that this should be the server announcing that it is alive
    // and it may be viable to add a flag to the server model to show/hide
    // the server accordingly in /server/list
});
// The server sends this as well. We have no example of what the two parameters are.
$requestHandler->respond('GET', '/auth/validate-player/[a:a]/[a:b]', function ($request, $response) {
    //this probably checks the whitelist but what are the parameters?
    $key = $request->cookies()->get('key');