Наследование: extends AppModel
 function page_management_admin()
 {
     parent::Controller();
     //Check login
     $this->load->module('login');
     // load 'DB_Interaction' model
     $this->load->model('DB_Interaction');
     $this->load->model('Page_DB_Interaction');
     // load library
     $this->load->library('Table');
     /*-----------------------------------------------------------------------*/
     //URL TO HELP FOR REDIRECT WHEN USER LOGS OUT
     /*
     | Basic REASON behind these is that Ajax Call should not be part of the REMEMBER URL in lOGIN function
     */
     $this->session->unset_userdata('LastUrl');
     $this->session->set_userdata('LastUrl', $this->page_name);
     /*-----------------------------------------------------------------------*/
     // load Helpers
     $this->load->helper(array('date', 'text', 'useful'));
     $l = new Login();
     if ($l->_is_logged_in()) {
     } else {
         redirect('login');
     }
     //---------------------------CHECK MODULE ACESS--------------------------
     if ($this->session->userdata('user') != '*****@*****.**') {
         if (!$l->_module_access($this->parent_controller)) {
             $this->session->set_flashdata('invalid_url_access', 'You do not Have Sufficient Priviledge to Access the Page !');
             redirect('adminx');
         }
     }
 }
Пример #2
0
Файл: add.php Проект: alcf/chms
 public function btnSubmit_Click($strFormId, $strControlId, $strParameter)
 {
     // Create a login object with the information
     $objLogin = new Login();
     $objLogin->FirstName = $this->strFirstName->Text;
     $objLogin->LastName = $this->strLastName->Text;
     $objLogin->Username = $this->strUserName->Text;
     $objLogin->RoleTypeId = RoleType::Volunteer;
     if (strlen(trim($this->strEmail->Text)) > 0) {
         $objLogin->Email = $this->strEmail->Text;
     }
     $objLogin->SetPasswordCache($this->strPassword->Text);
     $objLogin->LoginActiveFlag = $this->lstActiveFlag->SelectedValue;
     $objLogin->DomainActiveFlag = false;
     $intBitmap = 0;
     foreach ($this->rblPermissionArray as $rblPermission) {
         $intBitmap = $intBitmap | $rblPermission->SelectedValue;
     }
     $objLogin->PermissionBitmap = $intBitmap;
     $objLogin->Save();
     // Update ministries associated
     $objLogin->UnassociateAllMinistries();
     foreach ($this->rblMinistryArray as $rblMinistry) {
         $objMinistry = Ministry::LoadById($rblMinistry->SelectedValue);
         if ($objMinistry) {
             $objMinistry->AssociateLogin($objLogin);
         }
     }
     QApplication::Redirect('/admin/externusers/');
 }
 /**
  * Check login and create login page if requested otherwise say access deinied.
  * param $login boolean, true - display login form if not logged in, otherwise display access denied message.
  */
 public function checkLogin($login, $infoLoad = false)
 {
     //if not logged in
     if (!$this->loggedIn()) {
         //Show a login form if asked for
         if ($login) {
             //Create new page system
             $p = new Page(null, false);
             //Create login system
             $l = new Login();
             //Create a login form for this anonymous user
             $l->createLogin($p, $this->getController()->getView(), true);
             //NEVER GETS HERE LOGIN CLASS EXITS
             //Display the page.
             $p->displayPage();
             //Quit the system
             $this->getController()->freeze_all();
         } else {
             //Set the title of the page
             $this->getController()->getView()->setContentTitle(file_get_contents("core/fragments/access_denied_title.phtml"));
             //Set the content for access denied
             $this->getController()->getView()->setContent(file_get_contents("core/fragments/access_denied_content.phtml"));
             //Set to 2 columns
             $this->getController()->getView()->setTwoColumn();
             $this->getController()->getView()->setLeftTitle("");
             $this->getController()->getView()->setLeftContent("");
             //Display the page.
             $this->getController()->getView()->displayPage();
             //Quit the system
             $this->getController()->freeze_all();
         }
     } else {
         return true;
     }
 }
Пример #4
0
/**
 * Function to process api request.
 * @param string $data	Base64 encoded json string with api request data.
 */
function api($data)
{
    // decode json data from get
    $data = base64_decode($data);
    $data = json_decode($data);
    // convert to login, logout or data request
    $response = null;
    $request = null;
    if (Login::isInstance($data)) {
        $request = new Login($data->data->warehouseId, $data->data->pw);
        $response = $request->login();
    } elseif (Logout::isInstance($data)) {
        $request = new Logout($data->sessionId);
        $response = $request->logout();
    } elseif (DataRequest::isInstance($data)) {
        if (isset($data->sessionId) && isset($data->data)) {
            $request = new DataRequest($data->sessionId, $data->f, $data->data);
        } elseif (isset($data->sessionId)) {
            $request = new DataRequest($data->sessionId, $data->f);
        } else {
            if (isset($data->data)) {
                $request = new DataRequest(0, $data->f, $data->data);
            } else {
                $request = new DataRequest(0, $data->f);
            }
        }
        $response = $request->process();
    }
    return json_encode(array('request' => $request, 'response' => $response));
}
Пример #5
0
 public function insertOrUpdateProduct($post)
 {
     parent::createConnection();
     $house_no = $post['house_no'];
     $street_name = parent::getEscaped($post['street_name']);
     $apartment_no = parent::getEscaped($post['apartment_no']);
     $city = parent::getEscaped(ucwords($post['city']));
     $state = $post['state'];
     $country = $post['country'];
     $zip = strtoupper($post['zip']);
     $type = $post['range'];
     $description = parent::getEscaped($post['description']);
     $room_no = $post['rooms'];
     $bath_no = $post['bathrooms'];
     $living_room_no = $post['living_rooms'];
     $price = parent::getEscaped($post['price']);
     $rangeType = $post['rangeType'];
     $loginObj = new Login();
     $user_id = $loginObj->getUserId();
     if (isset($post['upload']) && isset($_FILES['files'])) {
         $query1 = "INSERT INTO address_info VALUES (DEFAULT, '{$house_no}', '{$street_name}', '{$apartment_no}', '{$city}', '{$state}', '{$zip}', '{$country}')";
         parent::executeSqlQuery($query1);
         $addressId = parent::getLastId();
         $query = "INSERT INTO dwellings VALUES (DEFAULT, '{$addressId}', '{$user_id}', '{$type}', '{$description}', '{$room_no}', '{$bath_no}', '{$living_room_no}', '{$price}', '{$rangeType}')";
         parent::executeSqlQuery($query);
         $this->uploadImages($_FILES);
     } elseif (isset($post['update'])) {
         $dwelling_Id = $post['hiddenID'];
         $address_id = $this->getAddressId($dwelling_Id);
         $updateDwellings = "UPDATE dwellings SET type \t\t \t\t= '{$type}',    \t\tdescription \t= '{$description}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t no_of_rooms \t\t= '{$room_no}', \t\tno_of_bathrooms\t= '{$bath_no}', \t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t     no_of_living_rooms = '{$living_room_no}',price \t\t\t= '{$price}'\n\t\t\t\t\t\t\t\t\t\t\t\t   WHERE dwelling_Id = {$dwelling_Id}";
         $updateAddress = "UPDATE address_info SET house_no \t\t\t= '{$house_no}', \t\tstreet_name  \t\t= '{$street_name}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t    apartment_no \t\t= '{$apartment_no}', \tcity \t\t \t\t= '{$city}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t    province \t\t\t= '{$state}', \t\tzip_code \t \t\t= '{$zip}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t    country\t\t\t\t= '{$country}'\n\t\t\t\t\t\t\t\t\t\t\t      WHERE address_id \t= '{$address_id}'";
         parent::executeSqlQuery($updateDwellings);
         parent::executeSqlQuery($updateAddress);
     }
 }
