Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 08-25-2005 18:09:14

Blitzen
Member
From: USA
Registered: 01-01-2005
Posts: 936

Check For Missing Images

This mod checks for missing image files that are listed in the database tables (products and categories). An html page is written that lists the missing images. This mod is called from the Admin panel.

Okay, here goes! No growling. You should not have problems because we tested these instructions with a client who just recently purchased CCP51 (tiki). (Who is totally thrilled with it! Kudos to Nick, Kryptronic, Inc., and all those who posted invaluable suggestions here.). Please do not ask for further modifications unless someone else wants to have at it. Thank you and good luck!

(1) Add the following element file to your data/elements table. You can copy 'n' paste the code into Notepad.
Save as . Upload to your data/elements directory in ASCII mode.

Code:

(CGIGET TYPE="SUB" VALUE="adm_exec_check_images")
<p>
<a href="(CGIVAR)url_media_path(/CGIVAR)/html/missingImages.html" target="_blank">Click here to view missing images.</a>
</p>

(2)  if it doesn't already exist, add this directory with 777 permissions.


(3) , add the following line and upload to your server's /data/tables directory in BINARY mode.
NOTE: If you have this table in MySQL, first convert the table to CSV. Download your table, edit it, upload it, then convert back to MySQL.

Code:

Field:  ... Entry
admpage_id:     ... check_imgs
admpage_showmenu:     ... Y
admpage_submenu:     ... 03CATALOG
admpage_disp_submenu:     ... Y
admpage_accesslevel:     ... 700
admpage_description:     ... Check for Missing Images
admpage_element:     ... adm_check_imgs
admpage_subroutine: (blank)
admpage_params: (blank)
admpage_help: (blank)

(4) Here's the code.
, at the end, just before

Code:

#######################################################################
# Return True Value For End Of File                                   #
#######################################################################

1;

Insert the following and upload it to your server in ASCII mode.

Code:

#############################################################
#############################################################
###
### Check images
### This checks images only in the Click Cart Pro 5.1 (tiki) database that were
### entered as image filenames for 
### product_category, product_detail and product_xlarge.
### This also checks for Category images.
###
### This routine does not check images in the product description or templates.
###
### This module is freeware under the GNU license.
### This module is not to be sold without expressed written consent of
### Gardecor, llc
###

