CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
FileSize Again

 



scuffed
stranger

May 10, 2001, 7:31 PM

Post #1 of 3 (475 views)
FileSize Again Can't Post

ok that script that you gave me b4. ryan. it worked but i had trouble putting it into an array of names to find all of the sizes for different files. i used a foreach, for(i and so forth and i had no luck unless i put in the name it self



scuffed
stranger

May 10, 2001, 7:42 PM

Post #2 of 3 (472 views)
Re: FileSize Again [In reply to] Can't Post

alright ryan heres teh entire code dude

#!/usr/bin/perl
print "Content-type: text/html\n\n";





# Get form data #
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else {
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$form{$name} = $value;
}

$pword = " ";
$uname = " ";
$un = $form{'username'};
$pw = $form{'password'};
$gn = $form{'GAMENAME'};
$ed = $form{'edit'};
if ($un eq $uname and $pw eq $pword and $ed eq "EDIT"){

open(GL,">gn");
print GL $gn;
close(GL);
print <<EDIT;
<HTML>
<HEAD>
<TITLE>File Has been Saved</TITLE>
</HEAD>
<BODY>
<FORM ACTION="" METHOD="POST">
<INPUT TYPE="HIDDEN" VALUE="$un" NAME="username">
<INPUT TYPE="HIDDEN" VALUE="$pw" NAME="password">
<INPUT TYPE="SUBMIT" VALUE="Return">
</FORM>
</BODY>
</HTML>
EDIT

}else{
if ($un eq $uname and $pw eq $pword){
open(GL,"gn");
@gn=<GL>;
close(GL);
opendir (DIR, ".");
my @ls = readdir(DIR);
closedir (DIR);
$fs2 = &fs2;
print "<select>";
foreach $line(sort(@ls)){
chomp($line);
print <<MENU;
<option value="$line">$line - $fs2
MENU
}
print "</select>";

print <<ADMIN;
<HTML>
<HEAD>
<TITLE>Admin Panle for Game cheats</TITLE>
<HEAD>
<BODY>


<FORM ACTION="" METHOD="POST">
<TEXTAREA NAME="GAMENAME" COLS="30" ROWS="8">
@gn
</TEXTAREA></BR>
<INPUT TYPE="SUBMIT" VALUE="Save">
<INPUT TYPE="HIDDEN" NAME="username" VALUE="$un">
<INPUT TYPE="HIDDEN" NAME="password" VALUE="$pw">
<INPUT TYPE="HIDDEN" VALUE="EDIT" NAME="edit">
</FORM>
</BODY>
</HTML>
ADMIN
}else{


print <<LOGIN;
<HTML>
<HEAD>
<TITLE>Game COdes Admin Panel</TITLE>
</HEAD>
<BODY>


<FORM ACTION="" METHOD="post">
Username:<INPUT TYPE="" NAME="username"><BR>
Password:<INPUT TYPE="" NAME="password"><BR>
<INPUT TYPE="SUBMIT" NAME="submit" Value="Login"><BR>
</FORM>
</BODY>
</HTML>
LOGIN
}
}

sub fs {
# --------------------------------------------------------
# Prints out the file size.

my $size = shift;
my $formatted_size = int($size / 1024) . " kb";
$formatted_size == 0 ?
return "$size bytes" :
return $formatted_size;
}
#my ($filesize);
#($filesize) = (stat("."))[7,9,2];
#$fs = &fs($fs);

sub fs2{
foreach $name(@ls){
chomp($name);
$file = @ls;
}
$size = -s @ls;
$kb_s = int($size / 1024) . " kb";
}



scuffed
stranger

May 10, 2001, 8:16 PM

Post #3 of 3 (468 views)
Re: FileSize Again [In reply to] Can't Post

after i took it out of the sub and put it back into the foreach it worked :)
so thanx anyways dude


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives