本文整理汇总了PHP中start_session函数的典型用法代码示例。如果您正苦于以下问题:PHP start_session函数的具体用法?PHP start_session怎么用?PHP start_session使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了start_session函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processLogin
function processLogin()
{
global $cfg;
// Initialize or retrieve the current values for the login variables
$loginAttempts = !isset($_POST['loginAttempts']) ? 1 : $_POST['loginAttempts'];
$formUser = !isset($_POST['formUser']) ? NULL : $_POST['formUser'];
$formPassword = !isset($_POST['formPassword']) ? NULL : $_POST['formPassword'];
// If the posted username and/or password doesnt match whats set in config.
if ($formUser != $cfg->get('admin_user') || $formPassword != $cfg->get('admin_pass')) {
// If first login attempt, initiate a login attempt counter
if ($loginAttempts == 0) {
$_POST['loginAttempts'] = 1;
$auth = false;
return;
} else {
if ($loginAttempts >= 3) {
echo "<blink><p align='center' style=\"font-weight:bold;font-size:170px;color:red;font-family:sans-serif;\">Log In<br>Failed.</p></blink>";
exit;
} else {
$_POST['loginAttempts'] += 1;
return;
}
}
} elseif ($formUser == $cfg->get('admin_user') && $formPassword == $cfg->get('admin_pass')) {
// Start Session, set session variables
start_session();
$_SESSION['adminAuth'] = md5($cfg->get('admin_user') . $cfg->get('admin_pass'));
$_SESSION['adminTime'] = time();
$SID = session_id();
$_POST['task'] = 'home';
} else {
$_POST['loginAttempts'] += 1;
return;
}
}
示例2: __construct
function __construct()
{
if (!session_id()) {
start_session();
}
$this->_db = new my_mysql();
}
示例3: is_logged_in
function is_logged_in()
{
//function to see if the user is logged in
start_session();
//PhP session must be started before you can start storing infromation
return isset($_SESSION['user']);
//return session of the "user"
}
示例4: authenticate_user
function authenticate_user($inputUsername, $inputPassword, $connection)
{
//query database to return password for the username that was input
//usernames are unique so only 1 row should be returned
$result = $connection->query("SELECT password FROM employee \n\t\tWHERE username = '{$inputUsername}'");
//get the returned result as an array
$row = $result->fetch_array(MYSQLI_NUM);
//verify the passwords match
if ($inputPassword == $row[0]) {
echo "true";
start_session($inputUsername, $inputPassword);
} else {
echo "false";
}
}
示例5: validate
function validate()
{
$clean_email = strstr($email, '@');
if (empty($name) || !isset($name)) {
echo 'please fill all fields';
}
//check if array has a value
if (!in_array($clean_email, $domains)) {
echo 'please enter a valid email provider';
}
if ($password !== $confirm) {
echo 'plase check your password match';
}
if (isset($_POST['register'])) {
start_session();
}
}
示例6: processLogin
function processLogin()
{
global $cfg;
// Initialize or retrieve the current values for the login variables
$loginAttempts = !isset($_POST['loginAttempts']) ? 1 : $_POST['loginAttempts'];
$formUser = !isset($_POST['formUser']) ? NULL : $_POST['formUser'];
$formPassword = !isset($_POST['formPassword']) ? NULL : $_POST['formPassword'];
// Check Values
if ($formUser != $cfg->get('admin_user') || $formPassword != $cfg->get('admin_pass')) {
if ($loginAttempts == 0) {
/* 3 strikes and they're out */
$_POST['loginAttempts'] = 1;
$auth = false;
return;
} else {
if ($loginAttempts >= 3) {
echo "<blink><p align='center' style=\"font-weight:bold;font-size:170px;color:red;font-family:sans-serif;\">Log In<br>Failed.</p></blink>";
exit;
} else {
$_POST['loginAttempts'] += 1;
return;
}
}
} elseif ($formUser == $cfg->get('admin_user') && $formPassword == $cfg->get('admin_pass')) {
// test for valid username and password
// Start Session
start_session();
$_SESSION['adminAuth'] = md5($cfg->get('admin_user') . $cfg->get('admin_pass'));
$_SESSION['adminTime'] = time();
$SID = session_id();
$_POST['task'] = 'home';
} else {
$_POST['loginAttempts'] += 1;
return;
}
}
示例7: do_acct_status
function do_acct_status($status)
{
$do_admin_acct = false;
// Change to 'true', if desired
if (get_device() || $do_admin_acct) {
switch ($status) {
case 'update':
update_session();
break;
case 'start':
start_session();
break;
case 'stop':
stop_session();
break;
case 'auth':
auth_session();
break;
}
}
}
示例8: start_session
</form>
<?php
}
if ($_GET['vars'] == "yes") {
$key_country = $_POST['key_country'];
$key_province = $_POST['key_province'];
$key_city = $_POST['key_city'];
$key_org = $_POST['key_org'];
$key_email = $_POST['key_email'];
$server_name = $_POST['server_name'];
$client_name = $_POST['client_name'];
//need to use bash commands to do this... permission issues.
//editing var file using sed
//define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);
if (!isset($_SESSION['password'])) {
start_session('create_certs.php?vars=yes');
}
$password = stripslashes(trim($_SESSION['password']));
$username = stripslashes(trim($_SESSION['username']));
if ($username == "") {
$username = "root";
}
$ssh = new Net_SSH2('localhost');
if (!$ssh->login($username, $password)) {
exit('Login Failed');
}
echo $ssh->read('/.*@.*/', NET_SSH2_READ_REGEX);
$ssh->write("sudo killall -v openvpn\n");
$ssh->setTimeout(10);
$output = $ssh->read('/.*@.*[$|#]|.*[P|p]assword.*/', NET_SSH2_READ_REGEX);
//$ssh->read();
示例9: set_include_path
require 'functions.php';
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include 'Net/SSH2.php';
//if (!(isset($_SESSION['password']))){
// start_session('install.php'); //getting username and password for phpseclib ssh terminal
//}
?>
<?
//error_reporting(E_ALL);
//ini_set('display_errors', 'on');
//functions.php includes session_start()
//will need to do the pkitool test now.... TODO move pkitool to previous heading so don't have to test for it twice :(
//Will reach this if the "initial-setup" button is pressed in code block after this
If ($_GET['action'] == "initial-setup"){
if (! (isset($_SESSION['password']))){
start_session('install.php&action=initial-setup');
}
$password = stripslashes(trim($_SESSION['password']));
$username = stripslashes(trim($_SESSION['username']));
if ($username == ""){
$username = "root";
}
$ssh = new Net_SSH2('localhost');
if (!$ssh->login($username, $password)) {
exit('Login Failed');
}
$default_pkitool_location = $config_dir . "/easy-rsa/pkitool";
if (!(file_exists($default_pkitool_location))){
echo "<font color='B22222'>Error!</font> PKITOOL not found... required, will attempt to copy into $config_dir<br />";
echo $ssh->exec("sudo cp -r $easy_rsa_dir $config_dir");
示例10: create_zip
function create_zip($files = array(), $destination = '', $cert_name, $overwrite = true)
{
//will need phpseclib later.... so...
if (!isset($_SESSION['password'])) {
start_session('certs.php?action=send_cert&type=$send_type&cert_name=$cert_name');
}
$password = stripslashes(trim($_SESSION['password']));
$username = stripslashes(trim($_SESSION['username']));
if ($username == "") {
$username = "root";
}
$ssh = new Net_SSH2('localhost');
if (!$ssh->login($username, $password)) {
exit('Login Failed');
}
//if the zip file already exists and overwrite is false, return false
if (file_exists($destination) && !$overwrite) {
echo "Will not overwrite!<br />";
return false;
}
//vars
$valid_files = array();
//if files were passed in...
if (is_array($files)) {
//cycle through each file
foreach ($files as $file) {
//make sure the file exists
if (file_exists($file)) {
$valid_files[] = $file;
}
}
}
//if we have good files...
if (count($valid_files)) {
//create the archive
$zip = new ZipArchive();
if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}
//add the files
foreach ($valid_files as $file) {
$zip->addFile($file, $file);
echo "File: {$file}<br />";
}
//debug
echo 'The zip archive contains ', $zip->numFiles, ' files with a status of ', $zip->status;
echo "<br />";
$zip->addFile($file);
//close the zip -- done!
$zip->close();
$curr_work_dir = getcwd();
echo "{$curr_work_dir}/Downloads/{$destination}<br />";
//now move the file to our Downloads folder
if (copy("{$destination}", "{$curr_work_dir}/Downloads/{$destination}")) {
unlink("{$destination}");
}
//and update destination
$zip_download = "{$destination}";
//TODO check if file exists
return $zip_download;
} else {
return false;
}
}
示例11: start_session
<?php
require_once 'inc/functions.php';
/*
* If posted information from login form
*/
if (isset($_POST['submitLogin'])) {
if (check_credentials($_POST)) {
start_session($_POST['uname']);
} else {
$msg = 'Invalid Login Credentials!';
}
}
/*
* If user is logged-in
* redirect to home.php
*/
if (isset($_SESSION['username'])) {
header('Location: home.php?u=' . $_SESSION['username']);
}
require 'inc/header.php';
?>
<div class="container">
<form method="POST" class="form-signin col-md-6 col-md-offset-3 col-xs-10 col-xs-offset-1">
<?php
if (isset($msg)) {
echo "<div class='alert alert-danger' role='alert'>Invalid Login Credentials!</div>";
}
?>
<input type="text" name="uname" class="form-control" placeholder="Username" required autofocus>
<input type="password" name="pword" class="form-control" placeholder="Password" required>
示例12: foreach
require_once DIR_FS_PRONTO . DS . 'core' . DS . 'factory.php';
require_once DIR_FS_PRONTO . DS . 'core' . DS . 'session.php';
if (defined('SESSION_USEDB') && SESSION_USEDB === true) {
// taken from pronto/profiles/web.php
if (defined('DB_NAME')) {
$db =& Factory::db(array('dsn' => DB_DSN, 'file' => DB_FILE, 'host' => DB_HOST, 'user' => DB_USER, 'pass' => DB_PASS, 'name' => DB_NAME));
Registry::set('pronto:db:main', $db);
} else {
foreach ($DATABASES as $key => $dbcfg) {
$db =& Factory::db($dbcfg);
Registry::set('pronto:db:' . $key, $db);
}
unset($key, $dbcfg);
}
}
start_session($_GET['sessidpass']);
/*
TinyBrowser 1.41 - A TinyMCE file browser (C) 2008 Bryn Jones
(author website - http://www.lunarvis.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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
示例13: start_session
// as well as links to various search forms.
// Incorporate some include files:
include 'initialize/db.inc.php';
// 'db.inc.php' is included to hide username and password
include 'includes/header.inc.php';
// include header
include 'includes/footer.inc.php';
// include footer
include 'includes/include.inc.php';
// include common functions
include 'initialize/ini.inc.php';
// include common variables
// --------------------------------------------------------------------
// START A SESSION:
// call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
start_session(true);
// --------------------------------------------------------------------
// Initialize preferred display language:
// (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function)
include 'includes/locales.inc.php';
// include the locales
// --------------------------------------------------------------------
// If there's no stored message available:
if (!isset($_SESSION['HeaderString'])) {
$HeaderString = $loc["Default Welcome Message"];
} else {
$HeaderString = $_SESSION['HeaderString'];
// extract 'HeaderString' session variable (only necessary if register globals is OFF!)
// Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
deleteSessionVariable("HeaderString");
// function 'deleteSessionVariable()' is defined in 'include.inc.php'
示例14: json_encode
<?php
include '../include/webzone.php';
$login = $_POST['login'];
$password = $_POST['password'];
if ($login == '' || $password == '') {
$display .= '<div class="alert fade in alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>';
$display .= 'Missing login and/or password';
$display .= '</strong></div>';
$d['display'] = $display;
$d['code'] = 0;
echo json_encode($d);
} else {
if ($login == $GLOBALS['admin_username'] and $password == $GLOBALS['admin_password']) {
start_session(array('user_id' => '99999', 'login' => $login));
$d['code'] = 1;
//success
echo json_encode($d);
} else {
$display .= '<div class="alert fade in alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>';
$display .= 'The user and/or password are incorrect';
$display .= '</strong></div>';
$d['display'] = $display;
$d['code'] = 0;
echo json_encode($d);
}
}
示例15: POST_login__openid
function POST_login__openid()
{
if (USER_USE_OPENID !== true) {
$this->redirect(url('User', 'login'));
return;
}
if (isset($_SESSION['openid']['validated'])) {
if ($_SESSION['openid']['validated']) {
$err = $this->models->user->authenticate_openid($_SESSION['openid']['identity']);
if ($err === false) {
// no user exists yet, but we have a positive openid auth,
// so let's create a new account...
$_SESSION['newuser_data'] = array();
if (is_array($_SESSION['openid']['sreg'])) {
$_SESSION['openid_identity'] = $_SESSION['openid']['identity'];
$_SESSION['openid_user_data'] = $_SESSION['openid']['sreg'];
$this->redirect(url('User', 'signup'));
return;
}
}
} else {
$err = $_SESSION['openid']['error'];
}
unset($_SESSION['openid']);
if ($err !== true) {
$this->tset('error', $err);
$this->GET_login();
} else {
$return_url = $this->param('return_url', '/');
$this->redirect(url($return_url));
}
} else {
if ($this->param('openid_url')) {
define('OPENID_NOKEYMANAGER', 1);
define('OPENID_SREG_REQUEST', 'nickname,email,fullname,dob,gender,postcode,country,language,timezone');
start_session();
require_once dirname(__FILE__) . '/../extlib/openid/processor.php';
}
}
}