eAuction
  Not just another Perl script
Google
Welcome, Guest. Please Login or Register


If you use eAuction a lot and like it or if you make money from eAuction or from eAuction-related activities ...
then the project asks you for a donation in favor of the further development.



The forums are protected by
AccessControl
(written by Dieter Werner)
Click here if you want to check your IP against the most important RBLs of the net.
Click here in order to visite the AccessControl forums.


<< Visit the international e Auction Marketplace >>
Buy and sell PC and Consumer Electronic components






  HomeHelpSearchLoginRegister
 



Pages: 1
sub disp_list (Replacement) (Read 433 times)
Dieter Werner
Administrator
*****
Offline

Dipl. Paranoiac ®

Posts: 1162
Germany
Gender: male
sub disp_list (Replacement)
11/23/03 at 17:04:22
 
The following code should be used as a replacement of the original subroutine.
The layout of the tables has been changed and they are able to display 'thumbnails' of an item-image instead of displaying only the camera-icon.

Code:
##############################################
# Sub: Display all needed Listings
# Written by: Dieter Werner
##############################################
sub disp_list {
   my $itm_cnt = 0;
   my $line_cnt = 0;
   my $page_cnt = 0;
   my $found = 0;
   my $dest = undef;
   my $ret_val = 1;
   my @allfiles = ();
   my (
	  $query, $item, $cat, $title, $reserve, $inc, $desc, $end_date,
	$end_time, $start_time, $close_time, $the_time, $image,
	$img_info, $bid, $bids, $buy_it, $buy_it_info, $row,
	$rowcolor, $check_string, $tbl_title, $record,
	  @bids, @firstbid, @lastbid, @closetime, @image, @output
   );
   local $_;
  
   $form{'page'} = 0 unless exists $form{'page'};
   $form{'trash'} = 0 unless exists $form{'trash'};
   ($check_string = $form{'searchstring'}) =~ s/\s//g;

   oops($txt{'The searchstring may not contain any non word characters'})
   if $check_string =~ /\W/ or !$check_string;
  
   $query = {
	  'end'			=> q|$close_time - $the_time < ($config{'soon_time'} * 3600)|,
	  'hot'			=> q|$#bids > $config{'hot_num'}|,
	  'new'			=> q|$the_time - $start_time < ($config{'new_time'} * 3600)|,
	  'min'			=> q|$firstbid[2] == 1|,
	  'reserve'		=> q|$reserve <= $lastbid[2]|,    
	  'keyword'		=> q|$title =~ /$form{'searchstring'}/i or $desc =~ /$form{'searchstring'}/i|,
	  'username'		=> q|$firstbid[0] eq $form{'searchstring'}|,
	  'itemnumber'	=> q|$item =~ /$form{'searchstring'}/o|,
	  'price'		=> q|$lastbid[2] <= $form{'searchstring'}|,
	  'buyitnow'		=> q|$firstbid[3] > 0|,
	  'items'		=> q|$cat eq $form{'searchstring'}|
   };   
  
   $form{'searchtype'} eq 'items'
	  ?   do {
		    $dest = "$config{'categories'}/$form{'searchstring'}";
		    $tbl_title = $category{$form{'searchstring'}};
		}
	  :   do {
		    ($form{'searchtype'} eq 'keyword'
			  or $form{'searchtype'} eq 'username'
			  or $form{'searchtype'} eq 'itemnumber'
			  or $form{'searchtype'} eq 'price'
		    )
			  ? ($tbl_title = "$txt{'Search Result'}: $form{'searchstring'}")
			  : ($tbl_title = $form{'searchstring'});
		};
 
print <<EO_HTML;
<div align="center">
<h4>$tbl_title</h4>
<table width="660" border="0" cellspacing="1" cellpadding="3">
   <tr bgcolor="$config{'colortablehead'}">
	  <td align="center" colspan="2"><b>$txt{'Item'}</b></td>
EO_HTML

print <<EO_HTML if $form{'searchtype'} ne 'items';  
	  <td align="center" width="190"><b>$txt{'Category'}</b></td>
	  <td align="center" width="60" nowrap><b>$txt{'Bids'}</b></td>
	  <td align="center" width="100" nowrap><b>$txt{'High Bid'}</b></td>
	  <td align="center" width="60" nowrap><b>$txt{'Closes'}</b></td>
   </tr>
EO_HTML

print <<EO_HTML if $form{'searchtype'} eq 'items';
	  <td align="center" width="60" nowrap><b>$txt{'Bids'}</b></td>
	  <td align="center" width="100" nowrap><b>$txt{'High Bid'}</b></td>
	  <td align="center" width="60" nowrap><b>$txt{'Closes'}</b></td>
   </tr>
EO_HTML


	  while ($ret_val) {
		(time - $^T > $config{'max_searchtime'}) && last; # We are the master of our CPU-Usage
		($ret_val, $itm_cnt) = read_dir_range($dest, $ret_val, $itm_cnt, \@allfiles);
	   
		    while ($#allfiles >= 0) {
			  ($item, $cat) = @allfiles;
			  shift @allfiles for 0 .. 1;
			    
			  (
				$title,
				$reserve,
				$inc,
				$desc,
				$image,
				$start_time,
				$close_time,
				undef,
				@bids
			  ) = @{read_item_file($cat, $item)};
			    
			  @firstbid = @{read_bid($bids[0])};
			  @lastbid = @{read_bid($bids[-1])};

			  $buy_it = $firstbid[3];
			  $start_time > time && next;  
			  $the_time = time;
			  eval $query->{$form{'searchtype'}} || next;
			  $line_cnt++;
			  $line_cnt > $config{'page_break'} && do { $line_cnt = 1; $page_cnt++ };

			  # This is saving Memory and CPU-Load ...
			  ($page_cnt - $form{'page'} > 3) && do { undef $ret_val; last };
		    # We have reached the PageBreak-Focus - no further informations are needed.
		   
			  $page_cnt != $form{'page'} && next;
			
		    $record = join '[]', (
				$close_time,
			$image,
			$cat,
			$item,
			$title,
			$#bids,
			$buy_it,
			$lastbid[2]
		    );
			
		    push @output, $record;
			  $found++;
		    }
	  }
  
	foreach $record (sort @output) {
	   
	    (
		    $close_time,
		$image,
		$cat,
		$item,
		$title,
		$bids,
		$buy_it,
		$bid
	    ) = split /\[\]/, $record;
	   
		@closetime = form_date($close_time);
	   
		$buy_it > 0
		    ? ($buy_it_info = qq|<font color="green" size="1"><b><i>Buy It <font color="red" size="1">Now</i></b></font>|)
		    : ($buy_it_info = "");	   
	   
		$image
		    ?   do {
			@image = split / /, $image;
			$image !~ /http\:/
			    ?	($img_info = qq|<img src="$config{'img_url'}/$image"@{[img_size($image[0], 50)]}>|)
			    :	($img_info = qq|<img src="$image[0]" width=50 border=0>|);
			
		    }
		    :   ($img_info = qq|<img src="$config{'icon_url'}/$config{'no_image'}" border="0">|);
	   
		$bid = form_amt($bid);	   
		($row, $rowcolor) = get_row_color($row);
	   
print <<EO_HTML if $form{'searchtype'} ne 'items';
   <tr $$rowcolor>
	  <td align="center" width="30">$img_info </td>
	  <td align="left" valign="middle" nowrap>
		<a class="item" href="$ENV{'SCRIPT_NAME'}?action=dispitem&category=$cat&item=$item&lang=$form{'lang'}">$title   $buy_it_info</a>
	  </td>
	  <td align="left" nowrap>
		<a class="item" href="$ENV{'SCRIPT_NAME'}?action=search&searchtype=items&searchstring=$cat&lang=$form{'lang'}">
		$category{$cat}</a>
	  </td>
	  <td align="center" nowrap>$bids</td>
	  <td align="right" nowrap>$bid  </td>
	  <td align="center" nowrap><font size="1">
		$closetime[0]<br>$closetime[1]</font>
	  </td>
   </tr>
EO_HTML

print <<EO_HTML if $form{'searchtype'} eq 'items';
   <tr $$rowcolor>
	  <td align="center" width="30">$img_info </td>
	  <td align="left" valign="middle" nowrap>
		<a class="item" href="$ENV{'SCRIPT_NAME'}?action=dispitem&category=$cat&item=$item&lang=$form{'lang'}">$title   $buy_it_info</a>
	  </td>
	  <td align="center" nowrap>$bids</td>
	  <td align="right" nowrap>$bid  </td>
	  <td align="center" nowrap><font size="1">
		$closetime[0]<br>$closetime[1]</font>
	  </td>
   </tr>
EO_HTML

	  }
  
print <<EO_HTML if $found == 0;
   <tr bgcolor="$config{'the_row_color'}">
	  <td align="center" colspan="6" valign="top" height="50">
		$txt{'There are no items matching your request'}</font><br>
		@{[disp_runtime()]}
	  </td>
   </tr>
</table>
<br>
@{[disp_banner('tbl')]}
</div>
<br>
EO_HTML

print <<EO_HTML if $found > 0 and $page_cnt > 0;
</table>
</div>
<br>
EO_HTML

print <<EO_HTML if $found > 0 and $page_cnt == 0;
</table>
<br>
@{[disp_runtime()]}
@{[disp_banner('tbl')]}
</div>
<br>
EO_HTML

   $page_cnt > 0 && pagebreak($page_cnt);
}



