public function getIndex()
 {
     $campaign = new Campaign();
     $image = $campaign->getCampaignImage();
     $users = new Users();
     $member = $users->getRecentUsers();
     $this->layout->foot = View::make("landing.foot")->with(array('data' => $image, 'data2' => $member));
     $this->layout->title = "Welcome to Sagip.ph";
     if (Session::has('userid')) {
         $username = Session::get('username');
         $logstatus = true;
         $userid = Session::get('userid');
         $profile = new Profile();
         $pic = "#";
         $result = $profile->getProfile($userid);
         if ($result) {
             $pic = $result->profilepic;
         }
         $data = array('username' => $username, 'logstatus' => $logstatus, 'profilepic' => $pic);
         $campaign = new Campaign();
         $data2 = $campaign->getCampaignHome();
         $this->layout->head = View::make("landing.head")->with($data);
         $this->layout->body = View::make("landing.bodycontributordash")->with($data);
     } else {
         $logstatus = false;
         $data = array('logstatus' => $logstatus);
         $campaign = new Campaign();
         $data2 = $campaign->getCampaignHome();
         $this->layout->head = View::make("landing.head")->with($data);
         $this->layout->body = View::make("landing.bodycontributordash")->with($data);
     }
 }
Esempio n. 2
0
 /**
  * Registration
  */
 public function upAction()
 {
     if ($this->request->isPost()) {
         $user = new Users();
         $user->login = $this->request->getPost('login', 'string');
         $user->password = $this->request->getPost('password', 'string');
         $passwordVerify = $this->request->getPost('password-verify', 'string');
         if (md5($user->password) !== md5($passwordVerify)) {
             $this->flashSession->error('Пароли не совпадают');
             return;
         }
         if (!$user->create()) {
             $this->flashSession->error(implode("<br/>", $user->getMessages()));
             return;
         }
         $auth = new Auth();
         $authSucceed = $auth->authorize($user);
         if ($authSucceed) {
             $this->response->redirect();
             return;
         }
         $this->dispatcher->forward(['controller' => 'sign', 'action' => 'in']);
         return;
     }
 }
Esempio n. 3
0
 public function create_user()
 {
     // If there are no users then let's create one.
     $db = Database::get_instance();
     $db->query('SELECT * FROM `users` LIMIT 1');
     if ($db->has_rows() && !Auth::get_instance()->logged_in()) {
         Flash::set('<p class="flash validation">Sorry but to create new users, you must be logged in.</p>');
         Core_Helpers::redirect(WEB_ROOT . 'login/');
     }
     $validator = Error::instance();
     if (isset($_POST['email'])) {
         $validator->email($_POST['email'], 'email');
         $validator->blank($_POST['username'], 'username');
         $validator->blank($_POST['password'], 'password');
         $validator->passwords($_POST['password'], $_POST['confirm_password'], 'confirm_password');
         $user = new Users();
         if ($user->select(array('username' => $_POST['username']))) {
             $validator->add('username', 'The username <strong>' . htmlspecialchars($_POST['username']) . '</strong> is already taken.');
         }
         if ($validator->ok()) {
             $user = new Users();
             $user->load($_POST);
             $user->level = 'admin';
             $user->insert();
             Flash::set('<p class="flash success">User created successfully.</p>');
             Core_Helpers::redirect(WEB_ROOT . 'login/');
         }
     }
     $this->data['error'] = $validator;
     $this->load_template('create_user');
 }
Esempio n. 4
0
 public function __construct()
 {
     $this->_siteID=$_SESSION["CATS"]->getSiteID();
     $users = new Users($this->_siteID);
     $this->usersRS = $users->getSelectList();
     $this->groupRS = $users->getSelectGroupList();
 }
Esempio n. 5
0
 public function pdoEditModelAction($id)
 {
     $this->_view->title = 'Model Edit Form';
     $this->_view->link = base_url() . 'pdo-database/pdo-model/pdo-edit-model/' . $id;
     $users = new Users();
     $row = $users->get($id);
     if (empty($row)) {
         redirect('pdo-database/pdo-model/pdo-model');
     }
     $this->_view->data = $row;
     if (!empty($_POST)) {
         $val = new Validation();
         $val->source = $_POST;
         $val->addValidator(array('name' => 'first_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'last_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'email', 'type' => 'email', 'required' => true));
         $val->addValidator(array('name' => 'address', 'type' => 'string', 'required' => true));
         $val->run();
         if (sizeof($val->errors) == 0) {
             $data = array('first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'email' => $_POST['email'], 'address' => $_POST['address']);
             $users->update($id, $data);
             redirect('pdo-database/pdo-model/pdo-model');
         }
         $this->_view->errorMessage = $val->errorMessage();
         $this->_view->data = $_POST;
     }
     $this->renderView('pdo-database/pdo-model/_form');
 }
 public function indexAction()
 {
     if ($this->request->isPost()) {
         $register = new Users();
         $register->id = UUID::v4();
         $register->password = $this->security->hash($this->request->getPost('password'));
         $register->phonenumber = $this->request->getPost('phonenumber');
         $register->email = $this->request->getPost('email');
         $register->name = $this->request->getPost('name');
         $register->created_date = Carbon::now()->now()->toDateTimeString();
         $register->updated_date = Carbon::now()->now()->toDateTimeString();
         $user = Users::findFirstByEmail($register->email);
         if ($user) {
             $this->flash->error("can not register, User " . $register->email . " Alredy Registerd! ");
             return true;
         }
         if ($register->save() === true) {
             $this->session->set('user_name', $register->name);
             $this->session->set('user_email', $register->email);
             $this->session->set('user_id', $register->id);
             $this->flash->success("Your " . $register->email . " has been registered Please Login for booking court");
             $this->response->redirect('dashboard');
         }
     }
 }
Esempio n. 7
0
 public function forgotpassAction()
 {
     $oForm = new Form_ForgotPass('/login/forgotpass/');
     $bSubmitted = false;
     if ($this->_request->isPost()) {
         if ($oForm->isValid($this->_request->getPost())) {
             $oUser = new Users();
             $oPersonalData = $oUser->getPersonalDataFromEmail($this->_request->getPost('email_add'));
             $oAccountData = $oUser->getAccountDataFromUserId($oPersonalData->id);
             //generate random password
             $sNewPassword = substr(md5(rand()), 0, 7);
             $oUser->updatePasswordData($oAccountData->id, $sNewPassword);
             //send email for reset
             $oEmail = new Emails();
             $oEmail->mailReset($oPersonalData['email_add'], $oAccountData['username'], $sNewPassword);
             $bSubmitted = true;
         } else {
             $auth = Zend_Auth::getInstance();
             $auth->clearIdentity();
             $oForm->populate($this->_request->getPost());
         }
     }
     if (!$bSubmitted) {
         $this->view->form = $oForm;
     } else {
         $this->view->form = "<h1>You have successfully resetted your password. Please check your email.</h1>";
     }
 }
 /**
  * Action to register a new user
  */
 public function indexAction()
 {
     $form = new RegisterForm();
     if ($this->request->isPost()) {
         $name = $this->request->getPost('name', array('string', 'striptags'));
         $username = $this->request->getPost('username', 'alphanum');
         $email = $this->request->getPost('email', 'email');
         $password = $this->request->getPost('password');
         $repeatPassword = $this->request->getPost('repeatPassword');
         if ($password != $repeatPassword) {
             $this->flash->error('Passwords are diferent');
             return false;
         }
         $user = new Users();
         $user->username = $username;
         $user->password = sha1($password);
         $user->name = $name;
         $user->email = $email;
         $user->created_at = new Phalcon\Db\RawValue('now()');
         $user->active = 'Y';
         if ($user->save() == false) {
             foreach ($user->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
         } else {
             $this->tag->setDefault('email', '');
             $this->tag->setDefault('password', '');
             $this->flash->success('Thanks for sign-up, please log-in to start generating invoices');
             return $this->forward('session/index');
         }
     }
     $this->view->form = $form;
 }
Esempio n. 9
0
 public function removeFavoriteBy(Users $user)
 {
     if ($user->hasFavoredThis($this)) {
         Favorites::query()->where('user_id = :user:'******'user' => $user->id])->andWhere('favoritable_type = :type:', ['type' => get_class($this)])->andWhere('favoritable_id = :id:', ['id' => $this->id])->execute()->delete();
     }
     return $this;
 }
Esempio n. 10
0
 public function registerAction()
 {
     // Instantiate the Query
     $query = $this->modelsManager->executeQuery("SELECT name,email FROM Users", $this->getDI());
     // Execute the query returning a result if any
     //$cars = $query->execute();
     echo '<pre>';
     print_r($query);
     /*$q = $this->modelsManager->executeQuery('select * from Users');*/
     foreach ($query as $k => $v) {
         echo $v;
     }
     die;
     $user = new Users();
     //		print_r($this->request->getHeaders());
     $res = $user->query('select * from users');
     print_r($res);
     print_r(get_class_methods($user));
     die;
     // Store and check for errors
     $success = $user->save($this->request->getPost(), array('name', 'email'));
     if ($success) {
         echo "Thanks for registering!";
     } else {
         echo "Sorry, the following problems were generated: ";
         foreach ($user->getMessages() as $message) {
             echo $message->getMessage(), "<br/>";
         }
     }
     $this->view->disable();
 }
 function login()
 {
     $u = new Users();
     if ($this->params['name'] && $this->params['password'] && $_POST['name'] && $_POST['password']) {
         $name = strtolower(trim($this->params['name']));
         $password = strtolower(trim($this->params['password']));
         if ($user = $u->find_by_name_and_password($name, $password)) {
             // Remmeber me forever
             if ($this->params['remember'] == 1) {
                 setcookie(DEFAULT_COOKIE, $user['session_id'], time() + 86400 * 360, "/");
             }
             $_SESSION['user'] = $user;
             $url = '/';
             if ($_SESSION['return_url']) {
                 $url = $_SESSION['return_url'];
                 unset($_SESSION['return_url']);
             }
             redirect_to($url);
             return;
         } else {
             $this->flash('Incorrect username or password!');
         }
     }
     $this->title = 'Login';
     $this->crumbs = array('Login');
 }
 public static function render($userInputObject, $user)
 {
     global $list_max_entries_per_page;
     $adb = PearDatabase::getInstance();
     $viewer = new Import_UI_Viewer();
     $ownerId = $userInputObject->get('foruser');
     $owner = new Users();
     $owner->id = $ownerId;
     $owner->retrieve_entity_info($ownerId, 'Users');
     if (!is_admin($user) && $user->id != $owner->id) {
         $viewer->display('OperationNotPermitted.tpl', 'Vtiger');
         exit;
     }
     $userDBTableName = Import_Utils::getDbTableName($owner);
     $moduleName = $userInputObject->get('module');
     $moduleMeta = self::getModuleMeta($moduleName, $user);
     $result = $adb->query('SELECT recordid FROM ' . $userDBTableName . ' WHERE status is NOT NULL AND recordid IS NOT NULL');
     $noOfRecords = $adb->num_rows($result);
     $importedRecordIds = array();
     for ($i = 0; $i < $noOfRecords; ++$i) {
         $importedRecordIds[] = $adb->query_result($result, $i, 'recordid');
     }
     if (count($importedRecordIds) == 0) {
         $importedRecordIds[] = 0;
     }
     $focus = CRMEntity::getInstance($moduleName);
     $queryGenerator = new QueryGenerator($moduleName, $user);
     $customView = new CustomView($moduleName);
     $viewId = $customView->getViewIdByName('All', $moduleName);
     $queryGenerator->initForCustomViewById($viewId);
     $list_query = $queryGenerator->getQuery();
     // Fetch only last imported records
     $list_query .= ' AND ' . $focus->table_name . '.' . $focus->table_index . ' IN (' . implode(',', $importedRecordIds) . ')';
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
         $count_result = $adb->query(mkCountQuery($list_query));
         $noofrows = $adb->query_result($count_result, 0, "count");
     } else {
         $noofrows = null;
     }
     $start = ListViewSession::getRequestCurrentPage($moduleName, $list_query, $viewId, false);
     $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
     $limit_start_rec = ($start - 1) * $list_max_entries_per_page;
     $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
     $recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows);
     $viewer->assign('recordListRange', $recordListRangeMsg);
     $controller = new ListViewController($adb, $user, $queryGenerator);
     $listview_header = $controller->getListViewHeader($focus, $moduleName, $url_string, $sorder, $order_by, true);
     $listview_entries = $controller->getListViewEntries($focus, $moduleName, $list_result, $navigation_array, true);
     $viewer->assign('CURRENT_PAGE', $start);
     $viewer->assign('LISTHEADER', $listview_header);
     $viewer->assign('LISTENTITY', $listview_entries);
     $viewer->assign('FOR_MODULE', $moduleName);
     $viewer->assign('FOR_USER', $ownerId);
     $isAjax = $userInputObject->get('ajax');
     if (!empty($isAjax)) {
         echo $viewer->fetch('ListViewEntries.tpl');
     } else {
         $viewer->display('ImportListView.tpl');
     }
 }
