I have created 5 validators classes in my project they are running well in my localhost with wampserver, but they are not running in my VPS hosting with godaddy under CentOS 6.9. I do not have any error message in the server logs.
|
Oct '20 |
6 |
387 |
0 |
<?php
namespace base;
use Phalcon\Validation as validador; use Phalcon\Validation\Message; use Phalcon\Validation\Validator; use Phalcon\Validation\ValidatorInterface;
class ValidaUserValidator extends Validator implements ValidatorInterface {
/**
*
* @param Validation $validator
* @param string $attribute
*
* @return boolean
*/
public function validate($validator, $attribute) {
//obtain the name of the field
$elcorreo = $this->getOption("correo");
//obtain field value
$elcorreo_value = $validator->getValue($elcorreo);
// obtain the input field value
$elpassword = $validator->getValue($attribute);
//try to obtain message defined in a validator
$message = $this->getOption('message');
//check if the value is valid
$user = Users::findFirst(array(
"(email = :email: OR username = :email:) AND password = :password: AND active = 'Y'",
'bind' => array('email' => $elcorreo_value, 'password' => sha1($elpassword))
));
if (!$user) {
$message = 'NO estan registrados en nuestra base de datos el correo o la palabra clave - Vuelva ha intentarlo';
$validator->appendMessage(new Message($message, $attribute, 'usuario'));
}
if (count($validator->getMessages())) {
return false;
}
return true;
}
} This is one of my validators.
<?php
use Phalcon\Forms\Form; use Phalcon\Forms\Element\Password; use Phalcon\Forms\Element\Text; use Phalcon\Validation\Validator\PresenceOf; use Phalcon\Validation\Validator\Email; use \base\ValidaUserValidator;
class SessionForm extends Form {
public function initialize() {
$email = new Text("email");
$email->setLabel("Correo Electronico");
$email->setFilters(array('striptags', 'string'));
$email->addValidators(array(
new PresenceOf(array(
'message' => 'No ha ingresado la direccion de correo'
)),
new Email(array(
'message' => 'debe ingresar una direccion de correo valida'
))
));
$this->add($email);
$password = new Password("password");
$password->setLabel("Password");
$password->addValidators(array(
new PresenceOf(array(
'message' => 'Debe ingresar una palabra clave'
)),
new ValidaUserValidator(array(
'correo' => 'email',
'message' => 'El Email o el password no han sido registrados vuelva ha intentarlo'
))
));
$this->add($password);
}
public function messages($nombre) {
if ($this->hasMessagesFor($nombre)) {
foreach ($this->getMessagesFor($nombre) as $mensaje) {
$this->flash->error($mensaje);
}
}
}
} This is the form that I am using with the validator. One again it is running perfectly in my wampserver environment. But they are not running in my VPS hosting with godaddy
http:\auroraec.online is the website. Just in case you can use the "Contacto" tab and send me a message, but you can not use the Login/Registrarse tab. Any ideas? I will appreciate your help. Thank you to all of you Phalconers.
I am running phalcon 3.4.2, php 7.2.20, apache 2.4 in my VPS CentOS 6.9 I am running apache 2.4.35 php 7.2.10 phalcon 3.4.0 in my wampserver Windows 10
what versions are you running?
I installed phalcon 3.4.3 in my wampserver. Everything is running well and smoothly.
can you try to run 3.4.2 on your wamp to see if you have the same problem?
I got this message
Fatal error: Declaration of base\ValidaUserValidator::validate($validator, $attribute) must be compatible with Phalcon\Validation\Validator::validate(Phalcon\Validation $validation, $attribute) in /home/ecuadoraurora/public_html/app/library/base/ValidaUserValidator.php on line 10
Would you please help me to fix it? Thank you in advance.
Try enabling error reporting for php on your server. The obvious reason would be a file not found because of case sensitivity.
public function validate(Phalcon\Validation $validator, $attribute) {
//code
}
You need to declarate the type like above. See also https://www.php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration I think there is some version issue also. I'm expecting that should see this locally also.
Thank you, I made the change and now is running smoothly.
public function validate(Phalcon\Validation $validator, $attribute) { //code }
You need to declarate the type like above. See also https://www.php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration I think there is some version issue also. I'm expecting that should see this locally also.
Also i suppose you were already including this thread. As i was offering some thing else, it truly seems like which you have on apps greater data that you do not need to go back, perhaps just move name and pid to different model likehttps://forum.phalcon.io/discussion/20082/phalcon-micro-swoole-http-server AppsInfo or something like this? Or AppsStatus due to the fact you have got pid