MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: Executing cgi-script from minivend page



Dmitriy Katsman <dmk@acinc.com> writes:

> I am a little 'unclear' with CGI-script executing from minivend page...
> how in the world is it going to work?
> 
> CGI program always returns something as the result in HTML format..
> so how is this HTML going to be displayed instead of Minivend page?
> if it gets displayed, minivend will lose the control of the session

You can pass the session id along your CGI scripts and call MiniVend
pages from your scripts.

E.g:

# ----------------------------------------------
# METHOD: mvpage NAME [FORCEAUTH]
#
# Returns the content of the MiniVend page NAME.
# An authorization header is included in the
# request if REMOTE_USER is set or FORCEAUTH
# has a truth value.
# ----------------------------------------------

sub mvpage
  {
	my ($self, $page) = @_;
	my $forceauth = shift || 0;
	my ($hdr, $req, $res);

	my $rc = $self -> {'RC'};

	if ($self -> remote_user () || $forceauth)
	  {
		# include authorization header in query
		$hdr = new HTTP::Headers;
		$hdr -> authorization_basic ('xxxxx', 'yyyyyyyyyyy');
	  }
		  
	# create a HTTP request for the headers used by MiniVend
	$req = new HTTP::Request (GET => 'http://' . $rc -> set ('server') .
							  '/' . $rc -> set ('prefix') . '/' . "$page.html?"
								. $self -> {'SESSION'} . ';;', $hdr);
	
	# execute it
	$res = $ua -> request ($req);

	# error handling
	unless ($res -> is_success)
	  {
		$self -> fatal (CEX_REQUEST_FAILED, $res -> code, $res -> message);
	  }

	$res -> content;
  }


-- 
LinuXia - Solutions of Cool Competence - Internetprogramming and more
D-30163 Hannover, Waldstra&#223;e 4, 0511-3941290 (http://www.linuxia.de/)
Wir realisieren Onlineshops mit Minivend (http://www.minivend.com)
und MiniMate (http://www.linuxia.de/minimate/).


Search for: Match: Format: Sort by: