Exemple #1
0
 public function create()
 {
     new Protect();
     $post = Input::post();
     echo '<pre>';
     if (!empty($post)) {
         if (Token::check($post['token'])) {
             Question::postQuestion($post);
             echo 'Posted';
         } else {
             echo 'Security token missing.';
         }
     } else {
         echo '
         <form method="post" action="">
             <input type="text" name="title" placeholder="Title">
             <input type="hidden" name="token" value="' . Token::generate() . '">
             <br>
             <textarea placeholder="Description" type="text" name="content"></textarea>
             <br>
             <input type="submit">
         </form>
     ';
     }
 }
Exemple #2
0
    public function RequesracallAction()
    {
        if (Input::exists() && Token::check(Input::get('token'))) {
            $this->_DB->insert('phones', array('id' => 0, 'name' => Input::get('name'), 'number' => Input::get('number')));
            $this->registerAction();
        }
        ?>
<form action="" method="post">
    <div class="field">
        <LABEL for="name">Name: </LABEL>
        <input
            type="text"
            name="name"
            id="name" />
    </div>
    <div class="field">
        <label for="number">Number: </label>
        <input
            type="tel"
            name="number"
            id="number" />
    </div>
    <input type="hidden" name="token" value="<?php 
        echo Token::generate();
        ?>
" />
    <input type="submit" value="Save"/>
</form>
        <?php 
    }
Exemple #3
0
 public function __construct()
 {
     $user_data = User::getUserData(['username', 'first_name', 'last_name', 'user_id', 'email', 'profile_pic'])[0];
     $this->data['title'] = 'Questions - NCube School';
     $this->data['first_name'] = ucwords($user_data['first_name']);
     $this->data['last_name'] = ucwords($user_data['last_name']);
     $this->data['token'] = Token::generate();
     $this->data['username'] = $user_data['username'];
     $this->data['side_active']['questions'] = ' active';
     $this->data['profile_pic'] = User::getProfilePic($user_data['profile_pic']);
     require_once 'include/header.php';
     $questions = Question::getPublicQuestions();
     foreach ($questions as $key => $value) {
         $questions[$key]['up_count'] = Question::getVoteUpCount($value['q_id']);
         $questions[$key]['down_count'] = Question::getVoteDownCount($value['q_id']);
         $questions[$key]['level'] = Question::getDifficultyLevel($value['q_id']);
         $questions[$key]['user_data'] = User::getPublicUserData($value['user_id'], ['profile_pic', 'first_name', 'last_name'])[0];
         $questions[$key]['answers'] = Question::getAnswersCount($value['q_id']);
         $questions[$key]['pic'] = User::getProfilePic($questions[$key]['user_data']['profile_pic']);
         $vote = Question::getVote($value['q_id']);
         if ($vote == 1) {
             $questions[$key]['my_data']['vote_up_class'] = 'vote-up-active';
         } else {
             if ($vote == 0) {
                 $questions[$key]['my_data']['vote_down_class'] = 'vote-down-active';
             }
         }
     }
     $this->data['questions'] = $questions;
 }
Exemple #4
0
 public function login($id = null)
 {
     $user = $this->user;
     $this->data['user']['name'] = $user->data()->user;
     Config::set('html.title', 'Авторизация');
     Config::set('html.description.val', 'На этой странице можно залогиниться');
     //$user = new User();
     $salt = uniqid();
     if (!Session::exists(Config::get('session.token_name'))) {
         Token::generate();
     }
     if (Input::exists()) {
         if (Token::check(Input::get('token'))) {
             $validate = new VALIDATE();
             $validation = $validate->check($_POST, array('user' => array('required' => true), 'password' => array('required' => true)));
             if ($validate->passed()) {
                 $remember = Input::get('remember') === 'on' ? true : false;
                 $login = $user->login(Input::get('user'), Input::get('password'), null);
                 if ($login) {
                     Redirect::to('/');
                 } else {
                     echo '<p>Sorry, logging in failed</p>';
                 }
             } else {
                 foreach ($validation->errors() as $error) {
                     //echo $error, '<br/>';
                     $this->data['validate_errors'][] = $error;
                 }
             }
         }
     }
     //$this->data['id']=$id;
     //$this->data['name']=Input::get('name');
     $this->view('user/login');
 }
