Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auction Script, Update Running Auctions Add-On Problems 1

Status
Not open for further replies.

Everyauction

Technical User
Dec 8, 2008
4
0
0
CH
Hello everybody

Now, this is going to be a rather long one...

I am working on a highly modified Everyauction 1.53 Auction Script. A flat DB type Registry file is created for every Auction item. This file contains, besides the Info on the Auction Item, beginning from line No.50 on, seller & bidder infos such as Name, email, bidtime, Bid, address, e.t.c. This information is used during auction time for certain "statements" and after the auction ends to inform participating members about the results of the Sale.

Such typical User-related Item File lines would look (about) like this,

($variables: $alias, $email, $bid, $time, $add1, $add2, $add3)

where the first Line is always the Seller, all the below following lines contain bidder-information:

Code:
Hans[]hans@mail.com[]1.00[]1221479939[]Hans Meier[]Huberweg 4[]3000[]Bern
Ernie[]ernie@mail.com[]1.00[]1221494526[]Ernst Jacob[]Postbox 25[]5000[]Aarau
Beni[]beni@mail.com[]2.00[]1221494667[]Beni Jacob[]Postbox 4[]5506[]Dottikon
Ernie[]ernie@mail.com[]3.00[]1221494678[]Ernst Jacob[]Postbox 25[]5000[]Aarau

Since Users sometimes move or change E-Mail Addresses during participation on Auctions (as seller or bidder), so it should be possible to have updated not only their personal User Registry Data File, but also all Auction Registry Files containing related information of those specific Users as well.

For the type of Auction Software I use, an addon exists meant to do just that!
But unfortunately, the fellow (Michael Ammar) creating this addon, has been using a rather different approach of programming (probably CGI routines?) compared to what I know about Perl (so far), and even this is not so very much...! Beeing a Swiss (german) and reading/writing self-studied english makes it even harder for me to get that stuff into my 62year aold brain...

