public function resend_mail()
 {
     $user = \CODOF\User\User::get();
     if ($user->loggedIn()) {
         $details = $user->getInfo();
         $errors = array();
         $reg = new \CODOF\User\Register($this->db);
         $reg->add_signup_attempt($details);
         $reg->send_mail($details, $errors);
         if (empty($errors)) {
             echo 'success';
         } else {
             echo $errors[0];
         }
     }
 }
         } else {
             //we got an email, lets check if it exists
             $qry = "SELECT id FROM " . PREFIX . "codo_users WHERE mail=:mail";
             $stmt = $this->db->prepare($qry);
             $stmt->execute(array(":mail" => $mail));
             $res = $stmt->fetch();
             if (!empty($res)) {
                 //looks like this user has already registered
                 $create_account = false;
                 CODOF\User\User::login($res['id']);
                 //now this will work if you change authentication from
                 //fb to gmail etc
             }
         }
         if ($create_account) {
             $reg = new CODOF\User\Register($db);
             $reg->mail = $mail;
             $reg->name = $user_profile->firstName . ' ' . $user_profile->lastName;
             $reg->oauth_id = $oauth_id;
             $reg->username = $username;
             $reg->avatar = $user_profile->photoURL;
             $reg->user_status = 1;
             //approved user
             $reg->register_user();
             $reg->login();
         }
     }
     header('Location: ' . CODOF\User\User::getProfileUrl());
     //$adapter->logout();
 } catch (Exception $e) {
     // In case we have errors 6 or 7, then we have to use Hybrid_Provider_Adapter::logout() to
    $smarty->assign('role_options', $sroles);
    $role = $u->rids;
    $smarty->assign('role_selected', $role);
    $smarty->assign('user', $res);
    $content = $smarty->fetch('user_edit.tpl');
} else {
    //NEW
    if (isset($_POST['a_username']) && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) {
        if (CODOF\Util::is_field_present($_POST['a_username'], 'username') === TRUE) {
        } else {
            if (CODOF\Util::is_field_present($_POST['a_email'], 'mail') === TRUE) {
            } else {
                if (CODOF\User\User::usernameExists($_POST['a_username']) || CODOF\User\User::mailExists($_POST['a_email'])) {
                    $msg = 'username or email already exists!';
                } else {
                    $reg = new CODOF\User\Register($db);
                    $reg->username = $_POST['a_username'];
                    $reg->name = $_POST['a_username'];
                    $reg->mail = $_POST['a_email'];
                    $reg->password = $_POST['a_password'];
                    $reg->user_status = 1;
                    $errors = $reg->register_user();
                    $msg = implode('<br>', $errors);
                }
                //$msg = $errors[0];
                $err = 1;
                $smarty->assign("msg", $msg);
            }
        }
    }
    //DELETE
Beispiel #4
0
 public function register($do)
 {
     if (isset($_SESSION[UID . 'USER']['id'])) {
         header('Location: ' . \CODOF\User\User::getProfileUrl());
         exit;
     }
     $this->view = 'user/register';
     $set_fields = array('username', 'password', 'mail');
     $req_fields = array('username', 'password', 'mail');
     $this->js_files = array(array(DATA_PATH . 'assets/js/user/register.js', array('type' => 'defer')));
     if (\CODOF\Util::is_set($_REQUEST, $set_fields) && !\CODOF\Util::is_empty($_REQUEST, $req_fields) && $do) {
         $register = new \CODOF\User\Register($this->db);
         $register->username = str_replace('"', '&quot;', $_REQUEST['username']);
         $register->name = null;
         //$_REQUEST['name'];
         $register->password = $_REQUEST["password"];
         $register->mail = $_REQUEST['mail'];
         $register->rid = ROLE_UNVERIFIED;
         $errors = $register->get_errors();
         if (empty($errors)) {
             $errors = $register->register_user();
             $register->login();
             header('Location: ' . \CODOF\User\User::getProfileUrl());
             exit;
         }
         $this->smarty->assign('errors', $errors);
     } else {
         $register = new \stdClass();
         $register->username = null;
         $register->name = null;
         //$_REQUEST['name'];
         $register->password = null;
         $register->mail = null;
     }
     if (\CODOF\Util::get_opt('captcha') == "enabled") {
         $publickey = \CODOF\Util::get_opt('captcha_public_key');
         // you got this from the signup page
         $this->smarty->assign('recaptcha', '<div class="g-recaptcha col-md-6" data-sitekey="' . $publickey . '"></div>');
         $this->js_files[] = array('https://www.google.com/recaptcha/api.js', array('type' => 'remote'));
     }
     $this->smarty->assign('min_pass_len', \CODOF\Util::get_opt('register_pass_min'));
     $this->smarty->assign('min_username_len', \CODOF\Util::get_opt('register_username_min'));
     $this->smarty->assign('register', $register);
     \CODOF\Store::set('sub_title', 'Register');
 }