Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Simple Multi Image Add-on (Un-Limited) with FancyBox Popups


spooks

Recommended Posts

I'm afraid your site is all messed up, you must ensure you follow the basic html rules to ensure compatibility with standard files (the supplied aqre stanard 2.2rc2a versions)

 

I see 2 sets of <head> 2 sets of <body> & 2 of <html> you must have only one of each, your header section also opens a table it fails to close.

 

It is imperative you fix these errors, as if you even descide to revert, google will not like your site in this state as it will display wildley different on different browsers.

 

thanks for the reply

 

sorry for the ignorance how to fix my site? my osc version 2.2rc2a and which php file needs to be fixed?

 

thanks in advance

 

 

br,

parot

Link to comment
Share on other sites

which php file needs to be fixed?

 

 

Your issues could be in a number, but clearly the includes/header.php appears to be the main cause.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

I've just installed this contrib and the new pop up image is working fine however I can't seem to get to the product edit page in admin anymore, it just leaves me on the list of products page and refuses to go into a specific product. I do have other contribs installed but the only bit of code I remember having to put somewhere other than where specified was this (in the admin/categories.php file):

 

<?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['read']) && ($HTTP_GET_VARS['read'] == 'only')) {

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;

}

?>

<!-- Simple multi image addon -->

<table summary=""><tr><td>Additional Images:</td><td class="main" colspan="3"><table summary=""><tr>

 

<?php $i=1; while (list($key, $value) = each($products_image_array)) { ?>

 

 

<?php echo '<td align="center">' . tep_image(DIR_WS_CATALOG_IMAGES . $value, $value, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, ' hspace="8" vspace="5"');

if($HTTP_POST_VARS['delete_image_' .$i] == 'on') echo '<br />To Be Deleted';

echo '</td>'; ++$i; } ?>

 

</tr>

</table></td></tr></table>

<!-- EOF Simple multi image addon -->

 

Any ideas?

Link to comment
Share on other sites

 

 

That section only deals with product preview, that addition is to show your added images.

 

You have made errors in the install, often people manage to repeat the same errors several times, try again, or try using a file compare tool, you could use the supplied file as a temporary test. wink.gif

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

for some reason when I upload new images, the image does not get updated. is there something in the admin/categories file that i should look for? please help. thanks.

Link to comment
Share on other sites

when I upload new images, the image does not get updated.

 

 

Do you get the message, Success: File upload saved successfully. after you click on preview?

 

The scection that uploads images is right at the start of the file, check you edits very carefully, you have made errors in the install, try using a file compare tool if you have trouble with the manual method, you could also use the supplied file instead.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

for some reason when I upload new images, the image does not get updated. is there something in the admin/categories file that i should look for? please help. thanks.

 

never mind. i got it.

Link to comment
Share on other sites

Hello,

it is very good add-on but I have a small problem

When I add a product or edit an existing I cannot set the primary picture. I took mesagges that the changes were made but the primary image doesn't change.

I'm using MySQL insteed of PHPmyadmin, I don't know if this is a problem

 

Do you have any suggestion?

Link to comment
Share on other sites

errors following install

 

 

Do you get the message, Success: File upload saved successfully. after you click on preview?

 

Check you edits again very carefully, you have made errors in the install, try using a file compare tool if you have trouble with the manual method, you could also use the supplied file instead. smile.gif

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

when I upload new images, the image does not get updated.

 

 

Do you get the message, Success: File upload saved successfully. after you click on preview?

 

The scection that uploads images is right at the start of the file, check you edits very carefully, you have made errors in the install, try using a file compare tool if you have trouble with the manual method, you could also use the supplied file instead.

 

Hello, same here. I have the Success: File upload saved successfully message for my multiple images, AND the Warning: No file uploaded message for my 1st image !!!???

 

My new images (your addon) are taken into account but not the 1st image (oscommerce function). Help more than welcome. I can't find what your addon modified for the 1st product image :(

valid xhtml + valid css + oscommerce = www.oscss.org"]oscss !

Link to comment
Share on other sites