In Addition to this, no discussion thread has been found by me at the former EA Auction Script User Forum, when searching for any information regarding this Addon (I saved thousand's of such pages during the Years when the forum was still alive!).

NOW:

I adapted the addon according my Auction Configuration (an my knowledge).

The Addon is basically called by a line like the one below :
---
Code:
&updateauctions({currentAlias => $currentAlias, alias => $newAlias, email => $email, add1 => $add1, add2 => $add2, add3 => $add3, add4 => $add4, country => $country, phone => $phone, age => $age, approved => $approved, verified => $verified, ip => $ip, referral => $referral, refname => $refname, canned => $canned, myanswer => $myanswer, numposts => $numposts, bids => \@bids});;
---

I also tried to write this line like this:

---
Code:
&updateauctions({currentAlias => $form{'ALIAS'}, alias => $form{'ALIAS'}, email => $form{'ALIAS'}, add1 => $form{'ADDRESS1'}, add2 => $form{'ADDRESS2'}, add3 => $form{'ADDRESS3'}, add4 => $form{'ADDRESS4'}, country => $country, phone => $phone, age => $age, approved => $approved, verified => $verified, ip => $ip, referral => $referral, refname => $refname, canned => $canned, myanswer => $myanswer, numposts => $numposts, bids => \@bids});;
---

in order to pass the updated $variables ($form{'whatever'}), where required, to the "processor" script.

This line defines (all) Values of the User Reg File as well as the individual Item Numbers of Auctions where the User participates in (bids =>\@bids).

I adapted the $variables in the Addon as required to match my registry lines. I spent several evenings, trying to find every possible and impossible way to get any result, but I just failed to do anything to my Auction Item File User-Content, but nothing happen, exept for the User Reg File, with is updated by the Change Reg Script correctly.

It does not produce any (visual) error nor makes it any entries in the server log, so I really have a hard time to find out why it's not working.

The fellow who wrote it originally was a rather respected Addon-Creator, but his Addons where not broadly used because he did no write (nor explain) them "the simple way" we where used from other Addon Writers who used mostly Perl and much less CGI-routines (what I think this is).

I am adding the links to the the updateauctions sub as well as a rudimentary change-reg sub as reference, if anyone cares to look a little deeper into this.



The original addon can be found here:


I know that somewhere I screw up, but that

$args->{alias} && $args->{email} && $args->{name} ....

stuff is rather strange to me....


Thanks a lot!

Ernie

PS. One more thing:

I am bound on certain restrictions and limitations because of the archidecture of the (not so young) EveryAuction Software. Therefore, I am not free to change essential parameters because of compatibility with other existing Addons. So general arguments about "basics" would make not much sense.
 
Ernie....

Why oh why? But anyway.....

$args is a scalar that is pointing to a hash, this is a reference, it is perl just like all perl:

$args->{'alias'}

its pretty much the same as:

$args{'alias'}

but you add the arrow operator '->' between the reference name and the desired data it points to, in this case a hash key.

in changreg the script calls the updateauctions function:

Code:
&updateauctions({currentAlias => $form{'ALIAS'}, alias => $form{'ALIAS'}, email => $form{'ALIAS'}, add1 => $form{'ADDRESS1'}, add2 => $form{'ADDRESS2'}, add3 => $form{'ADDRESS3'}, add4 => $form{'ADDRESS4'}, country => $country, phone => $phone, age => $age, approved => $approved, verified => $verified, ip => $ip, referral => $referral, refname => $refname, canned => $canned, myanswer => $myanswer, numposts => $numposts, bids => \@bids});;

it sends updateauctions an anonymous hash, all the data between the curly brackets {}. And the updateauctions function stores that in $args. You then get the data using the syntax you previously posted:

$args->{'email'} etc

in updateauctions change this line:

Code:
# opening the item file
	open ITEM, "$config{basepath}$key/$fileID.dat";

change to:

Code:
# opening the item file
	open ITEM, "$config{basepath}$key/$fileID.dat" or die "Can't open $config{basepath}$key/$fileID.dat: $!";

See if die returns an error message.

Signed....
Millenneum (remember me?)





------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
hi Kevin

you see, I am still trying hard to get something out of the old EA stuff. I don't give up, because the thing is running very smooth and it gets a little better every day. Remembering RASMAN's (sold) Site, I know how much one can get out of it, despite of the ancient Flat DB System used. I may change the Script to MySql to a later date, but for the time beeing, I don't really see a real need for this.

Thanks for the advise, but it did not help. Anyway, this piece of cr.. has been eating my brain out, I'm still not getting anything out of it. I still don't get the way it's been programmed, so I probably screwed up on different of those $args->{whatever}lines.

There should be an easier way by using "routines" I know (better) in order to get the item files updated, but I have to concentrate on finishing other parts of the script first after loosing long nights already for nothing (again).

Ernie
 
A quick lessaon may help you understand the code. Here is your code reduced to a few variables just to make an example:

Code:
my %form = (
 ALIAS => 'Kevin'
);
my @bids = qw(fee fii foo fum);

updateauctions({currentAlias => $form{'ALIAS'}, alias => $form{'ALIAS'}, email => $form{'ALIAS'},  bids => \@bids});

sub updateauctions {
   my ($args) = @_;
   print $args;
}

The above prints something like: HASH(0x1567e84) because $args is a reference to the anonymous hash that was passed to it. The anonymous hash was created by wrapping all the arguments inbetween curly brackets: {anonymous hash arguments} and passing them to the function.

So in order the get to the data that was passed in the anonymous hash you insert the arrow operator between the reference name and the desired hash key:

$arg->{'email'}

This has nothing to do with the fact that it is a CGI script. This is pure perl code. THere is no such thing really as a CGI routine or a perl routine, they are all perl functions.

But that is not the apparent source of your problem.

There is some suspicious code here:

Code:
# opening the item file for write
	hoppla( "Kann die Artikel Datei nicht bearbeiten." )
	[red]unless ( open NEWITEM, ">$config{basepath}$key/$fileID.dat" );[/red]

	# locking the item file
	if ( $config{'flock'} ) {
	flock( NEWITEM, 2 );
	seek( NEWITEM, 0, 2 );
	}

	# re-printing item details
	print NEWITEM "$title\n$subtitle\n$reserve\n$inc\n$desc\n$image\n$image0\n$image2\n$image3\n$image4\n$thumb\n$thumb2\n$thumb3\n$thumb4\n$itmcond\n$shipto\n$shipping\n$shipby\n$location\n$payment\n$pay0\n$pay1\n$pay2\n$pay3\n$pay4\n$pay5\n$pay6\n$pay7\n$pay8\n$paynow\n$paypal\n$charges\n$buyit\n$count\n$counter\n$relist\n$relistcnt\n$feat\n$catfeat\n$bolditem\n$pending\n$hide\n$snip\n$dutch\n$qty\n$seller\n$res1\n$res2\n$res3\n$hist\n";

	# re-printing bids
	foreach ( @itemBids ) {
	print NEWITEM $_ . "\n";
	}

	close NEWITEM; # relasing the file handle
	$modifiedFiles++;
	}

	return $modifiedFiles; # returning the number of modfied files to the calling subroutine


See the line in red. The 'unless' keyword is not used properly. It should be:

Code:
unless (condition) {
   do these expressions
}

or:

Code:
unless (condition) {
    do these expressions
}
else {
    do these other expressions
}

The line you have should produce an error:

Code:
unless ( open NEWITEM, ">$config{basepath}$key/$fileID.dat" );

its like writing:

Code:
if (condition);

Change the line in red to this:

Code:
open NEWITEM, ">$config{basepath}$key/$fileID.dat" or die "Your error message here: $!";

And see if that helps the code to run.





------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Kevin

please excuse the long delay. I work with 800x600 resolution regularely, and because of this Site's Layout, I could not even see the "answerring Window" with 800x600. Now, using 1024x768 res, at least I see some of it...

The siteowner should make sure that pages can be scrolled horizontally in order to get the whole page, even if someome inserts "long" Script-Lines.

Because of other work, I had no time yet to check the content of your replay, but I will do this asap, because I like to get that thing working anyway.

So, for now I wish you all the best for 2009!

Ernie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top