/**
  * Add new role into db.
  * @param $name Role name
  * @return array Response array that contains status (error or success) and message.
  */
 public function add($name)
 {
     $result = array();
     if (!$this->validator->roleExist($name)) {
         // role doesn't exist, create it
         $this->db->insert("as_user_roles", array("role" => strtolower(strip_tags($_POST['role']))));
         $result = array("status" => "success", "roleName" => strip_tags($_POST['role']), "roleId" => $this->db->lastInsertId());
     } else {
         // role exist, return error message
         $result = array("status" => "error", "message" => ASLang::get('role_taken'));
     }
     return $result;
 }
Example #2
0
 /**
  * Validate login fields
  * @param string $username User's username.
  * @param string $password User's password.
  * @return array Array with errors if there are some, empty array otherwise.
  */
 private function _validateLoginFields($username, $password)
 {
     $id = $_POST['id'];
     $errors = array();
     if ($username == "") {
         $errors[] = ASLang::get('username_required');
     }
     if ($password == "") {
         $errors[] = ASLang::get('password_required');
     }
     return $errors;
 }
Example #3
0
?>
                                    <b class="caret"></b>
                                </a>
                                <ul class="dropdown-menu">
                                    <li>
                                        <a href="profile.php">
                                            <i class="icon-user glyphicon glyphicon-user"></i> 
                                            <?php 
echo ASLang::get('my_profile');
?>
                                        </a>
                                    </li>
                                    <li class="divider"></li>
                                    <li>
                                        <a href="logout.php" id="logout">
                                            <i class="icon-off glyphicon glyphicon-off"></i> 
                                            <?php 
echo ASLang::get('logout');
?>
                                        </a>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                      </div>
                </div>
              </div>
            </div>
        
        
          <div class="container">
                                                <!-- Button -->
                                                <div class="controls col-lg-offset-4 col-lg-8">
                                                    <button id="btn-reset-pass" class="btn btn-success">
                                                        <?php 
    echo ASLang::get('reset_password');
    ?>
                                                    </button>
                                                </div>
                                            </div>
                                        </fieldset>
                                    </form>
                                <?php 
} else {
    ?>
                                    <?php 
    echo "<h5 class='text-error' style='text-align: center;'>" . ASLang::get('invalid_password_reset_key') . "</h5>";
    ?>
                                <?php 
}
?>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
            <script type="text/javascript" src="assets/js/sha512.js"></script>
            <script type="text/javascript" src="ASLibrary/js/asengine.js"></script>
            <script type="text/javascript" src="ASLibrary/js/passwordreset.js"></script>
            <script type="text/javascript">
                  	<td><?php 
    echo e($role['role']);
    ?>
</td>
                  	<td><?php 
    echo e($usersWithThisRole);
    ?>
</td>
                  	<td>
                  		<button type="button" class="btn btn-danger btn-sm" onclick="roles.deleteRole(this,<?php 
    echo $role['role_id'];
    ?>
);">
                  			<i class="icon-trash glyphicon glyphicon-trash"></i>
                            <?php 
    echo ASLang::get('delete');
    ?>
                  		</button>
                  	</td>
                  	
                  </tr>
              <?php 
}
?>
              </table>
          </div>

        </div>
    
    <?php 
include 'templates/footer.php';
Example #6
0
?>
 + 
                                <?php 
echo ASSession::get("bot_second_number");
?>
                                <span class="required">*</span>
                            </label>
                            <div class="controls col-lg-8">
                                <input type="text" id="reg-bot-sum" class="input-xlarge form-control">
                            </div>
                        </div>

                        <div class="control-group  form-group">
                            <div class="controls col-lg-offset-4 col-lg-8">
                                <button id="btn-register-student" class="btn btn-success"><?php 
echo ASLang::get('create_account');
?>
</button>
                            </div>
                        </div>
                       </fieldset>
                  </form>
                </div>
            </div>
          </div>
        </div>
                </div>
             </div>
        </div>

            <script type="text/javascript" src="assets/js/sha512.js"></script>
 </div>
        <div class="push"><!--//--></div>
    </div> <!-- end #wrap -->
    
    <footer class="footer">
      <div class="container">
       <p><?php 
echo ASLang::get('copyright_by');
?>
 &copy; <?php 
echo WEBSITE_NAME . " " . date("Y");
?>
</p>
      </div>
    </footer>
Example #8
0
                          <div class="control-group form-group">
                            <!-- Username -->
                            <label class="control-label col-lg-4"  for="forgot-password-email"><?php 
echo ASLang::get('your_email');
?>
</label>
                            <div class="controls col-lg-8">
                              <input type="email" id="forgot-password-email" class="input-xlarge form-control">
                            </div>
                          </div>

                          <div class="control-group form-group">
                            <!-- Button -->
                            <div class="controls col-lg-offset-4 col-lg-8">
                              <button id="btn-forgot-password" class="btn btn-success"><?php 
echo ASLang::get('reset_password');
?>
</button>
                            </div>
                          </div>
                        </fieldset>
                      </form>
                        
                  </div>
            </div>
          </div>
        </div>
                 </div>
             </div>
        </div>
            <script type="text/javascript" src="assets/js/sha512.js"></script>
