<?php
session_start();
$pass[] = "123456";
#create an array of passwords
#add as many as you want
#used for the logout link, changes the session 'loggedin' = false if ?action=logout
if($_GET['action'] == "logout"){
$_SESSION['loggedin'] = false;
$_SESSION['username'] = "";
}
if($_SESSION['loggedin'] == false){ #checks if the user isnt logged in
if(!$_POST['s1']){ #checks if the form has been submitted, if not show it
}else{
#username check
$tmppass = $_POST['pass']; #the password the user has submitted
$t = count($pass); #count the total passwords
$i = 0;
#create a loop to go through each password and compare it with the name pass which was submitted
while($i <= $t){
if($tmppass !== ""){
if($tmppass == $pass[$i]){
$_SESSION['loggedin'] = true;
header('Location: ?'); #reload the page
}
}
$i++;
}
echo "Invalid password 0.o"; #show an error message if the user enters an incorrect pass
}
die;
}
?>
<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size > 350000000)
{
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}
//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
if ($uploaded_size > 350000000)