/** * Test user logged in * Tests if the user is logged in * @author Jim Ahlstrand * @dataProvider DataLogin * @small * @test */ public function userLoggedIn($user_name, $password, $expected) { // Test so user isn't logged in $a = new Login(); $this->assertFalse($a->isUserLoggedIn()); // Now add some test data $_POST['login'] = true; $_POST['user_name'] = $user_name; $_POST['user_password'] = $password; // Recreate login class, now with login data $a = new Login(); $this->assertEquals($expected, $a->isUserLoggedIn()); // Try logout $a->doLogout(); $this->assertFalse($a->isUserLoggedIn()); }
function check_login_status() { $return_value = ""; // create a login object. when this object is created, it will do all login/logout stuff automatically // so this single line handles the entire login process. in consequence, you can simply ... $login = new Login(); // ... ask if we are logged in here: if ($login->isUserLoggedIn() == true) { // the user is logged in. you can do whatever you want here. // for demonstration purposes, we simply show the "you are logged in" view. //include("login/views/logged_in.php"); // do nothing. $return_value = "login_good"; } else { // the user is not logged in. you can do whatever you want here. // for demonstration purposes, we simply show the "you are not logged in" view. //include("login/views/not_logged_in.php"); //print "login_required" ; $return_value = "Login not good"; if (isset($login)) { if ($login->errors) { foreach ($login->errors as $error) { $return_value .= $error; } } if ($login->messages) { foreach ($login->messages as $message) { $return_value .= $message; } } } } return $return_value; }
function isUserLoggedIn() { // load the login class require_once "classes/Login.php"; // create a login object. when this object is created, it will do all login/logout stuff automatically // so this single line handles the entire login process. in consequence, you can simply ... $login = new Login(); // ... ask if we are logged in here: if ($login->isUserLoggedIn() == true) { // the user is logged in. you can do whatever you want here. // for demonstration purposes, we simply show the "you are logged in" view. return true; } else { // the user is not logged in. you can do whatever you want here. // for demonstration purposes, we simply show the "you are not logged in" view. return false; } }
// if you are using PHP 5.3 or PHP 5.4 you have to include the password_api_compatibility_library.php // (this library adds the PHP 5.5 password hashing functions to older versions of PHP) require_once "../libraries/password_compatibility_library.php"; } } // include the configs / constants for the database connection require_once "../config/db.php"; // load the login class require_once "../classes/Login.php"; // load the functions require_once "../includes/functions.php"; // create a login object. when this object is created, it will do all login/logout stuff automatically // so this single line handles the entire login process. in consequence, you can simply ... $login = new Login(); // ... ask if we are logged in here: if ($login->isUserLoggedIn() == true) { // the user is logged in. you can do whatever you want here. // for demonstration purposes, we simply show the "you are logged in" view. //include("views/index_old.php");*/ if ($_GET["prev"] == 1) { $mindb_connection = new mysqli(DB_HOST, DB_USER, DB_PASS, $_SESSION['focusrun']); } else { $mindb_connection = new mysqli(DB_HOST, DB_USER, DB_PASS, $_SESSION['active_run_name']); } //echo cleanname($_SESSION['active_run_name']);; //echo '<br>'; if (!$mindb_connection->connect_errno) { //Check if entry already exists in jsonstore table: $jsonjobname = "histogram"; $checkrow = "select name,json from jsonstore where name = '" . $jsonjobname . "' ;"; $checking = $mindb_connection->query($checkrow);
<?php require_once "../../login/classes/Login.php"; require_once "../../config.php"; $login = new Login(); // ... ask if we are logged in here: if ($login->isUserLoggedIn() == false) { header("Location: /faciejetser/login.php"); } header('Content-Type: application/excel'); header('Content-Disposition: attachment;filename="sample.csv"'); $fileData = array(); $data = file_get_contents("http://" . $_SERVER['SERVER_ADDR'] . "/faciejetser/library/scripts/api.php?table=" . $_GET['table'] . "&written=true"); $jsonDecode = json_decode($data, true); $chunkArray = array_chunk($jsonDecode['result'], $_GET['size']); $firstRow = ""; for ($i = 1; $i <= $_GET['size']; $i++) { $firstRow .= "naam" . $i . ";email" . $i . ";woonplaats" . $i . ";telefoon" . $i . ";datum" . $i . ";studie" . $i . ";stukje" . $i . ";@foto" . $i . ";"; } array_push($fileData, $firstRow); foreach ($chunkArray as $row) { $rowData = ""; foreach ($row as $item) { $rowData .= html_entity_decode($item['naam'], ENT_QUOTES) . ";" . html_entity_decode($item['email'], ENT_QUOTES) . ";" . html_entity_decode($item['woonplaats'], ENT_QUOTES) . ";" . html_entity_decode($item['telefoon'], ENT_QUOTES) . ";" . html_entity_decode($item['datum'], ENT_QUOTES) . ";" . html_entity_decode($item['studie'], ENT_QUOTES) . ";" . html_entity_decode($item['stukje'], ENT_QUOTES) . ";H:\\Desktop\\export\\" . html_entity_decode($item['foto'], ENT_QUOTES) . ".png;"; } array_push($fileData, $rowData); } $fp = fopen("php://output", "w"); foreach ($fileData as $line) { $val = explode(";", $line); fputcsv($fp, $val, ";");
* User: Zachery * Date: 12/11/2015 * Time: 8:28 AM */ if (version_compare(PHP_VERSION, '5.3.7', '<')) { exit("Sorry, Simple PHP Login does not run on a PHP version smaller than 5.3.7 !"); } else { if (version_compare(PHP_VERSION, '5.5.0', '<')) { require_once "../login/libraries/password_compatibility_library.php"; } } require_once "../login/config/db.php"; require_once "../login/classes/Login.php"; // Create a Login Object. $login = new Login(); if ($login->isUserLoggedIn() == TRUE) { // Include all needed session variables here $user = $_SESSION['user_name']; $email = $_SESSION['user_email']; $name = $_SESSION['first_name'] . " " . $_SESSION['last_name']; $admin = $_SESSION['admin']; $head = ''; $page = $_GET['page']; function getPage() { global $head; if (isset($_GET['page'])) { $page = $_GET['page']; include "views/{$page}.php"; } else { $head = "<META http-equiv='refresh' content='0;URL=../dashboard/index.php'>";
ini_set('display_errors', 'On'); error_reporting(E_ALL); // this includes all the classes that are needed by the script. // we use the "Database" and "Login" classes function autoload($class) { require 'classes/' . $class . '.class.php'; } // automatically loads all needed classes, when they are needed spl_autoload_register("autoload"); // create a or use the existing database connection and start login by giving it the newly opened db connection $db = new Database(); // Login class contains variables for all user data and methods that check for login status. It handles login/logout and session establishment. $login = new Login($db); // depending on established session information either go to login page or to logged in section: if (!$login->isUserLoggedIn()) { Header("Location: index.php"); // include("index.php"); } if (isset($_POST["p"])) { if ($_POST["p"] == "generate") { $pass = $_POST["pass"]; $user = $_SESSION["user_name"]; $mail = $_SESSION["user_email"]; $postdata = array('token' => '8b71091762b20c7cd08a66e346c4b918', 'name' => urlencode($user), 'pass' => urlencode($pass), 'mail' => urlencode($mail)); $ch = curl_init("https://{$CA_address}/generate.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_POST, count($postdata)); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
<?php $meta = array("<meta charset=\"UTF-8\">", "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">", "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"); $css = array("css/bootstrap.min.css", "css/theme.min.css", "css/main.css"); $js = array("https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js", "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js", "js/main.js"); renderHeader("Admin Tools", $meta, $css, $js); ?> <body> <?php require_once "../resources/templates/menu.php"; ?> <div class="container"> <div class="row"> <?php if ($login->isUserLoggedIn() and isset($_SESSION['id']) and privilegeCheck($mysqli, $_SESSION['id']) == 0) { ?> <h1>Hello Boss xD</h1> <div id="admId" class="hidden"><?php echo $_SESSION['id']; ?> </div> <h2>Vew users</h2> <div class="col-md-12"> <div class="panel panel-default"> <div class="panel-heading" role="tab"> <h4 class="panel-title"> <a class="collapsed" id="usersTitle" role="button" data-toggle="collapse" href="#usersPanel" aria-expanded="false" aria-controls="usersPanel">Not verified users</a> </h4>
/ Any issues, please email f0rkz@f0rkznet.net / For more information about the application, please see the README file /**********************************************************************************/ include '../includes/common.php'; // Figure out what page to render $request = $_GET; $input = $_POST; $nav_brand_url = BRAND_URL; $nav_brand_name = BRAND_NAME; $login = new Login(); /********************************************************************************** / Not Logged in processes / Anything ran under the if login->isUserLoggedIn False will be pages rendered / for the not logged in user. /**********************************************************************************/ if ($login->isUserLoggedIn() == false && !(isset($request['cmd']) && $request['cmd'] == 'generate_graph')) { if (isset($request['page']) && $request['page'] == 'register') { $registration = new Registration(); if (isset($registration)) { if ($registration->errors) { foreach ($registration->errors as $error) { $tpl_error = new Template("../includes/templates/error.tpl"); $tpl_error->set("error_text", $error); echo $tpl_error->fetch(); } } if ($registration->messages) { foreach ($registration->messages as $message) { $success_message = $message . " <a href=\"/\">Back to home</a>"; $tpl_success = new Template("../includes/templates/success.tpl"); $tpl_success->set("success_text", $success_message);
?> <br> Author: <?php echo $authorFirstName; echo " "; echo $authorLastName; ?> </div> <div class="col-md-3 col-md-offset-2 text-center"> <h2>Rating</h2> <?php if ($login->isUserLoggedIn() == true) { ?> <?php if (privilegeCheck($mysqli, $_SESSION['id']) == 0) { ?> <form action="admin_votes.php" method=post> Current user vote: <?php echo $voteCount; ?> <br> Current admin vote: <?php echo $adminVote; ?> <br> Update admin vote to: <input type="number" name="admin_votes" min="-1000000" max="1000000"/> <input type="hidden" name="adv_id" value="<?php
<?php // include the configs / constants for the database connection if (file_exists("config/db.php")) { require_once "config/db.php"; // load the login class require_once "classes/Login.php"; $login = new Login(); if (!isset($_SESSION['theme'])) { $_SESSION['theme'] = ""; } if ($login->isUserLoggedIn()) { if (isset($_POST['theme'])) { if ($_POST['theme'] == "assembly") { $_SESSION['theme'] = "assembly"; } if ($_POST['theme'] == "paradox") { $_SESSION['theme'] = "paradox"; } if ($_POST['theme'] == "sentinel") { $_SESSION['theme'] = "sentinel"; } if ($_POST['theme'] == "ventureleague") { $_SESSION['theme'] = "ventureleague"; } if ($_POST['theme'] == "nexus") { $_SESSION['theme'] = ""; } } $theme = $_SESSION['theme']; } else {
<?php session_start(); ob_start(); if (version_compare(PHP_VERSION, '5.5.0', '<')) { // if you are using PHP 5.3 or PHP 5.4 you have to include the password_api_compatibility_library.php // (this library adds the PHP 5.5 password hashing functions to older versions of PHP) require_once "libraries/password_compatibility_library.php"; } date_default_timezone_set('Asia/Calcutta'); require_once "config/config.php"; require_once "function.php"; // load the login class require_once "classes/Login.php"; // include the PHPMailer library require_once "libraries/PHPMailer.php"; //load the registration class require_once "classes/Registration.php"; $login = new Login(); $registration = new Registration(); if (isset($_GET['logout'])) { header('location:index.php'); } if ($login->post_success == true && $login->isUserLoggedIn() == false) { header('location:' . $_SERVER['REQUEST_URI'] . "#login"); } if ($login->post_success == true && $login->isUserLoggedIn() !== false) { header('location:' . $_SERVER['REQUEST_URI'] . '#success'); }
} } // include the config require_once 'config/config.php'; // include the to-be-used language, english by default. feel free to translate your project and include something else require_once 'translations/en.php'; // include the PHPMailer library require_once 'libraries/PHPMailer.php'; // load the login class require_once 'classes/Login.php'; // load the permissions class require_once 'classes/Permissions.php'; // create a login object. when this object is created, it will do all login/logout stuff automatically // so this single line handles the entire login process. $login = new Login(); // create a permissions object. it will handle permission checking and changing for the accounts $permissions = new Permissions(); // ... ask if we are logged in here: if ($login->isUserLoggedIn() == true && $permissions->isUserAdmin() == true) { // the user is logged in and is admin. you can do whatever you want here. // this page is demo of the admin functions include "includes/admin.php"; } elseif ($login->isUserLoggedIn() == true && $permissions->isUserAdmin() == false) { // the user is logged in but is not admin. // return user to the logged in page include "includes/logged_in.php"; } else { // the user is not logged in. you can do whatever you want here. // for demonstration purposes, we simply show the "you are not logged in" view. include "includes/not_logged_in.php"; }