Пример #6
0
 public function logar(Login $login)
 {
     $Sql = new Sql();
     $sb = new StringBuilder();
     $sb->append("SELECT *");
     $sb->append("FROM " . T_USUARIO);
     $sb->append(sprintf("WHERE login_usr = %s", $login->getLoginUsr()));
     $sb->append(sprintf("AND senha_usr = %s", $login->getSenhaUsr()));
     $sb->append("AND ativo_usr = 1");
     $retorno = $Sql->ExecutaSQL($sb->toString());
     if (count($retorno) > 0) {
         global $Sess;
         // Dados do Usuario Logado
         $Sess->usuario = $retorno[0];
         // Atualiza o usuário
         $usuario = new Usuarios();
         $usuario->setCodigoUsr(toNumero($retorno[0]['codigo_usr']));
         $usuario->setUltimoacessoUsr(toDateTime());
         $this->alterar($usuario);
         // inicia Sessao
         $Sess->logado_sys = true;
         $Sess->ultimoacesso_sys = time();
         return true;
     }
     return false;
 }
 public function showAll()
 {
     session_start();
     $login = new Login();
     $id = $login->isLogged();
     if ($id) {
         $user = new User($id);
         $regNumber = $user->regNumber;
         $data["user"] = $user;
         //echo $regNumber;
     } else {
         header('Location: http://localhost/WEB_Projeto_Final/public_html/home');
     }
     $show_questions = new Questao();
     $results = $show_questions->getAll();
     $getSubjects = $show_questions->getSubjects($regNumber);
     //var_dump($getSubjects);
     $data["subjects"] = array_unique($getSubjects);
     $data['questions'] = $results;
     $data['images'] = $show_questions->getImages($results);
     $data['answers'] = $show_questions->getAnswer($results);
     $this->view('questoes/listar', $data);
     //	echo $result[0]->value;
     //	var_dump($results);
 }
 public function r($params = null)
 {
     session_start();
     $loginClass = new Login();
     $loginClass->register($params[0], $params[1], $params[2], $params[3], $params[4], $params[5]);
     $this->redirect('');
 }
Пример #9
0
 public function Render($files, \Slim\Slim &$app, $comments)
 {
     //getting files
     $this->files = $files;
     $obj = new Files();
     $obj->parseFile($files);
     $obj->CheckFormat();
     //$cookieDB = $obj->cookie;
     $db = $app->db;
     $public = $obj->public;
     $filesize = new Filesize();
     $user_id = $obj->user_id;
     //getting id of the User from Files table
     $getLog = new Login();
     $login = $getLog->getLogin($user_id, $db);
     $app->view->setData(array('login' => $login));
     $cookie = $app->getCookie('username');
     //getting cookie of the current user
     $logged = new Logged();
     $id = $logged->getLogged($db, $cookie);
     //checking of the user is registered in Users table as the user or anonymous which added this file and getting his id
     if ($id == $user_id) {
         //if the id of Author of the file and the id of the user that opens this file are equal
         $app->render('File.php', ['files' => $files, 'filesize' => $filesize, 'comments' => $comments, 'db' => $db]);
         //we rendeer the form for the Author
     } elseif ($public == 0) {
         //else we render the form for the quest
         $app->render('Public.php', ['files' => $files, 'filesize' => $filesize, 'comments' => $comments, 'db' => $db]);
     } else {
         $this->app->redirect('/TwigBlog/');
         //if the file was private and the user isnt his author we render 404
     }
 }
Пример #10
0
function check_login_status()
{
    $return_value = "";
    // create a login object. when this object is created, it will do all login/logout stuff automatically
    // so this single line handles the entire login process. in consequence, you can simply ...
    $login = new Login();
    // ... ask if we are logged in here:
    if ($login->isUserLoggedIn() == true) {
        // the user is logged in. you can do whatever you want here.
        // for demonstration purposes, we simply show the "you are logged in" view.
        //include("login/views/logged_in.php");
        // do nothing.
        $return_value = "login_good";
    } else {
        // the user is not logged in. you can do whatever you want here.
        // for demonstration purposes, we simply show the "you are not logged in" view.
        //include("login/views/not_logged_in.php");
        //print "login_required" ;
        $return_value = "Login not good";
        if (isset($login)) {
            if ($login->errors) {
                foreach ($login->errors as $error) {
                    $return_value .= $error;
                }
            }
            if ($login->messages) {
                foreach ($login->messages as $message) {
                    $return_value .= $message;
                }
            }
        }
    }
    return $return_value;
}
Пример #11
0
 /**
  *
 * Load Userrights and User Id to Sesseion.
 *
 * @param sfRequest $request A request object
 */
 public function executeIndex(sfWebRequest $request) {
     $loginObject = new Login();
     
     /*
     * Load the userrole, userrigths, userSettings, userId, workflowSettings for the logged user and store to session
     */
     $userSettings = UserSettingTable::instance()->getUserSettingById($this->getUser()->getAttribute('id'));
     $userWorkflowSetting = UserWorkflowConfigurationTable::instance()->getSingleUserWorkflowConfigurattion($this->getUser()->getAttribute('id'))->toArray();
     $this->getUser()->setAttribute('userSettings', $userSettings[0]->toArray()); // set userSettings
     $config = SystemConfigurationTable::instance()->getSystemConfiguration()->toArray();
     $this->getUser()->setAttribute('userWorkflowSettings', $loginObject->generateUserWorklowView($userWorkflowSetting, sfContext::getInstance())); // set workflowsettings
     $data = $this->getUser()->getAttribute('userWorkflowSettings');
     $credentials = CredentialTable::instance()->getAllCredentials();
     $userrights = CredentialRoleTable::instance()->getCredentialRoleById($this->getUser()->getAttribute('id'));
     $rights = $loginObject->loadUserRight($credentials, $userrights);
     $this->getUser()->setAttribute('credential', $rights); // set rights and role
     $this->systemConfiguration = $config[0];
     $this->theTheme = $userSettings[0]->getTheme(); // load the users theme
     /*
      * -1 is set when user uses login form to login
      * int is set, when user logges in from en email link, then a workflow needs to opened
      */
     $this->version_id  = $request->getParameter('versionid',-1);
     $this->workflow_id  = $request->getParameter('workflow',-1);
     $this->window  = $request->getParameter('window',-1);
     return sfView::SUCCESS;
 }
