use strict; use Data::Page; # for page my $in_page = $query->param('page'); $in_page = 1 if ($in_page !~ /^[0-9]+$/); my $_build = $query->param('build'); # fecth the total of records. my $sth = $dbh->prepare( q~SELECT COUNT(*) FROM cms~ ); $sth->execute() or die "$DBI::errstr"; my ($total) = $sth->fetchrow_array(); my $page = Data::Page->new($total, 20, $in_page); # the page my $page_content = '' . $page->last_page . ' Pages, [ '; foreach (1 .. $page->last_page) { if ($_ == $page->current_page) { $page_content .= qq~$_ ~; } else { if ($_build) { $page_content .= qq~$_ ~; } else { $page_content .= qq~$_ ~; } } } $page_content =~ s/index1\./index\./s;# for the special first page $page_content .='ALL ]'; my $off_set = ($in_page - 1) * 20; # fecth the records $sth = $dbh->prepare( qq{SELECT * FROM cms ORDER BY cms_id DESC LIMIT $off_set, 20} ); $sth->execute(); my $cats = $sth->fetchall_arrayref({}); $sth->finish; #category $sth = $dbh->prepare( q{SELECT * FROM category ORDER BY cat_id} ); $sth->execute(); my $category = $sth->fetchall_arrayref({}); $sth->finish; #Sec Update & New my ($sec, $min, $hour, $day, $mon, $year) = localtime(); $mon++;$year += 1900; #End my @_list; foreach my $cat (@$cats) { #Sec Update & New,if MofidiedDay + 2 < NOW my $_statu; my ($_year, $_mon, $_day) = ( $cat->{'cms_cre_data'} =~ /^([0-9]+)\-([0-9]+)\-([0-9]+)/); #if New, forget Update if ($_mon == $mon && $_day + 4 > $day && $_year == $year) { $_statu = qq~ New~; } else { ($_year, $_mon, $_day) = ( $cat->{'cms_mod_data'} =~ /^([0-9]+)\-([0-9]+)\-([0-9]+)/); $_statu .= qq~ Update~ if ($_mon == $mon && $_day + 2 > $day && $_year == $year); } #End if ($_build) { push @_list, "
  • $cat->{'cms_title'}$_statu < $cat->{'cms_cre_data'} >
    $cat->{'cms_describe'}"; } else { push @_list, "
  • $cat->{'cms_title'}$_statu < $cat->{'cms_cre_data'} > (Build)(Edit)(Del)(ToP)
    $cat->{'cms_describe'}"; } } my $vars = { LASTMODDATA => "$year-$mon-$day $hour:$min:$sec", LIST => \@_list, cats => $category, build => $_build, total => $total, page => $page_content, }; if ($_build) { $in_page = '' if ($in_page == 1);# for the specail first page open(FH, ">$Cfg{'htmldir'}/index$in_page.html"); $tt->process('show.tt', $vars, \*FH) || die $tt->error( ); close(FH); print qq~build success .see $Cfg{'htmldir'}/index$in_page.html~; } else { $tt->process('show.tt', $vars) || die $tt->error( ); print qq~

    Add a new Entry? | Build This Page?(ALL) | Build All Topic Page? | Archive Page?(Build) | UPdate RSS
    BUild Category: ~; foreach my $cat (@$category) { print qq~$cat->{'cat_name'} ~; } print <ALL)

    Search:

    HTML } 1;