Switch layouts home | FAQ | | P1 | P2 | P3 | P4 | P5 |  | A1 | A2 | A3  | | B1

Customizable download

1. Create a copy or a link to PB. It may be either a hard link or a symbolic link depending on your preferences and settings of the web server. The name of the link can be anything as long as the web server is going to run it as a cgi script. For example, a3.cgi
ln ../cgi-bin/pb.pl ./a3.cgi    or
ln -sf ../cgi-bin/pb.pl ./a3.cgi

2. Create a project configuration file. The name should be cgi-script's name + ".pm". For a3.cgi this file should be ./a3.cgi.pm
use vars qw($dbh $sth);

sub a3_download
  my $file = "$templatesdir/a3-downloadsample.txt";
  my $fname = substr($file, rindex($file, '/')+1);
  my $s;
  $s = "";
  my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)= stat($file);
  if(open(IN,"<$file") > 0)
    read(IN, $s, $size);
  print "Content-Disposition: Attachment; filename=\"$fname\"\n"
  ."Content-length: "."$size"."\n\n"

3. Create an html-template file, a3-home.html
<!%if $Parameter{func} eq "a3_download()"%><!%set a3_download()%><!%else%>
Customizable download
<a href="/PB/a3.cgi?Page=download">download</a>

4. Create a file to customize for download, a3-downloadsample.txt
This file is customized for IP <IP>

5. This web project is complete. Check it out: