save() public method

Generic save procedure.
public save ( array $FormPostValues, array $Settings = [] )
$FormPostValues array The user to save.
$Settings array Controls certain save functionality. - SaveRoles - Save 'RoleID' field as user's roles. Default false. - HashPassword - Hash the provided password on update. Default true. - FixUnique - Try to resolve conflicts with unique constraints on Name and Email. Default false. - ValidateEmail - Make sure the provided email addresses is formatted properly. Default true. - NoConfirmEmail - Disable email confirmation. Default false.
コード例 #1
0
ファイル: UserService.php プロジェクト: hitechdk/Codeception
 function create($name)
 {
     $this->user->setName($name);
     $this->user->set('role', 'user');
     $this->user->set('email', $name . '@service.com');
     $this->user->save();
     return true;
 }
コード例 #2
0
 public function actionRegister()
 {
     $connection = Yii::app()->db;
     $email = $_REQUEST['email'];
     $password = $_REQUEST['pwd'];
     $ret = UserModel::model()->find('email=:email', array(':email' => $email));
     if (isset($ret)) {
         //email 已经注册
         echo json_encode(array('result' => 2, 'comment' => 'Email had been  registed'));
         return;
     }
     $userModel = new UserModel();
     $userModel->username = '******';
     $userModel->password = $password;
     $userModel->password2 = $password;
     $userModel->email = $email;
     $userModel->create_time = time();
     if ($userModel->save()) {
         //找到名字对应的_id。
         $sql = "select _id from tbl_user where email = :email";
         $command = $connection->createCommand($sql);
         $tmp = $command->query(array(':email' => $email))->readAll();
         echo json_encode(array('result' => 1, 'res' => $tmp[0]["_id"]));
     } else {
         echo json_encode(array('result' => 0));
     }
 }
コード例 #3
0
ファイル: WarningModel.php プロジェクト: amanai/next24
 function add($user_id, $cause)
 {
     if (strlen(trim($cause))) {
         $userModel = new UserModel();
         $currentUser = Project::getUser()->getDbUser();
         $userModel->load($user_id);
         if ($userModel->id) {
             $banHistoryModel = new BanHistoryModel();
             $paramModel = new ParamModel();
             $n_warnings_to_ban = $paramModel->getParam("UserController", "N_WARNINGS_TO_BAN");
             $t_ban_time_sec = $paramModel->getParam("UserController", "T_BAN_TIME_SEC");
             $count_user_warnings = $this->getUserWarningCount($user_id);
             $this->clear();
             $this->user_id = (int) $user_id;
             $this->cause = $cause;
             $warning_id = $this->save();
             if ($userModel->warnings_fromlast_ban + 1 >= $n_warnings_to_ban) {
                 // пора банить
                 $subject = "Ваш аккаун заблокирован в системе Next24.ru";
                 $userModel->warnings_fromlast_ban = 0;
                 $userModel->banned = 1;
                 $userModel->banned_date = time();
                 $banHistoryModel->ban($user_id, $currentUser->id, $warning_id, date("Y-m-d H:i:s", time() + $t_ban_time_sec));
             } else {
                 $userModel->warnings_fromlast_ban = $userModel->warnings_fromlast_ban + 1;
                 $subject = "Администратор Next24.ru установил Вам предупреждение";
             }
             $userModel->save();
             $url_referer = $_SERVER['HTTP_REFERER'];
             $this->sendMessage((int) $user_id, $subject, $cause, $url_referer);
             return $warning_id;
         }
     }
     return 0;
 }
