|
 |
 |
 |
 |
 |
#!/usr/bin/perl
BEGIN {
open(STDERR, '>> error.log');
}
print "Content-type: text/html\n\n";
use DBI;
$dbh = DBI->connect("DBI:mysql:database=alvigo:host=localhost", "alvigo", "8432ujre");
my $sth = $dbh->table_info;
$sth->execute();
while (my @row = $sth->fetchrow_array ) {
if ($row[2] eq "News") {$table_ok = 1}
}
if (!$table_ok) {
print "creating db\n";
$dbh->do(<
 |
|;
$allservs = $dbh->prepare("SELECT News_ID, Time, IP, Administrator, Message FROM News WHERE Lang=1 ORDER BY Time DESC LIMIT 5");
$allservs->execute;
while(@st = $allservs->fetchrow_array) {
$row_date=&fdate($st[1]);
#if (length($st[4]) > 5) { $short_msg = substr($st[4], 5, length($st[4])-5) . " ..."; }
if (length($st[4]) > 64) { $short_msg = substr($st[4], 0, 64) . " ..."; }
else { $short_msg = $st[4]; }
@b=split(//, $short_msg);
foreach $a (@b) {
#print $_;
if ($a eq '*' && $wasb == 1) { $wasb=0; $a=''; }
elsif ($a eq '*' && $wasb == 0) { $wasb=1; $a=''; }
}
# print @b;
$short_msg=join('', @b);
print qq|[$row_date]
$short_msg


|;
}
print qq|
| |;
$dbh->disconnect;
sub fdate {
my ($ftime) = shift;
my (undef, undef, undef, $wday, $wmonth, $wyear) = localtime($ftime);
return sprintf "%02i.%02i.%04i", $wday, $wmonth+1, $wyear+1900;
}
|
 |
|
|
 |
|
|
|
|
|
|
 |
|
 |
 |
|
|
 |
#!/usr/bin/perl
BEGIN {
open(STDERR, '>> error.log');
}
print "Content-type: text/html\n\n";
use DBI;
use CGI qw/:standard/;
$dbh = DBI->connect("DBI:mysql:database=alvigo:host=localhost", "alvigo", "8432ujre");
my $sth = $dbh->table_info;
$sth->execute();
while (my @row = $sth->fetchrow_array ) {
if ($row[2] eq "News") {$table_ok = 1}
}
if (!$table_ok) {
$dbh->do(<prepare("SELECT News_ID FROM News WHERE Lang=1 ORDER BY Time DESC $limit");
$allservs->execute;
while(@st = $allservs->fetchrow_array) {
detailed($st[0]);
}
}
$dbh->disconnect;
sub fdate {
my ($ftime) = shift;
my (undef, undef, undef, $wday, $wmonth, $wyear) = localtime($ftime);
return sprintf "%02i.%02i.%04i", $wday, $wmonth+1, $wyear+1900;
}
sub detailed {
my ($news_id) = shift;
($ttime, $message, $attach) = $dbh->selectrow_array("SELECT Time, Message, Attach FROM News WHERE News_ID=$news_id");
$message =~ s/\x0D\x0A/ \n/g;
# $message =~ s/\*//g;
@b=split(//, $message);
foreach $a (@b) {
#print $_;
if ($a eq '*' && $wasb == 1) { $wasb=0; $a=''; }
elsif ($a eq '*' && $wasb == 0) { $wasb=1; $a=''; }
}
# print @b;
$message=join('', @b);
$row_date=&fdate($ttime);
print qq|[$row_date]
$message
|;
if ($attach && -e "/home/alvigo/www.alvigo.ee/upload/$attach") { print qq|Ñêà÷àòü: $attach|; }
print qq| |;
}
Archive: 2004
|
|
 |
|
|
|
 |
|
 |
|
|
|
|
|
|
|
|
|