NorthWestSimulations
Members-
Posts
58 -
Joined
-
Last visited
Never
About NorthWestSimulations
- Birthday 03/06/1992
Profile Information
-
Gender
Male
-
Location
Winnipeg, MB
NorthWestSimulations's Achievements
Member (2/5)
0
Reputation
-
[SOLVED] image upload w/ xampp on windows w/ php5
NorthWestSimulations replied to programguru's topic in PHP Coding Help
Quick Script: Upload.php <?php $directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']); $uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . '/_uploaded/'; $uploadForm = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'index.php'; $uploadSuccess = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'upload2.php'; $fieldname = 'file'; $errors = array(1 => 'php.ini max file size exceeded', 2 => 'html form max file size exceeded', 3 => 'file upload was only partial', 4 => 'no file was attached'); isset($_POST['submit']) or error('the upload form is needed', $uploadForm); ($_FILES[$fieldname]['error'] == 0) or error($errors[$_FILES[$fieldname]['error']], $uploadForm); @is_uploaded_file($_FILES[$fieldname]['tmp_name']) or error('not an HTTP upload', $uploadForm); @getimagesize($_FILES[$fieldname]['tmp_name']) or error('only image uploads are allowed', $uploadForm); $now = time(); while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name'])) { $now++; } move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename.$fileext) or error('receiving directory insuffiecient permission', $uploadForm); header('Location: ' . $uploadSuccess); function error($error, $location, $seconds = 5) { header("Refresh: $seconds; URL=\"$location\""); echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'."\n". '"http://www.w3.org/TR/html4/strict.dtd">'."\n\n". '<html lang="en">'."\n". ' <head>'."\n". ' <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n\n". ' <link rel="stylesheet" type="text/css" href="stylesheet.css">'."\n\n". ' <title>Upload error</title>'."\n\n". ' </head>'."\n\n". ' <body>'."\n\n". ' <div id="Upload">'."\n\n". ' <h1>Upload failure</h1>'."\n\n". ' <p>An error has occured: '."\n\n". ' <span class="red">' . $error . '...</span>'."\n\n". ' The upload form is reloading</p>'."\n\n". ' </div>'."\n\n". '</html>'; exit; } ?> Upload2.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> <title>Successful upload</title> </head> <body> <div id="Upload"> <h1>File upload</h1> <p>Congratulations! Your file upload was successful</p> </div> </body> </html> index.php <?php $directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']); $uploadHandler = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'upload.php'; $max_file_size = 30000; ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> <title>Upload form</title> </head> <body> <form id="Upload" action="<?php echo $uploadHandler ?>" enctype="multipart/form-data" method="post"> <h1> Upload form </h1> <p> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size ?>"> </p> <p> <label for="file">File to upload:</label> <input id="file" type="file" name="file"> </p> <p> <label for="submit">Press to...</label> <input id="submit" type="submit" name="submit" value="Upload me!"> </p> </form> </body> </html> This script is great. I use it all the time for minimul security uploads. They will save files in directory "/_uploaded/" -
Im not asking for someone to write me up a script or anything, Im just curios how exactly PHP can take an image such as: And turn it into http://www.nwsim.com/ascii.html I did it already with that picture of my 2 bestest friends... using glassgiant. Just curious exactly how Glassgiant would have done it. Any functions I should look into guys?
-
[SOLVED] Where is that Extension type?
NorthWestSimulations replied to NorthWestSimulations's topic in PHP Coding Help
Thank you guys. I figured it out -
I know it has to be in the $_FILES["file"]['']; array somewhere. I just cant find it. Lets say I upload a file named "test.wav" How do I get just the part of "wav" or if someone uploads a file like "Walalal.Test.haha.BooYeah.txt" it will take "txt" as the extension type. Hmm... Im curious, Any ideas how I get this info? ???
-
[SOLVED] Hey! I didnt I just kick you out?
NorthWestSimulations replied to NorthWestSimulations's topic in PHP Coding Help
Thanks everyone. Im sure your all glad as I am to mark this "TOPIC SOLVED" Everyone who helped me out today. Feel free to grab a a couple Brownie points from that Jar over there tonight before you log out... -
[SOLVED] Hey! I didnt I just kick you out?
NorthWestSimulations replied to NorthWestSimulations's topic in PHP Coding Help
OKay guys, I Think I got it. One last question before i leave you for the night. What do you think of Startlogic Web hosting... I know its not as good as the WebFreaks... But... Whats your oppinion? -
[SOLVED] Hey! I didnt I just kick you out?
NorthWestSimulations replied to NorthWestSimulations's topic in PHP Coding Help
I searched in google. Couldnt find a straight foreward answer. Anyone here wanna give me a link or quickly tell me how crons work and write or supply a link to an example? -
[SOLVED] Hey! I didnt I just kick you out?
NorthWestSimulations replied to NorthWestSimulations's topic in PHP Coding Help
Hmm, Interesting... So it would be like every time someone attempts a login it is a $x++; which would update over the acc. if the likit was equal to or greater than 3 then it would lock the acc and insert a time stamp. Then I would use Cron(); to delete that data after a certain time. Or have the script see if current timestamp is greater than +5 minutes. Hmm... I think I got it. -
[SOLVED] Hey! I didnt I just kick you out?
NorthWestSimulations replied to NorthWestSimulations's topic in PHP Coding Help
Yes but session variables are being used for the overall login process. Someone who ha failed the authenication attempt could simply visit http://www.nwsim.com/index.php?action=logout and completly delete there session data. I need something that stores there IP in a database and stuff... Then if $Current_time >= 5 minutes deletes it. -
Here's a tough one for ya! Try to follow along:
NorthWestSimulations replied to affluent980's topic in PHP Coding Help
Also, could you please use the CODE Tags next time? I cant even begin to see what your problem is unless the code is neat... Remember CODE TAGS!!! -
Okay.. Interesting title, I know. Im awesome like that. Heres my problem My website: http://www.nwsim.com/ Has a login form. (I know the website is pale. I just started working on it a few moments ago...) But is there a way for me to make a thingy that allows a person to attempt to login 3 times and if they get it wrong the 4th time it bans them from the login system for oooh... I dont know? 5 minutes?
-
[SOLVED] Files in directory not 0kb?
NorthWestSimulations replied to NorthWestSimulations's topic in PHP Coding Help
Thank you bro. Works beautifully. Your a god... A PHPfreaks Recommended god -
<?php session_start(); ?> <html> <body> <form action="registration_action.php" method="post" name="lalal"> Name: <input type="text" name="name"> Age: <input type="text" name="age"> <input type="submit"> </form> </body> </html registration_action.php <?php session_start(); $_SESSION['name'] = $_POST["name"]; $_SESSION['age'] = $_POST["age"]; $name = $_SESSION['name']; $age = $_SESSION['age']; ?> <html> <body> Welcome <?php echo $name; ?>.<br /> You are <?php echo $age; ?> years old. <?php session_destroy(); ?> </body> </html>
-
URGENT PLEASE HELPPP!!!!!!!!!!!!!
NorthWestSimulations replied to stalian4002's topic in PHP Coding Help
haha Haku, ur funny.... ...OMG! Its the urgent sygnal! Quickly Batman! We need you!! -
<?php $page = $_GET['page']; if ($page == NULL){ include_once('pages/home.php'); } elseif (file_exists('pages/'.$page.'.php')){ include_once('pages/'.$page.'.php'); } else include_once('pages/error404.php'); Should work. Good luck with your website my friend