Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Protected Images for osCommerce 2.3.3


Snoopy10

Recommended Posts

Hi Oscommerce-User,

 

I've installed the addon from http://addons.oscommerce.com/info/8560/v,23 and I'm very content with it. It took a long time to install it, but save time, if you put 500 products into your shop. One has an image management und the images are resized automatically. It worked immediately.

 

Nevertheless, I've found a small bug in /admin/categories.php in the section "new_product_preview"

 

This is the new code:

 

} elseif ($action == 'new_product_preview') {

//BOF Protected Images

$product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_isbn, p.products_image, p.image_folder, p.image_display, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");

//EOF Protected Images

$product = tep_db_fetch_array($product_query);

 

$pInfo = new objectInfo($product);

//BOF Protected Images

$products_image_folder = DIR_WS_CATALOG_IMAGES_THUMBS . $pInfo->image_folder;

$products_image_name = $pInfo->products_image;

//EOF Protected Images

 

$languages = tep_get_languages();

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

$pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']);

$pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']);

$pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']);

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<!--BOF Protected Images-->

<!--<td class="pageHeading"><?php //echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . $pInfo->products_name; ?></td>-->

<td class="pageHeading"><?php echo tep_catalog_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . $pInfo->products_name; ?></td>

<!--EOF Protected Images-->

<td class="pageHeading" align="right"><?php echo $currencies->format($pInfo->products_price); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<!--BOF Protected Images-->

<!--<td class="main"><?php //echo tep_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $pInfo->products_description; ?></td>-->

<td class="main">

<?php

if ($pInfo->image_display == 1) { // use "No Picture Available" image

echo tep_image(DIR_WS_LANGUAGES . $language . '/images/' . 'no_picture.gif', TEXT_NO_PICTURE, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5" style="float: right;"');

} elseif (($pInfo->image_display != 2) && (tep_not_null($pInfo->products_image))) { // show product images

$pi_query = tep_db_query("select image, htmlcontent from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$pInfo->products_id . "' order by sort_order");

 

if (tep_db_num_rows($pi_query) > 0) {

 

echo '<div id="piGal'.$i.'" style="float: right;">';

?>

<!--<div id="piGal" style="float: right;">-->

<ul>

<?php

$pi_counter = 0;

while ($pi = tep_db_fetch_array($pi_query)) {

$pi_counter++;

 

$pi_entry = ' <li><a href="';

 

if (tep_not_null($pi['htmlcontent'])) {

$pi_entry .= '#piGalimg_' . $pi_counter;

} else {

$pi_entry .= tep_catalog_href_link(substr(DIR_WS_CATALOG_IMAGES_PROD, strlen(DIR_WS_CATALOG)) . $pInfo->image_folder . $pi['image'], '', 'NONSSL', false);

}

 

$pi_entry .= '" target="_blank" rel="fancybox">' . tep_catalog_image(DIR_WS_CATALOG_IMAGES_PROD . $pInfo->image_folder . $pi['image']) . '</a>';

 

if (tep_not_null($pi['htmlcontent'])) {

$pi_entry .= '<div style="display: none;"><div id="piGalimg_' . $pi_counter . '">' . $pi['htmlcontent'] . '</div></div>';

}

 

$pi_entry .= "</li>\n";

 

echo $pi_entry;

}

?>

</ul>

<a href="<?php echo tep_href_link(FILENAME_IMAGE_VIEWER, 'pID=' . $pInfo->products_id); ?>" target="_blank"><?php echo TEXT_CLICK_VIEW; ?></a>

</div>

 

<?php

} else { // one image

 

echo '<div id="piGal'.$i.'" style="float: right;">';

?>

 

<!--<div id="piGal" style="float: right;">-->

<?php echo '<ul><li><a href="' . tep_catalog_href_link(substr(DIR_WS_CATALOG_IMAGES_PROD, strlen(DIR_WS_CATALOG)) . $pInfo->image_folder . $pInfo->products_image, '', 'NONSSL', false) . '" target="_blank" rel="fancybox">' . tep_catalog_image(DIR_WS_CATALOG_IMAGES_PROD . $pInfo->image_folder . $pInfo->products_image) . '</a></li></ul>';

echo '<br /><a href="' . tep_href_link(FILENAME_IMAGE_VIEWER, 'pID=' . $pInfo->products_id) . '" target="_blank">' . TEXT_CLICK_VIEW . "</a>\n"; ?>

</div>

<?php

}

?>

 

<STYLE type="text/css">

<?php echo '#piGal'.$i.' ul {';?>

list-style-type: none;}

 

<?php echo '#piGal'.$i.' img {';?>

-webkit-box-shadow: 0px 0px 1px #000;

-moz-box-shadow: 0px 0px 1px #000;}

 

<?php echo '#piGal'.$i.' .outer {';?>

margin-left: -30px;}

 

/*google chrome fix*/

<?php echo '#piGal'.$i.' ul.thumbs li{height: 91px !important;}';?>

</STYLE>

<script type="text/javascript">

<?php echo '$(\'#piGal'.$i.' ul \').bxGallery({'; ?>

//$('#piGal ul').bxGallery({

maxwidth: 200,

maxheight: 150,

thumbwidth: <?php echo (($pi_counter > 1) ? '50' : '0'); ?>,

thumbcontainer: 200,

load_image: <?php echo "'" . tep_catalog_href_link('ext/jquery/bxGallery/spinner.gif') . "'\n"; ?>

});