Hello, same here. I have the Success: File upload saved successfully message for my multiple images, AND the Warning: No file uploaded message for my 1st image !!!???

 

My new images (your addon) are taken into account but not the 1st image (oscommerce function). Help more than welcome. I can't find what your addon modified for the 1st product image sad.gif

 

 

The section that uploads images is right at the start of the file, check your edits again, it only takes one charcter misplaced to cause an error, try the supplied file instead. Have you tried a file compare?

 

I cant tell what u have done wrong as only u have your code, but this works, so you must find where you went wrong. smile.gif

 

Perhaps this thread will help. wink.gif

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Thanks for your reply. First version of the plugin was ok, then I applied the update allowing multiple insertion in one edit. Then things went wrong ;)

I can't try the supplied file (other plugins installed)

File compare with NOTEPAD++ shows nothing

My host uses PHP4 so I checked every $_POST and $_GET... no success !

valid xhtml + valid css + oscommerce = www.oscss.org"]oscss !

Link to comment
Share on other sites

Thanks for your reply. First version of the plugin was ok, then I applied the update allowing multiple insertion in one edit. Then things went wrong wink.gif

I can't try the supplied file (other plugins installed)

File compare with NOTEPAD++ shows nothing

My host uses PHP4 so I checked every $_POST and $_GET... no success !

 

 

NOTEPAD++ is not a file compare tool, use a real file compare tool, like WinMerge or Beyond Compare.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

-->

 

If I Comment the very beginning of the file (this section) :

   if ($action == 'new_product_preview') {
// copy image only if modified
       $products_image = new upload('products_image');
       $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
       if ($products_image->parse() && $products_image->save()) {
         $products_image_name = $products_image->filename;
       } else {
         $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
       }
// Simple multi image addon  

			$products_image_array = array();
			for ($i = 1; $i <= (int)$HTTP_POST_VARS['image_array_limit']; ++$i) { 
			$products_images = new upload('products_image_' . $i);

			$products_images->set_destination(DIR_FS_CATALOG_IMAGES);
       if ($products_images->parse() && $products_images->save()) {
         $products_image_array[] = $products_images->filename;
		} else {
		if(isset($HTTP_POST_VARS['products_previous_image_' .$i])) $products_image_array[] = $HTTP_POST_VARS['products_previous_image_' .$i];
                }
			} 
// Simple multi image addon 

	if ($HTTP_POST_VARS['instant_update'] == 'on') { 
	  $HTTP_POST_VARS['products_image'] = stripslashes($products_image_name);
	  $i=1;
	  reset($products_image_array);
    while (list($key, $value) = each($products_image_array)) 
		    {
       $HTTP_POST_VARS['products_image_' . $i] = stripslashes($value);
		   ++$i;	}

	$action = 	(isset($HTTP_GET_VARS['pID']) ? 'update_product' : 'insert_product');  
	}
}	

... my image update still works

valid xhtml + valid css + oscommerce = www.oscss.org"]oscss !

Link to comment
Share on other sites

-->

 

 

 

Then you have made errors, since with a properly edited file, with that removed there would be no update!! huh.gif

 

In fact thinking about it, your failure to edit correctly further on, could indeed cause this issue, check it again!!

 

How come your file compare failed to show that up!!!

 

 

Post the whole file.

Edited by spooks

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

In fact I kept this part placed below <head></head> :

$products_image_array = array();
			for ($i = 1; $i <= (int)$HTTP_POST_VARS['image_array_limit']; ++$i) { 
			$products_images = new upload('products_image_' . $i);

			$products_images->set_destination(DIR_FS_CATALOG_IMAGES);
       if ($products_images->parse() && $products_images->save()) {
         $products_image_array[] = $products_images->filename;
       } else {
        if(isset($HTTP_POST_VARS['products_previous_image_' .$i])) $products_image_array[] = $HTTP_POST_VARS['products_previous_image_' .$i];
                                                                  }
			  } 

 

That's why it works. Not optimal but a good transition before I optimize (I am in a hurry right now)

Despite these few mistakes, I find this contribution is the best one for multiple images ! Congratulations again spooks :)

 

