Пример #1
0
function valid_csrf_token($csrf_token)
{
    if (is_empty($_SESSION["csrf_token"])) {
        return false;
    }
    return $csrf_token == $_SESSION["csrf_token"];
}
Пример #2
0
 public function login()
 {
     if (is_empty($this->post->user) || is_empty($this->post->password)) {
         throw_exception("User and Password are required");
     }
     $options['user']['lvl2'] = "one_login";
     $cod['user']['user'] = $this->post->user;
     $cod['user']['password'] = $this->post->password;
     $this->orm->connect();
     $this->orm->read_data(array("user"), $options, $cod);
     $user = $this->orm->get_objects("user");
     #echo $user[0]->get('type');
     $this->orm->close();
     if (is_empty($user)) {
         throw_exception("User or Password Incorrect");
     } else {
         $_SESSION['user']['id'] = $user[0]->get('id');
         $_SESSION['user']['name'] = $user[0]->get('name');
         $_SESSION['user']['user'] = $user[0]->get('user');
         $_SESSION['user']['type'] = $user[0]->get('type');
         $_SESSION['user']['email'] = $user[0]->get('email');
         $this->session = $_SESSION;
         $this->engine->assign('type_warning', 'success');
         $this->engine->assign('msg_warning', "Welcome!");
         $this->temp_aux = 'message.tpl';
     }
 }
 public function agregar()
 {
     $parque = new parque($this->post);
     if (is_empty($parque->get('codigo'))) {
         throw_exception("Debe ingresar un codigo");
     }
     if ($parque->get("nivel") == "alto" || $parque->get("nivel") == "bajo") {
     } else {
         throw_exception("El nivel debe de ser alto o bajo");
     }
     if ($parque->get("municipio") == "medellin" || $parque->get("municipio") == "rionegro" || $parque->get("municipio") == "la estrella" || $parque->get(" municipio") == "copacabana" || $parque->get(" municipio") == "guatape") {
     } else {
         throw_exception("El municipio debe de ser medellin, rionegro, la estrella, copacabana o guatape");
     }
     print_r($parque);
     $this->orm->connect();
     $this->orm->insert_data("normal", $parque);
     $this->orm->close();
     settype($data, 'object');
     $data->fecha = date("y-m-d");
     $data->calificacion = 0;
     $data->parque = $parque->get("codigo");
     $calificacion = new calificacion($data);
     $this->orm->connect();
     $this->orm->insert_data("normal", $calificacion);
     $this->orm->close();
     $this->type_warning = "sucess";
     $this->msg_warning = "parque agregado correctamente";
     $this->temp_aux = 'message.tpl';
     $this->engine->assign('type_warning', $this->type_warning);
     $this->engine->assign('msg_warning', $this->msg_warning);
 }
Пример #4
0
function menu_affiliates($args)
{
    if (defined('NO_DB')) {
        return;
    }
    global $objTPL, $objSQL;
    $settings = array('limit' => doArgs('limit', 6, $args), 'perRow' => doArgs('limit', 2, $args));
    //grab the table
    $table = $objSQL->getTable('SELECT * FROM `$Paffiliates` WHERE active = 1 AND showOnMenu = 1 ORDER BY rand() LIMIT %d;', array($settings['limit']));
    if ($table === NULL) {
        return 'Error: Could not query Affiliates.';
    }
    if (is_empty($table)) {
        return 'Error: No Affiliates in the database active.';
    }
    $return = NULL;
    $counter = 1;
    foreach ($table as $a) {
        $title = secureMe($a['title']) . '
            In: ' . $a['in'] . ' | Out: ' . $a['out'];
        $return .= '<a href="/' . root() . 'affiliates.php?out&id=' . $a['id'] . '" title="' . $title . '" target="_blank" rel="nofollow"><img src="' . $a['img'] . '" alt="' . $title . '" /></a>';
        if ($counter % $settings['perRow'] == 0) {
            $return .= '<br />';
        }
        $counter++;
    }
    return '<center>' . $return . '</center>';
}
Пример #5
0
 public function registrar()
 {
     $parque = new parque($this->post);
     $this->engine->assign('codigo', $parque->get('codigo'));
     $this->engine->assign('nombre', $parque->get('nombre'));
     $this->engine->assign('municipio', $parque->get('municipio'));
     $this->engine->assign('nivel', $parque->get('nivel'));
     if (is_empty($parque->get('codigo'))) {
         throw_exception("Debe ingresar un Codigo");
     } elseif (!is_numeric($parque->get('codigo')) or $parque->get('codigo') < 0) {
         throw_exception("Codigo invalido");
     }
     if (is_empty($parque->get('nombre'))) {
         throw_exception("Debe ingresar un nombre");
     }
     if (is_empty($parque->get('municipio'))) {
         throw_exception("Debe ingresar un municipio");
     } elseif ($parque->get('municipio') != "Medellín" and $parque->get('municipio') != "Rionegro" and $parque->get('municipio') != "La Estrella" and $parque->get('municipio') != "Copacabana" and $parque->get('municipio') != "Guatapé") {
         throw_exception("Municipio invalido, municipios validos: Medellín, Rionegro, La Estrella, Copacabana, Guatapé");
     }
     if (is_empty($parque->get('nivel'))) {
         throw_exception("Debe ingresar un nivel");
     } elseif ($parque->get('nivel') != "alto" and $parque->get('nivel') != "bajo") {
         throw_exception("Nivel invalido, niveles validos: alto, bajo");
     }
     $this->orm->connect();
     $this->orm->insert_data("normal", $parque);
     $this->orm->close();
     $this->type_warning = "Exito";
     $this->msg_warning = "parque agregado correctamente";
     $this->temp_aux = 'message.tpl';
     $this->engine->assign('type_warning', $this->type_warning);
     $this->engine->assign('msg_warning', $this->msg_warning);
 }
Пример #6
0
 public function validarCompletitud()
 {
     if (is_empty($this->get('nombre')) || is_empty($this->get('retribucion')) || is_empty($this->get('fechaPublicacion')) || is_empty($this->get('fechaFinalizacion')) || is_empty($this->get('empresa'))) {
         return false;
     }
     return true;
 }
Пример #7
0
 public function add()
 {
     $parque = new parque($this->post);
     if (is_empty($parque->get('nivel'))) {
         throw_exception("Debe ingresar un nivel");
     }
     $parque = new parque($this->post);
     if (is_empty($parque->get('nivel'))) {
         throw_exception("Debe ingresar un municipio");
     }
     if ($parque->get('municipio') != "Medellín" && $parque->get('municipio') != "La estrella" && $parque->get('municipio') != "Rionegro" && $parque->get('municipio') != "Copacabana" && $parque->get('municipio') != "Guatapé") {
         throw_exception("Municipio inválido");
     }
     if ($parque->get('nivel') != "alto" && $parque->get('nivel') != "bajo") {
         throw_exception("Nivel inválido");
     }
     $this->orm->connect();
     $this->orm->insert_data("normal", $parque);
     $this->orm->close();
     $this->type_warning = "sucess";
     $this->msg_warning = "Parque registrado correctamente";
     $this->temp_aux = 'message.tpl';
     $this->engine->assign('type_warning', $this->type_warning);
     $this->engine->assign('msg_warning', $this->msg_warning);
 }
 /**
  * Test savingForm
  * Test so a proper form is saved, with correct data.
  * Also test if it is possible to enter incorrect data that might ruin something.
  * @author Fredrik Andersson
  * @small
  * @test
  */
 public function formFunctions()
 {
     // Create new user class
     $a = new PP();
     // Check if the object was created
     $this->assertNotNull($a);
     // Adding some variables into the form class PP
     $a->student1 = "StudentName";
     $this->assertEquals("StudentName", $a->student1);
     //Test of the function test_num($data)
     $this->assertEquals(1, test_num(1));
     $this->assertEquals("-", test_num("-"));
     $this->assertEquals("-", test_num(10));
     //Test of the function test_input($data)
     $this->assertEquals("123", test_input("  123  "));
     //trim() removes spaces before the first char and after the last one.
     $this->assertEquals("123'hihi\ttab", test_input("123\\'hi\\hi\ttab"));
     //stripslashes() removes all slashes exept proper slashes like \t and \n etc.
     $this->assertEquals("&amp; &quot; &lt; &gt;", test_input("& \" < >"));
     //htmlspecialchars() changes some special characters to code that html can handle.
     //Test of the function is_empty($data)
     $this->assertEquals(false, is_empty(array('apple', 'banana ', ' cranberry ')));
     $this->assertEquals(false, is_empty(array('', '', '')));
     $temp[10] = "something";
     $this->assertEquals(false, is_empty($temp));
     //Test of the function input_length()
     $string128 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
     $string129 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab";
     $this->assertEquals($string128, input_length($string129));
     //Test of the function length_one()
     $this->assertEquals("1", length_one("12345"));
 }
