#VERSION: 2.7.beta3c ##################################################################### # This script is copyright (c)2002-2008 - 1001 Media Group. # # Please do not distribute it without permission. # ##################################################################### # __ __ # # /\ \ /\ \ # # ___ _____ ____\ \ \___ ___ _____\ \ \ # # /'___\/\ '__`\ /',__\\ \ _ `\ / __`\/\ '__`\ \_\ # # /\ \__/\ \ \L\ \/\__, `\\ \ \ \ \/\ \L\ \ \ \L\ \/_/_ # # \ \____\\ \ ,__/\/\____/ \ \_\ \_\ \____/\ \ ,__/ /\_\ # # \/____/ \ \ \/ \/___/ \/_/\/_/\/___/ \ \ \/ \/_/ # # \ \_\ \ \_\ # # \/_/ \/_/ # # # ########### ports multiple CafePress stores to your server ########## ################ http://cgi.marty.net/scripts/cpshop/ ############### ##################################################################### ##################################################################### ##################################################################### ##################################################################### # # SUBROUTINES # ##################################################################### ##################################################################### ##################################################################### ##################################################################### sub prepare { if (-e "${script_dir}cpdomain.txt") { open(DOMAIN, "${script_dir}cpdomain.txt"); { local $/; $cpdomain = ; } close(DOMAIN); $cpdomain =~ s/[^A-Za-z0-9\.]//g; } else { $cpdomain = "cafepress.com"; } &debug; &parseform; &addtocart; &genvars; &predecision; &uptodate; $outputcachecrc = &crc32_calc($areainfo); $outputcachefolder = substr($outputcachecrc,-2,2); $outputcachefile = "$outputcachefolder/$main_script.oc.$outputcachecrc.data"; if (-d "${script_dir}cpoutput") { unless (-d "${script_dir}$cpoutput/$outputcachefolder") { mkdir("${script_dir}$cpoutput/$outputcachefolder"); } } if (-e "${script_dir}$cpoutput/$outputcachefile" && (-M "${script_dir}$cpoutput/$outputcachefile" < $expiretime) && !$nocache && (-e "${script_dir}$cpcache/$main_script.safe")) { §ions("OUTPUT","${script_dir}$cpoutput/$outputcachefile"); $outputsidebarfolder = substr($OUTPUT{"sidebarid"},-2,2); unless (-d "${script_dir}$cpoutput/$outputsidebarfolder") { mkdir("${script_dir}$cpoutput/$outputsidebarfolder"); } if ($OUTPUT{"sidebarid"} && (!-e "${script_dir}$cpoutput/$outputsidebarfolder/$main_script.oc." . $OUTPUT{"sidebarid"} . ".sb.data")) { &decision; &createhtml; } else { if ($OUTPUT{"sidebarid"}) { open(SB,"<${script_dir}$cpoutput/$outputsidebarfolder/$main_script.oc." . $OUTPUT{"sidebarid"} . ".sb.data"); { local $/; $sidebar = ; } close(SB); $sidebar =~ s/\[<\[pid]>]/$pid/g; $sidebar =~ s/\[<\[xid]>]/$xid/g; $sidebar =~ s/\[<\[tid]>]/$tid/g; $sidebar =~ s/\[<\[cjpid]>]/$cjpid/g; } foreach $key(keys %OUTPUT) { ${$key} = $OUTPUT{$key}; ${$key} =~ s/\[<\[pid]>]/$pid/g; ${$key} =~ s/\[<\[xid]>]/$xid/g; ${$key} =~ s/\[<\[tid]>]/$tid/g; ${$key} =~ s/\[<\[cjpid]>]/$cjpid/g; } if ($mypath) { @mypath = split(/~mypath~/,$mypath); foreach $mypathitem(@mypath) { $INPATH{$mypathitem} = 1; } } &get_filters($storeid); } } else { &decision; &createhtml; } } sub gettemplate { if ($productno) { if ($FILTER{'prodtemplate'} && (($FILTER{'prodtemplate'} =~ /\.(htm|html|txt|tmpl|tpl|template)$/i) || ($FILTER{'prodtemplate'} =~ /template/i))) { $template_to_use = $FILTER{'prodtemplate'}; $template_to_use =~ s/\.+/\./g; } elsif ($productno && $inherited_prodtemplate && (($inherited_prodtemplate =~ /\.(htm|html|txt|tmpl|tpl|template)$/i) || ($inherited_prodtemplate =~ /template/i))) { $template_to_use = $inherited_prodtemplate; $template_to_use =~ s/\.+/\./g; } elsif ($FILTER{'template'} && (($FILTER{'template'} =~ /\.(htm|html|txt|tmpl|tpl|template)$/i) || ($FILTER{'template'} =~ /template/i))) { $template_to_use = $FILTER{'template'}; $template_to_use =~ s/\.+/\./g; } elsif ($SECTION{'HTMLproducttemplate'} && (-e $SECTION{'HTMLproducttemplate'} || -e "${script_dir}$SECTION{'HTMLproducttemplate'}" || ($SECTION{'HTMLproducttemplate'} =~ /^(http|nocache):\/\//i))) { $template_to_use = $SECTION{'HTMLproducttemplate'}; } elsif ($inherited_template && (($inherited_template =~ /\.(htm|html|txt|tmpl|tpl|template)$/i) || ($inherited_template =~ /template/i))) { $template_to_use = $inherited_template; $template_to_use =~ s/\.+/\./g; } elsif ($SECTION{'HTMLtemplate'}) { $template_to_use = $SECTION{'HTMLtemplate'}; } } elsif ($storeid) { if ($FILTER{'template'} && (($FILTER{'template'} =~ /\.(htm|html|txt|tmpl|tpl|template)$/i) || ($FILTER{'template'} =~ /template/i))) { $template_to_use = $FILTER{'template'}; $template_to_use =~ s/\.+/\./g; } elsif ($SECTION{'HTMLstoretemplate'} && (($number_of_stores > 1) || $areainfo) && (-e $SECTION{'HTMLstoretemplate'} || -e "${script_dir}$SECTION{'HTMLstoretemplate'}" || ($SECTION{'HTMLstoretemplate'} =~ /^(http|nocache):\/\//i))) { $template_to_use = $SECTION{'HTMLstoretemplate'}; } elsif ($inherited_template && (($inherited_template =~ /\.(htm|html|txt|tmpl|tpl|template)$/i) || ($inherited_template =~ /template/i))) { $template_to_use = $inherited_template; $template_to_use =~ s/\.+/\./g; } elsif ($SECTION{'HTMLtemplate'}) { $template_to_use = $SECTION{'HTMLtemplate'}; } } else { if ($SECTION{'HTMLtemplate'}) { $template_to_use = $SECTION{'HTMLtemplate'}; } } if ($template_to_use) { if (-e "${script_dir}$template_to_use") { $template_to_use = "${script_dir}$template_to_use"; } if ($template_to_use =~ m|^http://|i) { $getting_template = 1; $html = &getit("",$template_to_use); $getting_template = 0; } elsif ($template_to_use =~ m|^nocache://|i) { $getting_template = 1; $template_to_use =~ s|^nocache://|http://|i; $html = &getit("",$template_to_use,"nocache"); $getting_template = 0; } elsif ($template_to_use && !-d $template_to_use) { open(TEMPLATE,"<$template_to_use"); { local $/; $html =