Esempio n. 13
0
 public function init()
 {
     if (!Zend_Registry::isRegistered('user')) {
         if ($user = $this->getRequest()->getParam("user")) {
             $users = new Users();
             if ($user = $users->getUserFromUsername($user)) {
                 Zend_Registry::set("user", $user);
             }
         }
     }
     $this->_user = Zend_Registry::get("user");
     if (!Zend_Registry::isRegistered('shard')) {
         Zend_Registry::set("shard", $this->_user->id);
     }
     if (Zend_Registry::isRegistered("cache")) {
         $this->_cache = Zend_Registry::get("cache");
     }
     if (Zend_Registry::isRegistered("root")) {
         $this->_root = Zend_Registry::get("root");
     }
     if (Zend_Registry::isRegistered("configuration")) {
         $this->_config = Zend_Registry::get("configuration");
     }
     // Other global variables
     $this->_application = Stuffpress_Application::getInstance();
     $this->_properties = new Properties(array(Stuffpress_Db_Properties::KEY => $this->_user->id));
     $this->_admin = $this->_application->user && $this->_application->user->id == $this->_user->id ? true : false;
     // Disable layout if XMLHTTPRequest
     if ($this->_request->isXmlHttpRequest()) {
         $this->_helper->layout->disableLayout();
     }
 }
 function perform()
 {
     $this->_userNameHash = $this->_request->getValue("b");
     $this->_requestHash = $this->_request->getValue("a");
     $this->_newPassword = $this->_request->getValue("newPassword");
     $this->_retypeNewPassword = $this->_request->getValue("retypePassword");
     $this->_userId = $this->_request->getValue("userId");
     // check if the passwords are correct and are the same
     if ($this->_newPassword != $this->_retypeNewPassword) {
         $this->_view = new SummaryView("changepassword");
         $this->_view->setErrorMessage($this->_locale->tr("error_passwords_do_not_match"));
         $this->setCommonData(true);
         return false;
     }
     $userInfo = SummaryTools::verifyRequest($this->_userNameHash, $this->_requestHash);
     if (!$userInfo) {
         $this->_view = new SummaryView("summaryerror");
         $this->_view->setErrorMessage($this->_locale->tr("error_incorrect_request"));
         $this->setCommonData(true);
         return false;
     }
     // so if everything went fine, we can *FINALLY* change the password!
     $users = new Users();
     $userInfo->setPassword($this->_newPassword);
     $users->updateUser($userInfo);
     $this->_view = new SummaryView("message");
     $this->_view->setSuccessMessage($this->_locale->tr("password_updated_ok"));
     return true;
 }
