Jump to content

johlwiler

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

johlwiler's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I figured out the problem you can't unlink dir you have to use rmdir() so I built an if statement that showed if it was a dir or file and either unlinked it or opened it to delete what was in it and then unlinked it. Thanks for everyones input. jscix you headed me right where I needed. Thanks
  2. ok in the unlink I added the $start_Directory variable. $deldir=$start_Directory."/".$curEle; unlink($deldir); And it lopped through with this error which is making me think I need to call my host unless I am missing something. Warning: unlink(/home/worldproperties/www/worldpropertiesonline.net/propimg/1): Operation not permitted in /home/worldproperties/www/worldpropertiesonline.net/delete_all.php on line 19 unlink file: 4 is the error I am getting except it is looping through on every file. operation not permitted. this is getting very weird.
  3. ok I tryed rarebits code idea first and got some hang ups so I moved on to jscix got his to respond fine with out the unlink function. it echoed out all the directories. So right below the echo I add unlink to the and the same varible and got a loop of errors instead. Basically telling my that the files and dir do not exists. Warning: unlink(1): No such file or directory in /home/worldproperties/www/worldpropertiesonline.net/delete_all.php on line 18 unlink file: 4 here is the code <?php function DelTree($start_Directory) { $directory_List = array(); echo "<b>Removing all contents from: " . $start_Directory . "</b><br>"; if ($handle = opendir($start_Directory)) { while (false !== ($curEle = readdir($handle))) { if (is_dir($curEle) && substr($curEle,0,1) !== ".") { array_push($directory_List,$curEle); } else { echo "unlink file: " . $curEle . "<br>"; unlink($curEle); //added by me to unlink the files. } } closedir($handle); } foreach ($directory_List as $dir) { $new_Dir = $dir; array_shift($directory_List); DelTree($new_Dir); } } DelTree("/home/worldproperties/www/worldpropertiesonline.net/propimg"); ?>
  4. I can't ssh in just ftp. If I did and could su root I wouldn't have a problem at all. So I think my only option is php. I think I see what jscix is saying open the directory then read all contents from there I guess I can find a way to unlink them then close the directory the only thing is here how would I deal with sub directories I have a file propimg then under that I have folders with different contents under different naming conventions. then most of those folders have sub folders. Total it is like 700 different files and folders. Am I going to have to go one by one through them all?? Thats what I am trying to figure out.
  5. Hi all, I have a folder in my web site where I used php to create and copy in files. but now I can't delete them easily. The only way I know how that is possible is through php. I get an error the following ftp error: 550 th: Permission denied I had the chmod() set to 0777 on every file and folder. But I still seem to loss control over the files when I try and do things with them through other means. I think it is because the user I use to access the files via ftp a diffrent user. So I tryed to add a function with chown() for the new files I was posting and uploading. It didn't work on those new files. so it looks like the only thing I can do is use the unlink() function which deletes the files fine. The only problem is now I have something like 100 sub directories all with files in them. I need to figure out a way to batch delete them. I can't find a script that goes through and finds all file contents including all sub directories and unlink those things. I found some that will use a for loop to list out the contents of a folder but it is just files. No sub directories. Any body got any ideas on which functions I should use or know where a script is that I can base mine off of. I am not sure how to approach this since what I tryed with chown and chmod has failed thus far. I currently have no code and am starting from scratch on this batch flushing of my directory.
  6. I got it to work. It creates directories uploads the images and everything. With or without spaces in the file name. I do have a problem though. I don't have root access to the server and somehow even though I have everything set to 0777 chmod in my php scripts the files are still coming over to 755 for my user log in. So I can't edit, delete or change the chmod of those files and folders with my ftp program. I have read some things about shell extensions through php and things of that nature. Does anybody have a code that will go and change all folders and sub folders to a different chmod. Or what can I do from a coding perspective to unlock all of those files so I can do things with an FTP program and not get a 550 error code. Is it possible my host is blocking my code from creating a full 0777, and making the files on a server level to 0755?
  7. ok. I got the mkdir scritps down to where it makes the directory but when I go to upload a file I get thie Warning: copy(../propimg/4/full/Autumn Leaves.jpg): failed to open stream: No such file or directory in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 136 Warning: imagecreatefromjpeg(../propimg/4/full/Autumn Leaves.jpg): failed to open stream: No such file or directory in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 169 Warning: imagesx(): supplied argument is not a valid Image resource in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 170 Warning: imagesy(): supplied argument is not a valid Image resource in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 171 Warning: Division by zero in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 177 Warning: imagecreate(): Invalid image dimensions in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 181 Warning: imagetruecolortopalette(): supplied argument is not a valid Image resource in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 182 Warning: imagecolorstotal(): supplied argument is not a valid Image resource in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 183 Warning: imagecopyresized(): supplied argument is not a valid Image resource in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 188 Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 189 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 190 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 191 There was a problem uploading your script here is all my code for the whole page. I think the problem I am having now lies in where I put some of my if statements for validating the user and so on <?php @session_start(); ?> <?php if(!isset($_SESSION['username'])){ die ("You either are not logged in or you do not have permission to view this page you must log in. If you feel this is a mistake click here to <a href='../logout.php'>log out</a> and then immediatly log back in and try agian."); } //get userid needed ad so on $loginID=$_SESSION['loginID']; $username=$_SESSION['username']; include("../constents.php"); mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql' . mysql_error()); if(!isset($_GET['propID'])){ //search the database to see properties that need to be paid for $sql="SELECT * FROM ".$dbname.".tbl_props WHERE LoginID='".$loginID."' and userdeactive='0'"; $result=mysql_query($sql); $numberProps=mysql_num_rows($result); ?> <!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=utf-8" /> <title>Untitled Document</title> </head> <body> <p>You have <?=$numberProps ?> listings in the system.</p> <p>Please select the property you wish to view and or edit your pictures</p> <? while( $row = mysql_fetch_assoc($result)){ ?> <? //this is the picture echo echo "<img src='http://worldpropertiesonline.net/propimg/".$row['propID']."/th/".$row['mpic']."' width='125px' height='94px' />"; //followed by the detailed detialed stuff ?> <?=$row['title'] ?> <?=$row['propID'] ?> <?=$row['whenlisted'] ?> <?=$row['paidTill'] ?> <a href="<?=$_SERVER['PHP_SELF'] ?>?propID=<?=$row['propID'] ?>">Manage this listings pictures</a><br /> <? } ?> </body> </html> <? //---------------------------------------------------- //end of first pass //---------------------------------------------------- } elseif(isset($_REQUEST['propID'])){ //---------------------------------------------------- //start of second pass //---------------------------------------------------- //function to delete a pic and its thumbnail out of the system. function picdelete($filename, $property){ $path="../propimg/".$property."/reg/".$filename; $path2="../propimg/".$property."/th/".$filename; if (file_exists($path)){ fclose($path); unlink($path); } if (file_exists($path2)){ fclose($path2); unlink($path2); } } //if this pass has images to delete run the function for the valus if($_POST['delete']=="true"){ foreach($_REQUEST['imgdelete'] as $imgfile){ picdelete($imgfile, $_REQUEST['propID']); } } $sql="SELECT * FROM ".$dbname.".tbl_props WHERE LoginID='".$loginID."' and userdeactive='0' and propID='".$_REQUEST['propID']."'"; $result=mysql_query($sql); $numberProps=mysql_num_rows($result); mysql_close(); //checks to see if the propID belongs to the user that is accessing it if($numberProps !== 1){ $NoNouser=1; } else { //the image upload and resize stuff $idir = "../propimg/".$_REQUEST['propID']."/full/"; // Path To Images Directory $tdir = "../propimg/".$_REQUEST['propID']."/th/"; // Path To Thumbnails Directory $twidth = "125"; // Maximum Width For Thumbnail Images $theight = "94"; // Maximum Height For Thumbnail Images $ldir = "../propimg/".$_REQUEST['propID']."/reg/"; // Path To Thumbnails Directory $lwidth = "640"; // Maximum Width For Thumbnail Images $lheight = "480"; // Maximum Height For Thumbnail Images $pic=($_FILES['imagefile']['name']); $gallery = $_POST['gallery']; if (isset($_POST['gallery'])) { $error=0; $succ=0; // Uploading/Resizing Script $url = $_FILES['imagefile']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['imagefile']['type'] == "image/jpg" || $_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['imagefile']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['imagefile']['tmp_name'], "$idir" . $_FILES['imagefile']['name']); // Move Image From Temporary Location To Permanent Location if ($copy) { // If The Script Was Able To Copy The Image To It's Permanent Location $succ++;// Was Able To Successfully Upload Image $simg = imagecreatefromjpeg("$idir" . $url); // Make A New Temporary Image To Create The Thumbanil From $currwidth = imagesx($simg); // Current Image Width $currheight = imagesy($simg); // Current Image Height if ($currheight > $currwidth) { // If Height Is Greater Than Width $zoom = $twidth / $currheight; // Length Ratio For Width $newheight = $theight; // Height Is Equal To Max Height $newwidth = $currwidth * $zoom; // Creates The New Width } else { // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height) $zoom = $twidth / $currwidth; // Length Ratio For Height $newwidth = $twidth; // Width Is Equal To Max Width $newheight = $currheight * $zoom; // Creates The New Height } $dimg = imagecreate($newwidth, $newheight); // Make New Image For Thumbnail imagetruecolortopalette($simg, false, 256); // Create New Color Pallete $palsize = ImageColorsTotal($simg); for ($i = 0; $i < $palsize; $i++) { // Counting Colors In The Image $colors = ImageColorsForIndex($simg, $i); // Number Of Colors Used ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']); // Tell The Server What Colors This Image Will Use } imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); // Copy Resized Image To The New Image (So We Can Save It) imagejpeg($dimg, "$tdir" . $url); // Saving The Image imagedestroy($simg); // Destroying The Temporary Image imagedestroy($dimg); // Destroying The Other Temporary Image $succ++; // Resize successful } else { $error++; // Error Message If Upload Failed } $simg = imagecreatefromjpeg("$idir" . $url); // Make A New Temporary Image To Create The Thumbanil From $currwidth = imagesx($simg); // Current Image Width $currheight = imagesy($simg); // Current Image Height if ($currheight > $currwidth) { // If Height Is Greater Than Width $zoom = $lwidth / $currheight; // Length Ratio For Width $newheight = $lheight; // Height Is Equal To Max Height $newwidth = $currwidth * $zoom; // Creates The New Width } else { // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height) $zoom = $lwidth / $currwidth; // Length Ratio For Height $newwidth = $lwidth; // Width Is Equal To Max Width $newheight = $currheight * $zoom; // Creates The New Height } $dimg = imagecreate($newwidth, $newheight); // Make New Image For The Large Image imagetruecolortopalette($simg, false, 256); // Create New Color Pallete $palsize = ImageColorsTotal($simg); for ($i = 0; $i < $palsize; $i++) { // Counting Colors In The Image $colors = ImageColorsForIndex($simg, $i); // Number Of Colors Used ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']); // Tell The Server What Colors This Image Will Use } imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); // Copy Resized Image To The New Image (So We Can Save It) imagejpeg($dimg, "$ldir" . $url); // Saving The Image imagedestroy($simg); // Destroying The Temporary Image imagedestroy($dimg); // Destroying The Other Temporary Image $succ++; // Resize successful } else { $error++; // Error Message If Upload Failed } } //either gets the pics or creats a directory if noone has added pics before $file_path="../propimg/".$_GET['propID']."/th/"; $file_path2="../propimg/".$_GET['propID']."/reg/"; $picarray=array(); if(is_dir($file_path)){ $handle=opendir($file_path); $pics=1; $i=0; while(false!==($picloop=readdir($handle))){ $picarray[$i]=$picloop; $i++; } } elseif(!is_dir($filepath)) { mkdir("../propimg/".$_GET['propID'], 0777); mkdir($file_path, 0777); mkdir($file_path2, 0777); $pics=0; } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>World Properties Online</title> <meta name="keywords" content="glossary,property,real estate,rental,commercial,sale,by owner" /> <meta name="description" content="Welcome to World Properties Online, your guide to property for sale around the world." /> <link href="wpo.css" rel="stylesheet" type="text/css" /> </head> <body> <? if ($NoNouser==1){ die ("<p>Sorry but this property does not match our records. Please go back to <a href='".$_SERVER['PHP_SELF']."'>the picture management main area</a> and reslect your property. here is login id ".$loginID."</p></body></head>"); } if($error >= 1){ echo "There was a problem uploading your script"; } elseif ($succ == 3){ echo "image upload successful."; } if($pics==0){ echo "You currently do not have any pictures for this listing."; } else { ?> <p>You have <?=$i ?> pictures related to your listing </p> <p>Remember you are only allowed to have ten pictures per listing.</p> <form action="<?=$_SERVER['PHP_SELF'] ?>" method="post"> <input type="hidden" name="propID" value="<?=$_REQUEST['propID']?>" /> <input type="hidden" name="delete" value="true" /> <? foreach($picarray as $value){ if(strlen($value) >= 4){ if(strstr($value, "." )!=1) ?> <a href="http://www.worldpropertiesonline.net/propimg/<?=$_REQUEST['propID'] ?>/reg/<?=$value ?>"><img src="http://www.worldpropertiesonline.net/propimg/<?=$_REQUEST['propID'] ?>/th/<?=$value ?>" /></a> Delete<input type="checkbox" name="imgdelete[]" value="<?=$value ?>" /> <? } ?> <input type="submit" name="Delete Properties" /> </form> <? } } if($i < 10){ if (!isset($_POST['gallery'])) { ?> <fieldset> <legend><b>Image Upload</b></legend> <form enctype="multipart/form-data" action="<? $_SERVER['PHP_SELF']; ?>" method="post"> <input type="hidden" name="propID" value="<?=$_REQUEST['propID'] ?>" /> <input type="hidden" name="gallery" value="set" /> <input type="file" name="imagefile" /><br /> <input type="submit" name="submit" value="Upload Image" class="submit-button" /> </form> </fieldset><br /> <? } else { echo "You can not add more files till you delete the ohter ones."; } } ?> </body> </html> Please look through it and help my to understand my errors and where they are comming from thi si a little confusing and now complicated for me.
  8. I thought the code created the directories. or at least I want it to. please look at my code and tell me. I have this in there which should run if no directory exist. //either gets the pics or creats a directory if noone has added pics before $file_path=$_SERVER['DOCUMENT_ROOT']."/propimg/".$_GET['propID']."/th/"; $file_path2=$_SERVER['DOCUMENT_ROOT']."/propimg/".$_GET['propID']."/reg/"; $picarray=array(); if(is_dir($file_path)){ $handle=opendir($file_path); $pics=1; $i=0; while(false!==($picloop=readdir($handle))){ $picarray[$i]=$picloop; $i++; } } elseif(!is_dir($file_path)) { mkdir($file_path, 0777); mkdir($file_path2, 0777); $pics=0; } Basically that should create the directory. but I think that is where my problem is. Because you are right no directories were created. but I stilldoes anyone see an error there am is there a problem with my logic? I try using $_SERVER['DOCUMENT_ROOT'] as well to try and give the right directory. I moved a few things around in my if statments adn no get this error. Warning: mkdir(../propimg/4/th/): No such file or directory in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 222 Warning: mkdir(../propimg/4/reg/): No such file or directory in /home/worldproperties/www/worldpropertiesonline.net/control/addpic.php on line 223 which are my make directory statements. I don't understand I thought mkdir() created the directory. propimg already exists. do I have to create propimg/# before the other 2
  9. ok thanks for your help guys. this works. it hides the button and shows the div. function process(){ document.getElementById('showAfterClick').style.display = 'block'; document.getElementById('fsubmit').style.display='none'; document.getElementById('creditform').submit(); } </script>
  10. I tryed the And in IE 7 it did submit but nothing else worked. I took ou all of the legacy code. I am going to try it with what micah1707 said and just hide it. Hree is my current code <script language="javascript" type="text/javascript"> function process(){ document.getElementById("showAfteClick").style.display = 'block'; document.getElementById("fsubmit").disabled=true; document.getElementById('creditform').submit(); } </script> When I added the submit it was almost like it over rode everything else.
  11. ok after goin off of his script I have taken everything and have put it all into one file. Everything seems alright except when I go to upload a script nothing happends. The first pass is the same the second pass has all the options and everything goes back to the second pass. I got no errors of any type at all and I am starting to freak out again so I am going to post this code, step away, get some sleep and come back to it. Being that I get no syntax errors it has to be something with my logic. So I have a feeling this is going to be tricky. <?php @session_start(); ?> <?php if(!isset($_SESSION['username'])){ die ("You either are not logged in or you do not have permission to view this page you must log in. If you feel this is a mistake click here to <a href='../logout.php'>log out</a> and then immediatly log back in and try agian."); } //get userid needed ad so on $loginID=$_SESSION['loginID']; $username=$_SESSION['username']; include("../constents.php"); mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql' . mysql_error()); if(!isset($_GET['propID'])){ //search the database to see properties that need to be paid for $sql="SELECT * FROM ".$dbname.".tbl_props WHERE LoginID='".$loginID."' and userdeactive='0'"; $result=mysql_query($sql); $numberProps=mysql_num_rows($result); ?> <!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=utf-8" /> <title>Untitled Document</title> </head> <body> <p>You have <?=$numberProps ?> listings in the system.</p> <p>Please select the property you wish to view and or edit your pictures</p> <? while( $row = mysql_fetch_assoc($result)){ ?> <? //this is the picture echo echo "<img src='http://www.worldpropertiesonline.net/propimg/".$row['propID']."/th/".$row['mpic']."' width='125px' height='94px' />"; //followed by the detailed detialed stuff ?> <?=$row['title'] ?> <?=$row['propID'] ?> <?=$row['whenlisted'] ?> <?=$row['paidTill'] ?> <a href="<?=$_SERVER['PHP_SELF'] ?>?propID=<?=$row['propID'] ?>">Manage this listings pictures</a><br /> <? } ?> </body> </html> <? //---------------------------------------------------- //end of first pass //---------------------------------------------------- } elseif(isset($_REQUEST['propID'])){ //---------------------------------------------------- //start of second pass //---------------------------------------------------- //function to delete a pic and its thumbnail out of the system. function picdelete($filename, $property){ $path=$_SERVER['DOCUMENT_ROOT']."/propimg/".$property."/reg/".$filename; $path2=$_SERVER['DOCUMENT_ROOT']."/propimg/".$property."/th/".$filename; if (file_exists($path)){ fclose($path); unlink($path); } if (file_exists($path2)){ fclose($path2); unlink($path2); } } //if this pass has images to delete run the function for the valus if($_POST['delete']=="true"){ foreach($_REQUEST['imgdelete'] as $imgfile){ picdelete($imgfile, $_REQUEST['propID']); } } $sql="SELECT * FROM ".$dbname.".tbl_props WHERE LoginID='".$loginID."' and userdeactive='0' and propID='".$_REQUEST['propID']."'"; $result=mysql_query($sql); $numberProps=mysql_num_rows($result); mysql_close(); //checks to see if the propID belongs to the user that is accessing it if($numberProps !== 1){ $NoNouser=1; } else { //the image upload and resize stuff $idir = "../propimg/".$_REQUEST['propID']."/full/"; // Path To Images Directory $tdir = "../propimg/".$_REQUEST['propID']."/th/"; // Path To Thumbnails Directory $twidth = "125"; // Maximum Width For Thumbnail Images $theight = "94"; // Maximum Height For Thumbnail Images $ldir = "../propimg/".$_REQUEST['propID']."/reg/"; // Path To Thumbnails Directory $lwidth = "640"; // Maximum Width For Thumbnail Images $lheight = "480"; // Maximum Height For Thumbnail Images $pic=($_FILES['imagefile']['name']); $gallery = $_POST['gallery']; if (isset($_POST['gallery'])) { $error=0; $succ=0; // Uploading/Resizing Script $url = $_FILES['imagefile']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['imagefile']['type'] == "image/jpg" || $_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['imagefile']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['imagefile']['tmp_name'], "$idir" . $_FILES['imagefile']['name']); // Move Image From Temporary Location To Permanent Location if ($copy) { // If The Script Was Able To Copy The Image To It's Permanent Location $succ++;// Was Able To Successfully Upload Image $simg = imagecreatefromjpeg("$idir" . $url); // Make A New Temporary Image To Create The Thumbanil From $currwidth = imagesx($simg); // Current Image Width $currheight = imagesy($simg); // Current Image Height if ($currheight > $currwidth) { // If Height Is Greater Than Width $zoom = $twidth / $currheight; // Length Ratio For Width $newheight = $theight; // Height Is Equal To Max Height $newwidth = $currwidth * $zoom; // Creates The New Width } else { // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height) $zoom = $twidth / $currwidth; // Length Ratio For Height $newwidth = $twidth; // Width Is Equal To Max Width $newheight = $currheight * $zoom; // Creates The New Height } $dimg = imagecreate($newwidth, $newheight); // Make New Image For Thumbnail imagetruecolortopalette($simg, false, 256); // Create New Color Pallete $palsize = ImageColorsTotal($simg); for ($i = 0; $i < $palsize; $i++) { // Counting Colors In The Image $colors = ImageColorsForIndex($simg, $i); // Number Of Colors Used ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']); // Tell The Server What Colors This Image Will Use } imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); // Copy Resized Image To The New Image (So We Can Save It) imagejpeg($dimg, "$tdir" . $url); // Saving The Image imagedestroy($simg); // Destroying The Temporary Image imagedestroy($dimg); // Destroying The Other Temporary Image $succ++; // Resize successful } else { $error++; // Error Message If Upload Failed } $simg = imagecreatefromjpeg("$idir" . $url); // Make A New Temporary Image To Create The Thumbanil From $currwidth = imagesx($simg); // Current Image Width $currheight = imagesy($simg); // Current Image Height if ($currheight > $currwidth) { // If Height Is Greater Than Width $zoom = $lwidth / $currheight; // Length Ratio For Width $newheight = $lheight; // Height Is Equal To Max Height $newwidth = $currwidth * $zoom; // Creates The New Width } else { // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height) $zoom = $lwidth / $currwidth; // Length Ratio For Height $newwidth = $lwidth; // Width Is Equal To Max Width $newheight = $currheight * $zoom; // Creates The New Height } $dimg = imagecreate($newwidth, $newheight); // Make New Image For The Large Image imagetruecolortopalette($simg, false, 256); // Create New Color Pallete $palsize = ImageColorsTotal($simg); for ($i = 0; $i < $palsize; $i++) { // Counting Colors In The Image $colors = ImageColorsForIndex($simg, $i); // Number Of Colors Used ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']); // Tell The Server What Colors This Image Will Use } imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); // Copy Resized Image To The New Image (So We Can Save It) imagejpeg($dimg, "$ldir" . $url); // Saving The Image imagedestroy($simg); // Destroying The Temporary Image imagedestroy($dimg); // Destroying The Other Temporary Image $succ++; // Resize successful } else { $error++; // Error Message If Upload Failed } } //either gets the pics or creats a directory if noone has added pics before $file_path=$_SERVER['DOCUMENT_ROOT']."/propimg/".$_GET['propID']."/th/"; $file_path2=$_SERVER['DOCUMENT_ROOT']."/propimg/".$_GET['propID']."/reg/"; $picarray=array(); if(is_dir($file_path)){ $handle=opendir($file_path); $pics=1; $i=0; while(false!==($picloop=readdir($handle))){ $picarray[$i]=$picloop; $i++; } } elseif(is_dir($file_path2)) { mkdir($file_path, 0777); mkdir($file_path2, 0777); $pics=0; } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>World Properties Online</title> <meta name="keywords" content="glossary,property,real estate,rental,commercial,sale,by owner" /> <meta name="description" content="Welcome to World Properties Online, your guide to property for sale around the world." /> <link href="wpo.css" rel="stylesheet" type="text/css" /> </head> <body> <? if ($NoNouser==1){ die ("<p>Sorry but this property does not match our records. Please go back to <a href='".$_SERVER['PHP_SELF']."'>the picture management main area</a> and reslect your property. here is login id ".$loginID."</p></body></head>"); } if($error >= 1){ echo "There was a problem uploading your script"; } elseif ($succ == 3){ echo "image upload successful."; } if($pics==0){ echo "You currently do not have any pictures for this listing."; } else { ?> <p>You have <?=$i ?> pictures related to your listing </p> <p>Remember you are only allowed to have ten pictures per listing.</p> <form action="<?=$_SERVER['PHP_SELF'] ?>" method="post"> <input type="hidden" name="propID" value="<?=$_REQUEST['propID']?>" /> <input type="hidden" name="delete" value="true" /> <? foreach($picarray as $value){ if(strlen($value) >= 4){ if(strstr($value, "." )!=1) ?> <a href="http://www.worldpropertiesonline.net/propimg/<?=$_REQUEST['propID'] ?>/reg/<?=$value ?>"><img src="http://www.worldpropertiesonline.net/propimg/<?=$_REQUEST['propID'] ?>/th/<?=$value ?>" /></a> Delete<input type="checkbox" name="imgdelete[]" value="<?=$value ?>" /> <? } ?> <input type="submit" name="Delete Properties" /> </form> <? } } if($i < 10){ if (!isset($_POST['gallery'])) { ?> <fieldset> <legend><b>Image Upload</b></legend> <form enctype="multipart/form-data" action="<? $_SERVER['PHP_SELF']; ?>" method="post"> <input type="hidden" name="propID" value="<?=$_REQUEST['propID'] ?>" /> <input type="hidden" name="gallery" value="set" /> <input type="file" name="imagefile" /><br /> <input type="submit" name="submit" value="Upload Image" class="submit-button" /> </form> </fieldset><br /> <? } else { echo "You can not add more files till you delete the ohter ones."; } } ?> </body> </html> well good fight good night. Hope someone out there can find the error in my logic.
  12. Hey all I have what I thought was a basic javascript function that disables the submit button of my form and shows a div that is set to display none by flipping it to block. Here is the function as I have it defined in the header <script language="javascript" type="text/javascript"> function process(){ if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById("showAfteClick").style.display = 'block'; document.getElementById("fsubmit").disabled=true; } else { if (document.layers) { // Netscape 4 document.showAfteClick.display = 'block'; document.creditform.fsubmit.disabled=true; } else { // IE 4 document.all.showAfteClick.style.display = 'block'; } } } </script> the id of the form that the submit button resides in is creditform and the id of the submit button its self is submitf The div is after the form and has the id of showAfteClick. Here is how I call the function <input name='submit' type='submit' value='Submit' id="fsubmit" onclick="process()" /> In Firefox when I click the button the button disables and the div shows. And it post to the next page In IE 7 (I don't have 6 anymore so I don't know if same issue, but this script has worked on 6 before) the button disables and the dive shows but the form never post. I even tryed getting as simple as getting rid of the div and on the button going onclick="this.disabled=true;" and that didn't work either. I guess my question should be, is IE 7 introducing a new DOM or something. is there a work around for this. I need this submit button to work and if people click it twice there will be huge problems. Plus it takes a while to post because a lot is happening so I was going to put like an animated gif in the div so people would think it is loading. and in firefox it does. IE does not.
  13. This has given me a great start. I have a few errors to figure out with some of my validation and the way it checks to see if the user is aloud to do any uploading or anything but other than that it is good.
  14. Hi, all I am going crazy because I have been working on a project now for about 3 weeks. I am trying to get this last area to work right and I can't. I am at the deadline I have looked at a few tutorials dealing with this and trying to blend them all together but can figure out a few things. Every time I try and change something to the way I want it I get a syntax error or something. I am trying to have an area that someone can upload a file and it will resize it to 640 in width and then make another file and resize it to 125. Then save them in 2 diffrent directories delete the temp file and so on. Also validate that it is an image. I have my first file that the user takes 2 passes on. 1st pass List out the listing they have from the database. Loops them into where they can select which one they want to play with. They then click on the link and it brings them to the same file but ?propID= some number. 2nd The propIDs corrispond to the database. I run a check to make sure that the user that is logged in (gotten from session varible) is the use that can view this part (gotten from the database). It shows them either all the picture tied to that listing or it trys to create the directories which I have been unsuccessful at. The script runs with no errors. but when I ftp in I see no directories created. Then if they have less then 10 properties it shows them an upload form that post to another page upload.php Here is where I have most of my problems. I have never had to work with file systems before and so have to run back and forth to the php manual every ten seconds. I have learned a lot but not enough. I want this script to upload the files and then resize them to proper sizing and save them in the dynamically created directories. I also want them renamed to 1, 2, 3, 4, 5, 6,7 and so on for when I read them out. Here are the codes I have so far. addpic.php <?php @session_start(); ?> <?php if(!isset($_SESSION['username'])){ die ("You either are not logged in or you do not have permission to view this page you must log in. If you feel this is a mistake click here to <a href='../logout.php'>log out</a> and then immediatly log back in and try agian."); } //get userid needed ad so on $loginID=$_SESSION['loginID']; $username=$_SESSION['username']; include("../constents.php"); mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql' . mysql_error()); if(!isset($_GET['propID'])){ //search the database to see properties that need to be paid for $sql="SELECT * FROM ".$dbname.".tbl_props WHERE LoginID='".$loginID."' and userdeactive='0'"; $result=mysql_query($sql); $numberProps=mysql_num_rows($result); ?> <!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=utf-8" /> <title>Untitled Document</title> </head> <body> <p>You have <?=$numberProps ?> listings in the system.</p> <p>Please select the property you wish to view and or edit your pictures</p> <? while( $row = mysql_fetch_assoc($result)){ ?> <? //this is the picture echo echo "<img src='http://www.worldpropertiesonline.net/propimg/".$row['propID']."/th/1.jpg' width='125px' height='94px' />"; //followed by the detailed detialed stuff ?> <?=$row['title'] ?> <?=$row['propID'] ?> <?=$row['whenlisted'] ?> <?=$row['paidTill'] ?> <a href="<?=$_SERVER['PHP_SELF'] ?>?propID=<?=$row['propID'] ?>">Manage this listings pictures</a><br /> <? } ?> </body> </html> <? //---------------------------------------------------- //end of first pass //---------------------------------------------------- } elseif(isset($_GET['propID'])){ //---------------------------------------------------- //start of second pass //---------------------------------------------------- //function to delete a pic and its thumbnail out of the system. function picdelete($filename, $property){ $path=$_SERVER['DOCUMENT_ROOT']."/propimg/".$property."/reg/".$filename; $path2=$_SERVER['DOCUMENT_ROOT']."/propimg/".$property."/th/".$filename; if (file_exists($path)){ fclose($path); unlink($path); } if (file_exists($path2)){ fclose($path2); unlink($path2); } } $sql="SELECT * FROM ".$dbname.".tbl_props WHERE LoginID='".$loginID."' and userdeactive='0' and propID='".$_POST['propID']."'"; $result=mysql_query($sql); $numberProps=mysql_num_rows($result); //checks to see if the propID belongs to the user that is accessing it if($numberProps == 1){ $NoNouser=1; } else { //either gets the pics or creats a directory if noone has added pics before $file_path=$_SERVER['DOCUMENT_ROOT']."/propimg/".$_GET['propID']."/th/"; $file_path2=$_SERVER['DOCUMENT_ROOT']."/propimg/".$_GET['propID']."/reg/"; $picarray=array(); if(is_dir($file_path)){ $handle=opendir($file_path); $pics=1; $i=0; while(false!==($picloop=readdir($handle))){ $picarray[$i]=$picloop; $i++; } } elseif(is_dir($file_path2)) { mkdir($file_path, 0777); mkdir($file_path2, 0777); $pics=0; } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>World Properties Online</title> <meta name="keywords" content="glossary,property,real estate,rental,commercial,sale,by owner" /> <meta name="description" content="Welcome to World Properties Online, your guide to property for sale around the world." /> <link href="wpo.css" rel="stylesheet" type="text/css" /> </head> <body> <? if ($NoNouser==1){ die ("<p>Sorry but this property does not match our records. Please go back to <a href='".$_SERVER['PHP_SELF']."'>the picture management main area</a> and reslect your property.</p></body></head>"); } if($pics==0){ echo "You currently do not have any pictures for this listing."; } else { $sql="SELECT * FROM ".$dbname.".tbl_props WHERE LoginID='".$loginID."' and userdeactive='0' and propID='".$_POST['propID']."'"; $result=mysql_query($sql); ?> <p>You have <?=$i ?> pictures related to your listing </p> <p>Remember you are only allowed to have ten pictures per listing.</p> <form action="" method="post"> <input type="hidden" name="" value="" /> <? foreach($picarray as $value){ if(strlen($value) >= 4){ if(strstr($value, "." )!=1) ?> <a href="http://www.worldpropertiesonline.net/propimg/<?=$_REQUEST['propID'] ?>/reg/<?=$value ?>"><img src="http://www.worldpropertiesonline.net/propimg/<?=$_REQUEST['propID'] ?>/th/<?=$value ?>" /></a> Delete<input type="checkbox" name="imgdelete[]" value="<?=$value ?>" /> <? } } } ?> <input type="submit" /> </form> <? if($i < 10){ ?> <form enctype="multipart/form-data" action="upload.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000" /> <input type="hidden" name="pic" /> <input type="hidden" name="propID" value="<?=$_REQUEST['propID'] ?>" Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload" /> </form> <? } else { echo "You can not add more files till you delete the ohter ones."; } ?> </body> </html> upload.php <?php //checks to insure that it was posted from the form if(isset($_POST['Upload'])) { //make sure this directory is writable! $path_thumbs = $_SERVER['DOCUMENT_ROOT']."/propimg/".$_GET['propID']."/th/"; $path_reg= $_SERVER['DOCUMENT_ROOT']."/propimg/".$_GET['propID']."/reg/"; //the new width of the resized image, in pixels. $img_thumb_width = 125; // $img_reg_width = 640; $extlimit = "yes"; //Limit allowed extensions? (no for all extensions allowed) //List of allowed extensions if extlimit = yes $limitedext = array(".jpg",".jpeg", ".bmp", ".gif", ".png"); //the image -> variables $file_type = $_FILES['pic']['type']; $file_name = $_FILES['pic']['name']; $file_size = $_FILES['pic']['size']; $file_tmp = $_FILES['pic']['tmp_name']; //check if you have selected a file. if(!is_uploaded_file($file_tmp)){ echo "Error: Please select a file to upload!. <br />--<a href='addpic.php?propID=".$_REQUEST['propID']."'>back</a>"; exit(); //exit the script and don't process the rest of it! } //check the file's extension $ext = strrchr($file_name,'.'); $ext = strtolower($ext); //uh-oh! the file extension is not allowed! if (($extlimit == "yes") && (!in_array($ext,$limitedext))) { echo "Wrong file extension. we only allow .jpg .jpeg .gif .bmp and .png <br />--<a href='addpic.php?propID=".$_REQUEST['propID']."'>back</a>"; exit(); } //so, whats the file's extension? $getExt = explode ('.', $file_name); $file_ext = $getExt[count($getExt)-1]; //create a random file name $rand_name = md5(time()); $rand_name= rand(0,999999999); //the new width variable $ThumbWidth = $img_thumb_width; ////////////////////////// // CREATE THE THUMBNAIL // ////////////////////////// //keep image type if($file_size){ if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){ $new_img = imagecreatefromjpeg($file_tmp); }elseif($file_type == "image/x-png" || $file_type == "image/png"){ $new_img = imagecreatefrompng($file_tmp); }elseif($file_type == "image/gif"){ $new_img = imagecreatefromgif($file_tmp); } //list the width and height and keep the height ratio. list($width, $height) = getimagesize($file_tmp); //calculate the image ratio $imgratio=$width/$height; if ($imgratio>1){ $newwidth = $ThumbWidth; $newheight = $ThumbWidth/$imgratio; }else{ $newheight = $ThumbWidth; $newwidth = $ThumbWidth*$imgratio; } //function for resize image. if (function_exists(imagecreatetruecolor)){ $resized_img = imagecreatetruecolor($newwidth,$newheight); }else{ die("Error: Please make sure you have GD library ver 2+"); } //the resizing is going on here! imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); //finally, save the image ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext"); ImageDestroy ($resized_img); ImageDestroy ($new_img); } //ok copy the finished file to the thumbnail directory move_uploaded_file ($file_tmp, "$path_big/$rand_name.$file_ext"); $msg = "$title was uploaded! <a href=\"upload.php\">?</a>"; } else { echo "There was an error with this process please return to the <a href=''>main area and try agian</a>."; } echo $msg ?> <p><a href="addpic.php?propID=<?=$_REQUEST['propID'] ?>">add more photos</a></p> I know it seems like I am lazy and just trying to find someone else to do my work but thats not true. I am at the point with this project to were my head is spinning. You can't think straight you are tired and making the must stupid mistakes that you would normally never make and you have pressure coming down on you from all sides. I am about to just explode and this is the last little bit left of the whole site. If any one has done this before and will to sure the way they did it and why? I would really appreciate it. You don't have to write the code for me. though if I don't figure this out soon I may need that from some one. I am trying to learn it but keep getting spun around with all the tutorials from that I find in google. Some seem to contradict them selves and some don't seem that secure. Please help a phper out as I would try to do the same to you. Thanks,
×
×
  • 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.