function agregarAction() { $this->view->subtitle = $this->info->sitio->contacto->agregar->titulo; $this->view->contacto = new stdClass(); $this->view->action = $this->info->sitio->usuarios->agregar->action; $this->view->buttonText = $this->info->sitio->contacto->agregar->buttonText; if ($this->_request->isPost()) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $filter = new Zend_Filter_StripTags(); $this->view->contacto->nombre = trim($filter->filter($this->_request->getPost('nombre'))); $this->view->contacto->email = trim($filter->filter($this->_request->getPost('email'))); $this->view->contacto->comentario = trim($filter->filter($this->_request->getPost('comentario'))); $this->view->contacto->telefono = trim($filter->filter($this->_request->getPost('telefono'))); $fecha = date("Y-m-d H:i:s"); if ($this->view->contacto->nombre != '' && $this->view->contacto->email != '' && $this->view->contacto->comentario != '' && $this->view->contacto->telefono != '') { $data = array('nombre' => $this->view->contacto->nombre, 'email' => $this->view->contacto->email, 'comentario' => $this->view->contacto->comentario, 'telefono' => $this->view->contacto->telefono, 'fecha' => $fecha, 'id_sitio' => $this->session->sitio->id); $contacto = new Contacto(); $contacto->insert($data); //Enviamos el correo. $destinatario = $this->view->contacto->email; $asunto = $this->info->sitio->contacto->add->asunto; $cuerpo = $this->view->contacto->nombre . " " . $this->view->contacto->comentario; $headers = $this->info->sitio->contacto->add->sender; mail($destinatario, $asunto, $cuerpo, $headers); $this->view->message = " El comentario fue enviado con exito ! Muchas gracias."; $this->view->buttonText = $this->info->sitio->contacto->agregar->buttonText; return; } else { $this->view->message = "Deben completar todos los campos"; } } $this->render(); }
function loginAction() { $this->view->login_redirect = webconfig::getContestRelativeBaseUrl(); $this->view->message = ""; if ($this->_request->isPost()) { // collect the data from the user Zend_Loader::loadClass('Zend_Filter_StripTags'); $f = new Zend_Filter_StripTags(); $username = $f->filter($this->_request->getPost('username')); $password = $f->filter($this->_request->getPost('password')); if (empty($username)) { $this->view->login_message = 'Please provide a username.'; } else { $authAdapter = new MyAuthAdapter($username, $password); Zend_Loader::loadClass('Zend_Auth'); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $this->log->info($auth->getIdentity() . " has logged on."); $this->_redirect($this->_request->get("redirectto")); } else { $this->view->login_message = 'Login failed.'; } } } $this->view->title = "Log In"; }
public function indexAction() { $filter = new Zend_Filter_StripTags(); $login = trim($filter->filter($this->_request->getPost('login'))); $senha = trim($filter->filter($this->_request->getPost('senha'))); $uri = str_replace('kahina/', '', base64_decode($this->_request->getParam('u', base64_encode('painel/index')))); if (empty($login) || empty($senha)) { $this->view->message = 'Por favor, informe seu Usuário e Senha.'; return; } else { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter); $authAdapter->setTableName('login')->setIdentityColumn('login')->setCredentialColumn('senha'); $authAdapter->setIdentity($this->_getParam('login'))->setCredential($this->_getParam('senha'))->setCredentialTreatment('MD5(?)'); $result = $authAdapter->authenticate(); if ($result->isValid()) { $user = $authAdapter->getResultRowObject(); $storage = My_Auth::getInstance('Painel')->getStorage(); $storage->write($user); $this->_redirect($uri); } else { $this->view->error = 'Você deve informar Login e Senha.'; } } $this->render(); }
function loginAction() { $this->view->message = ''; if ($this->_request->isPost()) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $f = new Zend_Filter_StripTags(); $username = $f->filter($this->_request->getPost('username')); $password = md5($f->filter($this->_request->getPost('password'))); if (!empty($username)) { Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable'); $dbAdapter = Zend_Registry::get('dbAdapter'); $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter); $authAdapter->setTableName('utilisateur'); $authAdapter->setIdentityColumn('login_utilisateur'); $authAdapter->setCredentialColumn('pass_utilisateur'); $authAdapter->setIdentity($username); $authAdapter->setCredential($password); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $data = $authAdapter->getResultRowObject(null, 'password'); $auth->getStorage()->write($data); $this->_redirect('/'); } } $this->_redirect('auth/loginfail'); } }
public function modificarAction() { $this->view->subtitle = $this->info->sitio->faqs->modificar->titulo; $eFAQ = new Faqs(); if ($this->_request->isPost()) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $filter = new Zend_Filter_StripTags(); $id = (int) $this->_request->getPost('id'); $pregunta = trim($filter->filter($this->_request->getPost('pregunta'))); $respuesta = trim($filter->filter($this->_request->getPost('respuesta'))); if ($id !== false) { if ($pregunta != '' && $respuesta != '') { $data = array('pregunta' => $pregunta, 'respuesta' => $respuesta, 'id_sitio' => $this->session->sitio->id); $where = 'id = ' . $id; $eFAQ->update($data, $where); $this->_redirect('/admin/faqs/'); return; } else { $this->view->faq = $eFAQ->fetchRow('id=' . $id); } } } else { $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $this->view->faq = $eFAQ->fetchRow('id=' . $id); } } $this->view->action = $this->info->sitio->faqs->modificar->action; $this->view->buttonText = $this->info->sitio->faqs->modificar->buttonText; $this->render(); }
public function agregarAction() { $this->view->buttonText = $this->info->sitio->paginas->agregar->buttonText; $this->view->subtitle = $this->info->sitio->menus->agregar->titulo; $this->view->id_pagina = (int) $this->_request->getParam('pagina'); if ($this->_request->isPost()) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $filter = new Zend_Filter_StripTags(); $id_pagina = (int) $this->_request->getPost('id_pagina'); $id_menu = (int) $this->_request->getPost('id_menu'); $link = $this->_request->getPost('link'); $titulo = trim($filter->filter($this->_request->getPost('titulo'))); $alt = $this->_request->getPost('alt'); if ($titulo != '' && $link != '') { $data = array('titulo' => $titulo, 'id_pagina' => $id_pagina, 'id_menu' => $id_menu, 'link' => $link, 'alt' => $alt); $menupag = new PaginasMenu(); $menupag->insert($data); $this->_redirect(self::RETORNO . $id_pagina); return; } } $this->view->menupag = new stdClass(); $this->view->menupag->id_menu = null; $this->view->menupag->id_pagina = $this->view->id_pagina; $this->view->menupag->titulo = ''; $this->view->menupag->link = ''; $this->view->menupag->alt = ''; $this->view->action = "agregar"; }
public function init() { $request = $this->getRequest(); // action name based category $action = $request->getActionName(); $this->page = (int) $request->getParam('page'); if ($this->page < 1) { $this->page = 1; } $url_search_term = trim($this->getRequest()->getParam('term', false)); if ($url_search_term !== false) { // filter search input $filter_st = new Zend_Filter_StripTags(); $url_search_term = $filter_st->filter($url_search_term); $this->search_term = $url_search_term; } // minimum search string $min = 3; if ($url_search_term && strlen($this->search_term) < $min) { $this->search_term = ''; Application_Plugin_Alerts::error($this->view->translate('Search query to short'), 'off'); } // set global search form action & value $this->view->search_category = $action; $this->view->search_term = $this->search_term; // now that we have search_term we can build a menu $this->buildMenu(); }
public function modificarAction() { $this->view->subtitle = 'Modificar'; $archivos = new Archivos(); if ($this->_request->isPost()) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $filter = new Zend_Filter_StripTags(); $id = (int) $this->_request->getPost('id'); $descripcion = trim($filter->filter($this->_request->getPost('descripcion'))); if ($id !== false) { if ($descripcion != '') { $data = array('descripcion' => $descripcion); $where = 'id = ' . $id; $archivos->update($data, $where); $this->_redirect('/admin/archivos/'); return; } else { $this->view->archivo = $archivo->fetchRow('id=' . $id); $this->view->message = "Deben llenarse todos los campos"; } } } else { $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $this->view->archivo = $archivos->fetchRow('id=' . $id); } } $this->view->action = "modificar"; $this->view->buttonText = "Modificar"; $this->view->scriptJs = "lightbox"; }
public function init() { $stripTags = new Zend_Filter_StripTags(); $stripTags->setTagsAllowed(array('p', 'a', 'img', 'strong', 'b', 'i', 'em', 's', 'del')); $stripTags->setAttributesAllowed(array('href', 'target', 'rel', 'name', 'src', 'width', 'height', 'alt', 'title')); $this->addElement('textarea', 'description', array('class' => 'richedit', 'label' => 'Description:', 'required' => true, 'filters' => array('StringTrim', $stripTags), 'validators' => array(new Zend_Validate_NotEmpty())))->addElement('hidden', 'recipe_id')->addElement('submit', 'submit'); }
public function indexAction() { $this->view->headTitle("创建项目"); if ($this->getRequest()->isPost()) { $filter = new Zend_Filter_StripTags(); $name = $filter->filter(trim($this->_request->getParam('name'))); $pwd = $filter->filter(trim($this->_request->getParam('pwd'))); $confirmpwd = $filter->filter(trim($this->_request->getParam('confirmpwd'))); $email = $filter->filter(trim($this->_request->getParam('email'))); $issue_time = date('Y-m-d H:i:s', time()); if ($this->getRequest()->isXmlHttpRequest() || $this->_request->getParam('ajax') == 1) { $project = new Application_Model_DbTable_Project(); $lastinsret_id = $project->addProject($name, $pwd, $email, $issue_time); if ($lastinsret_id) { if ($this->createFile($name, $lastinsret_id)) { $status = "ok"; $response = "恭喜您,注册成功!"; $user = new Zend_Session_Namespace('user'); $user->name = $name; } else { $status = "sorry"; $response = "抱歉! 系统出错,请稍后再试!"; } } else { $status = "sorry"; $response = "抱歉! 系统出错,请稍后再试!"; } $res = '{"status":"' . $status . '","name":"' . $name . '"}'; $this->_helper->layout->setLayout('empty_layout'); $this->_helper->viewRenderer->setNoRender(); $this->_response->appendBody($res); } } }
public function indexAction() { $this->view->headTitle("uiwiki-登陆"); if ($this->getRequest()->isPost()) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $filter = new Zend_Filter_StripTags(); //表单的post值 $name = $filter->filter($this->_request->getPost('name')); $password = $filter->filter($this->_request->getPost('password')); if (!empty($name)) { $authAdapter = new Zend_Auth_Adapter_DbTable(); $authAdapter->setTableName('ui_project')->setIdentityColumn('name')->setCredentialColumn('password')->setIdentity($name)->setCredential($password); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); // 执行认证查询,并保存结果 if ($result->isValid()) { $data = $authAdapter->getResultRowObject(array('name', 'id')); if ($auth->hasIdentity()) { //auth之后写入session $user = new Zend_Session_Namespace('user'); $user->name = $data->name; $user->id = $data->id; $user->setExpirationSeconds(6000); //命名空间 "user" 将在第一次访问后 6000 秒过期 //echo '<h3><font color=red> 登录成功!</font></h3>'; $this->_redirect('/' . $name); } } else { echo '<h3><font color=red> 登录失败,请重新登录!</font></h3>'; } } } }
public function login($username, $password) { $ret = false; $filter = new Zend_Filter_StripTags(); $username = $filter->filter($username); $password = $filter->filter($password); if (isset($username) && isset($password)) { $db = Das_Db::factory(); $authAdapter = new Zend_Auth_Adapter_DbTable($db); $authAdapter->setTableName('v9_user'); $authAdapter->setIdentityColumn('username'); $authAdapter->setCredentialColumn('password'); $authAdapter->setIdentity($username); $authAdapter->setCredential($password); $result = $this->auth->authenticate($authAdapter); if ($result->isValid()) { $storage = $this->auth->getStorage(); // $retObj = $authAdapter->getResultRowObject(); // $storage->write($retObj->group_id); $storage->write($authAdapter->getResultRowObject()); $ret = true; } } return $ret; }
function modificarAction() { $this->view->subtitle = "Modificar Configuración"; $configuracion = new Configuracion(); if ($this->_request->isPost()) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $filter = new Zend_Filter_StripTags(); $id = (int) $this->_request->getPost('id'); $sitio_color_fondo = trim($filter->filter($this->_request->getPost('sitio_color_fondo'))); $sitio_color_cabezal = trim($filter->filter($this->_request->getPost('sitio_color_cabezal'))); $sitio_color_pie = trim($filter->filter($this->_request->getPost('sitio_color_pie'))); if ($id !== false) { $data = array('sitio_color_fondo' => $sitio_color_fondo, 'sitio_color_cabezal' => $sitio_color_cabezal, 'sitio_color_pie' => $sitio_color_pie, 'id_sitio' => $this->session->sitio->id); $where = 'id = ' . $id; $configuracion->update($data, $where); $this->_redirect('/admin/configuracion/'); return; } } else { $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $this->view->configuracion = Configuracion::getConfiguracionSitio($id); } } $this->view->action = "modificar"; $this->view->buttonText = "Modificar"; $this->view->scriptJs = "mooRainbow"; }
/** * The default action - show the contact form */ public function indexAction() { $request = $this->getRequest(); $form = $this->_getContactForm(); // check to see if this action has been POST'ed to if ($this->getRequest()->isPost()) { // now check to see if the form submitted exists, and // if the values passed in are valid for this form if ($form->isValid($request->getPost())) { // collect the data from the user $f = new Zend_Filter_StripTags(); $email = $f->filter($this->_request->getPost('email')); $message = $f->filter($this->_request->getPost('message')); //get the username if its nolotiro user $user_info = $this->view->user->username; $user_info .= $_SERVER['REMOTE_ADDR']; $user_info .= ' ' . $_SERVER['HTTP_USER_AGENT']; $mail = new Zend_Mail('utf-8'); $body = $user_info . '<br/>' . $message; $mail->setBodyHtml($body); $mail->setFrom($email); $mail->addTo('*****@*****.**', 'aLabs'); $mail->setSubject('nolotiro.org - contact from ' . $email); $mail->send(); $this->_helper->_flashMessenger->addMessage($this->view->translate('Message sent successfully!')); $this->_redirect('/' . $this->lang . '/woeid/' . $this->location . '/give'); } } $this->view->form = $form; }
function loginAction() { if ($this->_request->isPost('log-form')) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $filter = new Zend_Filter_StripTags(); $username = trim($filter->filter($this->_request->getPost('log-name'))); $password = trim($filter->filter($this->_request->getPost('log-pswd'))); $warnings = new Zend_Session_Namespace(); $warnings->username = $username; $warnings->error = ''; $error_msg = ''; if ($username == '') { $error_msg .= '<p>Enter your username.</p>'; } else { if ($password == '') { $error_msg .= '<p>Enter your password.</p>'; } else { $data = new Users(); $query = 'login = "******"'; $data_row = $data->fetchRow($query); if (!count($data_row)) { $error_msg .= '<p>There is no user with such username.</p>'; } else { if ($data_row == '0') { $error_msg .= '<p>Your account is not activated.</p>'; } $check_pass = sha1($password . $data_row['salt']); if ($check_pass != $data_row['password']) { $error_msg .= '<p>Wrong password.</p>'; } } } } if ($error_msg != '') { $warnings->error = $error_msg; $warnings->status = ''; $this->_redirect('/'); return; } else { Zend_Loader::loadClass('Zend_Date'); $date = new Zend_Date(); $current_date = $date->toString('YYYY-MM-dd HH:mm:ss'); $where = 'login = "******"'; $data = array('last_login' => $current_date); $user_update = new Users(); $user_update->update($data, $where); $warnings->error = ''; $warnings->username = ''; $warnings->email = ''; $warnings->real_name = ''; $warnings->status = ' hide'; $user_dates = new Zend_Session_Namespace(); $user_dates->username = $username; $user_dates->status = '1'; $this->_redirect('/profile/'); return; } } }
public function loginAction() { // Don't allow logged in people here $user = Zend_Auth::getInstance()->getIdentity(); if ($user !== null) { $this->_redirect('/'); } $this->view->title = 'Log in'; if ($this->_request->isPost()) { // collect the data from the user $f = new Zend_Filter_StripTags(); $username = $f->filter($this->_request->getPost('handle')); $password = $f->filter($this->_request->getPost('password')); if (empty($username) || empty($password)) { $this->addErrorMessage('Please provide a username and password.'); } else { // do the authentication $authAdapter = $this->_getAuthAdapter($username, $password); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $auth->getStorage()->write($authAdapter->getResult()); // Receive Zend_Session_Namespace object $session = new Zend_Session_Namespace('Zend_Auth'); // Set the time of user logged in $session->setExpirationSeconds(24*3600); // If "remember" was marked if ($this->getRequest()->getParam('rememberme') !== null) { // remember the session for 604800s = 7 days Zend_Session::rememberMe(604800); } $ns = new Zend_Session_Namespace('lastUrl'); $lastUrl = $ns->value; if ($lastUrl !== '') { $ns->value = ''; // If our last request was an tester ajax request just // go back to /tester $lastUrl = (strpos($lastUrl,'/tester/ajax') === false) ? $lastUrl : '/tester'; $this->_redirect($lastUrl); } $this->_redirect('/'); } else { // failure: clear database row from session $this->addErrorMessage('Login failed.'); } } } else { $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden'); } }
function stripTags($properties) { $tag_filter = new Zend_Filter_StripTags(); foreach ($properties as $property) { if ($this->has($property)) { $this->$property = $tag_filter->filter($this->$property); } } }
/** * default method, strips tags * * @param string $key */ public static function get($key) { $filter = new Zend_Filter_StripTags(); $post = self::toObject(); if (isset($_POST[$key])) { return trim($filter->filter($post->{$key})); } }
public function init() { $stripTags = new Zend_Filter_StripTags(); $stripTags->setTagsAllowed(array('p', 'a', 'img', 'strong', 'b', 'i', 'em', 's', 'del')); $stripTags->setAttributesAllowed(array('href', 'target', 'rel', 'name', 'src', 'width', 'height', 'alt', 'title')); $this->setAction('/rating/new'); $this->addElement('select', 'value', array('label' => 'Rating:', 'required' => true, 'multiOptions' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)))->addElement('textarea', 'comment', array('class' => 'richedit', 'label' => 'Comment:', 'filters' => array('StringTrim', $stripTags), 'validators' => array(new Zend_Validate_NotEmpty())))->addElement('hidden', 'recipe_id')->addElement('submit', 'submit'); }
public function testStripTagsUnicode() { set_time_limit(30); $value = '<div>This string will be<!-- Strange char r�d --> cleaned</div>'; $filter = new Zend_Filter_StripTags(); $valueFiltered = $filter->filter($value); $this->assertEquals('This string will be cleaned', $valueFiltered); }
public function setDescription($description, $htmlEntityDecode = false) { $filter = new Zend_Filter_StripTags(); if ($htmlEntityDecode) { $description = html_entity_decode($description); } $description = $filter->filter($description); $this->_tags['og:description'] = $description; }
public function loginAction() { $this->view->translate()->setLocale(isset($_GET['locale']) ? $_GET['locale'] : 'ru'); $this->view->resource = $this->_request->getParam('resource'); $this->view->headTitle($this->view->translate('Login page')); $this->view->headLink()->appendStylesheet(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => '/img/favicon.ico')); $this->view->headLink()->appendStylesheet('/modules/auth/css/login.css'); if ($this->_request->isPost()) { // file_put_contents('d:\\temp\\auth.txt', var_export($this->_request->getParams(), true)); $filter = new Zend_Filter_StripTags(); $username = $filter->filter($this->_request->getParam('username')); $password = $filter->filter($this->_request->getParam('password')); $woredir = $this->_request->getParam('woredir'); if ($woredir) { $this->getHelper('viewRenderer')->setNoRender(); $this->getHelper('layout')->disableLayout(); } if (empty($username)) { $this->_response->setHttpResponseCode(401); // Unauthorized if ($woredir) { echo 'Please, provide a username.'; } else { $this->view->message = 'Please, provide a username.'; } //$this->view->translate('Please provide a username.'); } else { Zend_Session::start(); if (Uman_Auth::login($username, $password)) { Zend_Session::rememberMe(); $auth = Zend_Auth::getInstance(); $identity = $auth->getIdentity(); $ns = new Zend_Session_Namespace('acl'); $ns->acl = new Uman_Acl($identity->NODEID, $identity->PATH); if ($woredir) { echo 'OK'; } else { $this->_redirect($this->_request->getParam('resource', '/')); } } else { $this->_response->setHttpResponseCode(401); // Unauthorized Zend_Session::destroy(); if ($woredir) { echo 'Authorization error. Please, try again.'; } else { $this->view->message = $this->view->translate('Authorization error. Please, try again.'); } } } } else { if (Zend_Session::sessionExists()) { Zend_Session::start(); Zend_Session::destroy(); } } }
/** * Output text preview * * @param string $text * @param int $length * @return string */ public static function outputTextPreview($text, $length = 100) { $filter = new Zend_Filter_StripTags(); $text = $filter->filter($text); if (strlen($text) <= 100) { return $text; } else { return substr($text, 0, $length) . '...'; } }
/** * returns a truncated version of the text * * @param unknown_type $text * @param unknown_type $count * @return unknown */ public function truncateText($text, $count = 25, $stripTags = true) { if ($stripTags) { $filter = new Zend_Filter_StripTags(); $text = $filter->filter($text); } $words = split(' ', $text); $text = (string) join(' ', array_slice($words, 0, $count)); return $text; }
public function RenderOutput($content, $context = 'default') { if ($context != 'post') { $filter = new Zend_Filter_StripTags(); $content = $filter->filter($content); } $content = nl2br($content); // trigger addons $data = array('content' => $content, 'context' => $context); Zend_Registry::get('hooks')->trigger('hook_data_renderoutput', $data); return $data['content']; }
function loginAction() { $this->_helper->layout->disableLayout(); Zend_Date_Cities::getCityList(); $form = new App_Form_Login(); $this->view->form = $form; $this->view->message = ''; if ($this->_request->isPost()) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $filter = new Zend_Filter_StripTags(); $username = $filter->filter($this->_request->getPost('username')); $password = $filter->filter($this->_request->getPost('password')); if (empty($username)) { $this->view->message = 'Please provide a username.'; } else { // setup Zend_Auth adapter for a database table Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable'); $db = Zend_Db_Table::getDefaultAdapter(); $authAdapter = new Zend_Auth_Adapter_DbTable($db); $authAdapter->setTableName('ourbank_user'); $authAdapter->setIdentityColumn('username'); $authAdapter->setCredentialColumn('password'); $authAdapter->setIdentity($username); $authAdapter->setCredential($password); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $data = $authAdapter->getResultRowObject(null, 'password'); $auth->getStorage()->write($data); $userinfo = new App_Model_Users(); $getresult = $userinfo->userinfo($username); foreach ($getresult as $getdata) { $user_id = $getdata["id"]; $username = $getdata["name"]; } $sessionName = new Zend_Session_Namespace('ourbank'); $sessionName->__set('primaryuserid', $user_id); $sessionName->primaryuserid; $sessionName->__set('username', $username); $sessionName->username; $globalsession = new App_Model_Users(); $this->view->globalvalue = $globalsession->getSession(); $sessionName->__set('language', $this->view->globalvalue[1]); $this->_redirect('/index/index'); } else { $this->view->message = 'Login failed.'; } } } $this->view->title = "Log in"; $this->render(); }
function loginAction() { $this->view->message = ''; if ($this->_request->isPost()) { // collect the data from the user Zend_Loader::loadClass('Zend_Filter_StripTags'); $f = new Zend_Filter_StripTags(); $name = $f->filter($this->_request->getPost('name')); $pass = $f->filter($this->_request->getPost('pass')); $pass = md5($pass); if (empty($name)) { $this->view->message = 'Please provide a username.'; } else { // setup Zend_Auth adapter for a database table Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable'); $db = Zend_Db_Table::getDefaultAdapter(); $authAdapter = new Zend_Auth_Adapter_DbTable($db); $authAdapter->setTableName('users'); $authAdapter->setIdentityColumn('name'); $authAdapter->setCredentialColumn('pass'); $authAdapter->setIdentity($name); $authAdapter->setCredential($pass); // do the authentication $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { // success: store database row to auth's storage // system. (Not the password though!) $data = $authAdapter->getResultRowObject(null, 'pass'); $auth->getStorage()->write($data); $auth = Zend_Auth::getInstance(); $user = $auth->getIdentity(); $activated = $this->view->escape(ucfirst($user->activated)); //user activation check if ($activated == "1") { $this->_redirect('/'); } else { Zend_Auth::getInstance()->clearIdentity(); $this->view->message = 'User not activated.'; } //$this->_redirect('/'); } else { // failure: clear database row from session $this->view->message = 'Login failed.'; } } } $this->view->title = "Log in"; $this->render(); }
function gestioncompteAction() { $this->user = Zend_Auth::getInstance()->getIdentity(); $this->view->title = "Modifiez votre profil"; $utilisateur = new Utilisateur(); $uti = array(); $erreurs = array(); if ($this->_request->isPost()) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $filter = new Zend_Filter_StripTags(); $id = $this->user->id_utilisateur; $uti['login'] = trim($filter->filter($this->_request->getPost('login'))); $uti['pass'] = trim($filter->filter($this->_request->getPost('pass'))); $uti['pass1'] = trim($filter->filter($this->_request->getPost('pass1'))); $uti['pass2'] = $filter->filter($this->_request->getPost('pass2')); $uti['mail'] = $filter->filter($this->_request->getPost('mail')); $uti['mail1'] = trim($filter->filter($this->_request->getPost('mail1'))); $uti['mail2'] = trim($filter->filter($this->_request->getPost('mail2'))); $pass = $this->user->pass_utilisateur; if (verifInfoUtilisateur($uti, $erreurs, $utilisateur, $pass)) { $id = $this->user->id_utilisateur; $data = array('login_utilisateur' => $this->user->login_utilisateur, 'pass_utilisauter' => md5($uti['pass1']), 'mail_utilisateur' => $uti['mail1']); $where = 'id_utilisateur = ' . $id; $utilisateur->update($data, $where); $this->_redirect('/'); return; } } $this->view->action = "gestioncompte"; $this->view->utilisateur = $utilisateur->createRow(); $this->view->erreurs = $erreurs; }
public function login($username, $password) { // Remove backslashes $username = str_replace("\\", "", $username); // filter data from the user $f = new Zend_Filter_StripTags(); $this->user = $f->filter($username); $this->pwd = $f->filter($password); // Validate credentials if (empty($username)) { throw new Exception('Invalid username'); } if (empty($password)) { throw new Exception('Invalid password'); } // Username can be alphanum with dash, underscore, @, periods and apostrophe $usernameValidator = new Zend_Validate_Regex('/^([A-Za-z0-9-_@\\.\']+)$/'); if (!$usernameValidator->isValid($username)) { throw new Exception('Please enter a valid username'); } // setup Zend_Auth adapter for a database table $this->db->setFetchMode(Zend_Db::FETCH_ASSOC); $authAdapter = new Zend_Auth_Adapter_DbTable($this->db); $authAdapter->setTableName('ol_admins'); $authAdapter->setIdentityColumn('user'); $authAdapter->setCredentialColumn('password'); // Set the input credential values to authenticate against $authAdapter->setIdentity($username); $authAdapter->setCredential(md5($password)); $authAdapter->getDbSelect()->where('active = ?', 1); // MUST be an active account // do the authentication $result = $this->auth->authenticate($authAdapter); $this->db->setFetchMode(Zend_Db::FETCH_OBJ); if (!$result->isValid()) { throw new Exception('Login failed.'); } //var_dump($authAdapter->getResultRowObject()); exit(); // Update last login date $users = new OneLogin_Acl_Users(); $users->updateLastLoginDate($username); // Define object and set auth information $objUser = new stdClass(); $objUser->user_id = $authAdapter->getResultRowObject()->id; $objUser->api_user_username = $username; $objUser->api_user_password = $password; $objUser->active = $authAdapter->getResultRowObject()->active; $this->auth->getStorage()->write($objUser); }
/** * Ensures that space is allowed between the double-hyphen '--' and the ending delimiter '>' * * @see http://www.w3.org/TR/1999/REC-html401-19991224/intro/sgmltut.html#h-3.2.4 * @return void */ public function testFilterCommentsAllowedDelimiterEndingWhiteSpace() { $input = '<a> <!-- <b> -- > <c>'; $expected = ' <!-- <b> -- > '; $this->_filter->commentsAllowed = true; $this->assertEquals($expected, $this->_filter->filter($input)); }