summaryrefslogtreecommitdiffstats
path: root/application/models/muser.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/models/muser.php')
-rw-r--r--application/models/muser.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/application/models/muser.php b/application/models/muser.php
index f2b961d89..4ec821f4d 100644
--- a/application/models/muser.php
+++ b/application/models/muser.php
@@ -134,6 +134,31 @@ class Muser extends CI_Model {
return $this->session->userdata('username');
}
+ /*
+ * Check if a given username is valid.
+ *
+ * Valid usernames contain only lowercase characters and numbers. They are
+ * also <= 32 characters in length.
+ *
+ * @return boolean
+ */
+ public function valid_username($username)
+ {
+ return strlen($username) <= 32 && preg_match("/^[a-z0-9]+$/", $username);
+ }
+
+ /**
+ * Check if a given email is valid. Only perform minimal checking since
+ * verifying emails is very very difficuly.
+ *
+ * @return boolean
+ */
+ public function valid_email($email)
+ {
+ $this->load->helper("email");
+ return valid_email($email);
+ }
+
function get_userid()
{
if (!$this->logged_in()) {