本文整理汇总了PHP中validate_session函数的典型用法代码示例。如果您正苦于以下问题:PHP validate_session函数的具体用法?PHP validate_session怎么用?PHP validate_session使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate_session函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
view()->composer(['main', 'main_wo_header_nav', 'category_items'], function ($view) {
$this->user_session = validate_session();
//fetch all the categories
$arrCategory = DB::table('category_master')->get();
//fetch all the item types
$arrType = DB::table('type_master')->get();
foreach ($arrCategory as $key => $category) {
foreach ($arrType as $key1 => $type) {
if ($type->category == $category->cat_id) {
$arrTypeCategoryWise[$category->cat_id][] = $type;
}
}
}
//get category id versus category name array
$arrCetegory_id_name = getKeyValueArray('cat_id', 'name', $arrCategory, 'object');
$arrType_id_name = getKeyValueArray('type_id', 'name', $arrType, 'object');
//get cart items count
if ($this->user_session->is_logged_in) {
$user_id = $this->user_session->user_id;
} else {
$user_id = null;
}
//get cart details
if ($this->user_session->is_logged_in) {
$count_cart = DB::connection('mongodb')->collection('cart')->where('user_id', $user_id)->orWhere('session_id', session_id())->count();
} else {
$count_cart = DB::connection('mongodb')->collection('cart')->where('session_id', session_id())->count();
}
$view->with(compact('count_cart', 'arrTypeCategoryWise', 'arrCategory', 'arrType', 'arrCetegory_id_name', 'arrType_id_name'));
});
}
示例2: __construct
function __construct()
{
session_start();
$this->user_session = validate_session();
$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
$web_root = $protocol . $_SERVER['HTTP_HOST'];
define('WEB_ROOT', $web_root);
define('DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT']);
}
示例3: validate_session
function &login()
{
// Check if there is still a valid session
validate_session(true);
// Create the HTML array and initialize values
$HTML = array();
$HTML['email'] = '';
$HTML['datepicker'] = '';
$HTML['login_error'] = '';
// Check if it was a page load or a submission
if (getRequest('submitted', true, 'post') !== 'yes') {
return $HTML;
}
// It was a page load so get the post values
foreach ($HTML as $key => &$value) {
$value = getRequest($key, true, 'post');
}
// Validate the email and password
$date = explode('-', $HTML['datepicker']);
if (empty($HTML['email'])) {
$HTML['login_error'] = 'Email Cannot be empty';
} elseif (empty($HTML['datepicker'])) {
$HTML['login_error'] = 'Date of birth cannot be empty';
} elseif (filter_var($HTML['email'], FILTER_VALIDATE_EMAIL) === false) {
$HTML['login_error'] = 'Invalid Email Address';
} else {
// The datepicker makes sure it is a valid date
// But should still check incase someone scripts a request
if (count($date) != 3 or !checkdate(intval($date[0]), intval($date[1]), intval($date[2]))) {
$HTML['login_error'] = "Invalid Date";
}
}
// If no errors, set session variable and go to account
if (empty($HTML['login_error'])) {
// Create a database record
if (empty($GLOBALS['DB'])) {
die('Database Link is not set');
}
$query = sprintf('INSERT INTO project (email, dob, ipaddr) VALUES (\'%s\',\'%s\',\'%s\')', mysql_real_escape_string($HTML['email']), mysql_real_escape_string($date[2] . '-' . $date[0] . '-' . $date[1]), mysql_real_escape_string(util_getenv('REMOTE_ADDR')));
$result = mysql_query($query);
// Make sure it executed properly
if (!$result) {
$HTML['login_error'] = 'Database Error. Please try again later';
return $HTML;
}
set_SESSION('dob', $HTML['datepicker']);
set_header('app');
exit;
}
// There were errors so load the login page again with errors
return $HTML;
}
示例4: start_session
function start_session($conn)
{
//DEBUG
//END DEBUG
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$time = time();
if (!isset($_COOKIE['token'])) {
$workerId = $_GET['workerId'];
$assignmentId = $_GET['assignmentId'];
$timeExpire = $time + 3600;
$turkSubmitTo = $_GET['turkSubmitTo'];
$token = create_token($workerId, $userAgent, $time);
set_app_cookies($token, $workerId, $turkSubmitTo, $timeExpire);
store_session($conn, $assignmentId, $workerId, $timeExpire, $time, $userAgent, $token);
} else {
$truth = validate_session($conn, $_COOKIE['token'], $_COOKIE['workerId'], $userAgent);
if (!$truth) {
//GOTO FAIL
echo 'failed';
header('Location: /gotofail.html');
}
}
}
示例5: login_sequence
function login_sequence($link, $login_form = 0)
{
$_SESSION["prefs_cache"] = false;
if (SINGLE_USER_MODE) {
authenticate_user($link, "admin", null);
cache_prefs($link);
load_user_plugins($link, $_SESSION["uid"]);
} else {
if (!$_SESSION["uid"] || !validate_session($link)) {
if (AUTH_AUTO_LOGIN && authenticate_user($link, null, null)) {
$_SESSION["ref_schema_version"] = get_schema_version($link, true);
} else {
authenticate_user($link, null, null, true);
}
if (!$_SESSION["uid"]) {
render_login_form($link, $login_form);
}
} else {
/* bump login timestamp */
db_query($link, "UPDATE ttrss_users SET last_login = NOW() WHERE id = " . $_SESSION["uid"]);
}
if ($_SESSION["uid"] && $_SESSION["language"] && SESSION_COOKIE_LIFETIME > 0) {
setcookie("ttrss_lang", $_SESSION["language"], time() + SESSION_COOKIE_LIFETIME);
}
if ($_SESSION["uid"]) {
cache_prefs($link);
load_user_plugins($link, $_SESSION["uid"]);
}
}
}
示例6: RegExp
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
</script>
</head>
<body>
<?php
// Logged in?
if ($_SESSION["uid"] && validate_session()) {
?>
<!-- Show form -->
<form id="gritttt-form" method="post" action="">
<div id="gritttt-logo">
<a href="http://gritttt-rss.nicolashoening.de/" target="_blank">
<img src="./gritttt-logo.png" alt="Go to Home of Gritttt" title="Go to Home of Gritttt"/>
</a>
</div>
<div id="gritttt-heading">Share this page in your tt-rss:</div>
<br/>
<input id="gritttt-url" name="gritttt-url" type="hidden" size="40" name="url"></input>
<div id="gritttt-row-title">
<label for="gritttt-title">Title:</label>
<input id="gritttt-title" name="gritttt-title" type="text" size="60" name="title"></input>
</div>
示例7: login_sequence
function login_sequence($link, $mobile = false)
{
if (!SINGLE_USER_MODE) {
$login_action = $_POST["login_action"];
# try to authenticate user if called from login form
if ($login_action == "do_login") {
$login = $_POST["login"];
$password = $_POST["password"];
$remember_me = $_POST["remember_me"];
if (authenticate_user($link, $login, $password)) {
$_POST["password"] = "";
$_SESSION["language"] = $_POST["language"];
$_SESSION["ref_schema_version"] = get_schema_version($link, true);
$_SESSION["bw_limit"] = !!$_POST["bw_limit"];
if ($_POST["profile"]) {
$profile = db_escape_string($_POST["profile"]);
$result = db_query($link, "SELECT id FROM ttrss_settings_profiles\n\t\t\t\t\t\t\tWHERE id = '{$profile}' AND owner_uid = " . $_SESSION["uid"]);
if (db_num_rows($result) != 0) {
$_SESSION["profile"] = $profile;
$_SESSION["prefs_cache"] = array();
}
}
header("Location: " . $_SERVER["REQUEST_URI"]);
exit;
return;
} else {
$_SESSION["login_error_msg"] = __("Incorrect username or password");
}
}
if (!$_SESSION["uid"] || !validate_session($link)) {
render_login_form($link, $mobile);
//header("Location: login.php");
exit;
} else {
/* bump login timestamp */
db_query($link, "UPDATE ttrss_users SET last_login = NOW() WHERE id = " . $_SESSION["uid"]);
if ($_SESSION["language"] && SESSION_COOKIE_LIFETIME > 0) {
setcookie("ttrss_lang", $_SESSION["language"], time() + SESSION_COOKIE_LIFETIME);
}
/* bump counters stamp since we're getting reloaded anyway */
$_SESSION["get_all_counters_stamp"] = time();
}
} else {
return authenticate_user($link, "admin", null);
}
}
示例8: validate_session
<?php
require_once 'globals.php';
validate_session('tutor_licom');
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sistema de pasantías.</title>
<link href="css/estilo.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<div class="header">
<?php
include "include/cabecera.php";
?>
</div>
<?php
require_once "include/menu_licom.php";
?>
<div class="content">
<?php
require_once "include/fecha.php";
?>
<div align="center">
<h2>Seleccione una opción en el menú de la izquierda.</h2>
</div>
示例9: init_connection
}
init_connection($link);
$subop = $_REQUEST["subop"];
$mode = $_REQUEST["mode"];
if ((!$op || $op == "rss" || $op == "dlg") && !$_REQUEST["noxml"]) {
header("Content-Type: application/xml; charset=utf-8");
} else {
header("Content-Type: text/plain; charset=utf-8");
}
if (ENABLE_GZIP_OUTPUT) {
ob_start("ob_gzhandler");
}
if (SINGLE_USER_MODE) {
authenticate_user($link, "admin", null);
}
if (!($_SESSION["uid"] && validate_session($link)) && $op != "globalUpdateFeeds" && $op != "rss" && $op != "getUnread" && $op != "getProfiles" && $op != "share" && $op != "fbexport" && $op != "logout" && $op != "pubsub") {
if ($op == 'pref-feeds' && $_REQUEST['subop'] == 'add') {
header("Content-Type: text/html");
login_sequence($link);
render_login_form($link);
} else {
header("Content-Type: text/plain");
print json_encode(array("error" => array("code" => 6)));
}
return;
}
$purge_intervals = array(0 => __("Use default"), -1 => __("Never purge"), 5 => __("1 week old"), 14 => __("2 weeks old"), 31 => __("1 month old"), 60 => __("2 months old"), 90 => __("3 months old"));
$update_intervals = array(0 => __("Default interval"), -1 => __("Disable updates"), 15 => __("Each 15 minutes"), 30 => __("Each 30 minutes"), 60 => __("Hourly"), 240 => __("Each 4 hours"), 720 => __("Each 12 hours"), 1440 => __("Daily"), 10080 => __("Weekly"));
$update_intervals_nodefault = array(-1 => __("Disable updates"), 15 => __("Each 15 minutes"), 30 => __("Each 30 minutes"), 60 => __("Hourly"), 240 => __("Each 4 hours"), 720 => __("Each 12 hours"), 1440 => __("Daily"), 10080 => __("Weekly"));
$update_methods = array(0 => __("Default"), 1 => __("Magpie"), 2 => __("SimplePie"), 3 => __("Twitter OAuth"));
if (DEFAULT_UPDATE_METHOD == "1") {
示例10: validate_session
<?php
/* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Page: index.php - Site default document. Runs functions to validate session, validate requested page, and generate HTML to be displayed
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#Load system framework
include 'vitae/system_on_load.php';
#Validate session and requested page definition
validate_session();
$display_page = load_page_definition();
#Generate page and print to console/browser
echo '<pre>';
var_dump($_SESSION);
echo '</pre>';
echo $display_page->print_title();
示例11: validate_session
<?php
require '../fpdf/fpdf.php';
require_once '../globals.php';
require_once '../db.php';
validate_session('estudiante');
date_default_timezone_set('America/Caracas');
class PDF_MC_Table extends FPDF
{
var $widths;
var $aligns;
var $height;
function SetWidths($w)
{
//Set the array of column widths
$this->widths = $w;
}
function SetAligns($a)
{
//Set the array of column alignments
$this->aligns = $a;
}
function Row($data)
{
$height = 2;
//Calculate the height of the row
$nb = $height;
for ($i = 0; $i < count($data); $i++) {
$nb = max($nb, $this->NbLines($this->widths[$i], $data[$i]));
}
$h = 5 * $nb;
示例12: validate_session
<?php
require '../fpdf/fpdf.php';
require_once '../globals.php';
require_once '../db.php';
validate_session("estudiante");
date_default_timezone_set('America/Caracas');
$db = new PgDB();
$id = session_var('usuario_id');
$qry = "SELECT nombre, apellido, cedula, dirigido_a, numero_carta FROM usuario INNER JOIN pasantia ON pasantia.usuario_id = usuario.id AND usuario.id = {$id}";
$reco = $db->query($qry);
$row = pg_fetch_array($reco);
$pdf = new FPDF('P', 'mm', 'Letter');
$pdf->AddPage();
$fecha = date('d-m-Y', time());
$nroCP = "{$row['numero_carta']}";
$ciudadano = "{$row['dirigido_a']}";
$nombre = "{$row['nombre']} {$row['apellido']}";
$cedula = "{$row['cedula']}";
//linea superior
$pdf->Line(28, 20, 187, 20);
$pdf->Line(28, 20.7, 187, 20.7);
//linea inferior
$pdf->Line(28, 53, 187, 53);
$pdf->Line(28, 53.7, 187, 53.7);
//linea izquierda
$pdf->Line(186, 54, 186, 20);
$pdf->Line(186.7, 54, 186.7, 20);
//linea derecha
$pdf->Line(28, 54, 28, 20);
$pdf->Line(28.7, 54, 28.7, 20);
示例13: logout
/**
* Logs a user out of SiT
*
* @author Paul Heaney
* @param string $sessionid - The session ID to log out of
* @return Array - Status
*/
function logout($sessionid)
{
$status = new SoapStatus();
if (validate_session($sessionid)) {
session_id($sessionid);
session_start();
// End the session, remove the cookie and destroy all data registered with the session
$_SESSION['auth'] = FALSE;
$_SESSION['portalauth'] = FALSE;
$_SESSION = array();
session_unset();
session_destroy();
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time() - 42000, '/');
}
} else {
$status->set_error('session_not_valid');
}
return array('status' => $status->getSOAPArray());
}
示例14: validate_session
function &signup($edit = false)
{
// Check if there is still a valid session
validate_session(!$edit);
$valid_input = true;
// Create the HTML array with empty values
$HTML = array();
$HTML['password'] = '';
$HTML['confirm_password'] = '';
$HTML['email'] = '';
$HTML['city'] = '';
$HTML['countryID'] = '';
$HTML['password_encrypted'] = '';
// Check the submitted field
if (getRequest('submitted', true, 'post') !== 'yes') {
// Fill in the fields if it is an edit
if ($edit) {
$fields = getUserInfo(get_SESSION('userID'));
$HTML['email'] = $fields['email'];
$HTML['city'] = $fields['city'];
$HTML['countryID'] = $fields['countryID'];
$HTML['password_encrypted'] = $fields['password_encrypted'];
}
// Populate the select drop down box
getCountries($HTML['country_options_escape'], $HTML['countryID']);
return $HTML;
}
// Fill the array with the form data
foreach ($HTML as $key => &$value) {
$value = getRequest($key, true, 'post');
}
// Validate the email
if (empty($HTML['email'])) {
$HTML['email_error'] = 'Email cannot be empty';
$valid_input = false;
} else {
if (filter_var($HTML['email'], FILTER_VALIDATE_EMAIL) === false) {
$HTML['email_error'] = 'Invalid Email Address';
$valid_input = false;
} else {
$newID = validate_record($HTML['email']);
if ($newID > 0 and (!$edit or $newID !== trim(get_SESSION('userID')))) {
$HTML['email_error'] = 'An account already exists with that email';
$valid_input = false;
}
}
}
// Validate the password
$saved_pass = false;
if ($edit and empty($HTML['password']) or $HTML['password'] === PASS_HOLDER and !empty($HTML['password_encrypted'])) {
// use the password that was saved before
$saved_pass = true;
} else {
if (empty($HTML['password'])) {
$HTML['confirm_password_error'] = 'Password cannot be empty';
$valid_input = false;
} else {
if ($HTML['password'] !== $HTML['confirm_password']) {
$HTML['confirm_password_error'] = 'Passwords do not match';
$valid_input = false;
} else {
if (!preg_match('/(?=.*\\d)(?=.*[a‐z])(?=.*[A-Z])(?=.*[\\.\\+\\\\*\\?\\[\\^\\]\\$\\(\\)\\{\\}\\=\\!\\<\\>\\|\\:\',"~`&@_;\\/#%-]).{6,20}/', $HTML['password'])) {
$HTML['confirm_password_error'] = 'Password must be 6-20 chars and more secure!';
$valid_input = false;
}
}
}
}
// Validate the city
if (empty($HTML['city'])) {
$HTML['city_error'] = 'City cannot be empty';
$valid_input = false;
} else {
if (preg_match('/(?=.*[\\d\\.\\+\\\\*\\?\\[\\^\\]\\$\\(\\)\\{\\}\\=\\!\\<\\>\\|\\:\'"~`&@_;\\/#%])/', $HTML['city'])) {
$HTML['city_error'] = 'Special characters are not allowed';
$valid_input = false;
}
}
// Validate the country
if (empty($HTML['countryID'])) {
$HTML['countryID_error'] = 'Please select your country';
$valid_input = false;
} else {
if (!validate_countryID($HTML['countryID'])) {
$HTML['countryID_error'] = 'Invalid country submitted';
$valid_input = false;
}
}
if ($valid_input) {
// If it is the edit page update the user and return to account page
if ($edit) {
updateUser($HTML, $saved_pass);
set_header('account');
exit;
}
if (empty($GLOBALS['DB'])) {
die('Database Link is not set');
}
// Create a user
$query = sprintf('INSERT INTO users (email, password, city, countryID) VALUES (\'%s\',\'%s\',\'%s\',\'%s\')', mysql_real_escape_string($HTML['email']), mysql_real_escape_string($saved_pass ? $HTML['password_encrypted'] : md5($HTML['password'])), mysql_real_escape_string($HTML['city']), mysql_real_escape_string($HTML['countryID']));
//.........这里部分代码省略.........
示例15: login_sequence
function login_sequence($link, $mobile = false)
{
$_SESSION["prefs_cache"] = array();
if (!SINGLE_USER_MODE) {
$login_action = $_POST["login_action"];
# try to authenticate user if called from login form
if ($login_action == "do_login") {
$login = $_POST["login"];
$password = $_POST["password"];
$remember_me = $_POST["remember_me"];
if (authenticate_user($link, $login, $password)) {
$_POST["password"] = "";
$_SESSION["language"] = $_POST["language"];
$_SESSION["ref_schema_version"] = get_schema_version($link, true);
$_SESSION["bw_limit"] = !!$_POST["bw_limit"];
header("Location: " . $_SERVER["REQUEST_URI"]);
exit;
return;
} else {
$_SESSION["login_error_msg"] = __("Incorrect username or password");
}
}
if (!$_SESSION["uid"] || !validate_session($link)) {
render_login_form($link, $mobile);
//header("Location: login.php");
exit;
} else {
/* bump login timestamp */
db_query($link, "UPDATE ttirc_users SET last_login = NOW(), \n\t\t\t \t\ttwitter_last_id = NULL WHERE id = " . $_SESSION["uid"]);
if ($_SESSION["language"] && SESSION_COOKIE_LIFETIME > 0) {
setcookie("ttirc_lang", $_SESSION["language"], time() + SESSION_COOKIE_LIFETIME);
}
/* Enable automatic connections */
db_query($link, "UPDATE ttirc_connections SET enabled = true \n\t\t\t\t\tWHERE auto_connect = true AND owner_uid = " . $_SESSION["uid"]);
initialize_user_prefs($link, $_SESSION["uid"]);
/* $tmp_result = db_query($link, "SELECT id FROM ttirc_connections
WHERE status != ".CS_DISCONNECTED." AND owner_uid = " .
$_SESSION["uid"]);
while ($conn = db_fetch_assoc($tmp_result)) {
push_message($link, $conn['id'], "---",
"Accepted connection from " . $_SERVER["REMOTE_ADDR"],
true);
} */
}
} else {
return authenticate_user($link, "admin", null);
}
}