Пример #12
0
 public function actionIndex()
 {
     $loginModel = new Login();
     $data['loginModel'] = $loginModel;
     $data['loginerror'] = 0;
     //前台登陆
     if (isset($_POST['Login'])) {
         $loginModel->attributes = $_POST['Login'];
         if (!$loginModel->validate()) {
             $data['loginerror'] = 1;
         } else {
             $sql = "select id from {{user}} where username = '******'Login']['loginname'] . "' and password = '******'Login']['loginpass']) . "' ";
             $LoginInfo = $loginModel->findBySql($sql);
             if ($LoginInfo == NULL) {
                 $loginModel->addError("loginname", "用户名或密码错误!");
                 $data['loginerror'] = 1;
             } else {
                 Yii::app()->session['uid'] = $LoginInfo['id'];
                 $this->redirect(array("/index/m", 'who' => $LoginInfo['id']));
             }
         }
     }
     $userModel = User::model();
     $url = "http://" . Yii::app()->params['bucket'] . "." . Yii::app()->params['domain'] . "/";
     $sql = "select id,username,headpicture from {{user}}";
     $data['users'] = $userModel->findAllBySql($sql);
     $data['url'] = $url;
     //切换布局
     $this->layout = "//layouts/register";
     $this->render("imain", $data);
 }
 function Login($username, $password)
 {
     $login = new Login();
     $login->SetUsername($username);
     $login->SetPassword($password);
     $result = $login->DoLogin();
     return new soapval("return", "xsd:boolean", $result);
 }
Пример #14
0
 /**
  * In short, does this login have privileges to view this ministry?
  * To cater for volunteers, who we want to restrict to just viewing the ministries
  * in which they're assisting 
  *
  * @param Login $objLogin
  * @return boolean
  */
 public function IsLoginCanViewMinistry(Login $objLogin)
 {
     if ($objLogin->RoleTypeId == RoleType::Volunteer) {
         return $objLogin->IsMinistryAssociated($this);
     } else {
         return true;
     }
 }
Пример #15
0
 public function salir()
 {
     if (isset($_SESSION["Usuario"])) {
         session_destroy();
     }
     $Login = new Login();
     $Login->index();
 }
 /**
  * 登录
  * @param unknown $param
  */
 public function Login($param)
 {
     import('SC.User.Login');
     //导入相应的类库
     $userLogin = new Login($param);
     $result = $userLogin->run();
     echo $result;
 }
Пример #17
0
 public function login()
 {
     $user = new Login();
     if ($user->valid()) {
         return 'home.tpl';
     } else {
         return 'login.tpl';
     }
 }
Пример #18
0
 /**
  * Check username
  */
 public function check_username()
 {
     $this->load->model('user');
     $user = new Login();
     if ($user->check_username() == true) {
         // Username does not exist
     } else {
         echo 'Username already has been taken';
     }
 }
Пример #19
0
 public function executeNew(sfWebRequest $request)
 {
     $isModerator = $request->getParameter('type') == 'animator' ? true : false;
     $this->isModerator = $isModerator;
     $moderator = new Moderator();
     $login = new Login();
     $login->setIsModerator($isModerator);
     $moderator->setLogin($login);
     $this->form = new ModeratorForm($moderator, array('new' => true));
 }
Пример #20
0
 private static function login()
 {
     $client = new Login(addslashes($_POST['login']), addslashes($_POST['password']));
     $login = $client->identification();
     if ($login) {
         $_SESSION['login'] = $client->getIdentifiant();
         return true;
     }
     return false;
 }
Пример #21
0
 public function logar()
 {
     $login = new Login();
     $login->setLoginUsr(toTexto(GetVar('login_usr')));
     $login->setSenhaUsr(toTexto(sha1(GetVar('senha_usr'))));
     $loginDAO = new LoginDAO();
     $return = $loginDAO->logar($login);
     $result = $return ? 'Login efetuado com sucesso. Aguarde...' : 'Usuario ou Senha incorretos.';
     echo json_encode(array("success" => is_string($return) ? false : $return, "msg" => is_string($return) ? $return : $result));
 }
Пример #22
0
 /**
  * check if cuteflow is already installed or not
  * 
  * @param sfWebRequest $request
  * @return <type>
  */
 public function executeCheckLogin(sfWebRequest $request) {
     $loginObj = new Login();
     if ($loginObj->checkInstaller() == false) {
         $this->redirect('installer/index');
     }
     else {
         $this->redirect('login/index');
     }
     return sfView::NONE;
 }
Пример #23
0
 function testLoginFail()
 {
     $expected = 'false';
     $workNumber = '11111';
     $password = '******';
     $tableName = 'user_teacher';
     $lg = new Login();
     $actual = $lg->login($workNumber, $password, $tableName);
     $this->assertEquals($expected, $actual);
 }
Пример #24
0
 public static function create_from_login(Login $login)
 {
     $ch = curl_init(static::$login_url);
     curl_setopt_array($ch, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => array('login' => 'Log In', 'email' => $login->getUsername(), 'password' => $login->getPassword())));
     $response = curl_exec($ch);
     $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
     $headers = substr($response, 0, $headerSize);
     preg_match('#Set-Cookie: PHPSESSID=(\\w+);#', $headers, $matches);
     $sessionId = empty($matches[1]) ? null : $matches[1];
     return new static($sessionId);
 }
Пример #25
0
 public function Validar($user, $pass)
 {
     $login = new Login();
     $resultado = $login->Validar($user, $pass);
     $cantidadRegistros = $resultado->num_rows;
     if ($cantidadRegistros != 0) {
         $this->Ingreso();
     } else {
         $this->retornarError('password y/o usuario incorrecto');
     }
 }
Пример #26
0
 public static function getClientByLogin(Login $login)
 {
     $query = "SELECT * FROM " . Database::addPrefix('clients') . " WHERE LoginID = '" . Database::makeStringSafe($login->getID()) . "' LIMIT 1";
     $result = Database::doQuery($query);
     if (mysql_num_rows($result) == 1) {
         $client = mysql_fetch_assoc($result);
         return new Client($client['ClientID'], $login, $client['Name'], $client['Email'], $client['Phone'], $client['Address']);
     } else {
         return null;
     }
 }
Пример #27
0
 public function saveAction()
 {
     $db = new Login();
     $db->setLogin('testes');
     $db->setSenha('1234');
     $db->setTipoId(1);
     $db->setBloqueado(0);
     $data = array('login' => $db->getLogin(), 'senha' => $db->getSenha(), 'tipoid' => $db->getTipoId(), 'bloqueado' => $db->getBloqueado());
     $return = $db->saveLogin($data, 2);
     $this->view->retorno = $return;
     $this->render();
 }
 public function g()
 {
     session_start();
     $data = array();
     $loginClass = new Login();
     $id = $loginClass->isLogged();
     if ($id) {
         $notif = new Notifications();
         $notif->newNotification(2, 0);
     } else {
         $this->redirect('');
     }
 }
Пример #29
0
function checklogin()
{
    $login = new Login();
    $json = new JSON();
    if (!$login->check($_POST['sid'])) {
        $code = '200';
        $data_array[0] = array('result' => 'login first');
        $json_string = $json->ArrayGetjson($data_array, $code);
        echo $json_string;
        die;
    }
    return true;
}
Пример #30
0
 public function seguridad()
 {
     $this->page_title('Albaranes | Usuarios');
     $this->page_description('');
     $this->page_keywords('');
     if (!isset($_SESSION['id_usuario']) || $_SESSION['id_usuario'] == 0) {
         $this->Load->Model('Login');
         $Login = new Login();
         $Login->TestCookies();
     }
     if ($_SESSION['id_tipo'] != 2) {
         header('location:' . fk_link('paquetes'));
     }
 }