示例#1
0
 /**
  * Get current language
  * @return mixed String abbreviation of current language
  */
 public static function getLanguage()
 {
     // check if cookie exist and language value in cookie is valid
     if (isset($_COOKIE['as_lang']) && self::isValidLanguage($_COOKIE['as_lang'])) {
         return $_COOKIE['as_lang'];
     } else {
         return ASSession::get('as_lang', DEFAULT_LANGUAGE);
     }
 }
/**
 * Get page where user should be redirected, based on user's role.
 * If there is no specific page set for provided role, redirect to default page.
 *
 * @return string Page where user should be redirected.
 */
function get_redirect_page()
{
    $login = new ASLogin();
    if ($login->isLoggedIn()) {
        $user = new ASUser(ASSession::get("user_id"));
        $role = $user->getRole();
    } else {
        $role = 'default';
    }
    $redirect = unserialize(SUCCESS_LOGIN_REDIRECT);
    if (!isset($redirect['default'])) {
        $redirect['default'] = 'index.php';
    }
    return isset($redirect[$role]) ? $redirect[$role] : $redirect['default'];
}
<?php

include "admin/ASEngine/AS.php";
if (!$login->isLoggedIn()) {
    redirect("login.php");
}
$user = new ASUser(ASSession::get("user_id"));
$userInfo = $user->getInfo();
require 'conf/data.php';
require 'includes/header.php';
require 'includes/nav.php';
require 'includes/modal.php';
?>
<div class="container">

<?php 
if (strlen($search) <= 1) {
    ?>

<br><br><br>
<h3>Search term "<?php 
    echo $search;
    ?>
" too short</h3><hr>

<?php 
} else {
    ?>
<h3>You searched for "<i><?php 
    echo $search;
    ?>
示例#4
0
文件: AS.php 项目: akrana1990/bmoc
<?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']);
}
示例#5
0
 /**
  * Log out user and destroy session.
  */
 public function logout()
 {
     ASSession::destroySession();
 }
function onlyAdmin()
{
    $login = new ASLogin();
    if (!$login->isLoggedIn()) {
        exit;
    }
    $loggedUser = new ASUser(ASSession::get("user_id"));
    if (!$loggedUser->isAdmin()) {
        exit;
    }
}
示例#7
0
				<li>
					<a href="/Fed/Production/index.php?id=<?php 
echo $previd;
?>
">Previous</a>
				</li>
				<li>
					<a href="/Fed/Production/index.php?id=<?php 
echo $nextid;
?>
">Next</a>
				</li>


<?php 
$userId = ASSession::get('user_id');
$user = new ASUser($userId);
?>



<li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?php 
echo ASLang::get('welcome');
?>
, <?php 
echo e($userInfo['username']);
?>
 <span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
<li>
示例#8
0
						<div class="control-group  form-group">
                            <label class="control-label col-lg-4" >Course, applied for<span class="required">*</span></label>
                            <div class="controls col-lg-8">
							<input name="fr_course" id="fr_course" value="Abacus_Education" type="radio" />Abacus Education  
                            <input name="fr_course" id="fr_course" value="Vedic_Maths" type="radio" /> Vedic Maths <br> 
							<input name="fr_course" id="fr_course" value="Abacus_Education-Vedic_Maths" type="radio" /> Both Abacus Education & Vedic Maths  
                            </div>
                        </div>	
                        <div class="control-group  form-group">
                            <label class="control-label col-lg-4" for="reg-bot-sum">
                                <?php 
echo ASSession::get("bot_first_number");
?>
 + 
                                <?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>
示例#9
0
<?php

include 'ASEngine/AS.php';
ASSession::destroySession();
header('Location: login.php');
<?php

require_once 'ASEngine/AS.php';
$provider = @$_GET['p'];
$token = @$_GET['token'];
if ($token == '' || $token == null || $token !== ASSession::get('as_social_token')) {
    ASSession::destroy('as_social_token');
    die('Wrong social auth token!');
}
if ($provider == '' || $provider == null) {
    die('Wrong provider.');
}
switch ($provider) {
    case 'twitter':
        if (!TWITTER_ENABLED) {
            die('This provider is not enabled.');
        }
        break;
    case 'facebook':
        if (!FACEBOOK_ENABLED) {
            die('This provider is not enabled.');
        }
        break;
    case 'google':
        if (!GOOGLE_ENABLED) {
            die('This provider is not enabled.');
        }
        break;
    default:
        die('This provider is not supported!');
}
 /**
  * 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 ASValidator();
     //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 is not empty
     if ($validator->isEmpty($user['password'])) {
         $errors[] = array("id" => $id['password'], "msg" => ASLang::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" => 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 ($validator->emailExist($user['email'])) {
         $errors[] = array("id" => $id['email'], "msg" => ASLang::get('email_taken'));
     }
     //check if username is available
     if ($validator->usernameExist($user['username'])) {
         $errors[] = array("id" => $id['username'], "msg" => ASLang::get('username_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;
 }
示例#12
0
<?php

include "ASEngine/AS.php";
if ($login->isLoggedIn()) {
    header("Location: index.php");
}
$token = $register->socialToken();
ASSession::set('as_social_token', $token);
$register->botProtection();
?>
<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="BMOC">
        <meta name="author" content="BMOC">
        <title>Login | BMOC</title>
        <script type="text/javascript" src="assets/js/jquery.min.js"></script>
        <link rel='stylesheet' href='assets/css/bootstrap.min3.css' type='text/css' media='all' />
        <script type="text/javascript" src="assets/js/bootstrap.min3.js"></script>
        <link rel='stylesheet' href='ASLibrary/css/style3.css' type='text/css' media='all' />
        <link href="assets/css/bootstrap-responsive.min.css" rel="stylesheet">
        <script type="text/javascript" src="assets/js/respond.min.js"></script>
        <script type="text/javascript">
            var SUCCESS_LOGIN_REDIRECT = "<?php 
echo SUCCESS_LOGIN_REDIRECT;
?>
";
            var $_lang = <?php 
示例#13
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;
 }