diff buy.pl @ 0:599d0315537d laserkard

[svn r1] initial import
author rlm
date Wed, 30 Dec 2009 02:01:25 -0500
parents
children e2e7c63a0a08
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/buy.pl	Wed Dec 30 02:01:25 2009 -0500
     1.3 @@ -0,0 +1,172 @@
     1.4 +#!/usr/bin/perl
     1.5 +
     1.6 +
     1.7 +use List::Util qw(first max maxstr min minstr reduce shuffle sum);
     1.8 +use Storable;
     1.9 +use CGI::Ajax;
    1.10 +use CGI;
    1.11 +
    1.12 +
    1.13 +
    1.14 +my $q = new CGI;
    1.15 +
    1.16 +
    1.17 +
    1.18 +my %hash = ( 
    1.19 +
    1.20 +'material' => \&material,
    1.21 +'template'	=> \&template, 
    1.22 +'inputbox'	=> \&inputbox,
    1.23 +'display'	=> \&display,
    1.24 +'change_rules' => \&change_rules);
    1.25 +
    1.26 + 
    1.27 +
    1.28 +my $pjx = CGI::Ajax->new(%hash);
    1.29 +#$pjx->JSDEBUG(1);
    1.30 +#$pjx->DEBUG(1);
    1.31 +
    1.32 +print $pjx->build_html($q,\&gen); # this outputs the html for the page
    1.33 +
    1.34 +
    1.35 +
    1.36 +
    1.37 +
    1.38 +sub material{
    1.39 +	
    1.40 +	$newvar = shift;
    1.41 +	
    1.42 +	my $t = $newvar;
    1.43 +	
    1.44 +	$newvar =~ m/([^_]*)_/;
    1.45 +	$newvar = $1;
    1.46 +	
    1.47 +	#return (($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked');
    1.48 +	
    1.49 +	#$y = "$t<br>".(($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked')."
    1.50 +	$y = ""."
    1.51 +	<form id=\"radiobuttons\">
    1.52 +		<h3>PICK your Materials?:&nbsp;</h3>
    1.53 +		
    1.54 +		<div class = \"Acrylic\">
    1.55 +		Acrylic:
    1.56 +		<input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']);  \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_acrylic_clear\"".(($t =~ m/_acrylic_clear/) ? 'CHECKED' : '')."><a href=\"\#\">Clear</a>
    1.57 +		<input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']);  \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_acrylic_blue\"".(($t =~ m/_acrylic_blue/) ? 'CHECKED' : '')."><a href=\"\#\">Blue</a>
    1.58 +		<input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']);  \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_acrylic_green\"".(($t =~ m/_acrylic_green/) ? 'CHECKED' : '')."><a href=\"\#\">Green</a>
    1.59 +		</div>
    1.60 +		
    1.61 +		<div class = \"Aluminum\">
    1.62 +		Aluminum:
    1.63 +		<input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_red\"".(($t =~ m/_aluminum_red/) ? 'CHECKED' : '')."><a href=\"\#\">Red</a>
    1.64 +		<input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_blue\"".(($t =~ m/_aluminum_blue/) ? 'CHECKED' : '')."><a href=\"\#\">Blue</a>
    1.65 +		<input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_green\"".(($t =~ m/_aluminum_green/) ? 'CHECKED' : '')."><a href=\"\#\">Green</a>
    1.66 +		<input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_black\"".(($t =~ m/_aluminum_black/) ? 'CHECKED' : '')."><a href=\"\#\">Black</a>
    1.67 +		</div>
    1.68 +		
    1.69 +	
    1.70 +		</form>
    1.71 +	";
    1.72 +	
    1.73 +	return $y;
    1.74 +		
    1.75 +	
    1.76 +}
    1.77 +
    1.78 +
    1.79 +
    1.80 +sub template
    1.81 +{
    1.82 +	
    1.83 +$all = shift;
    1.84 +$all =~ m/_(.*)/;
    1.85 +
    1.86 +$materialcolor = $1;
    1.87 +
    1.88 +	
    1.89 +$r = "	
    1.90 +   <input TYPE=\"image\" src = \"./templates/thumbnails/classic_$materialcolor.jpg\" 	onclick=\"display([\'template1\'], [\'display\']); inputbox([\'template1\'], [\'inputbox\']);material([\'template1\'], [\'materials\']);\" ID=\"template1\" NAME=\"template1\" VALUE=\"classic_$materialcolor\">
    1.91 +   <input TYPE=\"image\" src = \"./templates/thumbnails/big_$materialcolor.jpg\" 		onclick=\"display([\'template2\'], [\'display\']); inputbox([\'template2\'], [\'inputbox\']);material([\'template2\'], [\'materials\']);\" ID=\"template2\" NAME=\"template2\" VALUE=\"big_$materialcolor\">
    1.92 +   <input TYPE=\"image\" src = \"./templates/thumbnails/basic_$materialcolor.jpg\" 	onclick=\"display([\'template3\'], [\'display\']); inputbox([\'template3\'], [\'inputbox\']);material([\'template3\'], [\'materials\']);\" ID=\"template3\" NAME=\"template3\" VALUE=\"basic_$materialcolor\"> 
    1.93 +   <input TYPE=\"image\" src = \"./templates/thumbnails/lines_$materialcolor.jpg\" 	onclick=\"display([\'template4\'], [\'display\']); inputbox([\'template4\'], [\'inputbox\']);material([\'template4\'], [\'materials\']);\" ID=\"template4\" NAME=\"template4\" VALUE=\"lines_$materialcolor\"> 
    1.94 + 
    1.95 +
    1.96 +";
    1.97 +
    1.98 +return $r;
    1.99 +}
   1.100 +
   1.101 +
   1.102 +
   1.103 +
   1.104 +sub inputbox
   1.105 +{
   1.106 +
   1.107 +#grab the type of template we'll be using <<<<
   1.108 +	$type = shift;
   1.109 +#	return $type;
   1.110 +# we have to care about both the type of template and the material and the color. these are stored in $type>>>>
   1.111 +
   1.112 +#Then, update with a special custon paypal form, taken from the paypal folder and specially designed for that particular template.
   1.113 +#will probaly eventually create a script to automate the generation of these files.
   1.114 +
   1.115 +
   1.116 +#take care of everythign but acrylic clear type
   1.117 +if (not($type =~ m/acrylic_clear/))
   1.118 +{
   1.119 +return "comming soon!";
   1.120 +}
   1.121 +
   1.122 +
   1.123 +#every type has it's own associated paylist file the contains the things we need
   1.124 +open FILE, "<./paypal/$type.paylist";
   1.125 +return do { local $/; <FILE> };
   1.126 +
   1.127 +
   1.128 +
   1.129 +}
   1.130 +
   1.131 +
   1.132 +
   1.133 +
   1.134 +
   1.135 +
   1.136 +
   1.137 +
   1.138 +sub display
   1.139 +{
   1.140 +	$all = shift;
   1.141 +	
   1.142 +	
   1.143 +	
   1.144 +	$t ="$all
   1.145 +	<input TYPE=\"image\" src = \"./templates/display/$all.jpg\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); \" ID=\"temp1\" NAME=\"temp1\" VALUE=\"\">
   1.146 +	";
   1.147 +	return $t;
   1.148 +	
   1.149 +}
   1.150 +
   1.151 +
   1.152 +
   1.153 +
   1.154 +sub gen
   1.155 +{
   1.156 +  {
   1.157 +    local( $/, *FH ) ;
   1.158 +    open( FH, "<./buy.html" ) or die "sudden flaming death\n";
   1.159 +    $a = <FH>;
   1.160 +   }
   1.161 +
   1.162 +  {
   1.163 +    local( $/, *FH ) ;
   1.164 +    open( FH, "<./top_menu.include" ) or die "sudden flaming death\n";
   1.165 +    $b = <FH>;
   1.166 +   }
   1.167 +
   1.168 +$a =~ s/PERL-REPLACE::TOP_MENU/$b/; #equivalent to <?php include("top_menu.html"); ?>, but in perl with more memory problems :)
   1.169 +
   1.170 +return $a
   1.171 +
   1.172 +
   1.173 +};
   1.174 +
   1.175 +