Jump to content

kdreg

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kdreg's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. another workaround I found in the php.net info is the following, but I'm not sure how to implement that either. Please, any help for a newbie? I haven't worked with the script for about 3 years and at that time I understood things better. But I'm lost with this security change. Surely a lot of people were affected when it happened. the workaround however is if you create the file using some other function, before call imagejpeg(). something like this <? $fh=fopen($file_name_dest,'w'); fclose($fh); imagejpeg($dest,$file_name_dest, $quality); ?>
  2. But it worked fine before. I just need to get it working again and am hoping maybe I have the workaround misplaced or something (the touch()
  3. Hello, The following script used to work great. I hadn't used it for a long time and in the meantime I guess, things changed with php (safe mode? etc.). I get the following error now when trying to scale an image: Warning: imagejpeg() [function.imagejpeg]: Unable to open '/home/domain/public_html/fileresize/temp/18d7011550ad5fa215d9e089a5aa27aa-image.jpeg' for writing in /home/domain/public_html/fileresize/resizejpg.php on line 90 I searched and found recommendations to use touch(); I tried that and it still doesn't work. So I don't know if I'm putting touch(); in the wrong place, or what else might be wrong. I'm really hoping someone can help get this working again. It's for a non-profit animal rescue website and having the image resize is vital to what I need to accomplish. Thanks. Here's the full code: <html> <head> <title>Image resize</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php /* * php+gd image scaling and overlay demo. * copyright 2003, B. Johannessen <bob@db.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version, and provided that the above * copyright and permission notice is included with all distributed * copies of this or derived software. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * A copy of the GNU General Public License is available from the GNU * website at the following URL: http://www.gnu.org/licenses/gpl.txt */ /* * configuration: sets the full path of the overlay image, * the rgb value to make transparant in the overlay image, * the path to store the scaled images and the uri prefix * for the scaled images. */ $cache_fs = '/home/domain/public_html/fileresize/temp/'; $cache_uri = 'http://www.domain.org/fileresize/temp/'; /* * calculate the filesystem and uri prefixes based on a semi-random string. */ $srid = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['REMOTE_PORT'] . time()); $base_fs = $cache_fs . $srid; $base_uri = $cache_uri . $srid; if($_SERVER['PATH_INFO'] == '/source') { $source = str_replace(' ', ' ', htmlspecialchars(implode('', file('resizejpg.php')))); $show = 'source'; } else if(isset($_FILES['file'])) { /* * open original (uploaded) image, based on type. */ switch($_FILES['file']['type']) { case 'image/jpeg': case 'image/pjpeg': $orig = imagecreatefromjpeg($_FILES['file']['tmp_name']); break; case 'image/png': $orig = imagecreatefrompng($_FILES['file']['tmp_name']); break; case 'image/gif': $orig = imagecreatefromgif($_FILES['file']['tmp_name']); break; default: $error = 'Unknown File Format or MIME Type'; $show = 'error'; } if($orig) { /* * fetch the size of the original image, * and calculate the size of the new image and thumb. */ $orig_x = imagesx($orig); $orig_y = imagesy($orig); $image_x = $_REQUEST['image_x']; $image_y = round(($orig_y * $image_x) / $orig_x); /* * create the new image, and scale the original into it. */ $image = imagecreatetruecolor($image_x, $image_y); imagecopyresampled($image, $orig, 0, 0, 0, 0, $image_x, $image_y, $orig_x, $orig_y); // write the jpg to disk. [b] [color=red]// here is where i added touch($image); // but it didn't work. Did I do it wrong?[/color][/b] imagejpeg($image, $base_fs . '-image.jpeg'); // calculate the uri of the 3 images. $image_uri = $base_uri . '-image.jpeg'; } else { if(!$error) $error = 'Error reading uploaded image'; $show = 'error'; } if(!isset($show)) $show = 'result'; } $title = 'Scale Image Utility'; ?> <?php if($show == 'error') { ?> <h2><?=$error?></h2> <?php } else if($show == 'source') { ?> <h2>Source</h2> <pre class="php-source"><?=$source?></pre> <?php } else if($show == 'result') { ?> <h2>Scaled Image</h2> <p><img src="<?=$image_uri?>"/></p> <?php } else { ?> <h2>Resize</h2> <?php } ?> <table width="600" border="0" cellspacing="0" cellpadding="0"> <tr> <td><form enctype="multipart/form-data" action="http://www.domain.org/fileresize/resizejpg.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <table> <tr> <td>Width:</td> <td><input name="image_x" type="text" size="10"> pixels</td> </tr> <tr> <td>Image File:</td> <td><input name="file" type="file"> </td> </tr> <tr> <td><input name="submit" type="submit" value="Scale"> </td> <td></td> </tr> </table> <p>Instructions: In the width field, select the new width you would like your image to be. 'Browse' to the image on your hard drive, then select 'Scale.' Be patient while the image is scaled. When the process is complete, the scaled image will be viewable on the page. Put your mouse over the scaled image, right-click and select 'Save Picture As....' Save it to your desktop, then you will be able to upload the image.... (The resized image will have a long file name; be sure to rename it to its original name.)</p> </form></td>
  4. I tried t upload an image and got this error message: Warning: copy() [function.copy]: open_basedir restriction in effect. File(/1.jpg) is not within the allowed path(s): (/home/foobar/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/foobar/public_html/upload.php on line 51 Here's line 51: // Store the orignal file copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename); What can I do differently to get around this message, which from what I understand from searching is a security measure by my host? Thanks.
  5. Thank you, Renlok. It actually turned out to be in this case that there was a space after the HTML_END and that was causing the problem. Well, that's interesting, about that being another way to store html. It really threw me! Thanks again...
  6. Hi, I'm trying to follow along in a tutorial, but I don't recognize part of it (sorry, I can't post in code... this forum doesn't maintain my cookies or allow me to do any text options): $result = mysql_query('SELECT category_id,category_name FROM gallery_category'); while($row = mysql_fetch_array($result)) { $photo_category_list .= <<<__HTML_END <option value="$row[0]">$row[1]</option>\n __HTML_END; } mysql_free_result( $result ); this part: $photo_category_list .= <<<__HTML_END is throwing up this error: Parse error: syntax error, unexpected T_SL in /home/something/public_html/preupload.php on line 15 should the ___HTML_END not be there? I've never encountered an unexpected T_SL error before, or <<< for that matter. Thank you for any assistance.
  7. Nevermind, I was able to fix it under Operations in phpMyAdmin.
  8. I've forgotten how to do this... I duplicated a table and since the first one had 21 entries already, the duplicated table began the first entry at 22. How can I fix the second table so that it begins incrementing at 1 (it has two entries now, actually, #1 and #21). I think when I duplicated it and made the first entry, I went in and manually entered 1 for the ID (auto increment), but the next entry started at 22. Thanks...
  9. Just a thought, but since you mention the problem appears on your cart page, could the error be in cart.inc? If so, maybe it would be helpful to post cart.inc here.
  10. Also, another possibility for your specific error (just found the info in some older phpfreak info) is to make sure that <?php session start(): comes before anything else. i.e., <?php session_start(); echo "Blah, blah..."; ?> and not <?php echo "Blah, blah..."; session_start(); ?>
  11. I realize my problem isn't exactly like yours, but did find this. I don't know if it will help. According to an old php tutorial, a solution is to enter header("Cache-control: private"); right below the session_start() of each script.
  12. Usually if you get a "headers already sent error message," you need to add output buffering; it must be the very first thing on page, like below: <?php ob_start(); // Start output buffering ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> and, I think you also need to add this at the end of the page: ob_end_flush(); Hopefully someone who's experienced will come along to clarify or offer other suggestions.
  13. Thanks, when I have enough time I'll re-do the forms to submit to self and give that a try. Thanks.
  14. Yes, I think the public_html is the default directory, and I don't *think* the full path should have been visible. I guess my original intent with using the document_root was in part to start brushing up on php since it's been over two years since I've really done any coding and can't remember very much; and, when I have files in different folders, then just having forms/contact.php won't work. I thought I'd try document root rather than putting in the full path since that always worked for my include files. So, for now I just put in the full path, but this has been a good experience for me and is helping me to learn as I see other codes and I'm sure I'll have an occasion to use that again in a setting that will work. Thank you very much!
  15. Thank you. This is an interesting learning experience. The new code appeared to be working at first, but for some reason it broke the links to css styles and logo images. I'll work with it some more so I understand exactly what's happening with it. I'm puzzled why document root works for the inc files but not how you showed it first for the link. Is there an easy explanation so that I can learn? I know when I've used document root before (over two years ago) that I used require once or require @ with it and it didn't bring up the public_html. Thanks again, I appreciate your help and quick responses. (I always thought google was my friend, but two times now when I've googled extensively for help (including last night) I've ended up with attempts to download trojans just by visiting web pages, even though they appeared to be safe sources. So I'm getting more and more afraid to search.)
×
×
  • 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.