sub adm_exec_check_images {

&initialize_sub_add('adm_check_images');

open (IMGFILE, ">$server_media_path/html/missingImages.html");

print IMGFILE '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><html>';
print IMGFILE '<HEAD><TITLE>Missing Product Images</TITLE></head><body>';
print IMGFILE '<h2>MISSING IMAGES</h2>';
print IMGFILE '<table border="1">';
print IMGFILE '<tr><td><b>ID</b></td>';
print IMGFILE '<td><b>Name</b><td><b>Missing Image</b></td>';
print IMGFILE '</tr>';

my @product = ();

$sql_statement = "

SELECT product_id,product_name,product_imglg,product_imgsm,product_imgxlg
FROM product
WHERE product_id<>''

";

@product = database_call('product','SELECT',$sql_statement);

print IMGFILE '<tr><td colspan="3" bgcolor="#FFEEEE"><b>Product Category Image</b><br>db name = product_imgsm<br>dir = product_category</td></tr>';

$xcnt = 0;
foreach $row(@product) {

($product_id,$product_name,$product_imglg,$product_imgsm,$product_imgxlg) = @$row;

$product_id =~ s/\"//gs;
$product_name =~ s/\"//gs;
$product_imgsm =~ s/\"//gs;
$product_imglg =~ s/\"//gs;
$product_imgxlg =~ s/\"//gs;

###
### Product Category images, product_imgsm
### In product_category directory
###

if (!-e "$server_media_path/images/product_category/$product_imgsm") {
++$xcnt;
print IMGFILE '<tr><td><a href="',$url_script_path,'/cp-app.cgi?pg=prod&ref=',$product_id,'">',$product_id,'</a></td>';
print IMGFILE '<td>',$product_name,'</td>';
print IMGFILE '<td>',$product_imgsm,'</td></tr>';
} ### end if
} ### end foreach

if ($xcnt < 1) {
print IMGFILE '<tr><td colspan = "3" bgcolor="#FFEEEE">No missing Product Category Images.</td></tr>';
}

###
### Product Detail images on product page, product_imglg
### Found in product_detail directory
###

print IMGFILE '<tr><td colspan="3" bgcolor="#DDFFFF"><b>Product Detail Image</b><br>db name = product_imglg<br>dir = product_detail</td></tr>';
$xcnt = 0;
foreach $row(@product) {

($product_id,$product_name,$product_imglg,$product_imgsm,$product_imgxlg) = @$row;

$product_id =~ s/\"//gs;
$product_imgsm =~ s/\"//gs;
$product_imglg =~ s/\"//gs;
$product_imgxlg =~ s/\"//gs;

if (!-e "$server_media_path/images/product_detail/$product_imglg") {
++$xcnt;
print IMGFILE '<tr><td><a href="',$url_script_path,'/cp-app.cgi?pg=prod&ref=',$product_id,'">',$product_id,'</a></td>';
print IMGFILE '<td>',$product_name,'</td>';
print IMGFILE '<td>',$product_imglg,'</td>';
print IMGFILE '</tr>';

} ### end if
} ### end foreach

if ($xcnt < 1) {
print IMGFILE '<tr><td colspan = "3" bgcolor="#DDFFFF">No missing Product Detail Images.</td></tr>';
}

###
### Product XLarge images, product_imgxlg
### Located in product_xlarge directory
###

print IMGFILE '<tr><td colspan="3" bgcolor="#DDDDFF"><b>Product Extra Large Image</b><br>db name = product_imgxlg<br>dir = product_xlarge</td></tr>';

$xcnt = 0;

foreach $row(@product) {

($product_id,$product_name,$product_imglg,$product_imgsm,$product_imgxlg) = @$row;

$product_id =~ s/\"//gs;
$product_imgsm =~ s/\"//gs;
$product_imglg =~ s/\"//gs;
$product_imgxlg =~ s/\"//gs;

if (!-e "$server_media_path/images/product_xlarge/$product_imgxlg") {
++$xcnt;
print IMGFILE '<tr><td><a href="',$url_script_path,'/cp-app.cgi?pg=prod&ref=',$product_id,'" target="_blank">',$product_id,'</a></td>';
print IMGFILE '<td>',$product_name,'</td>';
print IMGFILE '<td>',$product_imgxlg,'</td></tr>';
} ### end if
} ### End foreach

if ($xcnt < 1) {
print IMGFILE '<tr><td colspan="3" bgcolor="#DDDDFF">No missing Product Extra Large Images.</td></tr>';
}

###
### Category images located in category directory.
###
my @product = ();

$sql_statement = "

SELECT category_id,category_name,category_imgsm
FROM category
WHERE category_id<>''

";

@category = database_call('category','SELECT',$sql_statement);

print IMGFILE '<tr><td colspan="3" bgcolor="#FFDDFF"><b>Category Image</b><br>db name = category_imgsm<br>dir = category</td></tr>';

$xcnt=0;
foreach $row(@category) {

($category_id,$category_name,$category_imgsm) = @$row;

$category_id =~ s/\"//gs;
$category_name =~ s/\"//gs;
$category_imgsm =~ s/\"//gs;

if (!-e "$server_media_path/images/category/$category_imgsm") {

++$xcnt;

print IMGFILE '<tr><td><a href="',$url_script_path,'/cp-app.cgi?pg=cat&ref=',$category_id,'" target="_blank">',$category_id,'</a></td>';
print IMGFILE '<td>',$category_name,'</td>';
print IMGFILE '<td>',$category_imgsm,'</td></tr>';

} ### end if
} ### End foreach

if ($xcnt < 1) {
print IMGFILE '<tr><td colspan="3" bgcolor="#FFDDFF">No missing Category Images.</td></tr>';
}


print IMGFILE '</table></body></HTML>';

&display_print('adm_check_images');

&initialize_sub_remove('adm_check_images');

} ### End of sub