Esempio n. 15
0
 public function getUsers($tagId)
 {
     $user = new Users();
     $tag = new Filfolders();
     $selector = $this->select(Zend_Db_Table::SELECT_WITHOUT_FROM_PART)->setIntegrityCheck(false)->from(array('u' => $user->getTableName(true)), 'id')->join(array('fu' => $this->getTableName(true)), 'u.id = fu.users_id', '')->join(array('ff' => $tag->getTableName(true)), 'fu.filfolders_id = ff.id', '')->where('ff.id = ?', $tagId)->order('ff.pagorder');
     return $this->fetchAll($selector);
 }
 function perform()
 {
     // fetch the data
     $this->_userName = $this->_request->getValue("userName");
     $this->_userEmail = $this->_request->getValue("userEmail");
     // try to see if there is a user who has this username and uses the
     // given mailbox as the email address
     $users = new Users();
     $userInfo = $users->getUserInfoFromUsername($this->_userName);
     // if the user doesn't exist, quit
     if (!$userInfo) {
         $this->_view = new SummaryView("resetpassword");
         $this->_form->setFieldValidationStatus("userName", false);
         $this->setCommonData(true);
         return false;
     }
     // if the user exists but this is not his/her mailbox, then quit too
     if ($userInfo->getEmail() != $this->_userEmail) {
         $this->_view = new SummaryView("resetpassword");
         $this->_form->setFieldValidationStatus("userEmail", false);
         $this->setCommonData(true);
         return false;
     }
     // if everything's fine, then send out the email message with a request to
     // reset the password
     $requestHash = SummaryTools::calculatePasswordResetHash($userInfo);
     $config =& Config::getConfig();
     $baseUrl = $config->getValue("base_url");
     $resetUrl = $baseUrl . "/summary.php?op=setNewPassword&a={$requestHash}&b=" . md5($userInfo->getUsername());
     SummaryTools::sendResetEmail($userInfo, $resetUrl);
     $this->_view = new SummaryMessageView($this->_locale->tr("password_reset_message_sent_ok"));
     $this->setCommonData();
     return true;
 }