コード例 #4
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->detectContao($output, true);
     if ($this->initContao()) {
         // Username
         if (($username = $input->getArgument('username')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $username = $dialog->ask($output, '<question>Username:</question>');
         }
         // Email
         if (($email = $input->getArgument('email')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $email = $dialog->ask($output, '<question>Email:</question>');
         }
         // Password
         if (($password = $input->getArgument('password')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $password = $dialog->ask($output, '<question>Password:</question>');
         }
         // Name
         if (($name = $input->getArgument('name')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $name = $dialog->ask($output, '<question>Name:</question>');
         }
         // create new user
         $user = new \UserModel();
         $user->setRow(array('username' => $username, 'name' => $name, 'email' => $email, 'password' => \Encryption::hash($password), 'admin' => 1))->save();
         $user->save();
         $output->writeln('<info>User <comment>' . $username . '</comment> successfully created</info>');
     }
 }
コード例 #5
0
ファイル: ControllerPro.php プロジェクト: goginyan/tutorial
 public function actionInsert()
 {
     if (isset($_POST['submit']) && $_POST['submit'] == 'Insert Procuct') {
         $pro = new ProModel();
         $pro->name = $_POST['product_name'];
         $pro->description = $_POST['product_desc'];
         $product_image = $_FILES['product_image']['name'];
         $product_image_tmp = $_FILES['product_image']['tmp_name'];
         move_uploaded_file($product_image_tmp, "img/{$product_image}");
         $pro->image = $product_image;
         $pro->price = $_POST['product_price'];
         $pro->save();
         header('Location: http://localhost/task/task2/admin_area/index.php');
         exit;
     }
     if (isset($_POST['sub'])) {
         $user = new UserModel();
         $user->first_name = $_POST['fn'];
         $user->last_name = $_POST['ln'];
         $user->email = $_POST['em'];
         $user->save();
         $ord = new OrdersModel();
         $ord->user_id = $_POST['id'];
         $ord->sum = $_POST['price'];
         $ord->order_date = date("Y/m/d h:i:s");
         $ord->save();
         $ordPro = new OrdersProModel();
         $ordPro->order_id = $_POST['id'];
         $ordPro->product_id = $_POST['id'];
         $ordPro->qty = $_POST['quantity'];
         $ordPro->save();
         header('Location: http://localhost/task/task2/admin_area/index.php');
         exit;
     }
 }
コード例 #6
0
 /**
  * Display listing of the resource
  *
  * @return Response
  */
 public function signup()
 {
     // obtin data curenta
     $today = date("Y-m-d H:i:s");
     $userdata = array('givenname' => Input::get('givenname'), 'surname' => Input::get('surname'), 'username' => Input::get('username'), 'email' => Input::get('email'), 'password' => Input::get('password'), 'password_confirmation' => Input::get('password_confirmation'));
     //set validation rules
     $rules = array('givenname' => 'alpha_num|max:50', 'surname' => 'alpha_num|max:50', 'username' => 'required|unique:users,username|alpha_dash|min:5', 'email' => 'required|unique:users,email|email');
     //run validation check
     $validator = Validator::make($userdata, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         $user = new UserModel();
         $user->givenname = Input::get('givenname');
         $user->surname = Input::get('surname');
         $user->username = Input::get('username');
         $user->email = Input::get('email');
         $user->photo = 'No photo found';
         $user->password = Hash::make(Input::get('password'));
         $user->active = "1";
         $user->isdel = "0";
         $user->last_login = $today;
         $user->access = "User";
         $user->save();
     }
     //else if
     return Redirect::to('login')->with('message', FlashMessage::DisplayAlert('User account created', 'success'));
 }
コード例 #7
0
function user_model_test($delete)
{
    $user = new UserModel("Not", "Here", "*****@*****.**", "password", date("Y-m-d H:i:s"));
    $user->save();
    $user->print_fields();
    $user->set("failed_login_attempts", 3);
    $user->set("first_name", "User");
    $user->set("last_name", "McUsage");
    $user->save();
    $user->print_fields();
    if ($delete) {
        $user->delete();
    }
    $um = UserModel::find(UserModel::first()->id);
    $um->print_fields();
    $um = UserModel::find(UserModel::last()->id);
    $um->print_fields();
    UserModel::find(999);
}
コード例 #8
0
 public function createUserModelByUser($user)
 {
     $treeObject = $this->getTree();
     $tree = $treeObject->fetchTree();
     foreach ($tree as $node) {
         $um = new UserModel();
         $um->DomainModel = $node;
         $um->User = $user;
         $um->save();
     }
 }
コード例 #9
0
ファイル: user_acl.php プロジェクト: jaeko44/time-tracking
 public function save($acl = false)
 {
     $this->removeProperties('actags');
     if (parent::save()) {
         if ($acl) {
             $this->saveACL($acl);
         }
         return true;
     }
     return false;
 }
コード例 #10
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new UserModel();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['user'])) {
         $model->attributes = $_POST['user'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
コード例 #11
0
ファイル: users.create.php プロジェクト: LZJCodeup/AdLister
function processForm()
{
    $errors = [];
    $errors['count'] = 0;
    //form was submitted when $_POST is not empty
    if (!empty($_POST)) {
        try {
            $firstName = Input::getString('first_name');
        } catch (Exception $e) {
            $errors['first_name'] = 'First Name: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $lastName = Input::getString('last_name');
        } catch (Exception $e) {
            $errors['last_name'] = 'Last Name: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $email = Input::getString('email');
        } catch (Exception $e) {
            $errors['email'] = 'Email Address: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            if ($_POST['password1'] != $_POST['password2']) {
                throw new UnexpectedValueException("Do Not Match!");
            }
            $passwordOneHashed = Input::getPassword('password1', $firstName, $lastName, $email);
        } catch (Exception $e) {
            $errors['password1'] = 'Password: '******'count']++;
        }
        if ($errors['count'] == 0) {
            //no errors - add to the database
            $userObject = new UserModel();
            $userObject->first_name = $firstName;
            $userObject->last_name = $lastName;
            $userObject->email = $email;
            $userObject->password = $passwordOneHashed;
            $userObject->save();
            header("Location: /users.show.php?id=" . $userObject->id);
            //this will be the $_GET for the users.show.php
            die;
        }
    }
    return $errors;
}
コード例 #12
0
ファイル: AccessController.php プロジェクト: Alamast/pravoved
 public function actionForget()
 {
     $model = new UserForm('foget');
     $msg = '';
     if (!empty($_POST['UserForm'])) {
         $model->attributes = $_POST['UserForm'];
         if ($model->validate()) {
             $user = new UserModel();
             $user->password = UserModel::model()->cryptPass($pass = UserModel::model()->genPassword());
             $user->save();
             Yii::app()->email->send($model->email, 'Новый пароль', 'Ваш новый пароль:' . $pass);
             $msg = 'Новый пароль отправлен Вам на почту.';
         }
     }
     $this->render('forget', ['model' => $model, 'msg' => $msg]);
 }
コード例 #13
0
 public function signUpAction()
 {
     $form = new SignUpForm();
     $this->view->form = $form;
     if (isset($_POST)) {
         if ($form->isValid($_POST)) {
             $user = new UserModel();
             $user->populate($_POST);
             $user->save();
         } else {
             foreach ($form->getMessages() as $message) {
                 $this->flash->error($message);
             }
         }
         // $this->view->disable();
     }
 }
コード例 #14
0
 public function register()
 {
     $reguser = array('regfirst' => Input::get('regfirst'), 'reglast' => Input::get('reglast'), 'reguser' => Input::get('reguser'), 'password' => Input::get('password'), 'cpassword' => Input::get('cpassword'));
     $rules = array('regfirst' => 'alpha_num|max:50', 'reglast' => 'alpha_num|max:50', 'reguser' => 'required|unique:users,username|alpha_num|min:5', 'password' => 'required|alpha_num|between:6,100', 'cpassword' => 'required|alpha_num|between:6,100|same:password');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::Back()->withInput()->withErrors($validator);
     } else {
         $user = new UserModel();
         $user->firstname = Input::get('regfirst');
         $user->lastname = Input::get('reglast');
         $user->username = Input::get('reguser');
         $user->password = Hash::make(Input::get('password'));
         $user->roles = Input::get('roles');
         $user->save();
     }
     return Redirect::route('login')->with('flash_notice', 'You are successfully Register.');
 }