Example #9
0
                        </div>
                        <div class="control-group form-group">
                             <div class="controls">
                                <button class="btn btn-success" id="comment">
                                  <?php 
    echo ASLang::get('comment');
    ?>
                                </button>
                            </div>
                        </div>
                    </div>
                    <?php 
} else {
    ?>
                        <p><?php 
    echo ASLang::get('you_cant_post');
    ?>
</p>
                    <?php 
}
?>
                    
        
              </div>
            </div>
        
    <?php 
include 'templates/footer.php';
?>

    <script src="ASLibrary/js/asengine.js" type="text/javascript" charset="utf-8"></script>
Example #10
0
 /**
  * Validate data provided during user update
  * @param $data
  * @return array
  */
 private function _validateUserUpdate($data)
 {
     $id = $data['fieldId'];
     $user = $data['userData'];
     $errors = array();
     $validator = new ASValidator();
     $userInfo = $this->getInfo();
     if ($userInfo == null) {
         $errors[] = array("id" => $id['email'], "msg" => ASLang::get('user_dont_exist'));
         return $errors;
     }
     //check if email is not empty
     if ($validator->isEmpty($user['email'])) {
         $errors[] = array("id" => $id['email'], "msg" => ASLang::get('email_required'));
     }
     //check if username is not empty
     if ($validator->isEmpty($user['username'])) {
         $errors[] = array("id" => $id['username'], "msg" => ASLang::get('username_required'));
     }
     //check if password and confirm password are the same
     if (!$user['password'] == hash('sha512', '') && $user['password'] != $user['confirm_password']) {
         $errors[] = array("id" => $id['confirm_password'], "msg" => ASLang::get('passwords_dont_match'));
     }
     //check if email format is correct
     if (!$validator->emailValid($user['email'])) {
         $errors[] = array("id" => $id['email'], "msg" => ASLang::get('email_wrong_format'));
     }
     //check if email is available
     if ($user['email'] != $userInfo['email'] && $validator->emailExist($user['email'])) {
         $errors[] = array("id" => $id['email'], "msg" => ASLang::get('email_taken'));
     }
     //check if username is available
     if ($user['username'] != $userInfo['username'] && $validator->usernameExist($user['username'])) {
         $errors[] = array("id" => $id['username'], "msg" => ASLang::get('username_taken'));
     }
     return $errors;
 }
Example #11
0
                        <div class="controls col-lg-9">
                          <input id="adduser-phone" name="adduser-phone" type="text" class="input-xlarge form-control" >
                        </div>
                      </div>
                  </form>
                </div>
                <div align="center" class="ajax-loading"><img src="assets/img/ajax_loader.gif" /></div>
                <div class="modal-footer">
                    <a href="javascript:void(0);" class="btn btn-default" data-dismiss="modal" aria-hidden="true">
                      <?php 
echo ASLang::get('cancel');
?>
                    </a>
                    <a href="javascript:void(0);" id="btn-add-user" class="btn btn-primary">
                      <?php 
echo ASLang::get('add');
?>
                    </a>
                </div>
              </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
          </div><!-- /.modal -->

        
        
        <script type="text/javascript" src="assets/js/sha512.js"></script>
        <script type="text/javascript" src="assets/js/jquery.dataTables.min.js"></script>
        <script type="text/javascript" src="assets/js/dataTables.bootstrap.js"></script>
        <?php 
if (BOOTSTRAP_VERSION == 2) {
    ?>
                            <h3><?php 
echo WEBSITE_NAME;
?>
</h3>
                        </div>
                        <div class="modal-body">
                            <div class="well">
                                <?php 
$key = $_GET['k'];
$result = $db->select("SELECT * FROM `as_users`\n                                         WHERE `confirmation_key` = :k", array("k" => $key));
if (count($result) == 1) {
    $db->update('as_users', array("confirmed" => "Y"), "`confirmation_key` = :k", array("k" => $key));
    echo "<h4 class='text-success'>" . ASLang::get('email_confirmed') . ".</h4>";
    echo "<h5 class='text-success'>" . ASLang::get('you_can_login_now', array('link' => 'login.php')) . "</h5>";
} else {
    echo "<h5 class='text-error'>" . ASLang::get('user_with_key_doesnt_exist') . "</h5>";
}
?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
         <script type="text/javascript">
                $(document).ready(function () {
                   $("#confirm-modal").modal({
                       keyboard: false,
                       backdrop: "static"
                   }); 
                });
Example #13
0
    echo ASLang::get('login_with');
    ?>
 Facebook"/>
                          </a>
                      <?php 
}
?>
                      <?php 
if (GOOGLE_ENABLED) {
    ?>
                          <a href="socialauth.php?p=google&token=<?php 
    echo $token;
    ?>
">
                              <img src="assets/img/gplus.png" class="fade high-opacity" alt="Google+" title="<?php 
    echo ASLang::get('login_with');
    ?>
 GooglePlus"/>
                          </a>
                      <?php 
}
?>
                  </div>
            </div>
          </div>
        </div>
                 </div>
             </div>
        </div>
            <script type="text/javascript" src="assets/js/sha512.js"></script>
            <script type="text/javascript" src="ASLibrary/js/asengine.js"></script>