Esempio n. 17
0
 function train($f3)
 {
     // Check if Logged In User is Allowed to Train
     if (!$f3->get('SESSION.active') || !$f3->get('SESSION.admin') && !\R::findOne('trainings', 'users_id=? AND tools_id=? AND level=?', array($f3->get('SESSION.id'), $this->D->id, 'T'))) {
         throw new \Exception('You are not authorized to train for this machine.');
     }
     if ($f3->get('POST')) {
         // Check Instructor Validity
         if ($f3->get('POST.instructor') != $f3->get('SESSION.username')) {
             if (!$f3->get('SESSION.admin')) {
                 throw new \Exception('Cannot Change Instructor');
             }
         }
         if (!($instructor = \R::findOne('users', 'username=? AND active=1', array($f3->get('POST.instructor'))))) {
             throw new \Exception('Invalid Instructor Username');
         }
         $f3->set('instructor', $instructor);
         if ($f3->exists('POST.username')) {
             // Ensure User Checked the Affirmation
             if (!$f3->get('POST.affirmation')) {
                 throw new \Exception('Did not check legal aggreement box.');
             }
             // Get Trained User
             $user = new Users($f3);
             $user->authenticate($f3);
             $user->update_user($f3);
             $this->create_record($f3, $user->D, $instructor);
         }
     }
     $f3->set('data.training_levels', json_decode($f3->get('data.training_levels')));
     show_page($f3, 'trainings.train');
 }
Esempio n. 18
0
/**
 *
 * @param WebserviceId $id
 * @param String $oldPassword
 * @param String $newPassword
 * @param String $confirmPassword
 * @param Users $user 
 * 
 */
function vtws_changePassword($id, $oldPassword, $newPassword, $confirmPassword, $user)
{
    vtws_preserveGlobal('current_user', $user);
    $idComponents = vtws_getIdComponents($id);
    if ($idComponents[1] == $user->id || is_admin($user)) {
        $newUser = new Users();
        $newUser->retrieve_entity_info($idComponents[1], 'Users');
        if (!is_admin($user)) {
            if (empty($oldPassword)) {
                throw new WebServiceException(WebServiceErrorCode::$INVALIDOLDPASSWORD, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$INVALIDOLDPASSWORD));
            }
            if (!$user->verifyPassword($oldPassword)) {
                throw new WebServiceException(WebServiceErrorCode::$INVALIDOLDPASSWORD, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$INVALIDOLDPASSWORD));
            }
        }
        if (strcmp($newPassword, $confirmPassword) === 0) {
            $success = $newUser->change_password($oldPassword, $newPassword);
            $error = $newUser->db->hasFailedTransaction();
            if ($error) {
                throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR));
            }
            if (!$success) {
                throw new WebServiceException(WebServiceErrorCode::$CHANGEPASSWORDFAILURE, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$CHANGEPASSWORDFAILURE));
            }
        } else {
            throw new WebServiceException(WebServiceErrorCode::$CHANGEPASSWORDFAILURE, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$CHANGEPASSWORDFAILURE));
        }
        VTWS_PreserveGlobal::flush();
        return array('message' => 'Changed password successfully');
    }
}
Esempio n. 19
0
function vtws_login($username, $pwd)
{
    $user = new Users();
    $userId = $user->retrieve_user_id($username);
    if (empty($userId)) {
        throw new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, 'Given user cannot be found');
    }
    $token = vtws_getActiveToken($userId);
    if ($token == null) {
        throw new WebServiceException(WebServiceErrorCode::$INVALIDTOKEN, "Specified token is invalid or expired");
    }
    $accessKey = vtws_getUserAccessKey($userId);
    if ($accessKey == null) {
        throw new WebServiceException(WebServiceErrorCode::$ACCESSKEYUNDEFINED, "Access key for the user is undefined");
    }
    $accessCrypt = md5($token . $accessKey);
    if (strcmp($accessCrypt, $pwd) !== 0) {
        throw new WebServiceException(WebServiceErrorCode::$INVALIDUSERPWD, "Invalid username or password");
    }
    $user = $user->retrieveCurrentUserInfoFromFile($userId);
    if ($user->status != 'Inactive') {
        return $user;
    }
    throw new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, 'Given user is inactive');
}
Esempio n. 20
0
 function process(Vtiger_Request $request)
 {
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $baseUserId = $currentUserModel->getId();
     $userId = $request->get('id');
     $user = new Users();
     $currentUser = $user->retrieveCurrentUserInfoFromFile($userId);
     $name = $currentUserModel->getName();
     $userName = $currentUser->column_fields['user_name'];
     Vtiger_Session::set('AUTHUSERID', $userId);
     Vtiger_Session::set('authenticated_user_id', $userId);
     Vtiger_Session::set('user_name', $userName);
     Vtiger_Session::set('full_user_name', $name);
     $status = 'Switched';
     if (Vtiger_Session::get('baseUserId') == '') {
         Vtiger_Session::set('baseUserId', $baseUserId);
         $status = 'Signed in';
     } elseif ($userId == Vtiger_Session::get('baseUserId')) {
         $baseUserId = $userId;
         Vtiger_Session::set('baseUserId', '');
         $status = 'Signed out';
     } else {
         $baseUserId = Vtiger_Session::get('baseUserId');
     }
     $dbLog = PearDatabase::getInstance('log');
     $dbLog->insert('l_yf_switch_users', ['baseid' => $baseUserId, 'destid' => $userId, 'busername' => $currentUserModel->getName(), 'dusername' => $name, 'date' => date('Y-m-d H:i:s'), 'ip' => Vtiger_Functions::getRemoteIP(), 'agent' => $_SERVER['HTTP_USER_AGENT'], 'status' => $status]);
     header('Location: index.php');
 }
