Jump to content

Lamez

Members
  • Posts

    1,686
  • Joined

  • Last visited

    Never

Everything posted by Lamez

  1. what is salt? Also could you do 2 encryption, like encrypt a string, then in encrypt that string <?php $pass = "mypassword"; $sha1 = sha1($pass); $md5 = md5($sha1); echo $md5; ?>
  2. I keep switching my code, and I do not want to get confused, I understand if you have to delete this, and my other threads. sorry
  3. My script, I just wrote is suppose to check to see if the filename is a image, then it checks for spaces, if so replace them with _, then it is SUPPOSE to upload the file, then it generates a random number, renames that uploaded image with the new number, user, and old filename, then it takes that as a string and makes a hash encryption out of it, with the user, then it ends. Well it does not upload the file! Why? here is the code: <?php include ("../../style/include/session.php"); $user = $session->username; $uploaddir = '/'; ?> <html> <body> <form method="post" enctype="multipart/form-data"> <input type="file" name="file" id="file" /> <br/> <input type="submit" name="upload" value="Upload" /> </form> </body> </html> <?php if (isset($_POST['upload'])){ if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/bmp") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/x-png") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 104857600)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { $bfilename = $_FILES["file"]["name"]; $filename = str_replace(' ', '_', $bfilename); $uploaddir . basename($filename); $newfile = $uploaddir . "/$filename"; $tmp = $_FILES["file"]["tmp_name"]; move_uploaded_file($uploaddir, $tmp); $newname = rand(100, 9000000); $new_filename = rename($filename, $newname."-".$user."-".$filename); $final = md5($new_filename)."-".$user.".".getExt($filename); echo "<br>"; echo "Before Name: ".$bfilename; echo "<br>"; echo "Random Number: ".$newname; echo "<br>"; echo "After Name: ".$new_filename; echo "<br>"; echo "Hased Name: ".$final; echo "<br>Uploaded"; } } else { echo "Invalid file"; } } function getExt($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } ?>
  4. you could mod this system for your own needs http://evolt.org/PHP-Login-System-with-Admin-Features?
  5. How would I be able to use the random function to rename a file? I have this <?php $filename = $_FILES["file"]["name"]; $newname = rand(100, 9000000); $new_filename = rename($filename, $newname["name"]); $final = md5($new_filename); ?> but I get this error: what am I doing wrong?
  6. <?php $connection = mysql_connect("mysql_server_name", "db_username", "db_pass"); mysql_select_db("db_name", $connection); ?> this help?
  7. I have been wondering on how to do that. like myspace has it (myspace.com/username), but how do they do that?
  8. Lamez

    unlink??

    I got this error in my image upload script, the script it suppose to take the file trying to be uploaded, and resize it. here is the error: here is the code with line 68 commented: <html> <head> <title>web.blazonry : PHP : Upload and Resize an Image</title> <?php if ($_SERVER['REQUEST_METHOD'] == "POST") { /* SUBMITTED INFORMATION - use what you need * temporary filename (pointer): $imgfile * original filename : $imgfile_name * size of uploaded file : $imgfile_size * mime-type of uploaded file : $imgfile_type */ /*== upload directory where the file will be stored relative to where script is run ==*/ $uploaddir = "."; /*== get file extension (fn at bottom of script) ==*/ /*== checks to see if image file, if not do not allow upload ==*/ $pext = getFileExtension($imgfile_name); $pext = strtolower($pext); if (($pext != "jpg") && ($pext != "jpeg") && ($pext != "png") && ($pext != "gif") && ($pext != "bmp") && ($pext != "tif")) { print "<h2>Error</h2>"; print "<p>The file you are trying to upload is not a image."; print "<br> jpg, jpeg, png, gif, bmp, and tif are only accepted</p>"; /*== delete uploaded file ==*/ unlink($imgfile); exit(); } //-- RE-SIZING UPLOADED IMAGE /*== only resize if the image is larger than 250 x 200 ==*/ $imgsize = GetImageSize($imgfile); /*== check size 0=width, 1=height ==*/ if (($imgsize[0] > 150) || ($imgsize[1] > 150)) { /*== temp image file -- use "tempnam()" to generate the temp file name. This is done so if multiple people access the script at once they won't ruin each other's temp file ==*/ $tmpimg = tempnam("/tmp", "MKUP"); /*== RESIZE PROCESS 1. decompress jpeg image to pnm file (a raw image type) 2. scale pnm image 3. compress pnm file to jpeg image ==*/ /*== Step 1: djpeg decompresses jpeg to pnm ==*/ system("djpeg $imgfile >$tmpimg"); /*== Steps 2&3: scale image using pnmscale and then pipe into cjpeg to output jpeg file ==*/ system("pnmscale -xy 150 150 $tmpimg | cjpeg -smoo 10 -qual 50 >$imgfile"); /*== remove temp image ==*/ unlink($tmpimg); #LINE 68 } /*== setup final file location and name ==*/ /*== change spaces to underscores in filename ==*/ $final_filename = str_replace(" ", "_", $imgfile_name); $newfile = $uploaddir . "/$final_filename"; /*== do extra security check to prevent malicious abuse==*/ if (is_uploaded_file($imgfile)) { /*== move file to proper directory ==*/ if (!copy($imgfile,"$newfile")) { /*== if an error occurs the file could not be written, read or possibly does not exist ==*/ print "Error Uploading File."; exit(); } } /*== delete the temporary uploaded file ==*/ unlink($imgfile); print("<img src=\"$final_filename\">"); /*== DO WHATEVER ELSE YOU WANT SUCH AS INSERT DATA INTO A DATABASE ==*/ } ?> </head> <body bgcolor="#FFFFFF"> <h2>Upload and Resize an Image</h2> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="1073741824"> <p>Upload Image: <input type="file" name="imgfile"><br> <font size="1">Click browse to upload a local file</font><br> <br> <input type="submit" value="Upload Image"> </form> </body> </html> <?php /*== FUNCTIONS ==*/ function getFileExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } ?> I know it is safe mode restrictions, but what does unlink do? How can I fix this?
  9. ahh that looks like something very similar to what I want, thanks I will take a look at it.
  10. just set your image with to 100% <img src="imagepath.png" alt="Footer Image" width="100%" height="%90px" />
  11. I have never ever wrote a script to upload images, and I know this can be done. Could someone write down the steps on getting a image to upload to a dir, I have already set the chmode of the dir to 777. Also a sample code of a file upload or something like that would help me out. I do not want anyone to spoon feed me, I just need someone to point me in the right direction. Thanks Guys P.S. is it possible to set a image size, file size, and file extension.
  12. Lamez

    ORDER BY

    that last idea could work. but they way I can tell if a topic is sticky or empty is by putting a one in the the column so if sticky = 1 topic is sticky same with the locked structure: could I still use that code if I changed it to 1's and 0's from trues and false?
  13. why don't you just include a menu on your head file?
  14. why don't you install mysql and phpmyadmin?
  15. Lamez

    ORDER BY

    in my query I have it to order by sticky, locked, datetime, and then id. well if I have a topic that is sticky, and locked, and one that is just sticky and unlocked it puts the unlocked on bottom between the two. This is what I wanted, however when it is just two regular topics, it order the locked one above the unlocked one. I want it to order like it would be if it was just datetime. I am kinda lost, and I am pretty sure this topic did not make sense to anyone who reads it. here is my query: $sql="SELECT * FROM $tbl_name ORDER BY sticky DESC, locked DESC, datetime DESC, id DESC";
  16. <?php mysql_query("UPDATE `table` SET `value` = 'this', `anothervalue` = 'that' WHERE `id` = 'id'"); ?>
  17. TOPIC SOLVED, lol why not just use isset's? finished code: <?php include ("../../style/include/session.php"); if($session->isAdmin()){ $tbl_name="forum_question"; $tbl_name2="forum_answer"; $id = $_POST['id']; if (isset ($_POST['lockt'])){ mysql_query("UPDATE $tbl_name SET locked = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if (isset ($_POST['unlockt'])){ mysql_query("UPDATE $tbl_name SET locked = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if (isset ($_POST['stick'])){ mysql_query("UPDATE $tbl_name SET sticky = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if (isset ($_POST['unstick'])){ mysql_query("UPDATE $tbl_name SET sticky = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if (isset ($_POST['dele'])){ mysql_query("DELETE FROM $tbl_name WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=main_forum.php">'; } }else{ echo "NOT ADMIN"; } ?>
  18. why, if it works, then use it.
  19. duh == well that fixed the logout problem, but now it does not go through the process, say I try to stick a topic, it will not do it, and it does not redirect. new code: <?php include ("../../style/include/session.php"); if($session->isAdmin()){ $tbl_name="forum_question"; $tbl_name2="forum_answer"; $lock = "lockt"; $unlock = "unlockt"; $stick = "stick"; $unstick = "unstick"; $dele = "dele"; $id = $_POST['id']; if ($lock == ($_POST['lockt'])){ mysql_query("UPDATE $tbl_name SET locked = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unlock == ($_POST['unlockt'])){ mysql_query("UPDATE $tbl_name SET locked = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($stick == ($_POST['stick'])){ mysql_query("UPDATE $tbl_name SET sticky = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unstick == ($_POST['unstick'])){ mysql_query("UPDATE $tbl_name SET sticky = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($dele == ($_POST['dele'])){ mysql_query("DELETE FROM $tbl_name WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=main_forum.php">'; } }else{ echo "NOT ADMIN"; } ?>
  20. kinda, what about a IF statment? if ($lvl == ('1')){ do somthing }
  21. function isAdmin(){ return ($this->userlevel == ADMIN_LEVEL || $this->username == ADMIN_NAME); } in session.php
  22. could you rephrase the question. are you asking how to get a page depending on what is sent through the drop down box?
  23. <?php $lvl = $_GET['level']; echo $lvl; ?> output: 1 any help?
  24. I have add '$id' now, but same thing happens. <?php include ("../../style/include/session.php"); if($session->isAdmin()){ $tbl_name="forum_question"; $tbl_name2="forum_answer"; $lock = "lockt"; $unlock = "unlockt"; $stick = "stick"; $unstick = "unstick"; $dele = "dele"; $userid = "userid"; $id = $_POST['id']; if ($lock = ($_POST['lockt'])){ mysql_query("UPDATE $tbl_name SET locked = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unlock = ($_POST['unlockt'])){ mysql_query("UPDATE $tbl_name SET locked = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($stick = ($_POST['stick'])){ mysql_query("UPDATE $tbl_name SET sticky = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unstick = ($_POST['unstick'])){ mysql_query("UPDATE $tbl_name SET sticky = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($dele = ($_POST['dele'])){ mysql_query("DELETE FROM $tbl_name WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=main_forum.php">'; } } ?>
  25. every time I delete a topic on my custom message board, it logs me off. Why? here is the code: <?php include ("../../style/include/session.php"); if($session->isAdmin()){ $tbl_name="forum_question"; $tbl_name2="forum_answer"; $lock = "lockt"; $unlock = "unlockt"; $stick = "stick"; $unstick = "unstick"; $dele = "dele"; $userid = "userid"; $id = $_POST['id']; if ($lock = ($_POST['lockt'])){ mysql_query("UPDATE $tbl_name SET locked = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unlock = ($_POST['unlockt'])){ mysql_query("UPDATE $tbl_name SET locked = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($stick = ($_POST['stick'])){ mysql_query("UPDATE $tbl_name SET sticky = '1' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($unstick = ($_POST['unstick'])){ mysql_query("UPDATE $tbl_name SET sticky = '0' WHERE id = '$id'") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=view_topic.php?id='.$id.'">'; } if ($dele = ($_POST['dele'])){ mysql_query("DELETE FROM $tbl_name WHERE id = $id") or die(mysql_error()); print '<meta http-equiv="refresh" content="0;url=main_forum.php">'; } } ?>
×
×
  • 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.