Example #14
0
<?php

include_once 'ASConfig.php';
include_once 'ASSession.php';
include_once 'ASValidator.php';
include_once 'ASLang.php';
include_once 'ASRole.php';
include_once 'ASDatabase.php';
include_once 'ASEmail.php';
include_once 'ASLogin.php';
include_once 'ASRegister.php';
include_once 'ASUser.php';
include_once 'ASComment.php';
$db = ASDatabase::getInstance();
ASSession::startSession();
$login = new ASLogin();
$register = new ASRegister();
$mailer = new ASEmail();
if (isset($_GET['lang'])) {
    ASLang::setLanguage($_GET['lang']);
}
                          <div class="controls col-lg-8">
                            <input id="phone" name="phone" type="text" value="<?php 
echo e($userDetails['phone']);
?>
" class="input-xlarge form-control">
                            
                          </div>
                        </div>
                        
                        <!-- Button -->
                        <div class="control-group form-group">
                          <label class="control-label col-lg-4" for="update_details"></label>
                          <div class="controls col-lg-8">
                            <button id="update_details" name="update_details" class="btn btn-primary">
                              <?php 
echo ASLang::get('update');
?>
                            </button>
                          </div>
                        </div>
                        
                        </fieldset>
                    </form>


              </div>
            </div>

    <?php 
include 'templates/footer.php';
?>
Example #16
0
 /**
  * Validate user provided fields.
  * @param $data User provided fieds and id's of those fields that will be used for displaying error messages on client side.
  * @param bool $botProtection Should bot protection be validated or not
  * @return array Array with errors if there are some, empty array otherwise.
  */
 public function validateUser($data, $botProtection = true)
 {
     $id = $data['fieldId'];
     $user = $data['userData'];
     $errors = array();
     $validator = new Validator();
     //check if email is not empty
     if ($validator->isEmpty($user['email'])) {
         $errors[] = array("id" => $id['email'], "msg" => ASLang::get('email_required'));
     }
     //check if username is not empty
     if ($validator->isEmpty($user['username'])) {
         $errors[] = array("id" => $id['username'], "msg" => Lang::get('username_required'));
     }
     //check if password is not empty
     if ($validator->isEmpty($user['password'])) {
         $errors[] = array("id" => $id['password'], "msg" => Lang::get('password_required'));
     }
     //check if password and confirm password are the same
     if ($user['password'] != $user['confirm_password']) {
         $errors[] = array("id" => $id['confirm_password'], "msg" => Lang::get('passwords_dont_match'));
     }
     //check if email format is correct
     if (!$validator->emailValid($user['email'])) {
         $errors[] = array("id" => $id['email'], "msg" => Lang::get('email_wrong_format'));
     }
     //check if email is available
     if ($validator->emailExist($user['email'])) {
         $errors[] = array("id" => $id['email'], "msg" => Lang::get('email_taken'));
     }
     //check if username is available
     if ($validator->usernameExist($user['username'])) {
         $errors[] = array("id" => $id['username'], "msg" => Lang::get('username_taken'));
     }
     if ($botProtection) {
         //bot protection
         $sum = Session::get("bot_first_number") + Session::get("bot_second_number");
         if ($sum != intval($user['bot_sum'])) {
             $errors[] = array("id" => $id['bot_sum'], "msg" => Lang::get('wrong_sum'));
         }
     }
     return $errors;
 }
Example #17
0
 /**
  * Validate user provided fields.
  * @param $data User provided fieds and id's of those fields that will be used for displaying error messages on client side.
  * @param bool $botProtection Should bot protection be validated or not
  * @return array Array with errors if there are some, empty array otherwise.
  */
 public function validateUser($data, $validateFor, $botProtection = true)
 {
     $id = $data['fieldId'];
     $user = $data['userData'];
     $errors = array();
     $validator = new ASValidator();
     //check if email is not empty
     if ($validator->isEmpty($user['email'])) {
         $errors[] = array("id" => $id['email'], "msg" => ASLang::get('email_required'));
     }
     //check if email format is correct
     if (!$validator->emailValid($user['email'])) {
         $errors[] = array("id" => $id['email'], "msg" => ASLang::get('email_wrong_format'));
     }
     //check if email is available
     if ($validateFor == "student") {
         if ($validator->studentemailExist($user['email'])) {
             $errors[] = array("id" => $id['email'], "msg" => ASLang::get('student_email_taken'));
         }
     } elseif ($validateFor == "franchise") {
         if ($validator->franchiseemailExist($user['email'])) {
             $errors[] = array("id" => $id['email'], "msg" => ASLang::get('franchise_email_taken'));
         }
     }
     if ($botProtection) {
         //bot protection
         $sum = ASSession::get("bot_first_number") + ASSession::get("bot_second_number");
         if ($sum != intval($user['bot_sum'])) {
             $errors[] = array("id" => $id['bot_sum'], "msg" => ASLang::get('wrong_sum'));
         }
     }
     return $errors;
 }