Exemple #1
0
 public function access()
 {
     if ($_POST) {
         $user = $_POST['user'];
         $pass = $_POST['pass'];
         $login = new Login_Model();
         $data_user = $login->systemLogin($user, $pass);
         $data_company = $login->dataCompany($data_user[0]['id_usuario']);
         $redirector = new RedirectorHelper();
         if ($data_user) {
             if ($data_company[0][2] == 1) {
                 if ($data_user[0]['nivel'] != 0) {
                     $session = new SessionHelper();
                     $session->createSession("userData", $data_user[0]);
                     $session->setDataCompany($data_company);
                     $redirector->goToController("");
                 } else {
                     $this->setMsg('erro', 'Usuário sem acesso.<br /> Entre em contato com o suporte para maiores informações!');
                     $redirector->goToController("");
                 }
             } else {
                 $this->setMsg('erro', 'Acesso negado. Entre em contato com o suporte para maiores informações!');
                 $redirector->goToController("");
             }
         } else {
             $this->setMsg('erro', 'Usuário ou Senha errados!');
             $redirector->goToController("");
         }
     } else {
         $redirector->goToController("");
     }
 }
 /**
  * Авторизует пользователя рамблера
  *
  * Страница рамблера передаёт в единственном аргументе зашифрованный
  * ассоциативный массив данных о пользователе например:
  * {
  *     "date":        "Sun, 12 Sep 2010 20:16:21 +0400",
  *     "id":          "ef-user-dsdsdsd-122121212",
  *     "name":        "Ivan",
  *     "email":       "*****@*****.**",
  *     "redirectUrl": "/my/wikiwrapper/tiki-view_blog.php?blogId=1"
  * }
  * @param $args
  */
 public function rambler($args)
 {
     $ramblerString = $args[0];
     $cipher = MCRYPT_RIJNDAEL_128;
     $key = 'X9Kls8DR72DqEFKLCMN02DdOQWdfLP2a';
     $iv = 'dOQWdfLP2aCZM12D';
     $decoded = urlsafe_b64decode($ramblerString);
     $json = mcrypt_cbc($cipher, $key, $decoded, MCRYPT_DECRYPT, $iv);
     $data = json_decode(trim($json), true);
     $default = array('id' => null, 'email' => null, 'name' => 'Рамблер', 'redirectUrl' => '/info/');
     $data = array_merge($default, (array) $data);
     $ramblerLogin = $data['id'] ? "rambler_{$data['id']}" : null;
     $user = Core::getInstance()->user;
     $user->destroy();
     // Пытаемся инициализировать пользователя
     $user->initUser($ramblerLogin, sha1($ramblerLogin));
     // Создаём нового пользователя
     if (!$user->getId() && $data['id']) {
         Login_Model::generateUserByRamblerLogin($ramblerLogin, $data['email'], $data['name']);
         $data['redirectUrl'] = '/my/review/';
         $user->initUser($ramblerLogin, sha1($ramblerLogin));
         setCookie("guide", "uyjsdhf", 0, COOKIE_PATH, COOKIE_DOMEN, false);
     }
     if ($user->getId()) {
         $this->model->login($ramblerLogin, sha1($ramblerLogin), true);
         header(sprintf('Location: %s', $data['redirectUrl']));
     } else {
         header('Location: /login/');
     }
     die;
 }
 /**
  * Создать пользователя по ключу Рамблера
  */
 public function testGenerateUserByRamblerLogin()
 {
     $ramblerKey = 'ef-user-icaneaa-' . time();
     $id = Login_Model::generateUserByRamblerLogin($ramblerKey);
     $query = "SELECT * FROM users WHERE id = '{$id}'";
     $cat = $this->getConnection()->selectRow($query);
     $login = isset($cat['user_login']) ? $cat['user_login'] : null;
     $this->assertEquals($ramblerKey, $login, 'Репа');
 }
Exemple #4
0
 public function update()
 {
     $model = new Login_Model();
     if ($model->on_update_email_check()) {
         $this->view->styles = array();
         array_push($this->view->styles, URL . "/Public/bootstrap/css/styles.css");
         array_push($this->view->styles, URL . "/Public/bootstrap/css/post.css");
         echo '</br></br></br><h1>email already exists</h1>';
         $this->view->user = $this->getUser(Session::get('id'));
         $this->view->render('login/edit_profile', 1);
         exit;
     }
     $x = $model->update();
     if ($x) {
         header('Location: ' . URL . '/post/index');
         exit;
     } else {
         echo 'error in profile edit';
     }
 }
 function get_login_info($login_id)
 {
     $logininfo = false;
     if ($login_id && (int) $login_id > 0) {
         $CI =& get_instance();
         $query = $CI->db->select("*")->from("cs_logins")->where(array("login_id" => $login_id))->get();
         if ($query && $query->num_rows() == 1) {
             $CI->load->model("login_model");
             $logininfo = new Login_Model();
             $rw = $query->row();
             $logininfo->setLoginid($rw->login_id);
             $logininfo->setUserid($rw->user_id);
             $logininfo->setLastactivity($rw->last_activity);
             $logininfo->setSessionid($rw->session_id);
             $logininfo->setIpaddress($rw->ip_address);
             $logininfo->setStatus($rw->status);
             $logininfo->setLastlogin($rw->last_login);
             $logininfo->setLastupdate($rw->last_update);
         }
     }
     return $logininfo;
 }
 /**
  * Регистрируем нового пользователя с азбуки финансов
  */
 private function _azbuka_registration()
 {
     $login = _Core_Request::getCurrent()->get['login'];
     $mail = _Core_Request::getCurrent()->get['mail'];
     // Генерируем нового пользователя на основе логина и его почты
     $newId = Login_Model::generateUserByAzbukaLogin($login, $mail);
     $row_user = Login_Model::getUserDataByID($newId);
     // @FIXME Непонятно что тут делает этот блок..
     // Если мы только что сделали сами пользователя, то мы и знаем его логин, нет?
     if (substr($row_user['user_login'], 0, 6) != 'azbuka') {
         $this->_redirect('/notfound', false, 404);
     }
     $uar = array('user_id' => $newId, 'user_name' => $row_user['user_login'], 'user_type' => 0);
     $this->templateEngine->assign('user_info', $uar);
     $this->templateEngine->assign('template_view', 'iframe');
     $this->_setCookie($row_user['user_login'], $row_user['user_pass']);
     $this->_redirect("Location: " . URL_ROOT_IFRAME . "info/");
     return $newId;
 }
Exemple #7
0
 public function init_admin()
 {
     $this->set_sess_history('admin');
     // Get history back from session if have
     $this->sess_admin = Login_Model::get('admin', FALSE);
     if ($this->sess_admin === FALSE) {
         if ($this->uri->segment(1) != "admin_login") {
             url::redirect('admin_login');
         }
     }
     //load language
     if ($this->session->get('sess_admin_lang')) {
         $lang_id = $this->session->get('sess_admin_lang');
         $lang_code = ORM::factory('languages')->find($lang_id)->languages_code;
     } else {
         $lang_id = $this->site['site_lang_admin'];
         $lang_code = ORM::factory('languages')->find($lang_id)->languages_code;
         $this->session->set('sess_admin_lang', $lang_id);
     }
     Kohana::config_set('locale.language', $lang_code);
     $this->site['lang_id'] = $lang_id;
     // Save active last time
     //if($this->uri->segment(1) != "admin_login") Login_Model::save_active_last($this->sess_admin['id']);
 }
Exemple #8
0
 private function update_account()
 {
     $old_pass = $this->input->post('txt_old_pass');
     $frm_myacc = $this->_get_myacc_valid();
     $sess_cus = Login_Model::get('customer');
     if ($sess_cus !== FALSE) {
         $rec_up = array('member_fname' => $frm_myacc['txt_first_name'], 'member_lname' => $frm_myacc['txt_last_name'], 'member_email' => $frm_myacc['txt_email'], 'company_name' => $frm_myacc['txt_company_name'], 'company_contact_name' => $frm_myacc['txt_contact_name'], 'company_contact_email' => $frm_myacc['txt_contact_email']);
         if (!empty($old_pass)) {
             $rec_up['member_pw'] = md5($frm_myacc['txt_new_pass']);
             $this->session->set_flash('info_msg', Kohana::lang('errormsg_lang.msg_change_pass'));
         }
         $this->db->update('member', $rec_up, array('uid' => $sess_cus['id']));
         $this->session->set_flash('success_msg', ' ');
         url::redirect('mypage/viewaccount');
         die;
     }
 }
Exemple #9
0
 public function log_out()
 {
     Login_Model::status_online($this->sess_admin['id'], 'offline');
     Login_Model::log_out('admin');
     Session::destroy();
     //url::redirect('home');
     $this->index();
 }
 /**
  * Авторизовать пользователя
  */
 protected function _authenticateUser($login, $password)
 {
     $login_Model = new Login_Model();
     $login_Model->login($login, $password);
 }
    static function process($request)
    {
        if (isset($request['url'])) {
            $url = $request['url'];
        } else {
            $url = 'http://localhost/';
        }
        if (isset($request['username'])) {
            $username = $request['username'];
        } else {
            $username = '******';
        }
        if (isset($request['accesskey'])) {
            $accesskey = $request['accesskey'];
        } else {
            $accesskey = '';
        }
        if (!empty($url) && !empty($username) && !empty($accesskey)) {
            $loginModel = new Login_Model($url, $username, $accesskey);
            $client = new Vtiger_WSClient($loginModel->getURL());
            $checkLogin = $client->doLogin($loginModel->getUsername(), $loginModel->getAccessKey());
            if ($checkLogin) {
                Session_Controller::setLoginContext($loginModel);
                $loginModel->setUserId($client->_userid);
                $loginModel->setSessionId($client->_sessionid);
                header('Location: index.php');
                exit;
                //return;
            }
        }
        Header_Controller::process($request);
        ?>
		<form method='POST' action='index.php' onsubmit='$("#wserrmsg").hide();this.__submitButton.value="Verifying"; this.__submitButton.disabled=true;'>
		<div class='form-group'>
			<label for='url'>URL</label>
			<input type='text' name='url' value='<?php 
        echo $url;
        ?>
' size=40 class='form-control'>
		</div>
		<div class='form-group'>
			<label for='username'>Username</label>
			<input type='text' name='username' value='<?php 
        echo $username;
        ?>
' size=40 class='form-control'>
		</div>
		<div class='form-group'>
			<label for='accesskey'>Access key</label>
			<input type='text' name='accesskey' value='<?php 
        echo $accesskey;
        ?>
' size=40 class='form-control'>
		</div>
		<div class='form-group'>
			<input class='btn btn-primary btn-large' type='submit' value='Login &raquo;' name='__submitButton'>
		</div>
		</form>
<?php 
        if (!empty($url) && !empty($username) && !empty($accesskey) && !$checkLogin) {
            echo '<div class="alert alert-danger" id="wserrmsg">There is an error with the validation data given, please review and try again.</div>';
        }
        Footer_Controller::process($request);
    }
Exemple #12
0
 public function log_out()
 {
     Login_Model::log_out('admin');
     Session::destroy();
     $this->index();
 }
Exemple #13
0
 private function log_out()
 {
     Login_Model::log_out();
     $this->session->destroy();
     url::redirect('home');
     die;
 }
Exemple #14
0
 /**
  * Validates login information from an array, and optionally redirects
  * after a successful login.
  *
  * @param  array    values to check
  * @param  string   URI or URL to redirect to
  * @return boolean
  */
 public function login(array &$array, $redirect = false)
 {
     // Login starts out invalid
     $status = false;
     // Log login attempt
     $login = new Login_Model();
     $login->password = !empty($array['password']);
     $login->username = $array['username'];
     if ($this->validate($array, false, array(), array(), array('rules' => 'login'))) {
         // Attempt to load the user
         $this->find_user($array['username']);
         if ($this->loaded()) {
             $login->uid = $this->id;
             $login->username = $this->username;
             if (Visitor::instance()->login($this, $array['password'])) {
                 $login->success = 1;
                 // Redirect after a successful login
                 if (is_string($redirect)) {
                     $login->save();
                     url::redirect($redirect);
                 }
                 // Login is successful
                 $status = true;
             } else {
                 $array->add_error('username', 'invalid');
             }
         }
     }
     $login->save();
     return $status;
 }