Example #1
0
<?php

include 'config.php';
include 'sessions.php';
//Connect to database
include 'readDB.php';
include 'writeDB.php';
$blacklist = array(".php", ".phtml", ".php3", ".php4", ".php5");
function generateShortName($length = 11)
{
    return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
}
// check user authentication
if (isset($_SESSION['user']) && $_SESSION['id'] == authenticated_session($_SESSION['user'])) {
    if ($_FILES["video"]["error"] == UPLOAD_ERR_OK) {
        // check title
        if (!isset($_POST["title"])) {
            header("Location: /post.php?message=" . urlencode("Missing title."));
            exit;
        }
        // check description
        if (!isset($_POST["description"])) {
            header("Location: /post.php?message=" . urlencode("Missing description."));
            exit;
        }
        // check upload file size is not greater than 100 megabytes
        if ($_FILES["video"]["size"] > 12500000) {
            header("Location: /post.php?message=" . urlencode("Only files <= 100 ΜΒ."));
            exit;
        }
        // check file type
Example #2
0
include 'readDB.php';
include 'writeDB.php';
$salt = 'salt$';
// get POST information from login form
$email = mysqli_escape_string($read, $_POST["email"]);
$password = mysqli_escape_string($read, $_POST["password"]);
//Hash the password
$password = openssl_digest($password . $salt, 'sha512');
//Prepare the sequel query and bind parameters
$stmt = $read->prepare('SELECT email, password FROM users WHERE email = ? AND password = ?');
$stmt->bind_param('ss', $email, $password);
//Retrieves data from user table
if (!$stmt->execute()) {
    header('Location: /login.php?message=Login%20Failed');
    die;
}
$stmt->store_result();
//Check if the password was correct
if ($stmt->num_rows()) {
    //Set session data
    $_SESSION['user'] = $email;
    $_SESSION['id'] = authenticated_session($email);
    header('Location: /index.php');
} else {
    // logout
    header('Location: /login.php?message=Incorrect%20Password');
    session_destroy();
}
// close connection to the database
$stmt->close();
include 'closedb.php';
Example #3
0
<?php

include 'config.php';
include 'headers.php';
include 'sessions.php';
if ($_SESSION['id'] != authenticated_session($_SESSION['user'])) {
    header("Location: /index.php");
    die;
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" href="/favicon.ico" type="image/x-icon">

    <title>Completely Digital Clips - Post Video</title>

    <!-- Bootstrap core CSS -->
    <link href="/static/css/bootstrap.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->