Esempio n. 21
0
 /**
  * 注册方法 
  * 完成数据的插入
  * @return boolean whether register is successful
  */
 public function register()
 {
     //将已经验证成功的数据插入数据库
     if (!$this->hasErrors()) {
         $user = new Users();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->salt = Help::fetchSalt();
         $user->password = md5(md5($this->password) . $user->salt);
         $user->reg_ip = Yii::app()->request->userHostAddress;
         $user->last_ip = Yii::app()->request->userHostAddress;
         $user->reg_time = time();
         $user->last_login = time();
         if (!$user->save()) {
             return false;
         }
     }
     //实行登入操作
     if ($this->_identity === null) {
         $this->_identity = new UserIdentity($this->email, $this->password);
         $this->_identity->authenticate();
     }
     if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
         Yii::app()->user->login($this->_identity);
         return true;
     } else {
         return false;
     }
 }
Esempio n. 22
0
 function indexAction()
 {
     $m = new Wtk_Form_Model('installation');
     $g = $m->addGroup('site', "Le site");
     $i = $g->addEnum('association', "Association", null, self::$associations);
     $m->addConstraintRequired($i);
     $g = $m->addGroup('admin', "Votre compte");
     $i = $g->addString('prenom', "Votre prénom");
     $m->addConstraintRequired($i);
     $i = $g->addString('nom', "Votre nom");
     $m->addConstraintRequired($i);
     $i = $g->addEnum('sexe', "Sexe", null, array('h' => 'Masculin', 'f' => 'Féminin'));
     $m->addConstraintRequired($i);
     $i = $g->addDate('naissance', "Date de naissance", 0);
     $m->addConstraintRequired($i);
     $i = $g->addString('adelec', "Adélec");
     $m->addConstraintRequired($i);
     $i = $i0 = $g->addString('motdepasse', "Mot de passe");
     $m->addConstraintRequired($i);
     $i = $i1 = $g->addString('confirmation', "Confirmation");
     $m->addConstraintEqual($i1, $i0);
     $this->view->model = $pm = new Wtk_Pages_Model_Form($m);
     if ($pm->validate()) {
         $installer = new Strass_Installer($m->get());
         $installer->run();
         /* Autologin. Écrire dans la session l'identité de l'admin */
         $t = new Users();
         $admin = $t->findByUsername($m->get('admin/adelec'));
         $auth = Zend_Auth::getInstance();
         $auth->getStorage()->write($admin->getIdentity());
         $this->_redirect('/', array('prependBase' => false, 'exit' => true));
     }
 }
