EIGHTEEN cool mods for ISC

For Articles relating to more than one ISC version
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: FOURTEEN cool mods for ISC

Post by Tony Barnes »

Dunno mate, my coding skillset includes a hammer...!!

Thanks, it's actually a simple little mod, just a lot of head banging to get it to work in first place, and brain scratching as to how to make it simple
mipra
Posts: 23
Joined: Fri Sep 03, 2010 7:08 pm

Re: Preview your upload before it goes live

Post by mipra »

Snooper wrote:ISC does not allow you to preview products that you are editing without making the product live in the store. This is plain silly; it’s vital for store owners to make sure their products pages look just as they expect when they make the product live in their store. As it is currently (in Interspire 5.5.x), this is not possible.
Hi Snooper,
They are very useful mods. I have aplied three of them and it has been nothing but helpful.
I am trying to apply this one above. However, I dont see where the link to preview the product. Can you please advise...? Is it the the edit product page?

Thank You
meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

Re: Bar code mod

Post by meules »

Snooper wrote:I needed a bar code for items I am sending customers and this needed to be based on a unique reference. My insisted requirement was it had to be readable by as damn it all scanners on the market. I need to have this code printed on all documents and packages that link the item to customer as part of a realistic audit trail… (They look good along side customes delivery addresss's too *lol*)

Somebody might find this useful, so here is the code = Copy past into notepad and save as barcode.php –

Code: Select all

<?php
/*==================================================================*/
if(isset($_GET["text"])) $text=$_GET["text"];
if(isset($_GET["format"])) $format=$_GET["format"];
if(isset($_GET["quality"])) $quality=$_GET["quality"];
if(isset($_GET["width"])) $width=$_GET["width"];
if(isset($_GET["height"])) $height=$_GET["height"];
if(isset($_GET["type"])) $type=$_GET["type"];
if(isset($_GET["barcode"])) $barcode=$_GET["barcode"];

if (!isset ($text)) $text = 1;
if (!isset ($type)) $type = 1;
if (empty ($quality)) $quality = 100;
if (empty ($width)) $width = 160;
if (empty ($height)) $height = 80;
if (!empty ($format)) $format = strtoupper ($format);
        else $format="PNG";

switch ($type)
{
        default:
                $type = 1;
        case 1:
                Barcode39 ($barcode, $width, $height, $quality, $format, $text);
                break;          
}

etc........................

[code]<IMG SRC="barcode.php?barcode=1166A&quality=75">

<IMG SRC="barcode.php?barcode=1166A-TAN&width=320&height=90">
[
Image
Snooper. might be a extremely dumb question...... but where do I save this file and how do I print out the barcodes on an invoice? Have I missed something?
And is there an easy way to use this for creating a (sale)ribbon to overlay over product images?

Thanks
ISC v6
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: Bar code mod

Post by Martin »

meules wrote:Snooper. might be a extremely dumb question...... but where do I save this file and how do I print out the barcodes on an invoice? Have I missed something?
And is there an easy way to use this for creating a (sale)ribbon to overlay over product images?
Not a dumb question as the mod isn't actually a mod but a suggested nugget of code that someone would need to rewrite to use in ISC... To my knowledge that hasn't been done yet.
meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

Re: Bar code mod

Post by meules »

Martin wrote:
meules wrote:Snooper. might be a extremely dumb question...... but where do I save this file and how do I print out the barcodes on an invoice? Have I missed something?
And is there an easy way to use this for creating a (sale)ribbon to overlay over product images?
Not a dumb question as the mod isn't actually a mod but a suggested nugget of code that someone would need to rewrite to use in ISC... To my knowledge that hasn't been done yet.
Martin,

Do you know a good way where to start implementing this? :D
Also, can this be used for overlaying product images?

Thanks
ISC v6
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: Bar code mod

Post by Martin »

meules wrote:Do you know a good way where to start implementing this? :D
Also, can this be used for overlaying product images?
Now, you're asking... Sadly not... I'm overburdened on time, pressure and lack of sleep as it is so it's not likely. But you may find someone else picks up the ball and runs with it...

I'd start a new thread referring to the relevant and see what pops loose...

Good luck.
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

Re: FOURTEEN cool mods for ISC

Post by Snooper »

Sorry for the sloooow reply.. Can I suggest for now you might use a sudo random number generator to give the impression the bar code IS attached to some bigger !

Make a file random.php script to generate the number –

Code: Select all

<?php
srand ((double) microtime()*100000);
$var = rand();
?>  
Add the PHP call to the HTML script –

<?php include("random.php"); ?> <= There are a number of ways to include PHP into HTML. This is one way, my demo shows another.

Now alter the HTML script used to call the barcode itself (I added to letters simply for effect) -

Code: Select all

<IMG SRC="barcode.php?barcode=<?php echo $var; ?>&width=320&height=90">
You may need to change the HTML page itself to PHP to get this to work.. But the effect is you now have a barcode and no matter how many times you recall, in theory you will never duplicate any number called. My demo code -

Code: Select all

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>

<?php
srand ((double) microtime()*100000);
$var = rand();
?> 

<IMG SRC="barcode.php?barcode=<?php echo $var; ?>&width=320&height=90">

</body>
</html>
BTW - I have updated the BarCode mod (above someplace) to include how to use with ISC !
Last edited by Snooper on Sun Mar 27, 2011 8:07 pm, edited 8 times in total.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

[mod] Meaningful emails

Post by Snooper »

If you do not enter any ‘shop’ name at the time of set up and rely on a graphic (as I do). Then you have left one element of the ‘setup/install’ process incomplete.

As you receive e-mails informing you of a sale from site, consequently, so also do your customers. The email you receave is actually not obvious and in amongst others, potentially lost.. Why?

Because the e-mail may read (unknown) or say nothing about who sent the email and the subject itself is also vague and meaningless !!

So, a quick code mod – /lib/orders.php

Locate the code...

// Create a new email API object to send the email
$store_name = GetConfig('StoreName');

$obj_email = GetEmailClass();
$obj_email->From(GetConfig('OrderEmail'), $store_name);
$obj_email->Set("Subject", sprintf(GetLang('YourOrderFrom'), $store_name));
$obj_email->AddBody("html", $message);
$obj_email->AddRecipient($email, "", "h");
$email_result = $obj_email->Send();


And simply change –

$store_name = GetConfig('StoreName');

To your own shops name...

$store_name = “NameHere”;

Image
Last edited by Snooper on Thu Mar 29, 2012 12:49 am, edited 1 time in total.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

[mod] Basic random adverts

Post by Snooper »

This is a simple mod for giving the ability to add random showing image/ or adverts to ISC to give a level of networking between site owners and customers. The neat thing about this addon, is it uses a simple but compact script. You can point to images where ever they are located within the www or have them local. And if they happen to be animated .GIFs no problem.

I use the side panel in this example, so the following ‘Panel’ script -

Code: Select all

 <div class="Block Moveable Panel AdvertShow" id="AdvertShow">
     <h2>Adverts</h2>
	<div class="BlockContent">
		<ul>
*** advert script goes here

		</ul>
	</div>
</div>
We use the IFRAME function to 'cut' away the port we intend to show our adverts through. This is the advert script to be located as above instructed. You also need to ensure the path to where the PHP used in the script is located on your server is included to the SRC pointer -

Code: Select all

<iframe marginwidth="0" marginheight="0" width="100%" height="130" scrolling="no" frameborder=0 src="randomad.php">
</iframe>
The width here is 100%, but this can be altered (as can be the height) to fit to site requirements. The PHP script referenced in the iframe line is shown below. You need to ensure the path to where TXT file used is located on your server is included to the $adfile pointer –

Code: Select all

<?php

// load the file that contain the ads
$adfile = "ads.txt";                       
$ads = array();

// one line per ad
$fh = fopen($adfile, "r");
while(!feof($fh)) {

  $line = fgets($fh, 10240);
  $line = trim($line);
  if($line != "") {
	$ads[] = $line;
  }
}

// randomly pick an ad
$num = count($ads);
$idx = rand(0, $num-1);

echo $ads[$idx];
?>
And the actual text file referenced in the PHP is where the pointers to adverts are held –

Code: Select all

<a target="_blank" href="http://www.awebsite.com"><img src="http://www.awebsite.com/a_banner.gif" width="XX" height="XX" border="0"></a>
<a href="[somelocalfolder]">a_banner..jpg" width="XX" height="XX" border="0"></a>
<a target="_blank" href="http://www.awebsite.com">some ad test</a>
<a target="_blank" href="http://www.awebsite.com">some more ad</a>
The <a></a> lines are examples of text you might use in this file. You can include ‘proper’ code into these lines (image maps etc.) but always present these as a single line as shown in my example. The width and height shown here (in example) as XX's should match the ones used in the iframe code from above. The options are ends.

Now to place the panel into the location of ISC - %%Panel.AdvertShow%%
Note that ISC demands you use the convention of 'calling' to page the name of the Panel by its 'public' name given in the Panel script - <div class="Block Moveable Panel AdvertShow" id="AdvertShow">

Each time a page is called and using the Panel, an advert is selected at random and shown.
Last edited by Snooper on Thu Mar 29, 2012 12:50 am, edited 1 time in total.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

[mod] Dynamic watermarking

Post by Snooper »

When you use the Lightbox function within ISC, you run the risk (depending on subject) of giving away more than just an idea of what is being sold. You could be giving away the very product itself, one way or another if it happens to be a personal painting or photo from a gallery.

Okay, downgrade the image so any enlargement renders it useless. But fractal based enlargers are getting good at ‘fixing’ this.

So we need an alternative that ‘marks’ the image in a way that renders almost copyright with considerable effort of anybody wanting to use your work.

I have yet to link this into ISC, but it works and is able to produce what we are looking for. But I’m sure somebody will figure that out !??

The class in the background -

Code: Select all

<?
class iMark{ 
        function create_iMark( $main_img_obj, $iMark_img_obj, $alpha_level = 100 ) { 
                $alpha_level        /= 100; 
                $main_img_obj_w        = imagesx( $main_img_obj ); 
                $main_img_obj_h        = imagesy( $main_img_obj ); 
                $iMark_img_obj_w        = imagesx( $iMark_img_obj ); 
                $iMark_img_obj_h        = imagesy( $iMark_img_obj ); 
                $main_img_obj_min_x        = floor( ( $main_img_obj_w / 2 ) - ( $iMark_img_obj_w / 2 ) ); 
                $main_img_obj_max_x        = ceil( ( $main_img_obj_w / 2 ) + ( $iMark_img_obj_w / 2 ) ); 
                $main_img_obj_min_y        = floor( ( $main_img_obj_h / 2 ) - ( $iMark_img_obj_h / 2 ) ); 
                $main_img_obj_max_y        = ceil( ( $main_img_obj_h / 2 ) + ( $iMark_img_obj_h / 2 ) ); 
 
                $return_img        = imagecreatetruecolor( $main_img_obj_w, $main_img_obj_h ); 
 
                for( $y = 0; $y < $main_img_obj_h; $y++ ) { 
                        for( $x = 0; $x < $main_img_obj_w; $x++ ) { 
                                $return_color        = NULL; 
                                $iMark_x        = $x - $main_img_obj_min_x; 
                                $iMark_y        = $y - $main_img_obj_min_y; 
                                $main_rgb = imagecolorsforindex( $main_img_obj, imagecolorat( $main_img_obj, $x, $y ) ); 
                                if ($iMark_x >= 0 && $iMark_x < $iMark_img_obj_w && 
                                                        $iMark_y >= 0 && $iMark_y < $iMark_img_obj_h ) { 
                                        $iMark_rbg = imagecolorsforindex( $iMark_img_obj, imagecolorat( $iMark_img_obj, $iMark_x, $iMark_y ));  
                                        $iMark_alpha = round( ( ( 127 - $iMark_rbg['alpha'] ) / 127 ), 2 ); 
                                        $iMark_alpha = $iMark_alpha * $alpha_level; 
                                        $avg_red = $this->_get_ave_color( $main_rgb['red'], $iMark_rbg['red'], $iMark_alpha ); 
                                        $avg_green = $this->_get_ave_color( $main_rgb['green'], $iMark_rbg['green'], $iMark_alpha ); 
                                        $avg_blue = $this->_get_ave_color( $main_rgb['blue'], $iMark_rbg['blue'], $iMark_alpha ); 
                                        $return_color = $this->_get_image_color( $return_img, $avg_red, $avg_green, $avg_blue ); 
                                } else { 
                                        $return_color = imagecolorat( $main_img_obj, $x, $y ); 
                                } 
                                imagesetpixel( $return_img, $x, $y, $return_color ); 
                        } 
                } 
                return $return_img; 
        } 
 
        function _get_ave_color( $color_a, $color_b, $alpha_level ) { 
                return round( ( ( $color_a * ( 1 - $alpha_level ) ) + ( $color_b        * $alpha_level ) ) ); 
        } 
 
        function _get_image_color($im, $r, $g, $b) { 
                $c=imagecolorexact($im, $r, $g, $b); 
                if ($c!=-1) return $c; 
                $c=imagecolorallocate($im, $r, $g, $b); 
                if ($c!=-1) return $c; 
                return imagecolorclosest($im, $r, $g, $b); 
        } 
} 
?>
The line == function create_iMark( $main_img_obj, $iMark_img_obj, $alpha_level = 100 ) is default to 100. If you want the watermark to seem to be more softer or bearly seen, lower this value.

The 'calling' script usingthe Class -

Code: Select all

<? 
        $___notjson=1; 
        include 'imark.php'; 
        $iMark = new iMark(); 
        $main_img_obj = imagecreatefromjpeg($_GET['main']); 
        $iMark_img_obj = imagecreatefrompng($_GET['iMark']); 
        $return_img_obj = $iMark->create_iMark($main_img_obj, $iMark_img_obj, 66); 
        header('Content-Type: image/jpeg'); 
        header('Content-Disposition: inline; filename=' . $_GET['src']); 
        imagejpeg($return_img_obj, '', 50); 
?>
And the line you would use to run the watermark script - <img src="image.php?main=product.jpg&iMark=logo.png">

Where product.jpg is the image to be protected and logo.png is what will mark the image. (the PNG used was set at 8bit RGB mode before being saved from photoshop)

Image

To embed this in to ISC (my next to do) -

ISC’s Lightbox option to display product, uses the lines located in includes/display/ProductDetails.php

while($image = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
$GLOBALS['LightBoxImageList'] .= '<a ';
$GLOBALS['LightBoxImageList'] .= 'href="'.$GLOBALS['ShopPath'].'/'.GetConfig('ImageDirectory').'/'.$image['imagefile'].'" ';
$GLOBALS['LightBoxImageList'] .= 'title="'.isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName()).'"';
$GLOBALS['LightBoxImageList'] .= '>&nbsp;</a>';


We need to ‘add’ into this line –
$GLOBALS['LightBoxImageList'] .= 'href="'.$GLOBALS['ShopPath'].'/'.GetConfig('ImageDirectory').'/'.$image['imagefile'].'" ';

Making the line before correcting syntax –
http://www.xxxxxxx.com/image.php?main= '.$GLOBALS['ShopPath'].'/'.GetConfig('ImageDirectory').'/'.$image['imagefile'].' &iMark=logo.png

To view this line another way -
http://www.xxxxxxx.com/image.php?main=product.jpg&iMark=logo.png

Where the section - '.$GLOBALS['ShopPath'].'/'.GetConfig('ImageDirectory').'/'.$image['imagefile'].' represents the 'product.jpg' or image shown through Lightbox.
Last edited by Snooper on Thu Mar 29, 2012 12:50 am, edited 2 times in total.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Post Reply