Jump to content


  • Posts

  • Joined

  • Last visited


Profile Information

  • Gender
    Not Telling

corrupshun's Achievements


Member (2/5)



  1. So i was reading up on PHP the other day and read that the IP of the user can be spoofed. I only read that the z-forwarded-ip can be spoofed. My question is this: Can the IP of the user be spoofed: $_SERVER['REMOTE_ADDR']
  2. I'm using PHP GD and everytime I upload a file I exported from photoshop/fireworks it crashes. (such as banners in .gif formats) The program basically uploads an image, resizes it based on it's height/width ratio, places it in a new location, and inserts the filename into the database to the corrosponding username. This is the info apace gave me. that may or may not be helpful.. Here's the code. Please note that apache doesn't comepltly crash, it opens a window that says it stopped running, but still runs. The php page then doesn't load. Here's the PHP: <?php function resize() { if(isset($_COOKIE['username'])) { //----------------------------------------------------------------------- //upload an image that is gif||jpg||jpeg||png && is less than 1mb //save to a temporary spot //set max height and width //get height and width of uploaded file //resize the image and save it to a new location //----------------------------------------------------------------------- //set local variables // $username = $_COOKIE['username']; $maxsize = 10*1048576; // // if(isset($_POST['submit']) && $_POST['submit'] == "Upload!") { if($maxsize > $_FILES['upload']['size']) { if(isset($_FILES['upload']['name']) && isset($_FILES['upload']['size'])) { if(isset($_FILES['upload']['type']) && ($_FILES['upload']['type'] == "image/gif") || ($_FILES['upload']['type'] == "image/jpeg") || ($_FILES['upload']['type'] == "image/pjpeg") || ($_FILES['upload']['type'] == "image/png") || ($_FILES['upload']['type'] == "image/x-png")) { if($_FILES['upload']['error'] > 0) { switch($_FILES['upload']['error']) { case 1: echo 'File is too big for the server to handle.'; break; case 2: echo 'File is bigger than the max file size.'; break; case 3: echo 'File was not uploaded fully.'; break; case 4: echo 'No file was even uploaded.'; break; }//switch }//if error else { ///////////////////SQL//////////////////// $con = mysql_connect('localhost','root'); mysql_select_db("Forum",$con); ///////////// $sql = "SELECT MAX(Avatar) FROM Users"; $query = mysql_query($sql); while($row = mysql_fetch_assoc($query)) { $max = $row['MAX(Avatar)']; } $max++; ///////////// $sql = "SELECT Avatar FROM Users WHERE Username='$username'"; $query = mysql_query($sql); while($row = mysql_fetch_assoc($query)) { $current = $row['Avatar']; } ////////////////////////////////////////// ////////////////Variables///////////////// $save = "img/avatars/{$max}.gif"; $max_h = '110'; $max_w = '110'; $name = $_FILES['upload']['name']; $type = $_FILES['upload']['type']; $temp = $_FILES['upload']['tmp_name']; $file = "uploads/$name"; $tempname = "uploads/temp.gif"; $currentav = "img/avatars/{$current}.gif"; ////////////////////////////////////////// move_uploaded_file($temp,"$file"); if($type == 'image/jpeg' || 'image/pjpeg') { $image = imagecreatefromjpeg($file); imagegif($image, $tempname); imagedestroy($image); } else if($type == 'image/png' || 'image/x-png') { $image = imagecreatefrompng($file); imagegif($image, $tempname); imagedestroy($image); } else if($type == 'image/gif') { $image = imagecreatefromgif($file); imagegif($image, $tempname); imagedestroy($image); } list($width, $height) = getimagesize($file); if($height > $width) { $ratio = $height/$width; $f_width = $max_w/$ratio; $f_height = $max_h; } else if($width > $height) { $ratio = $width/$height; $f_height = $max_h/$ratio; $f_width = $max_w; } else if($width == $height) { $f_height = $max_h; $f_width = $max_w; } $box = imagecreatetruecolor($f_width, $f_height); $image = imagecreatefromgif($tempname); imagecopyresampled($box, $image, 0, 0, 0, 0, $f_width, $f_height, $width, $height); unlink($tempname); imagegif($box, $save, 100); unlink($file); unlink($currentav); $insert = "UPDATE Users SET Avatar='$max' WHERE Username='$username'"; if(mysql_query($insert)) { echo '<div class="error">Success.</div>'; } }//else }//if upload else { echo '<div class="error">Form was submitted but nothing was uploaded..<br />'; echo "The MIME type of: {$_FILES['upload']['type']} is not currently allowed.</div>"; }//else }//if name and size isset else { echo '<div class="error">Submitted but not uploaded.</div>'; }//else }//if maxsize else { echo '<div class="error">It\'s too big.</div>'; }//else }//if submit is set else { ?> <form enctype="multipart/form-data" action="avatar.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $maxsize; ?>" /> Avatar File: <input type="file" name="upload" class="dupload" /><br /> <input type="submit" name="submit" value="Upload!" class="dsubmit" /> </form> <?php } } else { echo '<div class="error">You cannot upload an avatar while you are not logged in. <br /> Please <a href="login.php">Log-in</a> or <a href="register.php">Register</a>.</div>'; } }//end of function ?> Thank you to whomever reads this. I greatly appreciate it
  3. I can't use sessions (as you stated), so can anbody tell me how to do this in cURL? I've always heard of it but never looked into it. Thanks!
  4. process.php: <?php $email = $_POST['email']; header('Location: http://www.example.com'); ?> I would want process.php to take the $email variable and pass it to another page as a POST. Is this possible in conjunction with header()? Or is there another way I could do it?
  5. thank you for the response but it didn't quite answer my question
  6. While programming website i often wonder if I should use both sessions and cookies, just in case that the cookies are disabled. Also I was reading a php book (PHP in a Nutshell) and it said cookies are very insecure and can be edited to send false information to my server, because malicious users can edit them. I knew I could edit them but I didn't know I could hack them! Is this true? My third question is what I store in cookies when using a login script. (my current one sets the username as a cookie.) Thanks.
  7. (this may not help..) But I think it's very well done. Didn't read previous comment, they may have said this.. but... the contact us link is broken. plus it aligns left..
  8. make a form the has the action set to the website and the method as post..
  9. you can use preg_replace() unfourtunately I do not know much preg_match, but now you know where to start
  10. get rid of the submit variable, you won't be using it. replace: if ($submit) with if(isset($_POST['submit'])) this checks to see if submit is set. If it is set then it will produce 'true', if it's not true, it will be false. The 'if' statement checks to see if the condition is true or false. that's ALL it checks. If you still need more help look up booleans
  11. I know your problem, where you have $submit = $_POST['submit']; and then if ($submit) if checks to see if it is true or false, what your putting inside it is if(submit), which won't do anything. I am assuming your making it check to see if the person submitted the page, use this: <?php if(isset($_POST['submit'])) { //do register stuff } else { //show register form } ?> And as a side note, what you have here is VERY insecure, so i'm hoping your not uploading that script somewhere. It's open to SQL Injection.
  12. I know that, I'm mostly asking how to check if the same IP has been to the page before, and if so, to not increment it.
  13. I want to do it like a forum does, where everytime the page loads i could add 1 to the views in the database, while also making sure that the same IP doesn't add more than once? I know i could select the database then count it, then add it, but is there a simplier way (while implementing the same IP concept?) A link would be suffice -Aus THE BOSS
  • 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.