コード例 #15
0
ファイル: Auth.php プロジェクト: swash13/shop
 protected static function actionRegistration()
 {
     if (empty($_POST)) {
         self::redirect(App::getLink('Auth'));
     }
     $errors = array();
     if (empty($_POST['name'])) {
         $errors['name'] = App::t('Введите имя');
     }
     if (empty($_POST['email'])) {
         $errors['email'] = App::t('Введите email');
     } else {
         if (!preg_match('/^[-A-Za-z0-9_\\.]+@[-A-Za-z0-9_\\.]+\\.[a-z0-9]{2,4}$/', $_POST['email'])) {
             $errors['email'] = App::t('Некорректный email');
         }
     }
     if (empty($_POST['password'])) {
         $errors['password'] = App::t('Введите пароль');
     } else {
         if (empty($_POST['confirm'])) {
             $errors['confirm'] = App::t('Введите подтверждение');
         } else {
             if ($_POST['password'] != $_POST['confirm']) {
                 $errors['password'] = $errors['confirm'] = App::t('Пароли не совпадают');
             }
         }
     }
     if (empty($errors) && UserModel::getByEmail($_POST['email'])) {
         $errors['email'] = App::t('Этот email уже используется');
     }
     if (empty($errors)) {
         $user = new UserModel();
         $user->name = $_POST['name'];
         $user->email = $_POST['email'];
         $user->password = md5($_POST['password']);
         $user->save();
         App::currentUser($user);
         self::redirect('/');
     }
     self::templateVar('registration_errors', $errors);
     self::templateVar('post', $_POST);
     return self::displayPage('auth');
 }
コード例 #16
0
ファイル: GroupController.php プロジェクト: 00606/wechat
 public function actionUserCreate()
 {
     $model = new UserModel();
     $group = GroupModel::model()->findall();
     foreach ($group as $v) {
         $groupList[$v->group_id] = $v->name;
     }
     if (isset($_POST['UserModel'])) {
         // 收集用户输入的数据
         $model->attributes = $_POST['UserModel'];
         $model->scenario = 'create';
         if ($model->validate()) {
             //检查用户是否重复
             $model->pswd = md5($_POST['UserModel']['pswd']);
             $model->repswd = md5($_POST['UserModel']['repswd']);
             $model->save();
             $this->redirect(array('group/user'));
         }
     }
     $this->render('userCreate', array('model' => $model, 'group' => $groupList));
 }
コード例 #17
0
ファイル: User.php プロジェクト: asvinicius/ccb
 public function save()
 {
     if ($this->isLogged()) {
         $page = $this->getPage();
         $this->load->model('UserModel');
         $user = new UserModel();
         $data['id'] = null;
         $data['name'] = mb_strtoupper($this->input->get('name'));
         $data['username'] = $this->input->get('username');
         $data['phone'] = $this->input->get('phone');
         $data['password'] = md5($this->input->get('password'));
         $data['role'] = $this->input->get('role');
         if ($data['role'] == '1') {
             $data['help'] = 0;
         } else {
             $data['help'] = 1;
         }
         $data['status'] = 1;
         if ($this->input->get('password') === $this->input->get('confirmpass')) {
             if (!$user->verifyusn($this->input->get('username'))) {
                 if ($user->save($data)) {
                     redirect(base_url('user/index/1'));
                 }
             } else {
                 $savefail = array("class" => "danger", "message" => "Nome de usuário já existente no banco");
                 $msg = array("savefail" => $savefail);
                 $this->load->view('template/super/header', $page);
                 $this->load->view('super/newuser', $msg);
                 $this->load->view('template/public/footer');
             }
         } else {
             $savefail = array("class" => "danger", "message" => "As senhas inseridas não são iguais");
             $msg = array("savefail" => $savefail);
             $this->load->view('template/super/header', $page);
             $this->load->view('super/newuser', $msg);
             $this->load->view('template/public/footer');
         }
     }
 }
コード例 #18
0
 public function actionIndex()
 {
     $model = new UserModel();
     if (isset($_POST['UserModel'])) {
         $model->attributes = $_POST['UserModel'];
         $model->username = $model->email;
         if ($model->validate()) {
             $record = UserModel::model()->findByAttributes(array('email' => $model->email));
             if ($record !== null) {
                 $this->render('error', array('type' => 'repeate'));
                 exit;
             } else {
                 if ($model->save()) {
                     //$this->redirect(array('style/index','id'=>$model->_id));
                     $this->redirect(array('login/index'));
                 }
                 $this->refresh();
             }
         }
     }
     $this->render('index', array('model' => $model));
 }
コード例 #19
0
 public function save()
 {
     $user = new UserModel($this->exportData());
     $user->save();
 }
コード例 #20
0
ファイル: UserService.php プロジェクト: sergeyklay/AspectMock
 public static function renameStatic(UserModel $user, $name)
 {
     $user->renameUser($name);
     $user->save();
 }
コード例 #21
0
 function save()
 {
     //IMBAuth::checkOAuth();
     $device_id = addslashes($_POST['device_id']);
     $type = addslashes($_POST['type']);
     //completion check
     if ($device_id == "" || $type == "") {
         $json['status_code'] = 0;
         $json['status_message'] = "Incomplete Request";
         echo json_encode($json);
         die;
     }
     //check account..
     $acc = isset($_POST['acc_id']) ? addslashes($_POST['acc_id']) : 0;
     $res_id = isset($_POST['res_id']) ? addslashes($_POST['res_id']) : 0;
     //        IMBAuth::checkOAuth();
     $dn = new DeviceModel();
     $dnquery = new DeviceModel();
     // langkah 1 , device ID ada device type ada
     $arrs = $dnquery->getWhere("device_id = '{$device_id}' AND device_type = '{$type}'");
     $dn = $arrs[0];
     if ($dn->did == "") {
         $dn = new DeviceModel();
         $dn->device_id = $device_id;
         $dn->device_type = $type;
         $dn->acc_id = $acc;
         $dn->firstlogin = leap_mysqldate();
         $dn->dev_res_id = $res_id;
     } else {
         //kalau device id ada, acc di update
         $dn->load = 1;
         $dn->acc_id = $acc;
         $dn->dev_res_id = $res_id;
     }
     $dn->dev_lng = addslashes($_POST['lng']);
     $dn->dev_lat = addslashes($_POST['lat']);
     $dn->logindate = leap_mysqldate();
     //save user latlong to MasterUser -- 10 May 2016 sendy
     if (isset($_POST['lat']) && isset($_POST['lng']) && $acc != 0) {
         $user = new UserModel();
         $user->getByID($acc);
         $user->logindate = leap_mysqldate();
         $user->latitude = addslashes($_POST['lat']);
         $user->longitude = addslashes($_POST['lng']);
         $user->save();
     }
     //save user District and City to LocationModel -- 26 May 2016 sendy
     Generic::saveDistrictCityFromLatLng(addslashes($_POST['lat']), addslashes($_POST['lng']), $acc, $type == "cashier");
     if ($dn->save()) {
         $json['save_status'] = 1;
         $json['version'] = Efiwebsetting::getData('App_Version_' . strtolower($type));
         $json['url'] = Efiwebsetting::getData('App_URL_' . strtolower($type));
         //logged all device login 19 nov 2015 roy
         //            $logged = new DeviceLogger();
         //            $logged->log_acc_id = $dn->acc_id;
         //            $logged->log_date = leap_mysqldate();
         //            $logged->log_dev_id = $dn->device_id;
         //            $logged->log_dev_type = $dn->device_type;
         //            $logged->save();
     } else {
         $json['save_status'] = 0;
     }
     $json['status_code'] = 1;
     if ($_POST['do_not_die']) {
         return $json;
     } else {
         echo json_encode($json);
         die;
     }
 }
コード例 #22
0
 public function createAction()
 {
     $request = $this->get('request');
     // Get the input
     $name = $request->postVar('name');
     $mail = $request->postVar('mail');
     $password = $request->postVar('password');
     $roles = array('OPERATOR');
     // Validate the input
     $user = new UserModel(compact('name', 'mail', 'password', 'roles'));
     $errors = $this->get('model_validation')->validateUser($user->getData(true));
     if (count($errors) === 0) {
         // Create the user
         $user->password = $this->get('security')->encodePassword($user->password);
         if ($user->save()) {
             // Return a successful response
             return $this->json(array('success' => true, 'id' => $user->id));
         }
         $errors = array('Couldn\'t save the user');
     }
     // Return an error response
     return $this->json(array('success' => false, 'errors' => $errors));
 }
コード例 #23
0
 public static function payViaCreditCard($idOrder, $idUser = "")
 {
     $restoInitiate = Generic::IsNullOrEmptyString($idUser);
     $userInitiate = !$restoInitiate;
     $order = new MasterOrderModel();
     $order->getByID($idOrder);
     //KALO USER INITIATE CEK APA DIA LEADER
     if ($userInitiate) {
         $user = new UserModel();
         $user->getByID($idUser);
         if (!Util::isLeader($idOrder, $idUser)) {
             Generic::errorMsg(Keys::$ERR_PAYMENT_NOT_LEADER);
         }
     } else {
         $idUser = $order->id_user;
         $user = new UserModel();
         $user->getByID($idUser);
     }
     //CEK APA PEMBAYARAN PAKE CREDIT CARD
     if ($order->payment_method != Keys::$PAYMENT_TYPE_CREDIT_CARD) {
         Generic::errorMsg("This Order Not Using Credit Card as Payment Method");
     }
     Doku_Initiate::$sharedKey = "iMdRs8Iz987Z";
     Doku_Initiate::$mallId = "3199";
     $invoice = new Invoice($idOrder, true);
     $params = array('amount' => Generic::dokuMoneyValue($invoice->grandTotal), 'invoice' => $idOrder, 'currency' => '360');
     $detailOrders = $invoice->orderDetails;
     $basket = array();
     foreach ($detailOrders as $detailOrder) {
         $b = array();
         $b['name'] = $detailOrder->name_dish;
         $b['amount'] = Generic::dokuMoneyValue($detailOrder->single_price);
         $b['quantity'] = $detailOrder->quantity;
         $b['subtotal'] = Generic::dokuMoneyValue($detailOrder->price);
         $basket[] = $b;
     }
     $words = Doku_Library::doCreateWords($params);
     $customer = array('name' => $user->full_name, 'data_phone' => $user->phone_no, 'data_email' => $user->email, 'data_address' => $user->district . ',' . $user->city);
     //        $basket[] = array(
     //            'name' => 'sayur',
     //            'amount' => '10000.00',
     //            'quantity' => '1',
     //            'subtotal' => '10000.00'
     //        );
     //        $basket[] = array(
     //            'name' => 'buah',
     //            'amount' => '10000.00',
     //            'quantity' => '1',
     //            'subtotal' => '10000.00'
     //        );
     $dataPayment = array('req_mall_id' => Doku_Initiate::$mallId, 'req_chain_merchant' => 'NA', 'req_amount' => $params['amount'], 'req_words' => $words, 'req_purchase_amount' => $params['amount'], 'req_trans_id_merchant' => $params['invoice'], 'req_request_date_time' => date('YmdHis'), 'req_currency' => '360', 'req_purchase_currency' => '360', 'req_session_id' => sha1(date('YmdHis')), 'req_name' => $customer['name'], 'req_payment_channel' => '15', 'req_email' => $customer['data_email'], 'req_basket' => $basket, 'req_address' => $customer['data_address'], 'req_token_payment' => $user->payment_token, 'req_customer_id' => $idUser);
     $response = Doku_Api::doDirectPayment($dataPayment);
     if ($response->res_response_code == '0000') {
         $status = "SUCCESS";
         $order->status_payment = Keys::$PAYMENT_STATUS_PAID;
         $order->isPaid = Keys::$YES;
         $order->load = 1;
         $order->save();
         //success
         $trans = new MasterRestoTransactionModel();
         $trans->id_restaurant = $order->id_restaurant;
         $trans->id_request = $order->id_order;
         $trans->gross_amount = $invoice->grandTotal;
         $trans->type_transaction = "1";
         $trans->datetime_transaction = leap_mysqldate();
         $trans->approved = "1";
         $trans->mr_fee = $invoice->valFeeMR;
         //doubleval($order->mr_fee);//((double)($arrOrder[0]->grand_total * $resto->mr_fee)) / 100;
         //TODO LATER CHANGE 3 (BANK FEE) INTO GLOBAL VAR
         $trans->other_fee = 0;
         //((double)($arrOrder[0]->grand_total * $resto->cc_fee)) / 100;
         $trans->bank_disc = $invoice->valDiscBank;
         //doubleval($order->disc_bank);//$objOrder->disc_bank;
         $valNetAmount = doubleval($trans->gross_amount - $trans->mr_fee - $trans->other_fee + $trans->bank_disc);
         $trans->net_amount = $valNetAmount;
         $trans->save();
         //reset user credit to 0
         $user = new UserModel();
         $user->getByID($idUser);
         $user->credit = 0;
         $user->save();
     } else {
         $status = "FAILED";
     }
     $results['status'] = $status;
     $results['res_token_id'] = $user->payment_token;
     $results['invoice_no'] = $idOrder;
     $results['id_user'] = $idUser;
     $results['res_response_code'] = $response->res_response_code;
     $results['doku_results'] = $response;
     //        $results['data_payment'] = $dataPayment;
     //        pr($results);
     if ($status == "SUCCESS") {
         return array("success" => 1, $results);
     } else {
         return array("success" => 0, $results);
     }
     //        Generic::finish($results);
 }