</script>

 

<script type="text/javascript">

<?php echo '$("#piGal'.$i.' a[rel^=\'fancybox\']").fancybox({'; ?>

//$("#piGal a[rel^=fancybox]").fancybox({

cyclic: true

});

</script>

 

<?php

}

echo $pInfo->products_description; ?>

</td>

<!--EOF Protected Images-->

</tr>

<?php

if ($pInfo->products_url) {

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo sprintf(TEXT_PRODUCT_MORE_INFORMATION, $pInfo->products_url); ?></td>

</tr>

<?php

}

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<?php

if ($pInfo->products_date_available > date('Y-m-d')) {

?>

<tr>

<td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_AVAILABLE, tep_date_long($pInfo->products_date_available)); ?></td>

</tr>

<?php

} else {

?>

<tr>

<td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_ADDED, tep_date_long($pInfo->products_date_added)); ?></td>

</tr>

<?php

}

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<?php

}

 

if (isset($HTTP_GET_VARS['origin'])) {

$pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0);

if ($pos_params != false) {

$back_url = substr($HTTP_GET_VARS['origin'], 0, $pos_params);

$back_url_params = substr($HTTP_GET_VARS['origin'], $pos_params + 1);

} else {

$back_url = $HTTP_GET_VARS['origin'];

$back_url_params = '';

}

} else {

$back_url = FILENAME_CATEGORIES;

$back_url_params = 'cPath=' . $cPath . '&pID=' . $pInfo->products_id;

}

?>

<tr>

<td align="right" class="smallText"><?php echo tep_draw_button(IMAGE_BACK, 'triangle-1-w', tep_href_link($back_url, $back_url_params, 'NONSSL')); ?></td>

</tr>

</table>