Пример #9
0
 public function testIsEmpty()
 {
     $this->assertTrue(is_empty(null));
     $this->assertTrue(is_empty(''));
     $this->assertTrue(is_empty(0));
     $this->assertFalse(is_empty('asd'));
 }
Пример #10
0
 public function validarCompletitud()
 {
     if (is_empty($this->get('nit')) || is_empty($this->get('nombre')) || is_empty($this->get('direccion')) || is_empty($this->get('telefono'))) {
         return false;
     }
     return true;
 }
Пример #11
0
 private function validarIntereses()
 {
     if (is_empty($this->post->interes)) {
         return false;
     }
     return true;
 }
Пример #12
0
 public function execute(Sabel_Bus $bus)
 {
     $response = $bus->get("response");
     if ($response->isRedirected()) {
         return;
     }
     $controller = $bus->get("controller");
     $responses = $response->getResponses();
     $contents = isset($responses["contents"]) ? $responses["contents"] : "";
     $view = $this->setTemplateName($bus->get("view"), $response->getStatus(), $bus->get("destination")->getAction(), $bus->get("IS_AJAX_REQUEST") === true);
     if (is_empty($contents)) {
         if ($location = $view->getValidLocation()) {
             $contents = $view->rendering($location, $responses);
         } elseif (!$controller->isExecuted()) {
             $response->getStatus()->setCode(Sabel_Response::NOT_FOUND);
             if ($location = $view->getValidLocation("notFound")) {
                 $contents = $view->rendering($location, $responses);
             } else {
                 $contents = "<h1>404 Not Found</h1>";
             }
         }
     }
     if ($bus->get("NO_LAYOUT")) {
         $bus->set("result", $contents);
     } else {
         $layout = isset($responses["layout"]) ? $responses["layout"] : DEFAULT_LAYOUT_NAME;
         if ($location = $view->getValidLocation($layout)) {
             $responses["contentForLayout"] = $contents;
             $bus->set("result", $view->rendering($location, $responses));
         } else {
             // no layout.
             $bus->set("result", $contents);
         }
     }
 }
Пример #13
0
/**
 *	$.ajax({ method: buscar_cep, cep: 12345-678, state: '', city: '', street2: '', street1: '', district: '', country: '' })
 *
 *	return: [ x...x, ..., x...x ]
 */
function JKY_buscar_cep($data)
{
    $my_cep = fix_digits($data['zip']);
    if (strlen($my_cep) == 8) {
        if ($data['state'] == '' or $data['city'] == '' or $data['street2'] == '' or $data['street1'] == '' or $data['district'] == '') {
            $my_curl = curl_init();
            curl_setopt($my_curl, CURLOPT_URL, 'http://www.buscarcep.com.br/?&chave=146RwGh.Q3UM1x2871JTmxKemqLfYX/&formato=xml&cep=' . $my_cep);
            curl_setopt($my_curl, CURLOPT_RETURNTRANSFER, 1);
            $my_return = curl_exec($my_curl);
            curl_close($my_curl);
            if (!is_empty($my_return)) {
                $my_cep = new SimpleXMLElement($my_return);
                if ($my_cep->retorno->resultado == '1') {
                    $data['state'] = remover_acentos($my_cep->retorno->uf);
                    $data['city'] = remover_acentos($my_cep->retorno->cidade);
                    $data['street2'] = remover_acentos($my_cep->retorno->bairro);
                    $data['street1'] = remover_acentos($my_cep->retorno->tipo_logradouro . ' ' . $my_cep->retorno->logradouro);
                    $data['district'] = remover_acentos($my_cep->retorno->ibge_municipio_verificador);
                }
            }
        }
        $data['country'] = get_control_value('System Defaults', 'Company Country');
    }
    $data['status'] = 'ok';
    return $data;
}
Пример #14
0
 public function getContent()
 {
     if (is_empty($this->path)) {
         return "";
     } else {
         return file_get_contents($this->path);
     }
 }