Exemple #5
0
 public function __construct($url)
 {
     $user_data = User::getUserData(['username', 'first_name', 'last_name', 'user_id', 'email', 'profile_pic'])[0];
     $this->data['title'] = 'Question - NCube School';
     $this->data['first_name'] = ucwords($user_data['first_name']);
     $this->data['last_name'] = ucwords($user_data['last_name']);
     $this->data['token'] = Token::generate();
     $this->data['username'] = $user_data['username'];
     $this->data['side_active']['questions'] = ' active';
     $this->data['profile_pic'] = User::getProfilePic($user_data['profile_pic']);
     $this->data['question'] = Question::getPublicQuestion($url[0])[0];
     $this->data['q_user'] = User::getPublicUserData($this->data['question']['user_id'])[0];
     $this->data['q_user']['profile_pic'] = User::getProfilePic($this->data['q_user']['profile_pic']);
     $this->data['question']['up_count'] = Question::getVoteUpCount($this->data['question']['q_id']);
     $this->data['question']['down_count'] = Question::getVoteDownCount($this->data['question']['q_id']);
     $this->data['question']['level'] = Question::getDifficultyLevel($this->data['question']['q_id']);
     $this->data['question']['answers_count'] = Question::getAnswersCount($this->data['question']['q_id']);
     $answers = Question::getAnswers($this->data['question']['q_id']);
     foreach ($answers as $key => $value) {
         $answers[$key]['user'] = User::getPublicUserData($value['user_id'])[0];
         $answers[$key]['user']['profile_pic'] = User::getProfilePic($answers[$key]['user']['profile_pic']);
     }
     $this->data['answers'] = $answers;
     require_once 'include/header.php';
 }
 /**
  * Looks up user supplied email address / alias and sends a mail
  *
  * @param $email email address or username
  */
 function sendMail($in)
 {
     $in = trim($in);
     if (is_email($in)) {
         $user_id = UserFinder::byEmail($in);
     } else {
         $user_id = UserFinder::byUsername($in);
     }
     $error = ErrorHandler::getInstance();
     if (!$user_id) {
         $error->add('Invalid email address or username');
         return false;
     }
     $email = UserSetting::getEmail($user_id);
     if (!$email) {
         throw new \Exception('entered email not found');
     }
     $code = Token::generate($user_id, 'activation_code');
     $pattern = array('/@USERNAME@/', '/@IP@/', '/@URL@/', '/@EXPIRETIME@/');
     $user = User::get($user_id);
     $page = XmlDocumentHandler::getInstance();
     $url = $page->getUrl() . 'u/reset_pwd/' . $code;
     $replacement = array($user->getName(), client_ip(), $url, shortTimePeriod($this->expire_time_email));
     $msg = preg_replace($pattern, $replacement, $this->password_msg);
     //d($msg);
     $mail = SendMail::getInstance();
     $mail->addRecipient($email);
     $mail->setSubject('Forgot password');
     $mail->send($msg);
     return true;
 }
Exemple #7
0
 public function test1()
 {
     // TODO make proper test
     $tok = new Token();
     $val = $tok->generate(1000, 'bajs');
     echo $val . "\n";
 }
Exemple #8
0
 public function __construct()
 {
     $user_data = User::getUserData(['username', 'first_name', 'last_name', 'user_id', 'email', 'profile_pic'])[0];
     $this->data['title'] = 'Home - NCube School';
     $this->data['first_name'] = ucwords($user_data['first_name']);
     $this->data['last_name'] = ucwords($user_data['last_name']);
     $this->data['token'] = Token::generate();
     $this->data['username'] = $user_data['username'];
     $this->data['side_active']['home'] = ' active';
     $this->data['profile_pic'] = User::getProfilePic($user_data['profile_pic']);
     require_once 'include/header.php';
 }
Exemple #9
0
 public function __construct()
 {
     $this->data['title'] = 'Login - NCube School';
     $this->data['loginAction'] = '/login';
     $this->data['registerAction'] = '/register';
     $this->data['token'] = Token::generate();
     $errors = Session::errors('errors');
     if (gettype($errors) === 'string') {
         $errors = array($errors);
     }
     $this->data['errors'] = $errors;
 }
Exemple #10
0
    public function create($Model)
    {
        $this->Model = $Model;
        echo '<p style="color:#FF0F13;">' . $this->errors() . '</p>';
        echo '<form action="" method="post">
				<input type="text" placeholder="username" name="Username" value="' . escape(\Input::get("username")) . '">
				<input type="password" placeholder="password" name="Password">
				<br>
				<span>Remember me:</span><input type="checkbox" name="remember">
				<br>
				<input type="hidden" name="token" value="' . \Token::generate() . '">

				<input type="submit">
			</form>';
    }
Exemple #11
0
    public function create($Model)
    {
        $this->Model = $Model;
        if ($this->Model->hasErrors()) {
            echo '<p style="color:#FF0F13;">' . $this->errors($this->Model->getErrors()) . '</p>';
        }
        echo '<form action="" method="post">
				<input type="text" placeholder="Username" name="Username" value="' . escape(\Input::get("username")) . '"><br>
				<input type="password" placeholder="Password" name="Password"><br>
				<input type="password" placeholder="Repeat Password" name="Password2"><br>
				<br>
				<input type="hidden" name="token" value="' . \Token::generate() . '">

				<input type="submit">
			</form>';
    }
Exemple #12
0
 public function __construct($url)
 {
     $user_data = User::getUserData(['username', 'first_name', 'last_name', 'user_id', 'email', 'profile_pic'])[0];
     $this->data['title'] = 'Requests - NCube School';
     $this->data['first_name'] = ucwords($user_data['first_name']);
     $this->data['last_name'] = ucwords($user_data['last_name']);
     $this->data['email'] = $user_data['email'];
     $this->data['token'] = Token::generate();
     $this->data['username'] = $user_data['username'];
     $this->data['url'] = $url;
     require_once 'include/header.php';
     $this->data['side_active']['requests'] = ' active';
     $this->data['profile_pic'] = User::getProfilePic($user_data['profile_pic']);
     $user_id = Session::get('user_id');
     $requests = User::getRequests();
     foreach ($requests as $key => $value) {
         $requests[$key]['user_data'] = User::getPublicUserData($value['user_id'])[0];
         if (empty($value['user_data']['profile_pic'])) {
             $requests[$key]['user_data']['profile_pic'] = '/public/images/profile-pic.png';
         } else {
             $requests[$key]['user_data']['profile_pic'] = '/data/images/profile/' . $value['user_data']['profile_pic'] . '.jpg';
         }
         switch ($value['type']) {
             case 'C':
                 $requests[$key]['type'] = 'Classmate';
                 break;
             case 'T':
                 $requests[$key]['type'] = 'Teacher';
                 break;
             case 'S':
                 $requests[$key]['type'] = 'Student';
                 break;
             case 'F':
                 $requests[$key]['type'] = 'Friend';
                 break;
             case 'P':
                 $requests[$key]['type'] = 'Parent or Guardian';
                 break;
             default:
                 $requests[$key]['type'] = '';
                 break;
         }
     }
     $this->data['requests'] = $requests;
 }
Exemple #13
0
 public function __construct($url)
 {
     $user_data = User::getUserData(['username', 'first_name', 'last_name', 'user_id', 'email', 'profile_pic'])[0];
     $this->data['title'] = 'Settings - NCube School';
     $this->data['first_name'] = ucwords($user_data['first_name']);
     $this->data['last_name'] = ucwords($user_data['last_name']);
     $this->data['email'] = $user_data['email'];
     $this->data['token'] = Token::generate();
     $this->data['username'] = $user_data['username'];
     $this->data['url'] = $url;
     require_once 'include/header.php';
     $this->data['side_active']['settings'] = ' active';
     $this->data['active'] = NULL;
     if (!empty($url[0])) {
         $this->data['active'][$url[0]] = ' stngs-menu-item-active';
     }
     $this->data['profile_pic'] = User::getProfilePic($user_data['profile_pic']);
 }
Exemple #14
0
 public function __construct($username)
 {
     $user_id = Session::get('user_id');
     $user_data = User::getPublicUserData($user_id)[0];
     $this->data['title'] = ucwords($username);
     $this->data['username'] = $user_data['username'];
     $this->data['token'] = Token::generate();
     $this->data['side_active']['profile'] = ' active';
     require_once 'include/header.php';
     $this->data['first_name'] = ucwords($user_data['first_name']);
     $this->data['last_name'] = ucwords($user_data['last_name']);
     $this->data['email'] = $user_data['email'];
     $this->data['profile_pic'] = User::getProfilePic($user_data['profile_pic']);
     $profile_id = User::getPublicUserId($username);
     $profile_data = User::getPublicUserData($profile_id)[0];
     $this->data['profile_data']['username'] = $username;
     $this->data['profile_data']['first_name'] = ucwords($profile_data['first_name']);
     $this->data['profile_data']['last_name'] = ucwords($profile_data['last_name']);
     $this->data['profile_data']['email'] = $profile_data['email'];
     $this->data['profile_data']['profile_pic'] = User::getProfilePic($profile_data['profile_pic']);
     $this->data['profile_data']['follow'] = User::checkFollow($username);
     $this->data['profile_data']['dob'] = $profile_data['dob'];
     //date in mm/dd/yyyy format; or it can be in other formats as well
     $birthDate = $profile_data['dob'];
     //explode the date to get month, day and year
     $birthDate = explode("-", $birthDate);
     //get age from date or birthdate
     $this->data['profile_data']['age'] = date("md", date("U", mktime(0, 0, 0, $birthDate[2], $birthDate[1], $birthDate[0]))) > date("md") ? date("Y") - $birthDate[0] - 1 : date("Y") - $birthDate[0];
     $this->data['profile_data']['country'] = $profile_data['country'];
     switch ($profile_data['gender']) {
         case 'M':
             $this->data['profile_data']['gender'] = 'Male';
             break;
         case 'F':
             $this->data['profile_data']['gender'] = 'Female';
             break;
         case 'O':
             $this->data['profile_data']['gender'] = 'Others';
             break;
         default:
             break;
     }
 }
Exemple #15
0
 public static function create()
 {
     // TODO: Remplacer 'root' par '' en prod absolument !!
     $public_key = $_SERVER['HTTP_X_PUBLIC_KEY'] ?? 'root';
     // TODO: Remplacer 'hash_hmac(...)' par '' en prod absolument !!
     $received_hash = $_SERVER['HTTP_X_HASH'] ?? hash_hmac('sha256', 'root', 'root');
     if (Client::exists('public_key', $public_key)) {
         $client = Client::getBy('public_key', $public_key);
         $expected_hash = hash_hmac('sha256', $client->name, $client->private_key);
         if ($received_hash == $expected_hash) {
             $token = Token::generate();
             $ttl = 600;
             Token::insertIntoDb([$token, Utils::time(), $ttl, $client->id]);
             Data::get()->add('token', $token);
             return null;
         }
     }
     Data::get()->add('error', 'Wrong keypair');
 }
Exemple #16
0
 public function __construct($url)
 {
     $user_data = User::getUserData(['username', 'first_name', 'last_name', 'user_id', 'email', 'profile_pic'])[0];
     $this->data['first_name'] = ucwords($user_data['first_name']);
     $this->data['last_name'] = ucwords($user_data['last_name']);
     $this->data['side_active']['messages'] = ' active';
     $this->data['profile_pic'] = User::getProfilePic($user_data['profile_pic']);
     require_once 'include/header.php';
     $this->data['title'] = 'Messages - Ncube';
     $this->data['token'] = Token::generate();
     $this->data['active_username'] = $url[0];
     $this->data['list_data'] = User::getAcceptedUsersData();
     if (!empty($url[0])) {
         $data = Message::getMessages($url[0]);
         foreach ($data as $key => $value) {
             $data[$key]['time'] = date("h:i A", $value['time']);
         }
         $this->data['msgs'] = $data;
     }
     $this->data['recipient'] = $url[0];
 }
Exemple #17
0
 public function request()
 {
     new Protect();
     $post = Input::post();
     $token = Token::check($post['token']);
     if (isset($post['type']) && !empty($post['type'] && $token === TRUE)) {
         $request = User::request($post);
         if ($request !== TRUE) {
             return $request;
         } else {
             return TRUE;
         }
     } else {
         if (!empty($post['username'] && $token === TRUE)) {
             echo '
                 <form action="/profile/' . $post['username'] . '/request" method="post">
                     <input type="hidden" name="token" value="' . Token::generate() . '">
                     <input type="hidden" name="username" value="' . $post['username'] . '">
                     <select name="type">
                     <option value="C">Classmate</option>
                     <option value="T">Teacher</option>
                     <option value="S">Student</option>
                     <option value="F">Friend</option>
                     <option value="P">Parent or Guardian</option>
                     </select>
                     <input type="submit" value="Send Request">
                 </form>
             ';
         } else {
             if (!$token) {
                 return 'Security Token Missing';
             } else {
                 Redirect::to('/profile');
             }
         }
     }
 }
                    foreach ($validation->errors() as $error) {
                        echo '<i class="fa fa-exclamation-triangle"></i>&nbsp;&nbsp;', $error, '<br>';
                        echo '<br />';
                    }
                } 

            }
        }
        ?>
        <p>
            <label for="username">USERNAME</label>
            <input type="text" name="username" id="username" value="<?php echo escape(Input::get('username')); ?>">
        </p>
        <p>
            <label for="password">PASSWORD</label>
            <input type="password" name="password" id="password">
        </p>
        <p>
            <input type="checkbox" name="remember" id="remember">
            <label for="remember">Remember me for 1 month</label>
        </p>
        </div>

        <input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
        <p class="p-container">
            <span>Forgot password?</span>
            <input type="submit" name="go" id="go" value="Log in">
        </p>
    </form>
</body>
</html>
Exemple #19
0
}
$breadcrumbs_string = '<li><a href="/forum">' . $forum_language['home'] . '</a></li>';
foreach (array_reverse($breadcrumbs) as $breadcrumb) {
    if (isset($breadcrumb['active'])) {
        $breadcrumbs_string .= '<li class="active">' . htmlspecialchars($breadcrumb['forum_title']) . '</li>';
    } else {
        $breadcrumbs_string .= '<li><a href="/forum/view_forum/?fid=' . $breadcrumb['id'] . '">' . htmlspecialchars($breadcrumb['forum_title']) . '</a></li>';
    }
}
$smarty->assign('BREADCRUMBS', $breadcrumbs_string);
// Search bar
$search = '
	<form class="form-horizontal" role="form" method="post" action="/forum/search/">
	  <div class="input-group">
	    <input type="text" class="form-control input-sm" name="forum_search" placeholder="' . $general_language['search'] . '">
		<input type="hidden" name="token" value="' . Token::generate() . '">
	    <span class="input-group-btn">
		  <button type="submit" class="btn btn-default btn-sm">
            <i class="fa fa-search"></i>
          </button>
	    </span>
	  </div>
	</form>
	';
$smarty->assign('SEARCH_FORM', $search);
// List online users
$online_users = $queries->getWhere('users', array('last_online', '>', strtotime("-10 minutes")));
if (count($online_users)) {
    $online_users_string = '';
    foreach ($online_users as $online_user) {
        $online_users_string .= '<a href="/profile/' . htmlspecialchars($online_user->username) . '">' . htmlspecialchars($online_user->username) . '</a>, ';
Exemple #20
0
 /**
  * Create token for the test
  *
  * @param $id
  */
 public function createAction($id)
 {
     if (!Auth::user()) {
         return Redirect::route('admin');
     }
     $test = Test::find($id);
     if (is_null($test)) {
         return Redirect::route('info')->with('message', 'Тест не найден');
     }
     $token = new Token();
     $token->token = $token->generate($test->name);
     $token->test_id = $id;
     $token->save();
     return View::make('test.token', ['token' => $token->token]);
 }
Exemple #21
0
// Constants for users group status
define('NO_PERMISSIONS', 1);
define('ADMIN', 2);
define('OWNER', 3);
require '../../classes/DB.php';
require '../../classes/Base_Account.php';
require '../../classes/User.php';
require '../../classes/Post_Manager.php';
require '../../classes/Session.php';
require '../../classes/Token.php';
if (isset($_POST['task']) && $_POST['task'] == 'post-submit') {
    if (Token::check($_POST['token'])) {
        // data to be encoded as JSON and passed back to client:
        $data = [];
        // need to generate new session token as we've just consumed the previous one:
        $new_token = Token::generate();
        // get instance of the post_manager:
        $pm = Post_Manager::getInstance();
        // user submitting the post:
        $user = new User($_POST['user']);
        // target of the post:
        // @TODO: switch target_type to instantiate the target as the appropriate type
        $target = new User($_POST['target']);
        // The target type (user, music, dance, comedy):
        // @TODO: this will be used to properly instantiate the target object
        $target_type = $_POST['target_type'];
        // The actual post with line breaks preserved:
        $post = str_replace("\n", "<br/>", $_POST['post']);
        if ($user->exists() && $target->exists()) {
            $post_info = $pm->create_post($user, $target, $target_type, $post);
            if ($post_info) {
Exemple #22
0
            ?>
                <script type="text/javascript">parent.GB_hide();</script>
                <?php 
        }
        if ($is_my_profile) {
            $url = "user_form.php?login={$login}";
            $url .= $msg != NULL ? "&msg={$msg}" : '';
            if ($exp_user != '') {
                $url .= "&action=expire_session&token=" . Token::generate('tk_f_users');
            }
        } else {
            $url = 'users.php';
            $url .= $msg != NULL ? "?msg={$msg}" : '';
            if ($exp_user != '') {
                $url .= $msg != NULL ? '&' : '?';
                $url .= "action=expire_session&user_id={$exp_user}&token=" . Token::generate('tk_f_users');
            }
        }
        ?>
            <script type='text/javascript'>document.location.href="<?php 
        echo $url;
        ?>
"</script>
            <?php 
    }
} else {
    $db->close();
    if ($greybox) {
        $config_nt = array('content' => _('Invalid action - Operation cannot be completed'), 'options' => array('type' => 'nf_error', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto; text-align: left;');
        $nt = new Notification('nt_1', $config_nt);
        $nt->show();
Exemple #23
0
<?php

require_once 'app/init.php';
if (!isset($_SESSION['user'])) {
    header('Location: login.php');
}
if (isset($_POST['updateName'])) {
    $User = new User_Name();
    $User->changeName();
}
if (isset($_POST['submitName'])) {
    $User = new User_Name();
    $User->createName();
}
$Token = new Token();
$token = $Token->generate();
?>

<!doctype html>

<html>
    <head>
    
    </head>
    
    <body>
        <?php 
if (isset($_SESSION['alert'])) {
    echo $_SESSION['alert'];
    unset($_SESSION['alert']);
}
<!DOCTYPE html>
<html>
<head>
	<title>Edit your profile - Egerton Campus Life</title>
	<link rel="stylesheet" type="text/css" href="http://localhost/userlr/assets/bootstrap/css/bootstrap.min.css">
</head>
<body>
	<div class="container">
		<div class="row">
			<form class="form" role="form" method="post" action="<?php 
echo htmlspecialchars($_SERVER['PHP_SELF']);
?>
">
			<div class="form-group">
				<label class="control-label" for="name">Change your name</label>
				<input type="text" class="form-control" maxlength="20" max="20" name="name" id="name" value="<?php 
print $user->data()->name;
?>
" required autofocus>		
			</div>
			<input type="hidden" name="token" value="<?php 
print Token::generate();
?>
" >
			<input type="submit" class="btn btn-lg btn-block btn-success" name="edit" value="save changes">	
			</form>
		</div>
	</div>

</body>
</html>
Exemple #25
0
 public function _index($url)
 {
     new Protect();
     if (!empty($url[0])) {
         if (!Group::publicGroupExists($url[0])) {
             // Set Header for 404
             header("HTTP/1.0 404 Not Found");
             echo 'Group Not Found or private group';
         } else {
             if ($url[1] === 'join') {
                 $post = Input::post();
                 $id = $url[0];
                 $token = Token::check($post['token']);
                 if (!empty($post) && $token === TRUE) {
                     if (Group::joinAsMember($id)) {
                         echo 'Requested';
                     } else {
                         echo 'Already Requested';
                     }
                 } else {
                     if (empty($post)) {
                         echo '
                         <form method="post" action="">
                             <input type="hidden" value="' . Token::generate() . '" name="token">
                             <button type="submit" class="btn btn-secondary"><i class="fa fa-user-plus"></i> Join</button>
                         </form>
                     ';
                     } elseif ($token === FALSE) {
                         echo 'Security Token Missing';
                     }
                 }
             } elseif ($url[1] === 'accept') {
                 if (!empty(Input::post('username'))) {
                     if (Token::check(Input::post('token'))) {
                         Group::acceptUser($url[0]);
                         echo 'Accepted';
                     } else {
                         echo 'Security Token Missing';
                     }
                 } else {
                     echo 'Username Required';
                 }
             } elseif ($url[1] === 'reject') {
                 if (!empty(Input::post('username'))) {
                     if (Token::check(Input::post('token'))) {
                         Group::rejectUser($url[0]);
                         echo 'Rejected';
                     } else {
                         echo 'Security Token Missing';
                     }
                 } else {
                     echo 'Username Required';
                 }
             } else {
                 self::init('GroupModel', 'group', $url);
             }
         }
     } else {
         self::init('GroupsListModel', 'groupsList', $url);
     }
 }
 /**
  * Generate authentication token.
  *
  * @param string $url URL for authenticate.
  * @param string $secret Secret key used for generate token. Leave empty to use secret from
  * config (Yii::$app->params['simpleauth']['secret']).
  * @return string
  */
 public static function generateAuthToken($url, $secret = null)
 {
     $time = time();
     return Token::generate($url, $time, $secret) . '_' . $time;
 }
Exemple #27
0
                    }
                } else {
                    echo 'Invalid token - <a href="/admin/vote">Back</a>';
                    die;
                }
            }
            if (!is_numeric($_GET["vid"])) {
                echo 'Error - <a href="/admin/vote">Back</a>';
                die;
            } else {
                $site = $queries->getWhere("vote_sites", array("id", "=", $_GET["vid"]));
            }
            if (count($site)) {
                $site = $site[0];
                echo '<h2>' . htmlspecialchars($site->name) . '</h2>';
                $token = Token::generate();
                ?>
					<form role="form" action="" method="post">
					  <div class="form-group">
						<label for="InputName">Name</label>
						<input type="text" name="vote_name" class="form-control" id="InputName" placeholder="Name" value="<?php 
                echo htmlspecialchars($site->name);
                ?>
">
					  </div>
					  <div class="form-group">
					    <label for="InputURL">URL</label>
						<input type="text" name="vote_url" id="InputURL" placeholder="URL" class="form-control" value="<?php 
                echo htmlspecialchars($site->site);
                ?>
">
Exemple #28
0
}
$form_content .= '" tabindex="1">
</div>' . PHP_EOL . '<div class="form-group">
    <input type="password" name="password" id="password" class="form-control input-lg" placeholder="' . $user_language['password'] . '" tabindex="2">
</div>' . PHP_EOL . '<div class="row">
	<div class="col-xs-12 col-md-6">
		<div class="form-group">
			<label for="remember">
				<input type="checkbox" name="remember" id="remember"> ' . $user_language['remember_me'] . '
			</label>				
		</div>
	</div>
	<div class="col-xs-12 col-md-6">
		<span class="pull-right"><a class="btn btn-sm btn-primary" href="/forgot_password">' . $user_language['forgot_password'] . '</a></span>
	</div>
</div>' . PHP_EOL . '<input type="hidden" name="token" value="' . Token::generate() . '">';
$submit = '<button type="submit" class="btn btn-primary btn-block btn-lg">' . $user_language['sign_in'] . '</button>';
// Smarty variables
$smarty->assign('SIGNIN', $user_language['sign_in']);
$smarty->assign('REGISTER', $user_language['register']);
$smarty->assign('FORM_CONTENT', $form_content);
$smarty->assign('FORM_SUBMIT', $submit);
if (isset($return_error)) {
    $smarty->assign('SESSION_FLASH', $return_error);
} else {
    $smarty->assign('SESSION_FLASH', '');
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
Exemple #29
0
</label>
			  <input type="text" class="form-control" id="<?php 
                echo htmlspecialchars($question->name);
                ?>
" name="<?php 
                echo $question->id;
                ?>
"><br />
			<?php 
            }
        }
    }
    ?>
			  <br />
			  <input type="hidden" name="token" value="<?php 
    echo Token::generate();
    ?>
">
			  <input type="submit" class="btn btn-primary" value="<?php 
    echo $general_language['submit'];
    ?>
">
			</form>
		  </div>
		</div>
		<?php 
} else {
    if (Session::exists('app_success')) {
        echo Session::flash('app_success');
    }
    if ($completed === 2) {
Exemple #30
0
* of the GNU General Public License.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this package; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA  02110-1301  USA
*
*
* On Debian GNU/Linux systems, the complete text of the GNU General
* Public License can be found in `/usr/share/common-licenses/GPL-2'.
*
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt
*
*/
require_once 'av_init.php';
Session::useractive('../session/login.php');
$f_name = POST('f_name');
ossim_valid($f_name, OSS_ALPHA, OSS_SCORE, 'illegal:' . _('Form name'));
$data['status'] = 'OK';
if (ossim_error()) {
    $data['status'] = 'error';
    $data['data'] = ossim_get_error_clean();
} else {
    $data['data'] = Token::generate('tk_' . $f_name);
}
echo json_encode($data);