Esempio n. 23
0
 /** The constructor
  * @access public
  * @param array $options
  * @return void
  */
 public function __construct(array $options = null)
 {
     $projecttypes = new ProjectTypes();
     $projectype_list = $projecttypes->getTypes();
     $authors = new Users();
     $authorOptions = $authors->getAuthors();
     parent::__construct($options);
     $this->setName('activity');
     $title = new Zend_Form_Element_Text('title');
     $title->setLabel('Project title: ')->setRequired(true)->setAttrib('size', 60)->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->addErrorMessage('Choose title for the project.');
     $description = new Pas_Form_Element_CKEditor('description');
     $description->setLabel('Short description of project: ')->setRequired(true)->setAttribs(array('rows' => 10, 'cols' => 40, 'Height' => 400))->setAttrib('ToolbarSet', 'Basic')->addFilters(array('BasicHtml', 'EmptyParagraph', 'StringTrim'));
     $length = new Zend_Form_Element_Text('length');
     $length->setLabel('Length of project: ')->setAttrib('size', 12)->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('You must enter a duration for this project in months')->addValidator('Digits')->setDescription('Enter length in months');
     $managedBy = new Zend_Form_Element_Select('managedBy');
     $managedBy->setLabel('Managed by: ')->addMultiOptions(array('Choose an author' => $authorOptions))->setRequired(false)->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addFilters(array('StripTags', 'StringTrim'))->addValidator('InArray', false, array(array_keys($authorOptions)))->addErrorMessage('You must enter a manager for this project.');
     $suitableFor = new Zend_Form_Element_Select('suitableFor');
     $suitableFor->setLabel('Suitable for: ')->addMultiOptions(array(null => 'Choose type of research', 'Available types' => $projectype_list))->setRequired(false)->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addValidator('InArray', false, array(array_keys($projectype_list)))->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('You must enter suitability for this task.');
     $location = new Zend_Form_Element_Text('location');
     $location->setLabel('Where would this be located?: ')->setAttrib('size', 12)->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('You must enter a location for the task.');
     $valid = new Zend_Form_Element_Checkbox('status');
     $valid->setLabel('Publish this task? ')->setRequired(true)->addFilters(array('StripTags', 'StringTrim'));
     $submit = new Zend_Form_Element_Submit('submit');
     $hash = new Zend_Form_Element_Hash('csrf');
     $hash->setValue($this->_salt)->setTimeout(480);
     $this->addElements(array($title, $description, $length, $valid, $managedBy, $suitableFor, $location, $submit, $hash));
     $this->addDisplayGroup(array('title', 'description', 'length', 'location', 'suitableFor', 'managedBy', 'status', 'submit'), 'details');
     $this->details->setLegend('Activity details: ');
     parent::init();
 }
Esempio n. 24
0
 public function loginAction()
 {
     $id = $this->getRequest()->getParam("id", "");
     $pwd = $this->getRequest()->getParam("pwd", "");
     if (empty($id)) {
         $this->view->err = "<font color='red'>用户名不能为空</font>";
         $this->_forward("index", "index");
         return;
     }
     if (empty($pwd)) {
         $this->view->err = "<font color='red'>密码不能为空</font>";
         $this->_forward("index", "index");
         return;
     }
     $users = new Users();
     $db = $users->getAdapter();
     $where = $db->quoteInto("id=?", $id) . $db->quoteInto("and pwd=?", md5($pwd));
     $loginuser = $users->fetchAll($where)->toArray();
     if (count($loginuser) > 0) {
         session_start();
         $_SESSION['loginuser'] = $loginuser[0]['name'];
         $_SESSION['userid'] = $loginuser[0]['id'];
         $this->_forward("hall", "hall");
     } else {
         $this->view->err = "<font color='red'>用户ID或密码不正确</font>";
         $this->_forward("index", "index");
         return;
     }
 }
