Exemple #1
0
 /**
  * Change the Framework Language.
  */
 public function change($language)
 {
     // Only set language if it's in the Languages array
     if (preg_match('/[a-z]/', $language) && in_array($language, CoreLanguage::$codes)) {
         Session::set('language', ucfirst($language));
         // Store the current Language into Cookie.
         Cookie::set(PREFIX . 'language', $language);
     }
     Url::redirect();
 }
Exemple #2
0
 public static function init()
 {
     if (Session::exists('language')) {
         // The Language was already set; nothing to do.
         return;
     } else {
         if (Cookie::exists(PREFIX . 'language')) {
             $cookie = Cookie::get(PREFIX . 'language');
             if (preg_match('/[a-z]/', $cookie) && in_array($cookie, self::$codes)) {
                 Session::set('language', ucfirst($cookie));
             }
         }
     }
 }
 public function resendActivation($email)
 {
     if (!Cookie::get('auth_cookie')) {
         // Input Verification :
         if (strlen($email) == 0) {
             $auth_error[] = $this->lang['register_email_empty'];
         } elseif (strlen($email) > MAX_EMAIL_LENGTH) {
             $auth_error[] = $this->lang['register_email_long'];
         } elseif (strlen($email) < MIN_EMAIL_LENGTH) {
             $auth_error[] = $this->lang['register_email_short'];
         } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $auth_error[] = $this->lang['register_email_invalid'];
         }
         if (count($auth_error) == 0) {
             // Input is valid
             // Check DataBase to see if email user is activated
             $query = $this->db->select("SELECT * FROM " . PREFIX . "users WHERE email=:email AND isactive=0", array(':email' => $email));
             $count = count($query);
             if ($count != 0) {
                 // User Account Is not yet active.  Lets get data to resend their activation with new key
                 $username = $query[0]->username;
                 $activekey = $this->randomKey(RANDOM_KEY_LENGTH);
                 // Store the new key in the user's database
                 $this->db->update(PREFIX . 'users', array('activekey' => $activekey), array('username' => $username));
                 //EMAIL MESSAGE USING PHPMAILER
                 $mail = new \Helpers\PhpMailer\Mail();
                 $mail->setFrom(EMAIL_FROM);
                 $mail->addAddress($email);
                 $subject = " " . SITE_NAME . " - Account Activation Link";
                 $mail->subject($subject);
                 $body = "Hello {$username}<br/><br/>";
                 $body .= "You recently registered a new account on " . SITE_NAME . "<br/>";
                 $body .= "To activate your account please click the following link<br/><br/>";
                 $body .= "<b><a href=\"" . DIR . ACTIVATION_ROUTE . "?username={$username}&key={$activekey}\">Activate my account</a></b>";
                 $body .= "<br><br> You May Copy and Paste this URL in your Browser Address Bar: <br>";
                 $body .= " " . DIR . ACTIVATION_ROUTE . "?username={$username}&key={$activekey}";
                 $body .= "<br><br> You Requested to have this email resent to your email.";
                 $mail->body($body);
                 $mail->send();
                 $this->logActivity($username, "AUTH_REGISTER_SUCCESS", "Account created and activation email sent");
                 $this->success[] = $this->lang['register_success'];
                 return true;
             } else {
                 return false;
             }
         } else {
             //some error
             return false;
         }
     } else {
         // User is logged in
         $auth_error[] = $this->lang['register_email_loggedin'];
         return false;
     }
 }
Exemple #4
0
        week : {
            dow : 1
        }
    });      
</script>

</head>
<body class="<?php 
if (SITEENV != '') {
    echo 'navbar-top-xs-sm';
} else {
    echo 'navbar-top-sm';
}
?>
 <?php 
echo Cookie::get('navigation');
?>
 <?php 
echo $data['bodyClass'];
?>
">

<?php 
//hook for running code after body tag
$hooks->run('afterBody');
?>

	<?php 
include 'topbar.php';
?>
 public function navigationReload()
 {
     Cookie::set('navigation', $_POST['status']);
 }
