public function confirmationEmailAction() { $token = $this->getParameters('token'); $max_days = $this->max_days_token; $status = 2; if (preg_match('/^[a-zA-Z0-9]+$/', $token)) { $ModelUser = $this->getDB()->model($this->model); $User = $ModelUser->fetch(array('token_email' => $token)); if ($User) { $diff = \Kodazzi\Tools\Date::diff($User->token_email_created, $this->getTimestamp(), 'd'); // Si es mayor o igual a uno o es menor que cero dias dice que ha expirado. if ($diff >= $max_days || $diff < 0) { // Error 3: Token ha expirado o no es valido $status = 3; } else { if ((int) $User->email_confirm === 1) { // Error 4: El email ya fue confirmado $status = 4; } else { $quantity = $ModelUser->update(array('email_confirm' => 1, 'token_email' => null, 'token_email_created' => null), array('id' => $User->id, 'token_email' => $User->token_email)); if ($quantity) { $status = 1; $this->sendEmailVerified($User); } } } } else { // Error 2: Token no valido. $status = 2; } } return $this->render('Dinnovos\\Users:Registration:confirmation_email', array('status' => $status, 'max_days' => $max_days)); }
public function renderField() { if (!$this->is_display) { return ''; } $format = $this->format ? $this->format : $this->name_form . '[' . $this->name . ']'; $id = $this->id ? $this->id : $this->name_form . '_' . $this->name; $value = $this->value ? \Kodazzi\Tools\Date::format($this->value, $this->format_time) : ''; return \Kodazzi\Helper\FormHtml::input($format, $value, $this->max_length, array('id' => $id, 'class' => $this->getClassCss(), 'disabled' => $this->isDisabled(), 'readonly' => $this->isReadonly(), 'placeholder' => $this->getPlaceholder())); }
public function modifyPasswordAction() { $token = $this->getRequest()->get('token'); $max_hours = 1; $status = 1; $post = $this->getPOST(); $errors = array(); $User = null; if (preg_match('/^[a-zA-Z0-9]+$/', $token)) { $ModelUser = $this->getDB()->model($this->model); $User = $ModelUser->fetch(array('token_forgotten' => $token, 'status' => 1)); if ($User) { $diff = \Kodazzi\Tools\Date::diff($User->token_forgotten_created, $this->getTimestamp(), 'h'); // SI es mayor o igual a uno o es mejor que cero dias dice que ha expirado. if ($diff >= $max_hours || $diff < 0) { // Error 2: Token ha expirado. $status = 2; } } else { // Error 2: Token no valido. $status = 5; } } if ($status === 1 && count($post) && array_key_exists('modify', $post) && array_key_exists('password', $post['modify']) && array_key_exists('confirmation_password', $post['modify'])) { $password = $post['modify']['password']; $confirmation_password = $post['modify']['confirmation_password']; if ($password != '' && $confirmation_password != '') { if ($password != $confirmation_password) { $errors['password'] = '******'; $errors['confirmation_password'] = '******'; } else { if (!\Kodazzi\Tools\RegularExpression::isValidPassword($password)) { $errors['password'] = '******'; } } } else { if ($password == '') { $errors['password'] = '******'; } if ($confirmation_password == '') { $errors['confirmation_password'] = '******'; } } if (count($errors) == 0) { $result = $ModelUser->update(array('password' => $this->getSession()->encript($password), 'token_forgotten' => null, 'token_forgotten_created' => null), array('id' => $User->id, 'status' => 1)); if ((int) $result == 1) { // Status 5: Clave modificada correctamente. $status = 4; } } } return $this->render('Dinnovos\\Amazonas:Admin/Session:modify_password', array('status' => $status, 'max_hours' => $max_hours, 'errors' => $errors)); }
public function __construct(ConfigBuilderInterface $config, SessionInterface $user, UrlGenerator $url_generator) { $this->User = $user; $this->Config = $config; $this->UrlGenerator = $url_generator; $bundles = Service::getBundles(); $theme_web = $config->get('app', 'theme_web'); $theme_admin = $config->get('app', 'theme_admin'); $enabled_path_themes = $config->get('app', 'enabled_path_themes'); $path_templates = array(Ki_APP . 'src/layouts', Ki_APP . 'src/templates'); if ($enabled_path_themes) { if (is_dir(Ki_THEMES . $theme_web . '/layouts')) { $path_templates[] = Ki_THEMES . $theme_web . '/layouts'; } if (is_dir(Ki_THEMES . $theme_web . '/templates')) { $path_templates[] = Ki_THEMES . $theme_web . '/templates'; } if (is_dir(Ki_THEMES . $theme_admin . '/layouts')) { $path_templates[] = Ki_THEMES . $theme_admin . '/layouts'; } if (is_dir(Ki_THEMES . $theme_admin . '/templates')) { $path_templates[] = Ki_THEMES . $theme_admin . '/templates'; } } foreach ($bundles as $bundle) { $path_bundles_templates = str_replace('\\', '/', $bundle->getPath() . '/templates'); if (is_dir($path_bundles_templates)) { $path_templates[] = $path_bundles_templates; } } $Twig_Loader_Filesystem = new \Twig_Loader_Filesystem($path_templates); $Twig = new \Twig_Environment(null, array('cache' => Ki_CACHE . 'views', 'debug' => Ki_DEBUG)); // Funcion para construir las url $build_url = new \Twig_SimpleFunction('build_url', function ($name_route, $parameters = array(), $locale = null) { return \Kodazzi\Tools\Util::buildUrl($name_route, $parameters, $locale); }); // Funcion para construir las url $cut_text = new \Twig_SimpleFunction('cut_text', function ($string, $limit = 100, $end_char = '...') { return \Kodazzi\Tools\StringProcessor::cutText($string, $limit, $end_char); }); // Funcion para cortar texto muy largo. $resume = new \Twig_SimpleFunction('resume', function ($string, $limit = 100, $end_char = '...') { return \Kodazzi\Tools\StringProcessor::resume($string, $limit, $end_char); }); // Funcion para dar formato a un numero $number_format = new \Twig_SimpleFunction('number_format', function ($number, $decimals = 0, $dec_point = ',', $thousands_sep = '.') { return number_format($number, $decimals, $dec_point, $thousands_sep); }); // Funcion para dar formato a un numero $date_format = new \Twig_SimpleFunction('date_format', function ($date, $format) { return \Kodazzi\Tools\Date::format($date, $format); }); // Funcion para dar formato a un numero $get_date = new \Twig_SimpleFunction('get_date', function ($string) { return \Kodazzi\Tools\Date::getDate($string); }); // Funcion para indicar si existe un archivo $isFile = new \Twig_SimpleFunction('isFile', function ($path, $file) { return \Kodazzi\Tools\Util::isFile($path, $file); }); // Funcion para indicar si existe un archivo $hash = new \Twig_SimpleFunction('hash', function ($id, $str = 'z6i5v36h3F5', $position = 5, $prefix = '') { return \Kodazzi\Tools\Util::hash($id, $str, $position, $prefix); }); // Funcion para indicar si existe un archivo $ucfirst = new \Twig_SimpleFunction('ucfirst', function ($string) { return ucfirst($string); }); // Funcion para acceder al catalogo de traduccion. $i18n = new \Twig_SimpleFunction('i18n', function ($string) { return Service::get('translator')->get($string); }); // Funcion para indicar si existe un archivo $dump = new \Twig_SimpleFunction('dump', function ($var) { ob_start(); var_dump($var); $a = ob_get_contents(); ob_end_clean(); return $a; }); $Twig->addFunction($build_url); $Twig->addFunction($cut_text); $Twig->addFunction($get_date); $Twig->addFunction($resume); $Twig->addFunction($number_format); $Twig->addFunction($isFile); $Twig->addFunction($date_format); $Twig->addFunction($hash); $Twig->addFunction($ucfirst); $Twig->addFunction($i18n); $Twig->addFunction($dump); $this->Twig_Loader_Filesystem = $Twig_Loader_Filesystem; $this->Twig = $Twig; }
protected function isValidEmail($User) { if ($User) { if ((int) $User->email_confirm === 1) { return true; } if ((int) $User->email_confirm === 0) { if ($this->start_after_registration) { $diff = \Kodazzi\Tools\Date::diff($User->created, $this->getTimestamp(), 'd'); if ($diff > 0 && $diff < $this->max_days_unconfirme_email) { return true; } } } } return false; }