Note : could post my whole file but it is an OSCSS version, some minor changes could appear, if it's not a problem to you, OK for me ;)

valid xhtml + valid css + oscommerce = www.oscss.org"]oscss !

Link to comment
Share on other sites

 

 

Not sure what your saying there? You have modified the add-on then it fails? Try the supplied file, it will show you that it works, you don't have to keep it.

 

PS that code must be placed where I put it so the dbase updates can work, unless u moved them too!!

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Great mod, thanks for your hard work. 2 things I noticed for MY application (may be applicable to others, may not).

 

 

In the lines with the links, such as:

echo '<a rel="image_group" title="'.$product_info['products_name'].'" href="' . ($m_source ? $m_source : DIR_WS_IMAGES . $product_info['products_image']) . '" alt="' . $product_info['products_name'] . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"', false, 5) . '</a><br />';

 

Adding htmlentities function to the product title allowed special characters (such as quotes) to be displayed in the product title on the modal correctly:

echo '<a rel="image_group" title="'.htmlentities($product_info['products_name']).'" href="' . ($m_source ? $m_source : DIR_WS_IMAGES . $product_info['products_image']) . '" alt="' . $product_info['products_name'] . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"', false, 5) . '</a><br />';

 

I was also having a problem with the number of elements in the image_group. I kept ending up with 1 extra, so even if I only had 1 image the modal was showing a next arrow. When using oscThumbs this created a larger issue because the class did not fall back to 0 position and instead threw an error when it attempted to retrieve the image for which there was no key. The resolution was to remove the link surrounding the "Click to Enlarge" text:

 

<?php echo '<tr><td align="center">' . TEXT_CLICK_TO_ENLARGE . '</td></tr>'; ?>

Link to comment
Share on other sites

 

 

Well spotted, thanks. smile.gif

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Not sure what your saying there? You have modified the add-on then it fails? Try the supplied file, it will show you that it works, you don't have to keep it.

 

PS that code must be placed where I put it so the dbase updates can work, unless u moved them too!!

 

No, osCSS is a modified (tableless, xhtml and css valid) OsCommerce fork. I adapted (with no modifications) the addon to osCSS - but maybe the dbase calls were moved on the original categories.php in osCSS, so I had to move your addon update too.

valid xhtml + valid css + oscommerce = www.oscss.org"]oscss !

Link to comment
Share on other sites

No, osCSS is a modified (tableless, xhtml and css valid) OsCommerce fork. I adapted (with no modifications) the addon to osCSS - but maybe the dbase calls were moved on the original categories.php in osCSS, so I had to move your addon update too.

 

 

You should not move the code and the code must not appear twice!!, its because you had it twice that caused your failure, with the code moved the instant update option will fail!! ohmy.gif

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

First, thanks for the great contribution =)

 

I am having a little problem though =/

 

On my site, everything is working properly, except when editing a product page. I get 5 lines of:

 

Warning: No file uploaded.

Warning: No file uploaded.

Warning: No file uploaded.

Warning: No file uploaded.

Warning: No file uploaded.

 

If I do upload pictures (3), I still get 2 of the 5. I don't think this is causing any issues with my site, but it is a bit annoying, is there anywhere specific I should look to fix this?

 

Also, I have tried uploading the included categories and product_info files, with the same result.

 

Thanks again for your great work!

Edited by commercenewb
Link to comment
Share on other sites

Warning: No file uploaded.

 

 

 

It is possible that an empty filename is presented to the upload class, but as the first thing that dose is check if the filename is empty, it should exit cleanly (ie no error)

 

Post your upload.php class code, I'll see if its non-standard.

 

The other possibility is that you server deals with post vars in a un-usual way.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

I don't think I've ever made any changes to this file, but here it is:

 