Пример #15
0
function select_cards_player($player)
{
    $player = select_with_request_string("cards", "player", array("player", "cards", "game"), array(), array("game" => game, "player" => $player));
    if (!is_empty($player[0]["cards"])) {
        return $player[0]["cards"];
    }
    return 0;
}
Пример #16
0
function displayMessages()
{
    $engine = EngineAPI::singleton();
    if (is_empty($engine->errorStack)) {
        return FALSE;
    }
    return '<section><header><h1>Results</h1></header>' . errorHandle::prettyPrint() . '</section>';
}
Пример #17
0
function query_array_unselecting_tag($tag, $query_array)
{
    $query_array["tags"] = array_diff($query_array["tags"], array($tag));
    if (is_empty($query_array["tags"])) {
        unset($query_array["tags"]);
    }
    return $query_array;
}
Пример #18
0
function get_status($card, $player)
{
    $results = select_with_request_string("status", "owned", array("game", "player", "card", "status"), array(), array("game" => game, "player" => $player, "card" => $card));
    if (!is_empty($results)) {
        return $results[0]["status"];
    }
    return unknown;
}
Пример #19
0
    public function Render($form = "", $response_location = "", $url = "", $args = "")
    {
        $errorMsg = '';
        $errors = FALSE;
        $Load = new Load();
        if (function_exists('is_empty') == FALSE) {
            // Load validate helper
            $Load->Helper('validate');
        }
        if (is_empty($form) == FALSE) {
            $this->form = $form;
        }
        if (is_empty($response_location) == FALSE) {
            $this->response_location = $response_location;
        }
        if (is_empty($url) == FALSE) {
            $this->url = $url;
        }
        if (is_empty($args) == FALSE) {
            $this->args = $args;
        }
        if (is_empty($this->form)) {
            $errorMsg .= ' form requerido :$obj-> Form("id-form")<br /> ';
            $errors = TRUE;
        }
        if (is_empty($this->response_location)) {
            $errorMsg .= ' response_location requerido : $obj-> ResponseLocation("id-div-location")<br /> ';
            $errors = TRUE;
        }
        if (is_empty($this->url)) {
            $errorMsg .= ' url requerida : $obj-> Url("Controller/Action")<br /> ';
            $errors = TRUE;
        }
        if ($errors == TRUE) {
            echo 'Error:<br />' . $errorMsg;
            return FALSE;
        } else {
            // Crear respuesta
            $butonsCode = $this->RenderButtons();
            $params = 'form:' . $this->form . ';url:' . $this->url . ';args:' . $this->args . ';';
            $fx = new fk_ajax('submit', $this->response_location, $params);
            $Result = ' <script type="text/javascript">
<!--
' . $butonsCode . '
$("#' . $this->form . '").validate({
	 submitHandler: function(form) {
		 ' . $fx->render() . '
		 return false;
	 },invalidHandler: function(form, validator){
      var errors = validator.numberOfInvalids();
      if (errors) { alert("Por favor, llena los campos obligatorios");}
	 }
});
//-->
</script>';
            return $Result;
        }
    }
Пример #20
0
 public function testIsEmpty()
 {
     $this->assertTrue(is_empty(''));
     $this->assertTrue(is_empty('    '));
     $this->assertTrue(is_empty(null));
     $this->assertTrue(is_empty(false));
     $this->assertFalse(is_empty(0));
     $this->assertFalse(is_empty('foobar'));
     $this->assertFalse(is_empty(true));
 }
Пример #21
0
/**
 * Checks a value for blankness.
 *
 * A blank value is one which is empty, a string containing only whitespace, or
 * an object whose is_blank() method returns true.
 *
 * @param $value value to check for blankness
 * @return true if $value is blank, false otherwise
 */
function is_blank($value)
{
    if (is_object($value) && method_exists($value, 'is_blank')) {
        return $value->is_blank();
    }
    if (is_string($value)) {
        $value = trim($value);
    }
    return is_empty($value);
}
Пример #22
0
function true_path($action, $model_name, $model_id = "", $prefix = "")
{
    if (is_empty($prefix)) {
        $prefix_string = "";
    } else {
        $prefix_elements = explode("/", $prefix);
        $prefix_string = "&prefix=" . $prefix_elements[0] . "&binet=" . $prefix_elements[1] . "&term=" . $prefix_elements[2];
    }
    $action = is_empty($action) ? "index" : $action;
    return "./" . ROOT_PATH . "index.php?controller=" . $model_name . "&action=" . $action . (is_empty($model_id) ? "" : "&" . $model_name . "=" . $model_id) . $prefix_string . "&";
}
Пример #23
0
 public function getSubtypes()
 {
     $rv = array();
     $children = midgard_reflector_object::list_children($this->classname);
     if (!is_empty($children)) {
         foreach ($children as $name => $v) {
             $children[$name] = new NodeType($name);
         }
     }
     return $rv;
 }
 public function __construct()
 {
     global $apiConfig;
     if (!function_exists('memcache_connect')) {
         throw new apiCacheException("Memcache functions not available");
     }
     $this->host = $apiConfig['ioMemCacheCache_host'];
     $this->port = $apiConfig['ioMemCacheCache_port'];
     if (is_empty($this->host) || is_empty($this->port)) {
         throw new apiCacheException("You need to supply a valid memcache host and port");
     }
 }
Пример #25
0
 /**
  * Render
  *
  * @param type $view
  * @param type $data
  * @param type $value
  */
 public function render($view, $data = null, $value = null)
 {
     $viewData = [];
     if (is_array($data)) {
         $viewData = $data;
     } else {
         if (is_string($data) && !is_empty($value)) {
             $viewData = [$data => $value];
         }
     }
     $this->view()->make($view, $viewData)->render();
 }
Пример #26
0
 function _get_options()
 {
     if (is_empty($this->options)) {
         $query = $this->db->get('forum_options');
         if ($query->num_rows() > 0) {
             $rows = $query->result_array();
             foreach ($rows as $row) {
                 $this->options[$row['name']] = $row['value'];
             }
         }
     }
 }
Пример #27
0
 public function __construct($id = null)
 {
     if (is_empty($this->modelName)) {
         $exp = explode("_", get_class($this));
         $this->modelName = array_pop($exp);
     }
     if (is_empty($id)) {
         $this->setModel(MODEL($this->modelName));
     } else {
         $this->setModel(MODEL($this->modelName, $id));
     }
 }
 public function add()
 {
     $parque = new parque($this->post);
     if (is_empty($parque->get('codigo'))) {
         throw_exception("Debe ingresar un codigo");
     }
     $this->orm->connect();
     $this->orm->insert_data("normal", $parque);
     $this->orm->close();
     $this->temp_aux = 'message.tpl';
     $this->engine->assign('type_warning', "success");
     $this->engine->assign('msg_warning', "parque registrado correctamente");
 }
 private function validarParticipacion($codigo)
 {
     $this->orm->connect();
     $options['beneficio']['lvl2'] = "by_encuesta";
     $cod['beneficio']['encuesta'] = $codigo;
     $this->orm->read_data(array("beneficio"), $options, $cod);
     $beneficio = $this->orm->get_objects("beneficio", $components);
     $this->orm->close();
     if (is_empty($beneficio)) {
         return true;
     } else {
         return false;
     }
 }
Пример #30
0
 public function __construct($id = null)
 {
     if (is_model($id)) {
         $model = $id;
         $this->modelName = $model->getName();
     } else {
         if (is_empty($this->modelName)) {
             $exp = explode("_", get_class($this));
             $this->modelName = array_pop($exp);
         }
         $model = is_empty($id) ? MODEL($this->modelName) : MODEL($this->modelName, $id);
     }
     $this->setModel($model);
 }