Back to top
 
 

Multimedia file viewing and clickable links are available for registered members only!!  You need to Login or Register!!


Greetings from Germany
Dieter Werner




Advertising
View Profile | WWW   IP Logged
thisolddoll
eAuction Novice
*
Offline

I love my cats!

Posts: 0
Ohio
Gender: female
Re: sub disp_list (Replacement)
Reply #1 - 11/23/03 at 23:50:37
 
Hi Dieter!

Tried swapping out the old sub disp_list with the new one on the forum.

Before:
Multimedia file viewing and clickable links are available for registered members only!!  You need to Login or Register!!


and after:
Multimedia file viewing and clickable links are available for registered members only!!  You need to Login or Register!!


However, as you can see from the first, I'd been noodling and came up with this from your "you can do it this way" code.

Also managed to make it work for the my items sub.  :-D

Multimedia file viewing and clickable links are available for registered members only!!  You need to Login or Register!!


Not using your image size subroutine because these photos in the listing need to be big and it wasn't letting me list with my photos.


# in sub disp_user_auction {
Again Replace this:
#    $image
#       ? ($img_info = qq|<img src="$config{'icon_url'}/$config{'if_image'}" border="0">|)
#       : ($img_info = qq|<img src="$config{'icon_url'}/$config{'no_image'}" border="0">|);
###########
################ with this
           my @image;  #not declared yet in disp_user_auction so do it here
           my $disp_img;  #use in place of img_info because it's used elsewhere and get confusing
           @image = split /\s/, $image;    #white space delimiter
           $image
      ?   do {                        
               $image !~ /http\:/  #this assumes the user didn't put in any direct links along with upload
                   ? ($disp_img = qq|<img src="$config{'img_url'}/$image[0]" width=50 border=0>|)
                    : ($disp_img = qq|<img src="$image[0]" width=50 border=0>|);
                }
         :   ($disp_img = qq|<img src="$config{'icon_url'}/$config{'no_image'}" border="0">|);

