Jump to content

bizerk

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bizerk's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey alright, well it echoes everything and reads the directory fine, but it dosen't actually UNLINK the file. and yes i did take the unlink func out of it's comment... here's what i have: ? $name = $_POST['name2']; $pass = $_POST['pass2']; if($name == "admin" && $password == "fakepass") { $some_dir = "../pictures/"; foreach (glob("$some_dir/{*.gif,*.jpg,*.png,*.GIF,*.JPG,*.PNG,*.JPEG,*.jpeg}", GLOB_BRACE) as $file) { echo "Deleting ".$file." <br />"; unset($file); } } ?>
  2. Okay well it's not the actual uploading that i have problems with. it's just I don't understand how to implement that radio button instances you told me, with the upload function. here I will upload the entire script that i have that WORKS, but i don't see how i can make it so it uploads to certain directories... here is what i have that works: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Joe Upload</title> <style type="text/css"> <!-- body { background-image: url(images/index_09.gif); } body,td,th { color: #000000; } .style1 {font-size: 10px} a:link { color: #CC9900; } a:visited { color: #666600; } --> </style></head> <body> <form name="form1" method="post" action="" enctype="multipart/form-data"> <div align="left"> <table width="527" border="1" align="center"> <tr> <td width="8" valign="top"> </td> <td colspan="2" valign="top" background="../images/hardwired.gif"><p class="style1"><b><u>LOGIN INFORMATION:</u></b><br /> Name: <input name="name" type="text" value="--CURRENTLY DISABLED--" /> <br /> <br /> Password: <input name="password" type="text" value="--CURRENTLY DISABLED--" /> </p> <p class="style1">Login is Currently Disabled. Account Creation will soon be avaible. To get a private upload directory click <a href="/makedirectory.php">here </a>.</p> <p class="style1">Have a Private Directory? Upload to it by clicking <a href="/privateupload.php">here </a></p></td> </tr> <tr> <td height="120" rowspan="2" valign="top"> </td> <td width="333" height="59" valign="top" background="../images/bg.gif"><b><u>Upload a File:</u></b><br /> 1. <input type="file" name="imagefile" /> <br /> <br /> 2. <input type="file" name="imagefile2" /> <br /> <br /> 3. <input type="file" name="imagefile3" /> <br /> <br /> 4. <input type="file" name="imagefile4" /> <br /> <br /> 5. <input type="file" name="imagefile5" /> <br /> <br /> 6. <input type="file" name="imagefile6" /> <br /> <br /> 7. <input type="file" name="imagefile7" /> <br /> <br /> 8. <input type="file" name="imagefile8" /> <br /> <br /> 9. <input type="file" name="imagefile9" /> <br /> <br /> 10. <input type="file" name="imagefile10" /> <br /> <br /> <br /> <br /> <br /></td> <td width="164" valign="top" background="../images/bg.gif"><p align="center"> <object width="260" height="199"> <param name="movie" value="http://www.youtube.com/v/H4tURCcrJYI"> </param> <embed src="http://www.youtube.com/v/H4tURCcrJYI" type="application/x-shockwave-flash" width="260" height="199"> </embed> </object> Submit to: </p> <p align="center"> <input type="radio" name="location" value="pictures" /> Pictures</label> <br /> <label> <input type="radio" name="location" value="school" /> School</label> <br /> <label> <input type="radio" name="location" value="music" /> Music</label> <br /> <br> <p align="center"> <input type="submit" name="Submit" value=" Submit" /> </p> </p></td> </tr> <tr> <td height="59" colspan="2" valign="top" background="images/index_04.gif"><? $lol = rand(1,100); $browser = $REMOTE_ADDR; $name = $_POST['name']; $password = $_POST['password']; $Submit = $_POST['Submit']; function uploadFiles($key) { $lol = rand(1,100); copy ($_FILES[$key]['tmp_name'], "pictures/$lol".$_FILES[$key]['name']) or die ("Error Occured When Uploading Image File to Directory"); echo "<br><u><b><center>File<br /> : {$_FILES[$key]['name']} Status</u></b></center><br><br> File Size: {$_FILES[$key]['size']}<br> File Type: {$_FILES[$key]['type']}<br> <br><br> File {$_FILES[$key]['name']} was uploaded Succesfully.<br>"; echo"<br> Click <a href='view/'>here</a> to see your files<br>"; } if($_POST['Submit']) { foreach ($_FILES as $key=>$file) { if (!empty($file['name'])) { uploadFiles($key); } } }else{ echo "Something Went Wrong with the upload process... try our back up uploader...<a href='/uploader.php'>Go To Simple Uploader</a>"; } ?></td> </tr> </table> <div align="center"></div> <p><br /> <br /> <br /> <br /> </p> </div> </form> </body> </html>
  3. Is there any way to make a function that deletes all files of a certain EXTENSION? let's say ".txt" files... how could you use the unlink command to delete all files that have the extension ".txt"?? I know how to recursively unlink all files in a directory, but I can't seem to figure out how to delete all files with a certain extension...
  4. okay so here is what i have so far... but it's not working. im like retarded. anyone tell me how to fix this...? or what i am doing wrong: <html> <form id="form1" name="form1" method="post" action=""> <p> <label> <input type="radio" name="location" value="pictures" /> Pictures</label> <br /> <label> <input type="radio" name="location" value="school" /> Movies</label> <br /> <label> <input type="radio" name="location" value="music" /> Music</label> <br /> <input type="file" name="imagefile" /> <br> </p> <input type="submit" value="Submit" name="submit" /> </form> <?php if($_POST['submit']) $lol = rand(1,100); { $location=$_POST['location']; switch($location) { case 'pictures'; $uploadto='/pictures'; break; case 'school'; $uploadto='/school'; break; case 'music'; $uploadto='/music'; break; default; $uploadto='/other'; break; } copy ($_FILES['imagefile']['tmp_name'], "$uploadto/$lol".$_FILES['imagefile']['name']) or die ("Error Occured When Uploading Image File to Directory $uploadto"); ; } ?> </html>
  5. lets say i have a <input type="radio" name="pictures" value=""> I want it so when the radio button named 'pictures' is clicked and a picture is submitted that it will upload to the already existing folder... /pictures...I already have the entire upload function coded I just need some help or an EXAMPLE of what this function would look like... like can someone write up a quick example of this? with the IF statement and everything
  6. Can anyone give me an example of how I would make a script that if a radio button lets say named 'pictures' is pressed and is submitted how would I make it so if that radio button was selected copy blablabla etc.?
  7. ah yeah that is a lot easier. I am not as good at JAVA as i am at php. alright well i understand that, but last time i tried radio buttons it didn't work well :/. Anyone give me an example of how to use a IF with radiobutton instance?
  8. Okay So yeah, add that java-add on and than make the php functions whatT? give me an example of what one button uploader would look like with the java script... please...
  9. Alright so basically I have Three Submit buttons and a image uploader with user verifcation. What i want to happen is when you press the button that says "Submit Pictures", it will upload pictures to the "files/pictures/" directory, when you press "Submit School", it will upload files to the "files/school/" directory, and when you press "Submit Random", it will upload to the "files/random" directory. I made the script so that right now if the user and password are correct it wil upload to the directory "/files". Can anyone tell me what to do from the script i have so far: <? $lol = rand(1,100); $browser = $REMOTE_ADDR; $name = $_POST['name']; $password = $_POST['password']; $Submit = $_POST['Submit']; $Submitschool = $_POST['Sschool']; $Submitrandom = $_POST['Srandom']; function uploadFiles($key) { $lol = rand(1,100); copy ($_FILES[$key]['tmp_name'], "files/$lol".$_FILES[$key]['name']) or die ("Error Occured When Uploading Image File to Directory"); echo "<br><u><b>File: {$_FILES[$key]['name']} Status</u></b><br><br> File Size: {$_FILES[$key]['size']}<br> File Type: {$_FILES[$key]['type']}<br> <br><br> File {$_FILES[$key]['name']} was uploaded Succesfully.<br>"; echo"<br> Click <a href='files/pictures/'>here</a> to see your files<br>"; } if($_POST['Submit']) { if($name =="test123" && $password =="lawlzzz" || $name=="rofl" && $password=="lolzorz") { foreach ($_FILES as $key=>$file) { if (!empty($file['name'])) { uploadFiles($key); } } }else{ echo "Wrong Credentials, Please try to Login Again"; } } ?> So once again... how would i make it so if i had three buttons: <input type="submit" name="Spictures" value="Submit PICTURES" /> </p> <p align="center"><input type="Sschool" name="Submit" value="Submit SCHOOL STUFF" /> </p> <p align="center"> <input type="submit" name="Srandom" value="Submit Random" /> What would i need to do to make my script so it uploads the FILES to the specific directory when the button is pressed :/
  10. Okay thanks guys, I got everything to work here is what I ended up using for the delete ALL code: <? $name = $_POST['name']; $password = $_POST['password']; if($name == "admin" && $password == "examplepass") { $dir = "files/"; $msg = ""; function deldir($dir) { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") unlink($dir.$file); } closedir($handle); } echo "Directory has been deleted"; } $result =deldir($dir); { #create output message if ($result == true) { $msg = "Done!"; } } }else{ echo "Not a Admin Account click <a href='index.php'>here</a> to go back"; } ?> and the array_map... I am not quite understanding what you want me to do... here is what i have right now for the txt.php file: <? //delete all txts $name = $_POST['name2']; $password = $_POST['pass2']; if($name == "admin" && $password == "pass123"){ array_map ( 'unlink', glob ( './files/*.txt' ) ); }else{ echo "You do not have the Right Privlages to Delete any Files"; } ?> is that supposed to work, because it is not working correctly...:/ any other suggestions?
  11. Alright well here is what I have for the remove ALL FILES of a directory: <? //delete ALL FILES $name = $_POST['name']; $password = $_POST['pass']; if($name == "admin" && $password == "admin") { $dirname = "/files/"; if (!is_dir($dirname)) return false; $dscan = array(realpath($dirname)); $darr = array(); while (!empty($dscan)) { $dcur = array_pop($dscan); $darr[] = $dcur; if ($d=opendir($dcur)) { while ($f=readdir($d)) { if ($f=='.' || $f=='..') continue; $f=$dcur.'/'.$f; if (is_dir($f)) $dscan[] = $f; else unlink($f); } closedir($d); } } $i_until = ($only_empty)? 1 : 0; for ($i=count($darr)-1; $i>=$i_until; $i--) { echo "\nDeleting '".$darr[$i]."' ... "; if (rmdir($darr[$i])) echo "ok"; else echo "FAIL"; } return (($only_empty)? (count(scandir)<=2) : (!is_dir($dirname))); }else{ echo "Do not have the correct Privlages"; } ?> It does not make any errors, but it dosen't do anything either :/. Here is what I used to delete specific files. Let's say for example ".txt" files. <? //delete all jpgs $name = $_POST['name']; $password = $_POST['pass']; if($name == "admin" && $password == "admin") { foreach (glob("/files/*.txt") as $filename) { echo "$filename size " . filesize($filename) . "\n"; unlink($filename); } }else{ echo "You do not have the Right Privlages to Delete any Files"; ?> but these both do not seem to be workingg :/. Any better suggestions or previosley written code so I can delete all files in a directory and SPECIFIC files like certain extensions? I could not get recursive deleting to work either...
  12. Thanks a lot sspoke for all that information, really really helpful.
  13. Yeah sspoke, that worked perfectly. This got me wondering though. Is there anyway that I can clear a page using php? or Would I have to make it go to another page... I was wondering now that I can make an admin account, that like I could make it so if a user logged in as ADMIN, they could delete all files or something which i have already made the unlink script for. Anyway thats possible?
  14. So do that for Both usernames? so for like user: example. how would I implement that. I mean i know how but would that be possible with two users?
  15. I have a script where if the user supplies the correct LOGIN NAME AND PASSWORD, that the user can upload images correctly, and if not it echos "Wrong credentials". I want to make it so there can be more than one username you can use, and more than one password. How can I make it so each user name has it's own password and there is more than one... I tried to do this: if($_POST['Submit']) { if($name =="example" or "example2"and $password =="pass123" or "pass456") { foreach ($_FILES as $key=>$file) { if (!empty($file['name'])) { uploadFiles($key); } } }else{ echo "Wrong Credentials, Please try to Login Again"; } } That usually works with my other script, but for this one it does not work... :/. Any tips? And how would I make it so that EXAMPLE username ONLY WORKS WITH pass123. I know I could just use mysql, but am lazy. :]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.