コード例 #24
0
 /**
  * try to log the user in
  *
  * @param $userData
  * @return bool
  */
 protected function loginUser($userData)
 {
     if (!is_array($userData) || !isset($userData['username'])) {
         return false;
     }
     $user = \UserModel::findByUsername($userData['username']);
     // Create new user
     if (!$user) {
         $user = new \UserModel();
         $user->tstamp = time();
         $user->uploader = 'FileUpload';
         $user->backendTheme = 'default';
         $user->dateAdded = time();
         $user->showHelp = true;
         $user->thumbnails = true;
         $user->useRTE = true;
         $user->useCE = true;
         $user->username = $userData['username'];
     }
     // Update general user data
     $user->name = $userData['name'];
     $user->email = $userData['email'];
     $user->language = isset($userData['language']) ? $userData['language'] : null;
     $user->admin = isset($userData['admin']) && $userData['admin'] == "1" ? true : false;
     // Save user
     $user->save();
     // Perform frontend login
     self::$allowLogin = true;
     $_POST['username'] = $user->username;
     $_POST['password'] = '******';
     $_POST['REQUEST_TOKEN'] = REQUEST_TOKEN;
     $this->setPreferredLoginProvider();
     $this->loginUserAction();
 }
コード例 #25
0
 public function validateAction()
 {
     $Request = Request::getInstance();
     $user_id = $Request->user_id;
     $given_code = rawurldecode($Request->code);
     $User = new UserModel((int) $user_id);
     $User->load();
     if (!$User->validateCode($given_code)) {
         $this->gotoPage('/user', 'The validation code is invalid!');
     }
     $User->role = 'registered';
     $User->save();
     $this->gotoPage("/user", "Congratulations, now you are fully registered!<br/>please login");
 }
コード例 #26
0
 public function signup()
 {
     $firstname = Input::get('firstname');
     $lastname = Input::get('lastname');
     $username = Input::get('username');
     $email = Input::get('email');
     $password = Input::get('password');
     $cpassword = Input::get('confirmpassword');
     $at = Input::get('accounttype');
     $parentusername = Input::get('parentusername');
     $contact = Input::get('contact');
     $picture = "";
     if ($password == $cpassword) {
         //check if username is already in database
         $user_check = UserModel::where('username', '=', $username)->first();
         if ($user_check == "") {
             $userid = bin2hex(mcrypt_create_iv(22, MCRYPT_DEV_URANDOM)) . "=" . $username . "+" . $at;
             if ($at == "Parent") {
                 if (Input::hasFile('file')) {
                     //upload profile picture and set filename to a variale to save to db
                     $file = Input::file('file');
                     $filename = bin2hex(mcrypt_create_iv(10, MCRYPT_DEV_URANDOM)) . "" . $username . "-" . $file->getClientOriginalName();
                     $file->move('public/profilepics', $filename);
                     $picture = $filename;
                 } else {
                     //set picture to null
                     $picture = "images/user.png";
                 }
                 //save as parent account
                 //$pw=Hash::make($password);
                 $pw = md5($password);
                 $user = new UserModel();
                 $user->userid = $userid;
                 $user->firstname = $firstname;
                 $user->lastname = $lastname;
                 $user->username = $username;
                 $user->password = $pw;
                 $user->email = $email;
                 $user->contact = $contact;
                 $user->accttype = $at;
                 $user->picture = $picture;
                 $user->occupation = 'Please specify';
                 $user->gender = 'Please specify';
                 $user->birthday = 'Please specify';
                 $user->city = 'Please specify';
                 $user->home = 'Please specify';
                 $user->save();
                 $parentid = bin2hex(mcrypt_create_iv(10, MCRYPT_DEV_URANDOM)) . "+" . $userid;
                 $membership = "";
                 $membership_status = "";
                 $parent = new ParentModel();
                 $parent->userid = $userid;
                 $parent->parentid = $parentid;
                 $parent->membership = $membership;
                 $parent->membership_status = $membership_status;
                 $parent->save();
                 $message = "Parent Registration Successful!";
                 return View::make('content.entry')->with('message', $message)->with('background', '#A9F5A9')->with('sets', $this->sets);
             } elseif ($at == "Child") {
                 $temp_at = "";
                 //setting $temp_at as null in default.
                 //check if parentusername in database
                 $user = UserModel::where('username', '=', $parentusername)->first();
                 $temp_at = $user['accttype'];
                 if ($temp_at == "" or $temp_at == "Child") {
                     //return Redirect::intended('http://localhost:8000/#toregister');
                     $return_sets = array('firstname' => $firstname, 'lastname' => $lastname, 'username' => $username, 'email' => $email, 'contact' => $contact);
                     //return Redirect::to('http://localhost:8000/#toregister')->with('message', 'Parent Username not found!')->with('sets', $return_sets);
                     return Redirect::intended('http://localhost:8000/#toregister')->with('message', 'Parent Username not found!')->with('sets', $return_sets);
                 } else {
                     if (Input::hasFile('file')) {
                         //upload profile picture and set filename to a variale to save to db
                         $file = Input::file('file');
                         $filename = bin2hex(mcrypt_create_iv(10, MCRYPT_DEV_URANDOM)) . "" . $username . "-" . $file->getClientOriginalName();
                         $file->move('public/profilepics', $filename);
                         $picture = $filename;
                     } else {
                         //set picture to null
                         $picture = "images/user.png";
                     }
                     $pw = md5($password);
                     //For User Database
                     $user = new UserModel();
                     $user->userid = $userid;
                     $user->firstname = $firstname;
                     $user->lastname = $lastname;
                     $user->username = $username;
                     $user->password = $pw;
                     $user->email = $email;
                     $user->contact = $contact;
                     $user->accttype = $at;
                     $user->picture = $picture;
                     $user->occupation = 'Please specify';
                     $user->gender = 'Please specify';
                     $user->birthday = 'Please specify';
                     $user->city = 'Please specify';
                     $user->home = 'Please specify';
                     $user->save();
                     $childid = bin2hex(mcrypt_create_iv(15, MCRYPT_DEV_URANDOM)) . "+" . $userid;
                     $computerid = bin2hex(mcrypt_create_iv(10, MCRYPT_DEV_URANDOM)) . "computer" . bin2hex(mcrypt_create_iv(10, MCRYPT_DEV_URANDOM)) . "*" . $username;
                     $status = "";
                     //For Child database
                     $child = new ChildModel();
                     $child->userid = $userid;
                     $child->childid = $childid;
                     $child->computerid = $computerid;
                     $child->parentusername = $parentusername;
                     $child->status = $status;
                     $child->save();
                     //For Computer Database
                     $os_username = "";
                     $domain_name = "";
                     $sid = "";
                     $computer = new ComputerModel();
                     $computer->computerid = $computerid;
                     $computer->username = $os_username;
                     $computer->domainname = $domain_name;
                     $computer->sid = $sid;
                     $computer->save();
                     $message = "Parent Registration Successful!";
                     return View::make('content.entry')->with('message', $message)->with('background', '#A9F5A9')->with('sets', $this->sets);
                 }
             }
             //end of elseif(child)
         } elseif ($user_check != "") {
             $return_sets = array('firstname' => $firstname, 'lastname' => $lastname, 'username' => $username, 'email' => $email, 'contact' => $contact);
             return Redirect::intended('http://localhost:8000/#toregister')->with('message', 'Username is already taken!')->with('sets', $return_sets);
         }
     }
     //end of if($password=$cpassword)
 }
