コード例 #1
0
ファイル: register.php プロジェクト: shaunfreeman/Uthando-CMS
 $num_rows = $sql->num_rows;
 if ($num_rows == 0) {
     // lets now register the user
     // connect user to database.
     $dsn = array('hostspec' => $this->get('config.database.hostspec'), 'phptype' => $this->get('config.database.phptype'), 'database' => $this->get('config.database.user'));
     $dsn = array_merge($dsn, $this->get('config.database_user'));
     $this->dsn = $dsn['phptype'] . ":host=" . $dsn['hostspec'] . ";dbname=" . $dsn['database'];
     $this->username = $dsn['username'];
     $this->password = $dsn['password'];
     $conn = new PDO($this->dsn, $this->username, $this->password);
     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     try {
         $conn->beginTransaction();
         // encrypt password.
         $user_config = new Config($this->registry, array('path' => $this->registry->ini_dir . '/user/user.ini.php'));
         $pwd = UthandoUser::encodePassword($password, $user_config->get('key', 'cipher'));
         // get user group for user.
         $stmt = $conn->prepare("\n\t\t\t\tSELECT user_group_id\n\t\t\t\tFROM " . $this->registry->user . "user_groups\n\t\t\t\tWHERE user_group='registered'\n\t\t\t");
         $stmt->execute();
         $res = $stmt->fetch(PDO::FETCH_OBJ);
         $stmt = $conn->prepare("\n\t\t\t\tINSERT INTO users (user_group_id, first_name, last_name, username, email, password, iv, cdate)\n\t\t\t\tVALUES (:user_group_id, :first_name, :last_name, :email, :email, :password, :iv, NOW())\n\t\t\t");
         $stmt->execute(array(':user_group_id' => $res->user_group_id, ':first_name' => $name['first'], ':last_name' => $name['last'], ':email' => $email, ':password' => $pwd[0], ':iv' => $pwd[1]));
         if ($conn->commit()) {
             // mail user comfirmation.
             // get mail config.
             $this->registry->mail_config = new Config($this->registry, array('path' => $this->registry->ini_dir . '/mail.ini.php'));
             // get mailer type and call class instance.
             $mailer = $this->registry->mail_config->get('type', 'mailer');
             $mail = new Mailer($mailer, $this->registry);
             $email_type = 'html';
             // set some headers.
コード例 #2
0
ファイル: edit.php プロジェクト: shaunfreeman/Uthando-CMS
     $password = $form->exportValue('password1');
     $update['user_group_id'] = $form->exportValue('group');
     if ($update['user_group_id'] == 0) {
         $update['user_group_id'] = $user->user_group_id;
     }
     if (!empty($password)) {
         $user_config = new Config($registry, array('path' => $this->registry->ini_dir . '/user/user.ini.php'));
         // encrypt password.
         // get group id
         $ugid = $this->registry->db->query("\n\t\t\t\t\t\tSELECT user_group\n\t\t\t\t\t\tFROM " . $this->registry->user . "user_groups\n\t\t\t\t\t\tWHERE user_group_id=:group\n\t\t\t\t\t", array(':group' => $update['user_group_id']));
         if ($ugid[0]->user_group == 'registered') {
             $key = array($user_config->get('key', 'cipher'), $this->get('config.server.web_url'));
         } else {
             $key = $user_config->get('key', 'cipher');
         }
         $pwd = UthandoUser::encodePassword($password, $key);
         $update['password'] = $pwd[0];
         $update['iv'] = $pwd[1];
     }
     $result = $this->registry->db->update($update, $this->registry->user . 'users', array('WHERE' => 'user_id=' . $this->registry->params['id']), $quote = true);
     if (!$result) {
         $this->registry->Error('record not updated.');
     } else {
         Uthando::go('/user/overview');
     }
 } else {
     $form->setDefaults(array('name' => array('first' => $user->first_name, 'last' => $user->last_name), 'username' => $user->username, 'email' => $user->email, 'group' => $user->user_group_id));
     // Output the form
     $renderer = new UthandoForm(TEMPLATES . $this->get('admin_config.site.template'));
     $renderer->setFormTemplate('form');
     $renderer->setHeaderTemplate('header');