Jump to content

allaboutthekick

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

allaboutthekick's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Extra:; I had read into some tutorials but all have pointed me towards this function: http://us3.php.net/manual/en/function.imagecopyresampled.php Im not sure how to impliment that the script and maybe im going down the wrong path.
  2. I would like to impliment a image resizer into this script that takes the image if it is bigger then 450w and resizes it. I dont know where or how to insert the code into this script, please suggest anything, thank you. [code] <?php // define the base image dir include("logincheck.php"); $base_img_dir = "./img/"; // define location of image conversion programs $img_conv_dir = "./bin/"; // define database table containing image info $img_table = "images"; // connect with database include('dbcon.php'); // generate unique id for use in filename $uniq = uniqid(""); // new file name $filename = $base_img_dir.$uniq; // move uploaded file to destination move_uploaded_file($HTTP_POST_FILES["file"]["tmp_name"], $filename); // retrieve image info $imginfo = getimagesize($filename); // handle image according to type switch ($imginfo[2]) {     case 1: // gif         // convert gif to png using shell command         $command = $img_conv_dir."gif2png $filename";         exec($command);                 // remove original gif file and rename converted png         unlink($filename);         rename("$filename.png", $filename);                 // check png image by loading and saving the file         //  to prevent wrong uploaded files and errors         $img = imagecreatefrompng($filename);         imagepng($img, $filename);         imagedestroy($img);                 // set image type to png         $img_type = "PNG";         break; case 2: // jpeg         // check jpeg image by loading and saving the file         //  to prevent wrong uploaded files and errors         $img = imagecreatefromjpeg($filename);         imagejpeg($img, $filename);         imagedestroy($img);                 // set image type to jpeg         $img_type = "JPG";         break;     case 3: // png         // check png image by loading and saving the file         //  to prevent wrong uploaded files and errors         $img = imagecreatefrompng($filename);         imagepng($img, $filename);         imagedestroy($img);                 // set image type to png         $img_type = "PNG";         break; case 4: // bmp         // rename file to bmp         rename($filename, "$filename.bmp");                 // convert bmp to png using shell command         $command = $img_conv_dir."bmptoppm $filename.bmp | ".                   $img_conv_dir."pnmtopng > $filename";         exec($command);                 // remove original bmp         unlink("$filename.bmp");                 // check png image by loading and saving the file         //  to prevent wrong uploaded files and errors         $img = imagecreatefrompng($filename);         imagepng($img, $filename);         imagedestroy($img);                 // set image type to png         $img_type = "PNG";         break;     default:         break; } // retrieve image file size $imgbytes = filesize($filename); // insert image into db mysql_query("INSERT INTO $img_table (username, img_file, img_type, img_height,   img_width, img_bytes, img_title, img_descr, img_alt)   VALUES( '$username', '$uniq', '$img_type', ".$imginfo[1].", ".$imginfo[0].",         $imgbytes, '".addslashes($HTTP_POST_VARS["title"])."', '".         addslashes($HTTP_POST_VARS["descr"])."',         '".addslashes($HTTP_POST_VARS["alt"])."');"); // display some information echo "Image uploaded.<br><img src=\"img/$uniq\"><br>".     "URL: img/$uniq"; ?>[/code]
  3. ok i implemented it here--- [code]<?PHP $Uname=''; $Pass=''; $contents=''; if (!file_exists("imgs/".$Uname.".nam")){ echo "Username does not exsist, please check that capslock is not on and that your entry was spelled correctly."; }else{ if ($_REQUEST['Uname'] != "") {   $Uname = $_REQUEST['Uname']; } else { die('You need both a Username and password to login'); } if ($_REQUEST['Pass'] != "") {   $Pass = $_REQUEST['Pass']; } else {   die('You need both a Username and password to login'); } $fp = fopen("imgs/".$Uname.".nam","rb"); $contents = fread($fp, filesize("imgs/".$Uname.".nam")); fclose($fp); $pieces = explode(" ", $contents); if ($pieces[2] == md5($Pass)) { setcookie('User',$Uname,time()+(60*60)); } else { die ('Sorry the password username combanation does not exist'); } header("Location: http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/index.php"); } ?> [/code] but no matter what, right entry or wrong entry it states my echo.
  4. One last thing....... I want this code to to report an error when someone enters a wrong password or username. [code]<?PHP $Uname=''; $Pass=''; $contents=''; if ($_REQUEST['Uname'] != "") { $Uname = $_REQUEST['Uname']; } else { die('You need both a Username and password to login'); } if ($_REQUEST['Pass'] != "") { $Pass = $_REQUEST['Pass']; } else { die('You need both a Username and password to login'); } $fp = fopen("imgs/".$Uname.".nam","rb"); $contents = fread($fp, filesize("imgs/".$Uname.".nam")); fclose($fp); $pieces = explode(" ", $contents); if ($pieces[2] == md5($Pass)) { setcookie('User',$Uname,time()+(60*60)); } else { die ('Sorry the password username combanation does not exist'); } header("Location: http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/index.php"); ?> [/code] the current checker is..... [code] if ($pieces[2] == md5($Pass)) { setcookie('User',$Uname,time()+(60*60)); } else { die ('Sorry the password username combanation does not exist'); }[/code] but this wont work if you cant even open the file .usr so i need something to report when the file isnt there. I feel the code should be placed right after this code [code] $fp = fopen("imgs/".$Uname.".nam","rb");[/code]
  5. i did some searching and found this command [code] exif_imagetype() [/code] http://us3.php.net/manual/en/function.exif-imagetype.php and this [code]image_type_to_extension[/code] http://us3.php.net/manual/en/function.image-type-to-extension.php i feel that one of those codes is the one i should use but i do not know how to implement them....
  6. ok so this is what i did right here [code] if(is_uploaded_file($_FILES['userfile']['tmp_name'])){ $userfile=$_FILES['userfile']['tmp_name']; $userfile_size=$_FILES['userfile']['size']; $userfile_type=$_FILES['userfile']['type']; $userfile_name=$_FILES['userfile']['name']; list($type) = getimagesize($userfile); if($type != 2){     die("Error not a jpeg"); [/code] but it always displays "error not jpeg" even when it is a jpeg....... sooooo close!!!!
  7. so something like if(!$type == 2); die("Error not a jpeg"); and how would i make it delete the uploaded file?
  8. how would i make it stop the script and display an error once the value of $type doesnt equal 2.
  9. i dont know too much about php how would i incorporate that into the script? is it a quick add or do i need to re arrange some stuff. I didnt write this script i just downloaded it and altered it a little. 
  10. I get this error------- Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in /nfs/cust/6/85/82/728586/web/upload.php on line 67 Not a JPEG file: starts with 0x47 0x49 Warning: imagecreatefromjpeg(): 'imgs/o1163112384.jpg' is not a valid JPEG file in /nfs/cust/6/85/82/728586/web/upload.php on line 67 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /nfs/cust/6/85/82/728586/web/upload.php on line 69 Error Re-sampling image Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in /nfs/cust/6/85/82/728586/web/upload.php on line 102 Not a JPEG file: starts with 0x47 0x49 Warning: imagecreatefromjpeg(): 'imgs/o1163112384.jpg' is not a valid JPEG file in /nfs/cust/6/85/82/728586/web/upload.php on line 102 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /nfs/cust/6/85/82/728586/web/upload.php on line 104 Error Re-sampling image Warning: imagedestroy(): supplied argument is not a valid Image resource in /nfs/cust/6/85/82/728586/web/upload.php on line 117 But i feel its because my file checker doesnt work......... here is my script------ http://pastebin.com/820708 my image checker is on line 28-29 and i want to make it only allow .jpeg or .jpg images
  11. Ok well i did what you recommended and it worked, except it doesnt stop files that are over 500kb but its ok cause i just realized when i resize it i create a new file that is smaller so it doesnt matter what size they upload. but it would still be nice to have image size checker, so people lets say cant upload images over 4mb
  12. around line 20 i have a image size checker is that incorrect? shouldnt that just do it right there? also after i recieve the error message when trying to upload images that are too big it just leaves 2 files on the server.... one is $badd.jpg and the other is o$badd.jpg ($badd being the time and date of the upload as shown on line 30.
  13. yo huggie i cant send you a PM because of security issues please send me an email to regrethedays@tmail.com and we will talk thanks.
  14. for some reason this script wont validate the image that is trying to be uploaded correctly.... I would usually post the script on a link but due to restrictions it wont allow me to post in code box. http://phpfreaks.pastebin.com/819524 I recieve this error while trying to upload an image that is too large..... Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 7728 bytes) in /nfs/cust/6/85/82/728586/web/upload.php on line 95
×
×
  • 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.