コード例 #27
0
ファイル: dba-save2.php プロジェクト: ydhl/yangzie
$sql = new \yangzie\YZE_SQL();
$sql->from("\\yangzie\\UserModel", "u")->where("u", "name", \yangzie\YZE_SQL::EQ, "aaaaa");
$user2->set("email", "12345");
$user2->save(YZE_SQL::INSERT_NOT_EXIST, $sql);
echo "\r\n";
echo $user2->get_key() && $user2->Get("email") == "1234" ? "INSERT_NOT_EXIST true" : "INSERT_NOT_EXIST false";
$user2->remove();
//测试不存在时添加,存在更新
$user3 = new UserModel();
$user3->set("name", "aa");
$user3->set("register_time", "2015-12-17 17:50:30");
$sql = new \yangzie\YZE_SQL();
$sql->from("\\yangzie\\UserModel", "u")->where("u", "name", \yangzie\YZE_SQL::EQ, "aaaaa");
$user3->set("email", "123456");
$user3->save(YZE_SQL::INSERT_NOT_EXIST_OR_UPDATE, $sql);
echo "\r\n";
echo $user3->get_key() && $user3->Get("email") == "123456" ? "INSERT_NOT_EXIST_OR_UPDATE true" : "INSERT_NOT_EXIST_OR_UPDATE false";
//测试不存在时添加,存在更新
$user3 = new UserModel();
$user3->set("name", "aa");
$user3->set("register_time", "2015-12-17 17:50:30");
$sql = new \yangzie\YZE_SQL();
$sql->from("\\yangzie\\UserModel", "u")->where("u", "name", \yangzie\YZE_SQL::EQ, "aaaaaaaa");
$user3->set("email", "1234567");
$user3->save(YZE_SQL::INSERT_NOT_EXIST_OR_UPDATE, $sql);
echo "\r\n";
echo $user3->get_key() && $user3->Get("email") == "1234567" ? "INSERT_NOT_EXIST_OR_UPDATE true" : "INSERT_NOT_EXIST_OR_UPDATE false";
//删除
$user->remove();
echo "\r\n";
echo $user->get_key() > 0 ? "remove false" : "remove true";
コード例 #28
0
 public function checkout_process()
 {
     if (empty($_POST['token_id'])) {
         die('Empty token_id!');
     }
     Veritrans_Config::$serverKey = 'VT-server-tHdPoLZ5B9msOwJBt-tN7jOE';
     if (Veritrans_Config::$serverKey == '<your server key>') {
         echo "<code>";
         echo "<h4>Please set real server key from sandbox</h4>";
         echo "In file: " . __FILE__;
         echo "<br>";
         echo "<br>";
         echo htmlspecialchars('Veritrans_Config::$serverKey = \'<your server key>\';');
         die;
     }
     // Uncomment for production environment
     // Veritrans_Config::$isProduction = false;
     // Uncomment to enable sanitization
     // Veritrans_Config::$isSanitized = false;
     $transaction_details = array('order_id' => time(), 'gross_amount' => 200000);
     // Populate items
     $items = array(array('id' => 'item1', 'price' => 100000, 'quantity' => 1, 'name' => 'Adidas f50'), array('id' => 'item2', 'price' => 50000, 'quantity' => 2, 'name' => 'Nike N90'));
     // Populate customer's billing address
     $billing_address = array();
     // Populate customer's shipping address
     $shipping_address = array();
     // Populate customer's info
     $customer_details = array('first_name' => "Andri", 'last_name' => "Litani", 'email' => "*****@*****.**", 'phone' => "081122334455");
     // Token ID from checkout page
     $token_id = $_POST['token_id'];
     // Transaction data to be sent
     $transaction_data = array('payment_type' => 'credit_card', 'credit_card' => array('token_id' => $token_id, 'type' => 'authorize', 'save_token_id' => isset($_POST['save_cc'])), 'transaction_details' => $transaction_details);
     try {
         $response = Veritrans_VtDirect::charge($transaction_data);
         $objUser = new UserModel();
         $objUser->getByID('2');
         $objUser->braintree_id = $response->saved_token_id;
         $objUser->load = 1;
         $objUser->save();
         pr($response);
     } catch (Exception $e) {
         echo $e->getMessage();
         die;
     }
     echo $response->transaction_status;
     // Success
     if ($response->transaction_status == 'capture') {
         echo "<p>Transaksi berhasil.</p>";
         echo "<p>Status transaksi untuk order id {$response->order_id}: " . "{$response->transaction_status}</p>";
         echo "<h3>Detail transaksi:</h3>";
         echo "<pre>";
         var_dump($response);
         echo "</pre>";
     } else {
         if ($response->transaction_status == 'deny') {
             echo "<p>Transaksi ditolak.</p>";
             echo "<p>Status transaksi untuk order id .{$response->order_id}: " . "{$response->transaction_status}</p>";
             echo "<h3>Detail transaksi:</h3>";
             echo "<pre>";
             var_dump($response);
             echo "</pre>";
         } else {
             if ($response->transaction_status == 'challenge') {
                 echo "<p>Transaksi challenge.</p>";
                 echo "<p>Status transaksi untuk order id {$response->order_id}: " . "{$response->transaction_status}</p>";
                 echo "<h3>Detail transaksi:</h3>";
                 echo "<pre>";
                 var_dump($response);
                 echo "</pre>";
             } else {
                 echo "<p>Terjadi kesalahan pada data transaksi yang dikirim.</p>";
                 echo "<p>Status message: [{$response->status_code}] " . "{$response->status_message}</p>";
                 echo "<pre>";
                 var_dump($response);
                 echo "</pre>";
             }
         }
     }
     echo "<hr>";
     echo "<h3>Request</h3>";
     echo "<pre>";
     var_dump($response);
     echo "</pre>";
 }