<?php

} else {

 

Yours sincerely,

 

Bernhard Bauer

 

P.S.: German installation:

 

I the attachment you see the code relating for german installation.

 

 

In BOTH catalog/includes/languages/german.php AND catalog/admin/includes/languages/german.php

 

ADD the following line before the closing ?>

 

define('TEXT_NO_PICTURE', 'Kein Bild verfügbar');

 

and then only in the ADMIN version of the file ADD the following lines (again before the closing ?>):

 

define('BOX_CATALOG_IMAGE_MANAGE', 'Bildverwaltung');

define('ERROR_DIRECTORY_NOT_REMOVED', 'Fehler: Ordner kann nicht gelöscht werden. Sie müssen ihn manuell löschen: %s');

define('ERROR_FILE_NOT_REMOVED', 'Fehler: Datei kann nicht gelöscht werden. Sie müssen diese manuell löschen: %s');

define('ERROR_FILE_ILLEGAL_CHAR', 'Ungültiges Zeichen im Dateinamen! <strong>%s</strong> sind nicht erlaubt bei Internet Dateinamen!');

$file_upload_errors = array();

$file_upload_errors[uPLOAD_ERR_OK] = "Keine Fehler, Datei erfolgreich hochgeladen.";

$file_upload_errors[uPLOAD_ERR_INI_SIZE] = "Größer als upload_max_filesize Einstellungen.";

$file_upload_errors[uPLOAD_ERR_FORM_SIZE] = "Größer als Form MAX_FILE_SIZE Einstellungen.";

$file_upload_errors[uPLOAD_ERR_PARTIAL] = "Nur teilweise hochgeladen.";

$file_upload_errors[uPLOAD_ERR_NO_FILE] = "Keine Datei wurde hochgeladen.";

$file_upload_errors[uPLOAD_ERR_NO_TMP_DIR] = "Kein temporärer Ordner. upload_tmp_dir muss gesetzt werden.";

$file_upload_errors[uPLOAD_ERR_CANT_WRITE] = "Schreiben auf Festplatte nicht möglich.";

$file_upload_errors[uPLOAD_ERR_EXTENSION] = "Hochladen der Datei wurde durch die PHP Erweiterung gestoppt.";

define('TEXT_THUMBNAIL_SUCCESS', 'Das Minibild wurde erfolgreich erzeugt.');

define('TEXT_THUMBNAIL_FAILURE', 'Fehler: Das Minibild konnte nicht erzeugt werden!');

define('TEXT_ORIGINAL_SUCCESS', 'Das Originalbild wurde erfolgreich zum Original Bildordner übertragen.');

define('TEXT_ORIGINAL_FAILURE', 'Fehler: 'Das Originalbild konnte nicht zum Original Bildordner übertragen werden.');

 

 

36 B) In catalog/admin/includes/languages/german/categories.php

 

Add the following lines somewhere before the closing ?>

 

// added for image protection

define('TEXT_IMAGE_DISPLAY', 'Bildanzeige:');

define('TEXT_NO_IMAGE', 'Kein Bild anzeigen (benutze dies, wenn es sich um kein physikalisches Produkt handelt; hochgeladene Bilder werden nicht gespeichert)');

define('TEXT_IMAGE_NOT_AVAILABLE', 'Zeige "Kein Bild verfügbar"-Bild (hochgeladene Bilder werden nicht gespeichert)');

define('TEXT_USE_PRODUCT_IMAGE', 'Zeige das Produktbild, welches unterhalb hochgeladen wurde');

define('BUTTON_MANAGE_IMAGES', 'Verwalte Produktbilder');

define('ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_NOT_WRITEABLE', 'Fehler: Katalog Produktbildordner ist nicht schreibbar: ' . DIR_FS_CATALOG_IMAGES_PROD);

define('ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST', 'Fehler: Katalog Produktbildordner existiert nicht: ' . DIR_FS_CATALOG_IMAGES_PROD);

define('ERROR_CATALOG_THUMB_IMAGE_DIRECTORY_NOT_WRITEABLE', 'Fehler: Katalog Produkt Minibildordner ist nicht schreibbar: ' . DIR_FS_CATALOG_IMAGES_THUMBS);

define('ERROR_CATALOG_THUMB_IMAGE_DIRECTORY_DOES_NOT_EXIST', 'Fehler: Katalog Produkt Minibildordner existiert nicht: ' . DIR_FS_CATALOG_IMAGES_THUMBS);

define('ERROR_CATALOG_CATEGORY_IMAGE_DIRECTORY_NOT_WRITEABLE', 'Fehler: Katalog Kategorie Bildordner ist nicht schreibbar: ' . DIR_FS_CATALOG_IMAGES_CAT);

define('ERROR_CATALOG_CATEGORY_IMAGE_DIRECTORY_DOES_NOT_EXIST', 'Fehler: Katalog Kategorie Bildordner existiert nicht: ' . DIR_FS_CATALOG_IMAGES_CAT);

define('ERROR_CATALOG_ORIGINAL_IMAGE_DIRECTORY_NOT_WRITEABLE', 'Fehler: Katalog Original Bildordner ist nicht schreibbar: ' . DIR_FS_CATALOG_IMAGES_ORIG);

define('ERROR_CATALOG_ORIGINAL_IMAGE_DIRECTORY_DOES_NOT_EXIST', 'Fehler: Katalog Original Bildordner existiert nicht: ' . DIR_FS_CATALOG_IMAGES_ORIG);

define('TEXT_IMAGE_IGNORED', 'Fehler: Dieses Produkt wurde nicht gesetzt, um hochgeladene Bilder zu benutzen; die Bilddatei, welche hochgeladen wurde, wird nicht gespeichert.');

define('TEXT_MORE_IMG', 'Zeige mehr Bilder');

define('TEXT_LARGE_IMAGE_FAILURE', 'Fehler: Das große Produktbid konnte nicht erzeugt werden.');

define('TEXT_CLICK_VIEW', 'Hier klicken, um alle originalen Produktbilder zu zeigen');

categories.php

post-317174-0-79640800-1358009470.gif

image-manager.php

image_viewer.php

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Hello,

 

I`m migrating from osc 2.2rc to 2.3.3 and installed this contribution and i have one question.

 

Where i need to copy my images?

 

1) cataloge/images/

2) cataloge/images/original/

 

and then run the script?

 

All the database is imported correctly and changes are made for new structure.

 

Another question is about the query UPDATE for TABLE `products` column `image_folder`.

 

I have run some test, but I did not sucseed with updating the column image_folder...

 

All other wise the contribution work as it should, THANKS!

Link to comment
Share on other sites

ok I understood the what was wrong, the execution time was to short as I have 10000+ products with miltiple image i did this trick:

At the start of setup file:

set_time_limit(2);

 

And at the end of setup file

flush();

 

But then i setup stoped at 3260 products, so i`m thinging to run this script from terminal (putty). When i get it done i will tell you.

 

If anyone knows the solution already, please post it.

Thank you in advance.

Link to comment
Share on other sites

set_time_limit(2);

 

A mistake here - must be set_time_limit(0);

 

p.s. Be careful with this, it can run your server to over load if YOUR script is has bad code!

Link to comment
Share on other sites

  • 3 weeks later...

Can this addon be used in conjunction with http://addons.oscommerce.com/info/8495 KISS Image Thumbnailer?

I already have this installed and wondering if I could use both? I need protected images in order to use Cross Sell for 2.3

 

I think not, because "Protect image" creates also thumbnail, but only thing that is missing is watermark... but still it`s great :D

And Yes it work`s great with Cross Sell.

Link to comment
Share on other sites

  • 3 weeks later...

A hint would be appreciative.

 

I would like to change the image resizeing on adding new product for GIF images as I want to leave the animation intact.

 

So what I have in mind is change the code for resizeng the large image if it`s a gif leave the large image original size.

 

My question is - Can someone from creators or forum users, give me a hint, where to look for the code of resizeing the images is taking place? The changes i will make myself.

 

Thank you all.

Link to comment
Share on other sites

  • 4 months later...

Resizing a GIF image will usually break any animation. I think you need to have (or pull apart the animated image to get) the individual frames, resize them, and put the animation back together. If anyone knows of a tool or library that will do this in one fell swoop, that would be great, as resizing animated GIF images seems to be a common requirement.

 

http://stackoverflow.com/questions/718491/resize-animated-gif-file-without-destroying-animation

https://www.google.com/search?q=gif+image+animated+resize

Link to comment
Share on other sites

  • 2 months later...

Hello everyone.

I have a problem regarding adding images with new product from categories/products page in admin. The problem is that new product is created but images are not. I receive this error in admin:

success.gif Success: File upload successfuly saved. error.gif Error: The original image could not be transferred to the original images folder. xyz.png error.gif Error: The large product image could not be created. xyz.png error.gif Error: The thumbnail image could not be created! xyz.png

Link to comment
Share on other sites

 

Hello everyone.

I have a problem regarding adding images with new product from categories/products page in admin. The problem is that new product is created but images are not. I receive this error in admin:

http://127.0.0.1/zom-impex/kancelarija/images/icons/success.gif[/img] Success: File upload successfuly saved. http://127.0.0.1/zom-impex/kancelarija/images/icons/error.gif[/img] Error: The original image could not be transferred to the original images folder. xyz.png http://127.0.0.1/zom-impex/kancelarija/images/icons/error.gif[/img] Error: The large product image could not be created. xyz.png http://127.0.0.1/zom-impex/kancelarija/images/icons/error.gif[/img] Error: The thumbnail image could not be created! xyz.png

 

Problem solved by changing error in code in categories.php when inserting product.

Hello everyone.

I have a problem regarding adding images with new product from categories/products page in admin. The problem is that new product is created but images are not. I receive this error in admin:

http://127.0.0.1/zom-impex/kancelarija/images/icons/success.gif[/img] Success: File upload successfuly saved. http://127.0.0.1/zom-impex/kancelarija/images/icons/error.gif[/img] Error: The original image could not be transferred to the original images folder. xyz.png http://127.0.0.1/zom-impex/kancelarija/images/icons/error.gif[/img] Error: The large product image could not be created. xyz.png http://127.0.0.1/zom-impex/kancelarija/images/icons/error.gif[/img] Error: The thumbnail image could not be created! xyz.png

Problem solved by changing error in code in categories.php when inserting product.
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

I'd like to report a bug - do I do that through this forum?

 

The problem is with the use of the php 'copy' function. I've spotted the problem and confirmed it in tep_create_thumbnail, but I am pretty sure that the same problem exists elsewhere.

 

On my own (Windows-based) test server running PHP 5.2 and fully under my own control, there is no problem, but when I run exactly the same code on my live host's server, which is PHP 5.3 on Linux with Apache, the 'copy' fails with 'unable to open stream', which is actually very misleading, because there is no problem with the source. The problem is with the destination when the copy function has to create a subfolder on the fly, e.g.

copy( 'test.txt', 'subfolder/test.txt'); // where subfolder does not exist

 

Here. the PHP routine has to create 'subfolder' in order to proceed with the copy. In the process, however, the permissions of the automatically-created subfolder are 744, which doesn't allow write access (to the script, that is). If I create the subfolder by hand ahead of time, setting the permissions to 777, the thumbnail create succeeds.

 

(SAFE_MODE is off in both environments)

 

Do the lines

 

$success = copy($source, $dest);

if ($success) {

@@CHMOD($dest, 0777);

return 1;

} else {

return -4; // thumbnail write failed

}

 

...need modifying to create and permit the subfolder (if it doesn't exist) before the copy is performed?

 

 

It seemed to me that @@sethy2's problem was related but I could not understand (or therefore implement) the solution given ('Problem solved by changing error in code in categories.php when inserting product.')

 

 

Stuart

Link to comment
Share on other sites

Problem fixed!

 

in tep_create_thumbnail, about 23 lines down,

 

after

 

if ($img_type == 'invalid') return -2; // invalid image, not a valid web type or not usable

 

Insert

 

$path_parts = pathinfo($dest);

if (!file_exists($path_parts['dirname'])) {

mkdir($path_parts['dirname']);

chmod($path_parts['dirname'],0777);

}

 

 

This ensures that the product subfolder exists and is set with permissions 777 before copying the file

The same routine is used for creating originals, large and thumbnail images (so, in fact, the function name is also misleading!)

 

The only other place I can find the PHP copy function used is in admin/categories.php, and since this doesn't involve subfolders, the problem doesn't arise.

 

Stuart

Link to comment
Share on other sites

Thanks @@MrPhil, I guess the mkdir and chmod calls should be coded with error handling as well. Perhaps the contribution author (Kevin Shelton, I believe, @@wdepot ) would care to look into this.

 

There is one other improvement I would like to suggest (I may think about a fix myself) - namely, as @@imop suggested, there are occasions when the database does not contain an image_folder value for an image (e.g. if the original image was placed there before), and I cannot find a way of correcting this except by deleting the image and re-installing it (other than by manually entering the value into the database).

 

These little niggles aside, I am very satisfied with this contribution - it will make my life a lot easier.

 

 

Stuart

Link to comment
Share on other sites

  • 7 months later...

Hi all,

i'm discovering this big contrib who looks useful. I'd like to ask you, before I begin the work, if it was possible to have a screenshot of the visitor side (and admin side if changed) and if this contrib is maintained (needed for osc 2.3.4's changes).

thanks, vg

Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

Was able to connect this addon to osCommerce 2.3.4 Bootstrap?

What changes should I make on the pages?

This can work through a separate class?
 
I apologize for the many questions. I work with osCommerce and use this script for many years. It is a pity, but I'm not a programmer. Therefore, there is a problem.
I see a new and good perspective for osCommerce 2.3.4 Bootstrap. However, the adaptation module seems not always easy to do.

Support forum for osCommerce in russian language - from Ashkelon. Support since 2002.

Best regards,

Fredi

Link to comment
Share on other sites

  • 3 months later...

hi, made a new clean installation of oscommerce 2.3.4 and took the time to make the changes and install the Protected Images for Oscommerce 2.3.4 add-on.

And i'm having the same problem that was discussed on the previous page.

To test my installation I created the category "cookies" and I'm trying to create a new product "cookie_1" under the category. I don't have a manufacturer set.

the product is created, but i'm getting the following error after I press the Save button and the images are not created

 

Success: File upload saved successfully.
Error: The original image could not be transferred to the original images folder. cookie_1.jpg
Error: The large product image could not be created. cookie_1.jpg
Error: The thumbnail image could not be created! cookie_1.jpg

 

so as far as I understand the original file is uploaded to the temp folder, there is an error happening when it's trying to copy the file to the other folders - paths are not created -  and then the uploaded file is deleted from the temp folder.

the error.log on the server the errors are the following

[warn] [client x.x.x.x] mod_fcgid: stderr: PHP Warning:  copy(/var/www/vhosts/xxxxxxx/images/originals/prod31/cookie_1.jpg): failed to open stream: No such file or directory in /var/www/vhosts/xxxxxxx/admin/includes/functions/general.php on line 1536, referer: hxxp://xxxxxx/admin/categories.php?cPath=24&pID=31&action=new_product

[warn] [client x.x.x.x] mod_fcgid: stderr: PHP Warning:  imagejpeg(/var/www/vhosts/xxxxxxx/images/originals/prod31/cookie_1.jpg): failed to open stream: No such file or directory in /var/www/vhosts/xxxxxxx/admin/includes/functions/general.php on line 1626, referer: hxxp://xxxxxxx/admin/categories.php?cPath=24&pID=31&action=new_product
[warn] [client x.x.x.x] mod_fcgid: stderr: PHP Warning:  imagejpeg(/var/www/vhosts/xxxxxxx/images/originals/prod31/cookie_1.jpg): failed to open stream: No such file or directory in /var/www/vhosts/xxxxxxx/admin/includes/functions/general.php on line 1626, referer: hxxp://xxxxxx/admin/categories.php?cPath=24&pID=31&action=new_product
 

Line 1536 in general.php is the following copy command

        $success = copy($source, $dest);  //line 1536
        if ($success) {
          @[member='CHMOD']($dest, 0777);
          return 1;
        } else {
          return -4; // thumbnail write failed
        }
      }

and line 1626 is

    imagecopyresampled($im_p, $im, $padwidth, $padheight, 0, 0, $width, $height, $orig_width, $orig_height);
    switch ($img_type) {
      case 'jpg':
        $success = imagejpeg($im_p, $dest); //this is line 1626 because my file is a jpg
        break;
      case 'gif':
        $success = imagegif($im_p, $dest);
        break;
      case 'png':
        $success = imagepng($im_p, $dest);
        break;
    }

all my folders from the oscommerce installation were created with 755 permissions,as such I altered the code in general.php to reflect this as someone suggested on a previous post but nothing changed.

so i'm stuck...

 

Any help is really appreciated...

Link to comment
Share on other sites

666 and 777 permissions are wrong on many systems. They are forbidden because they grant write permission to any other user sharing the system, and thus are a security risk. Files are generally no higher than 644, and folders/directories are generally no higher than 755, although it depends on what user ID (and thus permission needs) that PHP is running at. The bottom line is that you can't just blindly slap on permissions, without fully understanding what permissions are needed, which in turn is dependent on how your server is configured. You can figure this out by trial and error, or consult with your hosting tech support.

Link to comment
Share on other sites

Problem fixed!

 

in tep_create_thumbnail, about 23 lines down,

 

after

 

if ($img_type == 'invalid') return -2; // invalid image, not a valid web type or not usable

 

Insert

 

$path_parts = pathinfo($dest);

if (!file_exists($path_parts['dirname'])) {

mkdir($path_parts['dirname']);

chmod($path_parts['dirname'],0777);

}

 

 

This ensures that the product subfolder exists and is set with permissions 777 before copying the file

The same routine is used for creating originals, large and thumbnail images (so, in fact, the function name is also misleading!)

 

The only other place I can find the PHP copy function used is in admin/categories.php, and since this doesn't involve subfolders, the problem doesn't arise.

 

Stuart

As I read the thread again I noticed the above reply, inserted the code in the apropriate file (although i've opted to change the 0777 value to 0755) and "voila" ... my installation now works! I thought that it was fixed since it belonged to a previous version! Thank you very much Schizolocal :thumbsup: :thumbsup: :thumbsup: :thumbsup:

 

 

666 and 777 permissions are wrong on many systems. They are forbidden because they grant write permission to any other user sharing the system, and thus are a security risk. Files are generally no higher than 644, and folders/directories are generally no higher than 755, although it depends on what user ID (and thus permission needs) that PHP is running at. The bottom line is that you can't just blindly slap on permissions, without fully understanding what permissions are needed, which in turn is dependent on how your server is configured. You can figure this out by trial and error, or consult with your hosting tech support.

 

Thank you for your reply MrPhil,as I know a few about file permissions,I also think that 0777 is too much for this but the author chose to do it this way. So,as I mentioned earlier I have altered the values of this contribution on my site (following your advice on your previous post) so that new product folders would be created with permission 0755 and all image files in the folders to be created with 0644. This however didn't make the original code to work either.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...