Tutorials Scripts Free Q&A Books


 







:שמתשמ
:המסיס
  

0 :םויה תוסינכ
35 :שדוחה תוסינכ
1 :ןיילנוא םישלוג
רחא PHP CGI ASP JavaScript Cold Fusion JSP

CGIב םיטפירקס


?שדח המ
ץנימ רחש :רבחמה םש
http://shahar.dis.org.nz :תיב-רתא

:תורעה\תויחנה
יפל) םישדחה תא הגיצמו הירפסב םיצבקה תא תקדוב וז הנכות
(רדגומ םימי רפסמ
new.cgi?days=###

םשב ףסונ ץבוקב תשמתשמ תינכותה cgi-lib.pl
:ב גישהל ןתינ ץבוקה תא
http://cgi-lib.stanford.edu/cgi-lib/

:רדסל שי המצע הנכותב
פסה תבותכ#;"dir = "/home/user/some$

:דוק

#!/usr/bin/perl
#################################################
# What New? #
# Programd by Shahar Mintz #
#################################################

require "cgi-lib.pl";
&ReadParse(*input);

$dir = "/home/user/some";
$url = "http://www.site.co.il/";

@exts = ("*.htm","*.html","*.shtml","*.cgi");
$exts = join(" ",@exts);

$time = time();

print "Content-type: text/html\n\n";
#print "$exts\n";
############################
# Check files
$type="";
opendir( files, $dir ); # open a directory
@imsifiles = readdir(files);
closedir( files );

foreach $p (@imsifiles){
chomp ($p);
$file = $dir."/".$p;

@stat = stat $file;

$attr = $stat[2];
$size = $stat[7];
@attr = split(//, $stat[2]);

$week = $time-(86400*$input{'days'});
($name,$type) = split(/\./,$p);
$type="*.$type";
# print "$type<br>\n";
if (($stat[9] > $week) && ($attr[0] eq 3)){push(@new, "$p")}
}#end of foreach

###########################
#print
print <<"new";
<html>
<head>
<title>Whats new?</title>
</head>
<body>
<center>
<b>NEW FILES</b><bR>
<a href="new.cgi?days=365">last year</a> <a href="new.cgi?days=30">last month</a> <a href="new.cgi?days=7">last week</a> <a href="new.cgi?days=1">last day</a>
new
print <<"head";
<TABLE CellPadding=0 CellSpacing=0 BORDER=1 WIDTH=566>
<TR VALIGN=TOP>
<TD ALIGN=RIGHT WIDTH=126 NoWrap>ךיראת<BR>
</TD>
<TD ALIGN=RIGHT WIDTH=428 NoWrap>תרתוכ<BR>
</TD>
</TR>
head

foreach (sort @new){
$file = "$dir/$_";
@stat = stat $file;
$stat = join (";", @stat);

open(file, "$file");
@lines = <file>;
close(file);
$title="";
$string = join(" ",@lines);
$string =~ s/\n//g;
if ($string =~ /<title>(.*)<\/title>/i) {$title = "$1";}
else {$title = "$_";}
#print "$title";

($name,$ext) = split(/\./, $_);

$attr = $stat[2];
$size = $stat[7];

if($size >1000){ ($size) = split(/\./,$size/1000); $size .= " kb"}
if($size >10000){ ($size) = split(/\./,$size/10000); $size .= " mb"}

($sec,$min,$hr,$mday,$mon,$yr,$wday,$yday,$isdst) = gmtime($stat[9]);
$yr = $yr+1900;
$mon++;
$mtime = "$mday/$mon/$yr";

$type="*.$ext";
#print "$type\n";
# if ($temp =~ /$in{'searchkeys'}/i)
if($exts =~ /$ext/i){
print <<"table";
<TR VALIGN=TOP>
<TD ALIGN=RIGHT WIDTH=126 NoWrap>$mtime<BR>
</TD>
<TD ALIGN=RIGHT WIDTH=428 NoWrap><a href="$url$_">$title</a><BR>
</TD>
</TR>
table
}#end of exts
}#end of files

print <<"end";
</table>
</body>
</html>
end

 

הרזח >>
...