コード例 #29
0
 public function actionView()
 {
     $is_3g = $this->is3g;
     if (Yii::app()->user->isGuest) {
         $this->redirect($this->createUrl("/account/login"));
         return;
     }
     $error = $error2 = $error_success = "";
     //$user_id = Yii::app()->user->id;
     $phone = yii::app()->user->getState('msisdn');
     $user = UserModel::model()->findByAttributes(array('phone' => $phone));
     $user_id = $user->id;
     $cri = new CDbCriteria();
     $cri->condition = " user_phone = {$phone} AND status=1";
     $user_sub = WapUserSubscribeModel::model()->find($cri);
     $user_extra = UserExtraModel::model()->findbyPK($user->id);
     $forcus = "";
     if (Yii::app()->request->isPostRequest) {
         if (isset($_POST['Profile'])) {
             $error = '';
             $forcus = '';
             $error_code = 0;
             if (empty($_POST['Profile']['username'])) {
                 $error = Yii::t("wap", "Họ tên không được để trống");
                 $forcus = "username";
                 $error_code = 1;
             }
             $playlist_name = ucwords($_POST['Profile']['username']);
             if (preg_match('/[\'\\/~`\\!@#\\$%\\^&\\*\\(\\)_\\-\\+=\\{\\}\\[\\]\\|;:"\\<\\>,\\.\\?\\\\]/', $playlist_name)) {
                 $error = Yii::t("wap", "Họ tên không được chứa ký tự đặc biệt");
                 $forcus = "username";
                 $error_code = 1;
             }
             if (!empty($_POST['Profile']['email']) && !EmailHelper::isEmailAddress($_POST['Profile']['email'])) {
                 $error = Yii::t("wap", "Email incorrect");
                 $forcus = "email";
                 $error_code = 1;
             }
             $birthday = implode('-', array_reverse(explode('/', $_POST['Profile_birthday'])));
             $date = DateTime::createFromFormat("Y-m-d", $birthday);
             if (!$date && !empty($_POST['Profile_birthday'])) {
                 $error = Yii::t("wap", "Date of birth incorrect!");
                 $forcus = "birthday";
                 $error_code = 1;
             }
             if ($error_code == 0) {
                 if (empty($user)) {
                     $password = Common::randomPassword(6);
                     $user = new UserModel();
                     $user->username = $_POST['Profile']['username'];
                     $user->password = $password["encoderPass"];
                     $user->fullname = Yii::app()->user->getState('msisdn');
                     $user->phone = Yii::app()->user->getState('msisdn');
                     $user->gender = 0;
                     $user->status = UserModel::ACTIVE;
                     $user->validate_phone = 1;
                     $user->created_time = date('Y-m-d H:i:s');
                     $user->updated_time = date('Y-m-d H:i:s');
                     $user->email = $_POST['Profile']['email'];
                     $user->address = $_POST['Profile']['address'];
                     $user->gender = (int) $_POST['Profile']['genre'];
                     $ret = $user->save();
                 } else {
                     $user->username = $_POST['Profile']['username'];
                     $user->email = $_POST['Profile']['email'];
                     $user->address = $_POST['Profile']['address'];
                     $user->gender = (int) $_POST['Profile']['genre'];
                     $ret = $user->save();
                 }
                 if ($ret) {
                     if (!empty($user_extra)) {
                         $user_extra->birthday = !empty($birthday) ? $birthday : new CDbExpression('NULL');
                         $user_extra->save();
                     } else {
                         $user_extra = new UserExtraModel();
                         $user_extra->user_id = $user_id;
                         $user_extra->birthday = !empty($birthday) ? $birthday : new CDbExpression('NULL');
                         $user_extra->save();
                     }
                     $error_success = "Cập nhật thành công";
                 } else {
                     $error = Yii::t("wap", "An error occurred. Please try again later.");
                 }
             }
         }
         if (isset($_POST['Profile2'])) {
             $post = $_POST['Profile2'];
             if (empty($post['password'])) {
                 $error2 = Yii::t("wap", "Please input old password");
                 $forcus = "password";
             } elseif ($user['password'] == Common::endcoderPassword($post['password'])) {
                 if (empty($post['password_new'])) {
                     $error2 = Yii::t("wap", "Please input new password");
                 } elseif ($post['password_new'] == $post['password_new_retype']) {
                     $lengPassword = strlen($post['password_new']);
                     if ($lengPassword < 6) {
                         $error2 = Yii::t("wap", "Password required more than 6 characters!");
                         $forcus = "password";
                     } else {
                         $user->password = Common::endcoderPassword($post['password_new']);
                         $ret = $user->save();
                         if ($ret) {
                             Yii::app()->user->setFlash('change_pass_status', Yii::t("wap", "Your password was successfully changed"));
                             $this->redirect($this->createUrl("/account/view"));
                         } else {
                             $error2 = Yii::t("wap", "An error occurred. Please try again later.");
                         }
                     }
                 } else {
                     $error2 = Yii::t("wap", "Repassword not match");
                     $forcus = "password_new_retype";
                 }
             } else {
                 $error2 = Yii::t("wap", "Old password not match");
                 $forcus = "password_new";
             }
         }
     }
     $this->render('view', compact('user', 'user_sub', 'user_extra', 'error', 'error2', 'forcus', 'error_success', 'is_3g'));
 }
