-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathview_image.pl
36 lines (31 loc) · 992 Bytes
/
view_image.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl
use DBI;
use CGI::Fast qw(:standard);
#use Carp;
use CGI::Cookie;
use CGI::Carp qw/fatalsToBrowser/;
use strict;
print "Content-type: text/html\n\n";
do './admin/connect';
use vars qw($DBname $DBhost $DBuser $DBpassword);
my $dbh=DBI->connect("DBI:mysql:$DBname:$DBhost",$DBuser,$DBpassword, , { RaiseError => 1 }) || die($!);
while (new CGI::Fast) {
my $domain=$ENV{SERVER_NAME};
$domain=~s/^www\.//;
my $sth=$dbh->prepare("SELECT project_id from domain WHERE domain=?");
$sth->execute($domain);
my $project_id=$sth->fetchrow();
unless($project_id){
print "project_id not found";
exit;
}
my $key=substr($ENV{PATH_INFO},1);
$sth=$dbh->prepare("SELECT link,attach FROM banner where project_id=? and ban_code=?");
$sth->execute($project_id,$key);
my ($link,$file)=$sth->fetchrow();
# çäåñü ïîòîì âîòêí¸ì ïîäñ÷¸ò ñòàòèñòèêè
# äëÿ êàðòèíîê
print qq{
<div id='id_ban'><a href="$link"><img src="/files/project_$project_id/banners/$file" /></a></div>
};
}