Пример #1
0
function checkLoginStatus($config_username, $config_password, $post_username, $post_password)
{
    if (!empty($post_username) && !empty($post_password)) {
        if ($config_username == $post_username && password_verify($post_password, $config_password)) {
            $_SESSION["activeLogin"] = true;
            $_SESSION["username"] = $post_username;
            $_SESSION["loginID"] = hash("sha256", $_SERVER["HTTP_USER_AGENT"] . $_SERVER['REMOTE_ADDR'], false);
            $_SESSION["timeout"] = time();
            return "Success";
        } else {
            return "Wrong login information";
        }
    } else {
        if ($_SESSION["activeLogin"] != true || $_SESSION["username"] == "" || $_SESSION["loginID"] == "") {
            $_SESSION = array();
            return "";
        } else {
            $status = login_validation($config_username, $config_password);
            return $status;
        }
    }
}
//start session
session_start();
//unset/destroy/empty session post
if (isset($_POST['unset']) && $_POST['unset'] == "unset") {
    session_destroy();
    $_SESSION = array();
    header('location: index.php');
}
//verify with post, which form we are recieving posts from
//then decide where we should go, register, login, or exit.
//inside we will pass the entire post through to the function
if (isset($_POST['register']) && $_POST['register'] == "register") {
    register_validation($_POST);
} else {
    if (isset($_POST['login']) && $_POST['login'] == "login") {
        login_validation($_POST);
    } else {
        session_destroy();
        header('location:index.php');
    }
}
//register validaiton
function register_validation($post)
{
    //set error flags to 0
    $error_flags = 0;
    //first_name errors
    if (!empty($_POST['first_name'])) {
        $first_name = trim($_POST['first_name']);
        $_SESSION['first_name'] = $first_name;
        if (preg_match("/^[a-zA-Z ]*\$/", $first_name)) {
Пример #3
0
<?php

$error = '';
if (isset($_POST['submit'])) {
    if (empty($_POST['usertype']) || empty($_POST['email']) || empty($_POST['password'])) {
        $error = "Username or Password is invalid";
    } else {
        $dbc = dbConnect('local');
        /*$usertype =mysql_real_escape_string($_POST['usertype']);
        	$email =mysql_real_escape_string($_POST['email']);
        	$password= mysql_real_escape_string($_POST['password']);*/
        $usertype = $dbc->real_escape_string($_POST['usertype']);
        $email = $dbc->real_escape_string($_POST['email']);
        $password = $dbc->real_escape_string($_POST['password']);
        $result = login_validation($usertype, $email, $password);
        if ($result == 1) {
            redirect_to("profile.php");
        } else {
            $error = $result;
        }
    }
}
function custom_login_function()
{
    if (isset($_POST['submit'])) {
        login_validation($_POST['username'], $_POST['password']);
        // sanitize user form input
        global $username, $password;
        $username = sanitize_user($_POST['username']);
        $password = esc_attr($_POST['password']);
        // call @function complete_login to login
        // only when no WP_error is found
        complete_login($username, $password);
    }
    login_form($username, $password);
}
Пример #5
0
<?php

session_start();
//  Config file/files
require "config/config.php";
require "functions.php";
$returnData = array();
$loginStatus = login_validation($username, $password);
if ($loginStatus == "Success") {
    $outputDir = "uploads/";
    //Thumbnail creation
    function createThumb($fileName)
    {
        $outputDir = "uploads/";
        $thumbDir = "uploads/thumb/";
        if (preg_match('/[.](jpg)$/', $fileName) || preg_match('/[.](jpeg)$/', $fileName)) {
            $image = imagecreatefromjpeg($outputDir . $fileName);
        } else {
            if (preg_match('/[.](gif)$/', $fileName)) {
                $image = imagecreatefromgif($outputDir . $fileName);
            } else {
                if (preg_match('/[.](png)$/', $fileName)) {
                    $image = imagecreatefrompng($outputDir . $fileName);
                }
            }
        }
        $originalX = imagesx($image);
        $originalY = imagesy($image);
        $newX = 150;
        $newY = floor($originalY * (150 / $originalX));
        //$newXY = 100;