コード例 #30
0
 public function userSignUp()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $update = !Generic::IsNullOrEmptyString($_POST['id_user']);
     $idUser = Generic::IsNullOrEmptyString($_POST['id_user']) ? "" : $_POST['id_user'];
     $fullName = Generic::mustCheck($_POST['full_name'], Keys::$ERR_USER_EMPTY_FULL_NAME);
     $userName = Generic::mustCheck($_POST['user_name'], Keys::$ERR_USER_EMPTY_NICK_NAME);
     $email = Generic::mustCheck($_POST['email'], Keys::$ERR_USER_EMPTY_EMAIL);
     $password = Generic::mustCheck($_POST['pwd'], Keys::$ERR_USER_EMPTY_PASSWORD);
     //        $password2 = Generic::mustCheck($_POST['pwd2'], Keys::$ERR_USER_EMPTY_PASSWORD_2);
     $idCuisine = Generic::mustCheck($_POST['pref_cuisine'], Keys::$ERR_USER_EMPTY_CUISINE);
     $birthday = Generic::mustCheck($_POST['birthday'], Keys::$ERR_USER_EMPTY_BIRTHDAY);
     $phoneNo = Generic::mustCheck($_POST['phone_no'], Keys::$ERR_USER_EMPTY_PHONE);
     $fbId = Generic::IsNullOrEmptyString($_POST['fb_id']) ? "" : $_POST['fb_id'];
     $latitude = Generic::getOrDefault($_POST['lat'], Keys::$DEFAULT_LATITUDE);
     $longitude = Generic::getOrDefault($_POST['long'], Keys::$DEFAULT_LONGITUDE);
     $district = Generic::getOrDefault($_POST['district'], Keys::$EMPTY);
     $city = Generic::getOrDefault($_POST['city'], Keys::$EMPTY);
     $pic = Generic::getOrDefault($_POST['pic'], Keys::$EMPTY);
     ///START OF LOVELY VALIDATION TIME
     if (!Generic::isValidUserName($userName)) {
         Generic::errorMsg(Keys::$ERR_USER_INVALID_USERNAME);
     }
     if (!Generic::isValidUserNameLength($userName)) {
         Generic::errorMsg(Keys::$ERR_USER_USERNAME_TOO_LONG);
     }
     if (!Generic::isValidEmail($email)) {
         Generic::errorMsg(Keys::$ERR_USER_INVALID_EMAIL);
     }
     if (!Generic::isValidPassword($password)) {
         Generic::errorMsg(Keys::$ERR_USER_INVALID_PASSWORD);
     }
     //        if ($password != $password2)
     //            Generic::errorMsg(Keys::$ERR_USER_CONFIRM_PASSWORD_NOT_MATCH);
     $u = new UserModel();
     $arrU = $u->getWhere("user_name='{$userName}'");
     if (count($arrU) > 0) {
         Generic::errorMsg(Keys::$ERR_USER_DUPLICATE_USERNAME);
     }
     $u1 = new UserModel();
     $arrU = $u1->getWhere("email='{$email}'");
     if (count($arrU) > 0) {
         Generic::errorMsg(Keys::$ERR_USER_DUPLICATE_EMAIL);
     }
     if ($fbId != "") {
         $u2 = new UserModel();
         $arrU = $u2->getWhere("fb_id='{$fbId}'");
         if (count($arrU) > 0) {
             Generic::errorMsg(Keys::$ERR_USER_DUPLICATE_FB_ID);
         }
     }
     ///END OF LOVELY VALIDATION TIME, HOW SAD :(
     //pagar untuk regis
     if (Efiwebsetting::getData('Doku_switch')) {
         $doku = new PaymentDoku();
         $dokuId = $doku->registerCustomer($fullName, $email, $phoneNo);
         if (!$dokuId) {
             Generic::errorMsg(Keys::$ERR_USER_FAILED_CREATE_DOKU);
         }
     }
     $user = new UserModel();
     $user->full_name = $fullName;
     $user->user_name = $userName;
     $user->email = $email;
     $user->password = $password;
     $user->id_cuisine = $idCuisine;
     $user->birthday = $birthday;
     if ($pic == "") {
         $user->pic = "";
     } else {
         $user->pic = Util::savePic($pic);
     }
     $user->phone_no = $phoneNo;
     $user->fb_id = $fbId;
     $user->latitude = $latitude;
     $user->longitude = $longitude;
     $user->district = $district;
     $user->city = $city;
     $user->last_lat = $latitude;
     $user->last_long = $longitude;
     $user->last_district = $district;
     $user->last_city = $city;
     $user->status = "1";
     $user->payment_id = $dokuId;
     //        $user->load = 1;
     $uid = $user->save();
     if (!$uid) {
         Generic::errorMsg(Keys::$ERR_USER_FAILED_CREATE);
     } else {
         Generic::saveDistrictCityFromLatLng($latitude, $longitude, $uid, false);
         $results['fb_id'] = $fbId;
         $results['id_user'] = $uid;
         //$user->id_user;
         $results['user_name'] = $userName;
         $results['full_name'] = $fullName;
         $results['email'] = $email;
         $results['pic'] = Generic::insertImageUrl($pic);
         Generic::finish($results);
     }
 }