dg123
11-05-03, 01:11 PM
Hi
i'm very new w/ pearl but i have an auction script and i been trying to separate this script and 2 because is for a closed auction for the seller but on the script shows Sold auction and Unsold auction on the same template but i will like to have 2 different template one for sold and another for unsold
my questions is what have to be done to create 2 template for sold and unlsold items
(my main) <~~i add this on the script to change the name of main script just for the forum
here is the script
------------
use DBI;
use IO::Socket;
use (my main) qw(%form $couser $copass $db $dbh %config @auction_types);
use strict;
require "variables/variables.cgi";
(my main) ::service;
local %form = &(my main) ::fetch_form;
# connect to our database
my $db = &(my main)::mysql_connect;
my ($usernum,$authuser,$authpass);
if ($form{'username'} and $form{'password'} and $form{'useform'}) {
($usernum,$authuser,$authpass) = (my main)::authenticate($form{'username'},$form{'passw ord'},1,0,$db);
} elsif ($form{'username'} and $form{'password'} and !$form{'useform'}) {
($usernum,$authuser,$authpass) = (my main)::authenticate($form{'username'},$form{'passw ord'},0,1,$db);
} else {
($usernum,$authuser,$authpass) = (my main)::authenticate($form{'username'},$form{'passw ord'},0,0,$db);
}
if (!$usernum && !$authuser && !$authpass) {
&(my main)::auth_form("","Closed Auctions");
} else {
my $current_time = time + ($config{'timediff'} * 3600);
my $highbid;
my $itemnum;
my $itemtitle;
my $itembought;
my $itembuyername;
my $itembuyerrating;
my $itemqty;
my $itemtype;
my $itemopen;
my $itemclose;
my $image;
my $numbids;
my %tempitemhash;
my @itemorder;
my $icons;
my $grabber;
my $bold;
my $yellow;
my $db_query;
my $color = $config{'tablebody'};
my $page = $form{'page'};
my $coat = $form{'category'};
my $pagebreak = int $form{'pb'} || $config{'postsperpage'};
my $icount;
my $pcount;
my $display;
my $biprice;
my $bought;
my $highbid;
my $buser;
my $sysfunction;
my $days = $form{'query'} || 30;
my $header = &(my main) ::header; # Fetch the header
(my main) ::Display($header); # Display the Header
$db_query = "SELECT itemnum,title,bought,quantity,type,open,close,imag e1,bold,yellow,grabber,buyitprice,bought,buser FROM Items";
$db_query .= " WHERE closef <> 0 AND seller = '$usernum' AND $current_time < ($days * 86400 + close) ";
$db_query .= "ORDER BY close DESC";
$dbh=$db->prepare($db_query);
$dbh->execute();
my $numpgs = $dbh -> rows;
while (($itemnum,$itemtitle,$itembought,$itemqty,$itemty pe,$itemopen,$itemclose,$image,$bold,$yellow,$grab ber,$biprice,$bought,$buser) = $dbh->fetchrow_array()) {
@{$tempitemhash{$itemnum}} = ($itemnum,$itemtitle,$itembought,$itemqty,$itemtyp e,$itemopen,$itemclose,$image,$bold,$yellow,$grabb er,$biprice,$bought,$buser);
push (@itemorder, $itemnum);
}
FILE: foreach $itemnum (@itemorder) {
($itemnum,$itemtitle,$itembought,$itemqty,$itemtyp e,$itemopen,$itemclose,$image,$bold,$yellow,$grabb er,$biprice,$bought,$buser) = @{$tempitemhash{$itemnum}};
$dbh=$db->prepare("SELECT COUNT(*) FROM Bids WHERE biditem=" . int($itemnum));
$dbh->execute();
($numbids) = $dbh->fetchrow_array();
$dbh=$db->prepare("SELECT username FROM Members,Bids WHERE biditem=$itemnum AND usernum = bidder ORDER BY bidprice DESC,bidquantity DESC,bidtime LIMIT 1");
$dbh->execute();
($itembuyername) = $dbh->fetchrow_array();
$dbh=$db->prepare("SELECT fbitem FROM Feedback WHERE fbitem=$itemnum AND rater=$usernum");
$dbh->execute();
($itembuyerrating) = $dbh->fetchrow_array();
if (($buser) and (!$itembuyerrating)) {
$sysfunction = "<A HREF=$config{'script_dir'}/leavefeed2.pl?user=$buser&item=$itemnum>Give Buyer Feedback</a><br><A HREF=\"$config{'script_dir'}/relist.pl?item=$itemnum&username=$authuser&password=$authpass\">Start Auction again</A>";
}
elsif (($itembuyername) and (!$itembuyerrating)) {
$sysfunction = "<A HREF=$config{'script_dir'}/leavefeed2.pl?user=$itembuyername&item=$itemnum>Give Buyer a Feedback</a><br><A HREF=\"$config{'script_dir'}/relist.pl?item=$itemnum&username=$authuser&password=$authpass\">Start Auction again</A>";
}
else {
$sysfunction = "<A HREF=\"$config{'script_dir'}/relist.pl?item=$itemnum&username=$authuser&password=$authpass\">Start Auction again</A>";
}
if (($numbids==0) and (!$bought)) {
$sysfunction .= "<BR><A HREF=\"$config{'script_dir'}/deleteclosed.pl?item=$itemnum&username=$authuser&password=$authpass\">Delete Closed Auction</A>";
}
my $timeremain = (my main)::time_remain($itemclose);
if ($bought) {
$highbid = $biprice;
} else {
$highbid = (my main)::get_high_bid($itemnum,$itemqty,$db);
}
$highbid = (my main)::format_price($highbid,0);
my $grabberpic="";
$grabberpic = $config{'grabber1'} if ($grabber eq 1);
$grabberpic = $config{'grabber2'} if ($grabber eq 2);
$grabberpic = $config{'grabber3'} if ($grabber eq 3);
$grabberpic = $config{'grabber4'} if ($grabber eq 4);
$grabberpic = $config{'grabber5'} if ($grabber eq 5);
$grabberpic = $config{'grabber6'} if ($grabber eq 6);
$grabberpic = $config{'grabber7'} if ($grabber eq 7);
$grabberpic = $config{'grabber8'} if ($grabber eq 8);
$grabberpic = $config{'grabber9'} if ($grabber eq 9);
$grabberpic = $config{'grabber10'} if ($grabber eq 10);
my $timediff=($itemclose - time);
$icons = "";
$icons .= $config{'pic_item_icon'} if $image;
$icons .= $config{'hot_item_icon'} if $numbids >= $config{'hot_item_bids'};
$icons .= $config{'dutch_item_icon'} if $itemtype eq "Dutch";
$icons .= $config{'class_item_icon'} if $itemtype eq "Classified";
$icons .= $grabberpic;
if ($yellow eq "yes") {
$color = "yellow";
}
if ($itembought eq '1') {
$itembought = "<span class='small'><br><b>Buy-it-now</b></span>";
} else {
$itembought ="";
}
if(++$icount > $pagebreak){$icount=1; $pcount++}
next FILE if $pcount != $form{'page'};
if ($bold eq "yes") {
$display .= "<TR><TD BGCOLOR=$color>$itemnum</TD><TD BGCOLOR=$color><A HREF=$config{'script_dir'}/item.pl?item=$itemnum><B>$itemtitle</B></A> $icons</TD><TD BGCOLOR=$color ALIGN=RIGHT><B>$highbid$itembought</B></TD><TD BGCOLOR=$color ALIGN=RIGHT><B>$numbids</B></TD><TD BGCOLOR=$color ALIGN=RIGHT>$sysfunction</TD></TR>\n";
} else {
$display .= "<TR><TD BGCOLOR=$color>$itemnum</TD><TD BGCOLOR=$color><A HREF=$config{'script_dir'}/item.pl?item=$itemnum>$itemtitle</A> $icons</TD><TD BGCOLOR=$color ALIGN=RIGHT>$highbid$itembought</TD><TD BGCOLOR=$color ALIGN=RIGHT>$numbids</TD><TD BGCOLOR=$color ALIGN=RIGHT>$sysfunction</TD></TR>\n";
}
if ($color eq "$config{'tablebody'}") {
$color = "$config{'tablebody2'}";
} else {
$color = "$config{'tablebody'}";
}
}
if ($numpgs <= 0) {
$display .= "<TR><TD COLSPAN=5 BGCOLOR=$config{'tablebody'}><b><center>There are no closed auctions.</center></b></TD></TR>";
}
my $disppb = (my main) ::pagebreak($pcount,$pagebreak);
my $content=(my main) ::Open_Template("closedauctions.txt");
$content=~ s/<!-USERNAME-->/$authuser/g;
$content=~ s/<!-USERNUM-->/$usernum/;
$content=~ s/<!-USERNUM2-->/$usernum/;
$content=~ s/<!-ENCRYPTED_PASSWORD-->/$authpass/g;
$content=~ s/<!-DISPLAY_USERS_CLOSED_AUCTIONS-->/$display/;
$content=~ s/<!-DISPLAY_PAGEBREAKS-->/$disppb/;
$content=~ s/<!-DAYS-->/$days/g;
$content=~ s/<!-NUMBER_OF_TRANSACTIONS-->/$numpgs/g;
(my main) ::Display($content); # Display the Page Contents
my $footer = (my main) ::footer; # Fetch the Footer
(my main) ::Display($footer); # Display the Footer
}
# disconnect from our database
$dbh -> finish;
(my main) ::mysql_disconnect($db);
-------------------------------
Thank you
Claudia
i'm very new w/ pearl but i have an auction script and i been trying to separate this script and 2 because is for a closed auction for the seller but on the script shows Sold auction and Unsold auction on the same template but i will like to have 2 different template one for sold and another for unsold
my questions is what have to be done to create 2 template for sold and unlsold items
(my main) <~~i add this on the script to change the name of main script just for the forum
here is the script
------------
use DBI;
use IO::Socket;
use (my main) qw(%form $couser $copass $db $dbh %config @auction_types);
use strict;
require "variables/variables.cgi";
(my main) ::service;
local %form = &(my main) ::fetch_form;
# connect to our database
my $db = &(my main)::mysql_connect;
my ($usernum,$authuser,$authpass);
if ($form{'username'} and $form{'password'} and $form{'useform'}) {
($usernum,$authuser,$authpass) = (my main)::authenticate($form{'username'},$form{'passw ord'},1,0,$db);
} elsif ($form{'username'} and $form{'password'} and !$form{'useform'}) {
($usernum,$authuser,$authpass) = (my main)::authenticate($form{'username'},$form{'passw ord'},0,1,$db);
} else {
($usernum,$authuser,$authpass) = (my main)::authenticate($form{'username'},$form{'passw ord'},0,0,$db);
}
if (!$usernum && !$authuser && !$authpass) {
&(my main)::auth_form("","Closed Auctions");
} else {
my $current_time = time + ($config{'timediff'} * 3600);
my $highbid;
my $itemnum;
my $itemtitle;
my $itembought;
my $itembuyername;
my $itembuyerrating;
my $itemqty;
my $itemtype;
my $itemopen;
my $itemclose;
my $image;
my $numbids;
my %tempitemhash;
my @itemorder;
my $icons;
my $grabber;
my $bold;
my $yellow;
my $db_query;
my $color = $config{'tablebody'};
my $page = $form{'page'};
my $coat = $form{'category'};
my $pagebreak = int $form{'pb'} || $config{'postsperpage'};
my $icount;
my $pcount;
my $display;
my $biprice;
my $bought;
my $highbid;
my $buser;
my $sysfunction;
my $days = $form{'query'} || 30;
my $header = &(my main) ::header; # Fetch the header
(my main) ::Display($header); # Display the Header
$db_query = "SELECT itemnum,title,bought,quantity,type,open,close,imag e1,bold,yellow,grabber,buyitprice,bought,buser FROM Items";
$db_query .= " WHERE closef <> 0 AND seller = '$usernum' AND $current_time < ($days * 86400 + close) ";
$db_query .= "ORDER BY close DESC";
$dbh=$db->prepare($db_query);
$dbh->execute();
my $numpgs = $dbh -> rows;
while (($itemnum,$itemtitle,$itembought,$itemqty,$itemty pe,$itemopen,$itemclose,$image,$bold,$yellow,$grab ber,$biprice,$bought,$buser) = $dbh->fetchrow_array()) {
@{$tempitemhash{$itemnum}} = ($itemnum,$itemtitle,$itembought,$itemqty,$itemtyp e,$itemopen,$itemclose,$image,$bold,$yellow,$grabb er,$biprice,$bought,$buser);
push (@itemorder, $itemnum);
}
FILE: foreach $itemnum (@itemorder) {
($itemnum,$itemtitle,$itembought,$itemqty,$itemtyp e,$itemopen,$itemclose,$image,$bold,$yellow,$grabb er,$biprice,$bought,$buser) = @{$tempitemhash{$itemnum}};
$dbh=$db->prepare("SELECT COUNT(*) FROM Bids WHERE biditem=" . int($itemnum));
$dbh->execute();
($numbids) = $dbh->fetchrow_array();
$dbh=$db->prepare("SELECT username FROM Members,Bids WHERE biditem=$itemnum AND usernum = bidder ORDER BY bidprice DESC,bidquantity DESC,bidtime LIMIT 1");
$dbh->execute();
($itembuyername) = $dbh->fetchrow_array();
$dbh=$db->prepare("SELECT fbitem FROM Feedback WHERE fbitem=$itemnum AND rater=$usernum");
$dbh->execute();
($itembuyerrating) = $dbh->fetchrow_array();
if (($buser) and (!$itembuyerrating)) {
$sysfunction = "<A HREF=$config{'script_dir'}/leavefeed2.pl?user=$buser&item=$itemnum>Give Buyer Feedback</a><br><A HREF=\"$config{'script_dir'}/relist.pl?item=$itemnum&username=$authuser&password=$authpass\">Start Auction again</A>";
}
elsif (($itembuyername) and (!$itembuyerrating)) {
$sysfunction = "<A HREF=$config{'script_dir'}/leavefeed2.pl?user=$itembuyername&item=$itemnum>Give Buyer a Feedback</a><br><A HREF=\"$config{'script_dir'}/relist.pl?item=$itemnum&username=$authuser&password=$authpass\">Start Auction again</A>";
}
else {
$sysfunction = "<A HREF=\"$config{'script_dir'}/relist.pl?item=$itemnum&username=$authuser&password=$authpass\">Start Auction again</A>";
}
if (($numbids==0) and (!$bought)) {
$sysfunction .= "<BR><A HREF=\"$config{'script_dir'}/deleteclosed.pl?item=$itemnum&username=$authuser&password=$authpass\">Delete Closed Auction</A>";
}
my $timeremain = (my main)::time_remain($itemclose);
if ($bought) {
$highbid = $biprice;
} else {
$highbid = (my main)::get_high_bid($itemnum,$itemqty,$db);
}
$highbid = (my main)::format_price($highbid,0);
my $grabberpic="";
$grabberpic = $config{'grabber1'} if ($grabber eq 1);
$grabberpic = $config{'grabber2'} if ($grabber eq 2);
$grabberpic = $config{'grabber3'} if ($grabber eq 3);
$grabberpic = $config{'grabber4'} if ($grabber eq 4);
$grabberpic = $config{'grabber5'} if ($grabber eq 5);
$grabberpic = $config{'grabber6'} if ($grabber eq 6);
$grabberpic = $config{'grabber7'} if ($grabber eq 7);
$grabberpic = $config{'grabber8'} if ($grabber eq 8);
$grabberpic = $config{'grabber9'} if ($grabber eq 9);
$grabberpic = $config{'grabber10'} if ($grabber eq 10);
my $timediff=($itemclose - time);
$icons = "";
$icons .= $config{'pic_item_icon'} if $image;
$icons .= $config{'hot_item_icon'} if $numbids >= $config{'hot_item_bids'};
$icons .= $config{'dutch_item_icon'} if $itemtype eq "Dutch";
$icons .= $config{'class_item_icon'} if $itemtype eq "Classified";
$icons .= $grabberpic;
if ($yellow eq "yes") {
$color = "yellow";
}
if ($itembought eq '1') {
$itembought = "<span class='small'><br><b>Buy-it-now</b></span>";
} else {
$itembought ="";
}
if(++$icount > $pagebreak){$icount=1; $pcount++}
next FILE if $pcount != $form{'page'};
if ($bold eq "yes") {
$display .= "<TR><TD BGCOLOR=$color>$itemnum</TD><TD BGCOLOR=$color><A HREF=$config{'script_dir'}/item.pl?item=$itemnum><B>$itemtitle</B></A> $icons</TD><TD BGCOLOR=$color ALIGN=RIGHT><B>$highbid$itembought</B></TD><TD BGCOLOR=$color ALIGN=RIGHT><B>$numbids</B></TD><TD BGCOLOR=$color ALIGN=RIGHT>$sysfunction</TD></TR>\n";
} else {
$display .= "<TR><TD BGCOLOR=$color>$itemnum</TD><TD BGCOLOR=$color><A HREF=$config{'script_dir'}/item.pl?item=$itemnum>$itemtitle</A> $icons</TD><TD BGCOLOR=$color ALIGN=RIGHT>$highbid$itembought</TD><TD BGCOLOR=$color ALIGN=RIGHT>$numbids</TD><TD BGCOLOR=$color ALIGN=RIGHT>$sysfunction</TD></TR>\n";
}
if ($color eq "$config{'tablebody'}") {
$color = "$config{'tablebody2'}";
} else {
$color = "$config{'tablebody'}";
}
}
if ($numpgs <= 0) {
$display .= "<TR><TD COLSPAN=5 BGCOLOR=$config{'tablebody'}><b><center>There are no closed auctions.</center></b></TD></TR>";
}
my $disppb = (my main) ::pagebreak($pcount,$pagebreak);
my $content=(my main) ::Open_Template("closedauctions.txt");
$content=~ s/<!-USERNAME-->/$authuser/g;
$content=~ s/<!-USERNUM-->/$usernum/;
$content=~ s/<!-USERNUM2-->/$usernum/;
$content=~ s/<!-ENCRYPTED_PASSWORD-->/$authpass/g;
$content=~ s/<!-DISPLAY_USERS_CLOSED_AUCTIONS-->/$display/;
$content=~ s/<!-DISPLAY_PAGEBREAKS-->/$disppb/;
$content=~ s/<!-DAYS-->/$days/g;
$content=~ s/<!-NUMBER_OF_TRANSACTIONS-->/$numpgs/g;
(my main) ::Display($content); # Display the Page Contents
my $footer = (my main) ::footer; # Fetch the Footer
(my main) ::Display($footer); # Display the Footer
}
# disconnect from our database
$dbh -> finish;
(my main) ::mysql_disconnect($db);
-------------------------------
Thank you
Claudia