Esempio n. 25
0
 public function resultAction()
 {
     $post = $this->request->getPost();
     $email = $post["email"];
     $error = array();
     if ("" == $email) {
         array_push($error, "メールアドレスを入力してください");
     } else {
         $pre_user_id = uniqid(rand(100, 999));
         $userModel = new Users();
         $result = $userModel->addEmail(array($pre_user_id, $email));
         if (false == $result) {
             array_push($error, "データベースに登録できませんでした。");
         } else {
             mb_language("japanese");
             mb_internal_encoding("utf-8");
             $to = $email;
             $subject = "seapaメンバー登録URL";
             $message = "以下のURLよりメンバー登録を行ってください。\n" . "http://localhost/regist/input/{$pre_user_id}";
             $header = "From: mail.seapa@gmail.com";
             if (!mb_send_mail($to, $subject, $message, $header, '-f' . '*****@*****.**')) {
                 array_push($error, "メールが送信できませんでした。<a href='http://localhost/regist/input/{$pre_user_id}'>遷移先</a>");
             }
             $this->view->assign('email', $email);
         }
     }
 }
Esempio n. 26
0
 public function save_user($user_data)
 {
     $user = new Users();
     $user->fromArray($user_data);
     $user->save();
     return TRUE;
 }
Esempio n. 27
0
 public function register()
 {
     //check if data in post if filled
     if (CheckDataController::checkArrayData($_POST)) {
         $email = $_POST['email'];
         $first_name = $_POST['name'];
         $last_name = $_POST['lastname'];
         $age = $_POST['age'];
         $gender = $_POST['gender'];
         $pass = $_POST['pass'];
         $pass_check = $_POST['checkpass'];
         if (CheckDataController::checkEmail($email)) {
             if (CheckDataController::checkNotNumeric($first_name)) {
                 if (CheckDataController::checkNotNumeric($last_name)) {
                     if (CheckDataController::checkNumeric($age)) {
                         if ($pass == $pass_check) {
                             $pass = Encryption::setPassword($pass);
                             $user = new Users();
                             return "data : email = {$email} " . $user->set($email, $first_name, $last_name, $pass, $gender);
                         }
                     }
                 }
             }
         }
     } else {
         return "Something not filled in";
     }
     return "Some Error";
 }
Esempio n. 28
0
 public function processAction()
 {
     session_start();
     $mycart = new Mycart();
     $user = new Users();
     if ($_POST['updatecart']) {
         //更新菜单
         $bookid = $this->getRequest()->getParam('bookid');
         $booknum = $this->getRequest()->getParam('booknum');
         for ($i = 0; $i < count($bookid); $i++) {
             $mycart->updatecart($_SESSION['userid'], $bookid[$i], $booknum[$i]);
         }
         $this->view->info = '更新成功';
         $this->view->goto = '/cart/cart';
         $this->_forward("ok", "globals");
     } elseif ($_POST['checkout']) {
         //生成菜单
         $res = $user->getinfo($_SESSION['userid']);
         $this->view->user = $res;
         $res2 = $mycart->getmycart($_SESSION['userid']);
         $this->view->mycart = $res2;
         $this->view->totalprice = $mycart->totalprice;
         $this->_forward("checkout", "checkout");
     }
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // update the user information
     $this->_userInfo->setEmail(Textfilter::filterAllHTML($this->_request->getValue("userEmail")));
     if ($this->_userPassword != "") {
         $this->_userInfo->setPassword($this->_userPassword);
     }
     $this->_userInfo->setAboutMyself(Textfilter::filterAllHTML($this->_request->getValue("userAbout")));
     $this->_userInfo->setFullName(Textfilter::filterAllHTML($this->_request->getValue("userFullName")));
     $this->_userInfo->setPictureId($this->_request->getValue("userPictureId"));
     $this->_userInfo->setProperties($this->_request->getValue("properties"));
     $this->notifyEvent(EVENT_PRE_USER_UPDATE, array("user" => &$this->_userInfo));
     $this->_session->setValue("userInfo", $this->_userInfo);
     $this->saveSession();
     // update the user information
     $this->_view = new AdminUserProfileView($this->_blogInfo, $this->_userInfo);
     $users = new Users();
     if (!$users->updateUser($this->_userInfo)) {
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_user_settings"));
     } else {
         $this->_view->setSuccessMessage($this->_locale->pr("user_settings_updated_ok", $this->_userInfo->getUsername()));
         // if everything fine, also say so...
         $this->notifyEvent(EVENT_POST_USER_UPDATE, array("user" => &$this->_userInfo));
     }
     $this->setCommonData();
     return true;
 }
Esempio n. 30
0
 /** View a system role
  */
 public function systemroleAction()
 {
     $roles = new Roles();
     $this->view->roles = $roles->getRole($this->_getParam('id'));
     $users = new Users();
     $this->view->members = $users->getRolesMembers($this->_getParam('id'), $this->_getParam('page'));
 }