Exemple #6
0
 /**
  * Register a new user into the database 
  * @param string $username
  * @param string $password
  * @param string $verifypassword
  * @param string $email
  * @return boolean
  */
 public function register($username, $password, $verifypassword, $email)
 {
     if (!Cookie::get('auth_session')) {
         // Input Verification :
         if (strlen($username) == 0) {
             $this->errormsg[] = $this->lang['register_username_empty'];
         } elseif (strlen($username) > MAX_USERNAME_LENGTH) {
             $this->errormsg[] = $this->lang['register_username_long'];
         } elseif (strlen($username) < MIN_USERNAME_LENGTH) {
             $this->errormsg[] = $this->lang['register_username_short'];
         }
         if (strlen($password) == 0) {
             $this->errormsg[] = $this->lang['register_password_empty'];
         } elseif (strlen($password) > MAX_PASSWORD_LENGTH) {
             $this->errormsg[] = $this->lang['register_password_long'];
         } elseif (strlen($password) < MIN_PASSWORD_LENGTH) {
             $this->errormsg[] = $this->lang['register_password_short'];
         } elseif ($password !== $verifypassword) {
             $this->errormsg[] = $this->lang['register_password_nomatch'];
         } elseif (strstr($password, $username)) {
             $this->errormsg[] = $this->lang['register_password_username'];
         }
         if (strlen($email) == 0) {
             $this->errormsg[] = $this->lang['register_email_empty'];
         } elseif (strlen($email) > MAX_EMAIL_LENGTH) {
             $this->errormsg[] = $this->lang['register_email_long'];
         } elseif (strlen($email) < MIN_EMAIL_LENGTH) {
             $this->errormsg[] = $this->lang['register_email_short'];
         } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $this->errormsg[] = $this->lang['register_email_invalid'];
         }
         if (count($this->errormsg) == 0) {
             // Input is valid
             $query = $this->db->select("SELECT * FROM users WHERE username=:username", array(':username' => $username));
             $count = count($query);
             if ($count != 0) {
                 // Username already exists
                 $this->logActivity("UNKNOWN", "AUTH_REGISTER_FAIL", "Username ({$username}) already exists");
                 $this->errormsg[] = $this->lang['register_username_exist'];
                 return false;
             } else {
                 // Username is not taken
                 $query = $this->db->select('SELECT * FROM users WHERE email=:email', array(':email' => $email));
                 $count = count($query);
                 if ($count != 0) {
                     // Email address is already used
                     $this->logActivity("UNKNOWN", "AUTH_REGISTER_FAIL", "Email ({$email}) already exists");
                     $this->errormsg[] = $this->lang['register_email_exist'];
                     return false;
                 } else {
                     // Email address isn't already used
                     $password = $this->hashPass($password);
                     $activekey = $this->randomKey(RANDOM_KEY_LENGTH);
                     $this->db->insert('users', array('username' => $username, 'password' => $password, 'email' => $email, 'activekey' => $activekey));
                     //EMAIL MESSAGE USING PHPMAILER
                     $mail = new \Helpers\PhpMailer\Mail();
                     $mail->setFrom(EMAIL_FROM);
                     $mail->addAddress($email);
                     $mail->subject(SITE_NAME);
                     $body = "Hello {$username}<br/><br/>";
                     $body .= "You recently registered a new account on " . SITE_NAME . "<br/>";
                     $body .= "To activate your account please click the following link<br/><br/>";
                     $body .= "<b><a href=\"" . BASE_URL . ACTIVATION_ROUTE . "?username={$username}&key={$activekey}\">Activate my account</a></b>";
                     $mail->body($body);
                     $mail->send();
                     $this->logActivity($username, "AUTH_REGISTER_SUCCESS", "Account created and activation email sent");
                     $this->successmsg[] = $this->lang['register_success'];
                     return true;
                 }
             }
         } else {
             //some error
             return false;
         }
     } else {
         // User is logged in
         $this->errormsg[] = $this->lang['register_email_loggedin'];
         return false;
     }
 }