#################    
#Then instead of the line after this:
#print <<EO_HTML if $form{'searchtype'} =~ /^my_/;
#    <tr $$rowcolor>
#put this:
<td align="center" width="50">$disp_img</td>


#####################################
#
#  In sub disp_list
#
Replace this:
#    $image
#       ? ($img_info = qq|<img src="$config{'icon_url'}/$config{'if_image'}" border="0">|)
#       : ($img_info = qq|<img src="$config{'icon_url'}/$config{'no_image'}" border="0">|);
################ with this
           my $disp_img;
           @image = split /\s/, $image;  
           $image
                  ?   do {                        
                         $image !~ /http\:/
                         ? ($disp_img = qq|<img src="$config{'img_url'}/$image[0]" width=50 border=0>|)
                       : ($disp_img = qq|<img src="$image[0]" width=50 border=0>|);
   
              }
     :   ($disp_img = qq|<img src="$config{'icon_url'}/$config{'no_image'}" border="0">|);

#################  
and substitute $disp_img for img_info in the two html blocks:
print <<EO_HTML unless $form{'searchtype'} =~ /^my_/;
   <tr $$rowcolor>
       <td align="center" width="50">$disp_img</td>


print <<EO_HTML if $form{'searchtype'} =~ /^my_/;
   <tr $$rowcolor>
       <td align="center" width="50">$disp_img</td>


So, do that call that a "case statement" in perl?

Nice!

Thanks, Dieter!
Michele






Back to top
 
 

Michele


Advertising
View Profile | WWW | AIM   IP Logged
www.blitzday.com
eAuction User
**
Offline

I love the script
and hate it if it
does not work

Posts: 60

Re: sub disp_list (Replacement)
Reply #2 - 08/26/04 at 13:08:47
 
Michelles Way does not work for me as the uses strings which i cannot  even find back in the whole script like:

print <<EO_HTML if $form{'searchtype'} =~ /^my_/;

especially the =~ /^my_/;

Does someone have a  good working script which indeed shows on  the first page where the top items are listed which shows a a little  thumbnail? ie 20 x 20

Please met me know if you do, as will i try to figue out how to do this, you might save me time though Smiley

Back to top
 
 


Advertising
View Profile   IP Logged
Pages: 1


If you like eAuction, please Rate it.
If you don't like eAuction, please Rate it too.


1 is being poor and 10 is being excellent


EveryScript

ip-location


AccessControl - Members Only