#!/usr/bin/perl
##############################################################################
# PowerWebShop PWS                Version 1.0b                               #
# Copyright 1999-2000 Alex C      alex@world.pp.se                           #
#                                 http://www.world.pp.se                     #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1999-2000 Alex C  All Rights Reserved.                           #
#                                                                            #
# Selling the code for this program without prior written consent is         #
# expressly forbidden.  In other words, please ask first before you try and  #
# make money off of my program.                                              #
#                                                                            #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium.	In all cases copyright and header must remain intact #
##############################################################################
# DISCLAIMER                                                                 #
# In no event will Alex C be liable to the user of this script or any third  #
# party for any damages, including any lost profits, lost savings or other   #
# incidental, consequential or special damages arising out of the operation  #
# of or inability to operate this script, even if user has been advised of   #
# the possibility of such damages.                                           #
##############################################################################
print "Content-type: text/html\n\n";
&FormInput(*input);
$eda = "eda.txt";
$hkurl = "/cgi-bin/pws/demo/html_konverter.pl";
$frame2 = "/cgi-bin/pws/demo/frame2.pl";





open(DATA,"$eda");
   @lines = <DATA>;
close(DATA);

$addnew=0;

	open(DATA,">$eda");
	  foreach $line (@lines)
	  {
	  	($eda, $kundid) = split(/\|/,$line);
	  	if ($eda eq "eda") 
		  {
			$kundid++;
		 	print DATA ("$eda|$kundid");
		 	$addnew=1;
	  	  }}
	  	  if ($addnew == 0) 
	  	  {
	  	  print DATA ("eda|1\n");
	  	  }
close(DATA);

#promot/link3 ja eller nej
if ($input{'kategori'} eq "") 
		  {
		  $frame2 = "$frame2?kundid=$kundid";
		  }
		  else
		  {
		  $frame2 = "$frame2?kundid=$kundid&kategori=$input{'kategori'}";
		  }



print <<"HTML";
<html>

<head>
<title> PowerWebShop PWS 1.0 </title>
<meta name="GENERATOR" content="PowerWebShop PWS 1.0b">
</head>

<frameset cols="780,*" border="0" framespacing="0" frameborder="NO" border="0">

<frameset rows="50,*,102" frameborder="NO" border="0" framespacing="0" cols="*"> 
  <frame src="$hkurl?fil=top_logo.html&kundid=$kundid" scrolling="NO" noresize frameborder="NO">
  <frameset cols="230,*" border="0" framespacing="0"> 
      <frameset cols="220,*"> 
        <frame src="$hkurl?fil=neny.html&kundid=$kundid">
        <frame src="$hkurl?fil=vit_kil.html&kundid=$kundid" scrolling="NO" frameborder="NO">
      </frameset>
    <frame name="main" src="$hkurl?fil=erbjudande.html&kundid=$kundid">
  </frameset>
  <frameset cols="220,*" frameborder="NO" border="0" framespacing="0"> 
    <frame name="bottomFrame" scrolling="NO" noresize src="$hkurl?fil=left_botten.html&kundid=$kundid">
    <frame name="kundvagn" noresize src="$hkurl?fil=right_botten.html&kundid=$kundid">
  </frameset>
</frameset>
<frame src="$hkurl?fil=side.html&kundid=$kundid" scrolling="NO" frameborder="NO">
</frameset>


<noframes>
<body bgcolor="#FFFFFF" text="#000000">
<p>This page uses frames, but your browser doesn't support them.</p>**
</body>
</noframes>


HTML


#-------------------------------------------------------------
# function: FormInput
#-------------------------------------------------------------
sub FormInput
{
local (*qs) = @_ if @_;

if ($ENV{'REQUEST_METHOD'} eq "GET")
        {
        $qs = $ENV{'QUERY_STRING'};
        }
elsif ($ENV{'REQUEST_METHOD'} eq "POST")
        {
        read(STDIN,$qs,$ENV{'CONTENT_LENGTH'});
        }

@qs = split(/&/,$qs);

foreach $i (0 .. $#qs)
        {
        $qs[$i] =~ s/\+/ /g;
        $qs[$i] =~ s/%(..)/pack("c",hex($1))/ge;

        ($name,$value) = split(/=/,$qs[$i],2);

        if($qs{$name} ne "")
                {
                $qs{$name} = "$qs{$name}:$value";
                }
        else
                {
                $qs{$name} = $value;
                }
        }

return 1;
}