<?php
/*
 $Id: upload.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License
*/

 class upload {
   var $file, $filename, $destination, $permissions, $extensions, $tmp_filename, $message_location;

   function upload($file = '', $destination = '', $permissions = '777', $extensions = '') {
     $this->set_file($file);
     $this->set_destination($destination);
     $this->set_permissions($permissions);
     $this->set_extensions($extensions);

     $this->set_output_messages('direct');

     if (tep_not_null($this->file) && tep_not_null($this->destination)) {
       $this->set_output_messages('session');

       if ( ($this->parse() == true) && ($this->save() == true) ) {
         return true;
       } else {
         return false;
       }
     }
   }

   function parse() {
     global $HTTP_POST_FILES, $messageStack;

     $file = array();

     if (isset($_FILES[$this->file])) {
       $file = array('name' => $_FILES[$this->file]['name'],
                     'type' => $_FILES[$this->file]['type'],
                     'size' => $_FILES[$this->file]['size'],
                     'tmp_name' => $_FILES[$this->file]['tmp_name']);
     } elseif (isset($HTTP_POST_FILES[$this->file])) {
       $file = array('name' => $HTTP_POST_FILES[$this->file]['name'],
                     'type' => $HTTP_POST_FILES[$this->file]['type'],
                     'size' => $HTTP_POST_FILES[$this->file]['size'],
                     'tmp_name' => $HTTP_POST_FILES[$this->file]['tmp_name']);
     }

     if ( tep_not_null($file['tmp_name']) && ($file['tmp_name'] != 'none') && is_uploaded_file($file['tmp_name']) ) {
       if (sizeof($this->extensions) > 0) {
         if (!in_array(strtolower(substr($file['name'], strrpos($file['name'], '.')+1)), $this->extensions)) {
           if ($this->message_location == 'direct') {
             $messageStack->add(ERROR_FILETYPE_NOT_ALLOWED, 'error');
           } else {
             $messageStack->add_session(ERROR_FILETYPE_NOT_ALLOWED, 'error');
           }

           return false;
         }
       }

       $this->set_file($file);
       $this->set_filename($file['name']);
       $this->set_tmp_filename($file['tmp_name']);

       return $this->check_destination();
     } else {
       if ($this->message_location == 'direct') {
         $messageStack->add(WARNING_NO_FILE_UPLOADED, 'warning');
       } else {
         $messageStack->add_session(WARNING_NO_FILE_UPLOADED, 'warning');
       }

       return false;
     }
   }

   function save() {
     global $messageStack;

     if (substr($this->destination, -1) != '/') $this->destination .= '/';

     if (move_uploaded_file($this->file['tmp_name'], $this->destination . $this->filename)) {
       chmod($this->destination . $this->filename, $this->permissions);

       if ($this->message_location == 'direct') {
         $messageStack->add(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success');
       } else {
         $messageStack->add_session(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success');
       }

       return true;
     } else {
       if ($this->message_location == 'direct') {
         $messageStack->add(ERROR_FILE_NOT_SAVED, 'error');
       } else {
         $messageStack->add_session(ERROR_FILE_NOT_SAVED, 'error');
       }

       return false;
     }
   }

   function set_file($file) {
     $this->file = $file;
   }

   function set_destination($destination) {
     $this->destination = $destination;
   }

   function set_permissions($permissions) {
     $this->permissions = octdec($permissions);
   }

   function set_filename($filename) {
     $this->filename = $filename;
   }

   function set_tmp_filename($filename) {
     $this->tmp_filename = $filename;
   }

   function set_extensions($extensions) {
     if (tep_not_null($extensions)) {
       if (is_array($extensions)) {
         $this->extensions = $extensions;
       } else {
         $this->extensions = array($extensions);
       }
     } else {
       $this->extensions = array();
     }
   }

   function check_destination() {
     global $messageStack;

     if (!is_writeable($this->destination)) {
       if (is_dir($this->destination)) {
         if ($this->message_location == 'direct') {
           $messageStack->add(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error');
         } else {
           $messageStack->add_session(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error');
         }
       } else {
         if ($this->message_location == 'direct') {
           $messageStack->add(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error');
         } else {
           $messageStack->add_session(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error');
         }
       }

       return false;
     } else {
       return true;
     }
   }

   function set_output_messages($location) {
     switch ($location) {
       case 'session':
         $this->message_location = 'session';
         break;
       case 'direct':
       default:
         $this->message_location = 'direct';
         break;
     }
   }
 }
?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...