(5) Login into your Admin panel and select Store Catalog. You will see "Check for Missing Images". When you click this menu item, the program will run and list missing images in an html page. There will be a link to this page for you.

Offline

 

#2 08-25-2005 18:18:53

Big Dave
Member
Registered: 10-24-2003
Posts: 742

Re: Check For Missing Images

BUT WHAT DOES IT DO !?!?

lol

Offline

 

#3 08-25-2005 18:28:07

Blitzen
Member
From: USA
Registered: 01-01-2005
Posts: 936

Re: Check For Missing Images

It checks for missing images and lists them in an html page. Go down to the perl code and it explains it more.

olo.

Offline

 

#4 12-03-2005 11:49:20

Litemaster
Member
From: Plymouth, Devon, UK
Registered: 12-03-2005
Posts: 147
Website

Re: Check For Missing Images

Hi all,

What a brilliant bit of coding. Worked straight out of the box and does exactly what it says and checks for missing image files referenced in the product tables. It is 100% accurate and very fast.

We are new users of ClickCart Pro (2 weeks) and have added around 3800 products in the shop catalogue. This bit of coding has been invaluable in checking all the products have images linked to them. 

I would like to express my sincere thanks for allowing us to use the code.

Mike Simpson

Litemaster Systems

Offline

 

#5 12-06-2005 23:26:49

polarize
Moderator
Registered: 11-15-2004
Posts: 366

Re: Check For Missing Images

I tried this and got.....

ERROR: The page or function you requested does not exist within this software package.

Any ideas of what I might have done wrong?  Does the table have to run in SQL mode to be able to function this module? 

Please help.

Thanks,

Clint 


Using Kryptronic K9!  - v 9.4
Previous Versions:
ClickCartPro 8
ClickCartPro 7
ClickCartPro 6
ClickCartPro 5.1

Offline

 

#6 12-07-2005 10:17:57

Blitzen
Member
From: USA
Registered: 01-01-2005
Posts: 936

Re: Check For Missing Images


Hi,

This tested okay in either MySQL or CSV mode.

Because Litemaster had no problems, I would suggest that you carefully go through the instructions, especially step #4, to troubleshoot this.

Good luck.

-BLitzen

Offline

 

#7 12-11-2005 22:29:06

osluk
Member
Registered: 07-22-2005
Posts: 166

Re: Check For Missing Images

Great bit of code. Just to claify to less techies.
In section 3 ( (3) In admpage.csv, add the following line)

Format needs to be like this.

check_imgs,Y,03CATALOG,Y,Check for Missing Images,adm_check_imgs,,700

Cheers Chris

Offline

 

#8 02-04-2006 15:22:01

gedsta
Member
Registered: 05-06-2005
Posts: 147
Website

Re: Check For Missing Images

works fine for me - how did i miss this?

Offline

 

#9 02-04-2006 19:18:23

celdirect
Member
From: UK
Registered: 04-01-2005
Posts: 782

Re: Check For Missing Images

Hi,

This is a great mod.

Is there a way to get it to show up in the admin page rather than on a new page?



cheers
charlie

Offline

 

#10 11-19-2007 12:24:45

munchie75
Member
Registered: 11-19-2007
Posts: 2

Re: Check For Missing Images



Blitzen wrote:

This mod checks for missing image files that are listed in the database tables (products and categories). An html page is written that lists the missing images. This mod is called from the Admin panel.

Okay, here goes! No growling. You should not have problems because we tested these instructions with a client who just recently purchased CCP51 (tiki). (Who is totally thrilled with it! Kudos to Nick, Kryptronic, Inc., and all those who posted invaluable suggestions here.). Please do not ask for further modifications unless someone else wants to have at it. Thank you and good luck!

(1) Add the following element file to your data/elements table. You can copy 'n' paste the code into Notepad.
Save as . Upload to your data/elements directory in ASCII mode.


Code:

(CGIGET TYPE="SUB" VALUE="adm_exec_check_images")
<p>
<a href="(CGIVAR)url_media_path(/CGIVAR)/html/missingImages.html" target="_blank">Click here to view missing images.</a>
</p>

(2)  if it doesn't already exist, add this directory with 777 permissions.


(3) , add the following line and upload to your server's /data/tables directory in BINARY mode.


NOTE: If you have this table in MySQL, first convert the table to CSV. Download your table, edit it, upload it, then convert back to MySQL.

Code:

Field:  ... Entry
admpage_id:     ... check_imgs
admpage_showmenu:     ... Y
admpage_submenu:     ... 03CATALOG
admpage_disp_submenu:     ... Y
admpage_accesslevel:     ... 700
admpage_description:     ... Check for Missing Images
admpage_element:     ... adm_check_imgs
admpage_subroutine: (blank)
admpage_params: (blank)
admpage_help: (blank)

(4) Here's the code.
, at the end, just before

Code:

#######################################################################
# Return True Value For End Of File                                   #
#######################################################################

1;

Insert the following and upload it to your server in ASCII mode.

Code:

#############################################################
#############################################################
###
### Check images
### This checks images only in the Click Cart Pro 5.1 (tiki) database that were
### entered as image filenames for 
### product_category, product_detail and product_xlarge.
### This also checks for Category images.
###
### This routine does not check images in the product description or templates.
###
### This module is freeware under the GNU license.
### This module is not to be sold without expressed written consent of
### Gardecor, llc
###

sub adm_exec_check_images {

&initialize_sub_add('adm_check_images');

open (IMGFILE, ">$server_media_path/html/missingImages.html");

print IMGFILE '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><html>';
print IMGFILE '<HEAD><TITLE>Missing Product Images</TITLE></head><body>';
print IMGFILE '<h2>MISSING IMAGES</h2>';
print IMGFILE '<table border="1">';
print IMGFILE '<tr><td><b>ID</b></td>';
print IMGFILE '<td><b>Name</b><td><b>Missing Image</b></td>';
print IMGFILE '</tr>';

my @product = ();

$sql_statement = "

SELECT product_id,product_name,product_imglg,product_imgsm,product_imgxlg
FROM product
WHERE product_id<>''

";

@product = database_call('product','SELECT',$sql_statement);

print IMGFILE '<tr><td colspan="3" bgcolor="#FFEEEE"><b>Product Category Image</b><br>db name = product_imgsm<br>dir = product_category</td></tr>';

$xcnt = 0;
foreach $row(@product) {

($product_id,$product_name,$product_imglg,$product_imgsm,$product_imgxlg) = @$row;

$product_id =~ s/\"//gs;
$product_name =~ s/\"//gs;
$product_imgsm =~ s/\"//gs;
$product_imglg =~ s/\"//gs;
$product_imgxlg =~ s/\"//gs;

###
### Product Category images, product_imgsm
### In product_category directory
###

if (!-e "$server_media_path/images/product_category/$product_imgsm") {
++$xcnt;
print IMGFILE '<tr><td><a href="',$url_script_path,'/cp-app.cgi?pg=prod&ref=',$product_id,'">',$product_id,'</a></td>';
print IMGFILE '<td>',$product_name,'</td>';
print IMGFILE '<td>',$product_imgsm,'</td></tr>';
} ### end if
} ### end foreach

if ($xcnt < 1) {
print IMGFILE '<tr><td colspan = "3" bgcolor="#FFEEEE">No missing Product Category Images.</td></tr>';
}

###
### Product Detail images on product page, product_imglg
### Found in product_detail directory
###

print IMGFILE '<tr><td colspan="3" bgcolor="#DDFFFF"><b>Product Detail Image</b><br>db name = product_imglg<br>dir = product_detail</td></tr>';
$xcnt = 0;
foreach $row(@product) {

($product_id,$product_name,$product_imglg,$product_imgsm,$product_imgxlg) = @$row;

$product_id =~ s/\"//gs;
$product_imgsm =~ s/\"//gs;
$product_imglg =~ s/\"//gs;
$product_imgxlg =~ s/\"//gs;

if (!-e "$server_media_path/images/product_detail/$product_imglg") {
++$xcnt;
print IMGFILE '<tr><td><a href="',$url_script_path,'/cp-app.cgi?pg=prod&ref=',$product_id,'">',$product_id,'</a></td>';
print IMGFILE '<td>',$product_name,'</td>';
print IMGFILE '<td>',$product_imglg,'</td>';
print IMGFILE '</tr>';

} ### end if
} ### end foreach

if ($xcnt < 1) {
print IMGFILE '<tr><td colspan = "3" bgcolor="#DDFFFF">No missing Product Detail Images.</td></tr>';
}

###
### Product XLarge images, product_imgxlg
### Located in product_xlarge directory
###

print IMGFILE '<tr><td colspan="3" bgcolor="#DDDDFF"><b>Product Extra Large Image</b><br>db name = product_imgxlg<br>dir = product_xlarge</td></tr>';

$xcnt = 0;

foreach $row(@product) {

($product_id,$product_name,$product_imglg,$product_imgsm,$product_imgxlg) = @$row;

$product_id =~ s/\"//gs;
$product_imgsm =~ s/\"//gs;
$product_imglg =~ s/\"//gs;
$product_imgxlg =~ s/\"//gs;

if (!-e "$server_media_path/images/product_xlarge/$product_imgxlg") {
++$xcnt;
print IMGFILE '<tr><td><a href="',$url_script_path,'/cp-app.cgi?pg=prod&ref=',$product_id,'" target="_blank">',$product_id,'</a></td>';
print IMGFILE '<td>',$product_name,'</td>';
print IMGFILE '<td>',$product_imgxlg,'</td></tr>';
} ### end if
} ### End foreach

if ($xcnt < 1) {
print IMGFILE '<tr><td colspan="3" bgcolor="#DDDDFF">No missing Product Extra Large Images.</td></tr>';
}

###
### Category images located in category directory.
###
my @product = ();

$sql_statement = "

SELECT category_id,category_name,category_imgsm
FROM category
WHERE category_id<>''

";

@category = database_call('category','SELECT',$sql_statement);

print IMGFILE '<tr><td colspan="3" bgcolor="#FFDDFF"><b>Category Image</b><br>db name = category_imgsm<br>dir = category</td></tr>';

$xcnt=0;
foreach $row(@category) {

($category_id,$category_name,$category_imgsm) = @$row;

$category_id =~ s/\"//gs;
$category_name =~ s/\"//gs;
$category_imgsm =~ s/\"//gs;

if (!-e "$server_media_path/images/category/$category_imgsm") {

++$xcnt;

print IMGFILE '<tr><td><a href="',$url_script_path,'/cp-app.cgi?pg=cat&ref=',$category_id,'" target="_blank">',$category_id,'</a></td>';
print IMGFILE '<td>',$category_name,'</td>';
print IMGFILE '<td>',$category_imgsm,'</td></tr>';

} ### end if
} ### End foreach

if ($xcnt < 1) {
print IMGFILE '<tr><td colspan="3" bgcolor="#FFDDFF">No missing Category Images.</td></tr>';
}


print IMGFILE '</table></body></HTML>';

&display_print('adm_check_images');

&initialize_sub_remove('adm_check_images');

} ### End of sub

(5) Login into your Admin panel and select Store Catalog. You will see "Check for Missing Images". When you click this menu item, the program will run and list missing images in an html page. There will be a link to this page for you.

Offline

 

#11 12-18-2007 19:46:23

Blitzen
Member
From: USA
Registered: 01-01-2005
Posts: 936

Re: Check For Missing Images

munchie75 - Sorry for not answering sooner, but for some reason, I don't get notices when someone posts on this forum.

Anyway, you can transfer as "binary" or "ASCII" (readable text). There must be a place in your FTP program to select the transfer type.
If you upload the csv files and the CCP program still works, then your ftp program is downloading/uploading it okay.

admpage.csv may be used from the table in your MySQL database, not the admpage.csv file in the "tables" directory. Look in (Amin - Database Util -  Table Data Sources) to see if it's using that csv file of the MySQL table.

So, you can convert the admpage to CSV, download the file admpage.csv. Add the row, then upload it. Convert it back to MySQL.

HTH

Offline

 

Board footer