rendered paste body#!/usr/bin/perl
use strict;
sub readfile
{
my($fname)= @_ ;
my($ret) ;
local(*F, $/) ;
open(F, "<$fname") || return undef ;
undef $/ ;
$ret= <F> ;
close(F) ;
return $ret ;
}
my ($directory) = shift @ARGV;
# my @argv;
opendir( DIR, $directory) or die "couldn't open directory!\n";
chdir $directory;
my (@manyproxies) = readdir(DIR);
closedir DIR;
foreach (@manyproxies)
{
my ($proxy) = $_;
chomp($proxy);
if($proxy =~ m/^s_/)
{
print "starts with s_.";
chdir($proxy);
my $pwd = `pwd`;
chomp($pwd);
opendir(DIR, $pwd);
#print "changed to $pwd ";
my (@files) = readdir(DIR) or print "readdir returned false.!";
#open(COMBO, combo.bin) or die "couldn't open file combo.bin.\n";
open(COMBO, ">combo.dat");
my ($filename) = "username.txt";
my ($username1) = &readfile($filename);
$username1 =~ s#[^A-Za-z0-9]*##g;
foreach (@files)
{
my ($file) = $_;
if($file =~ m/.txt$/)
{
unless($file =~ m/^combo.txt$/)
{
my ($data) = &readfile($file);
if ($data)
{
# convert inclusions:
$data =~ s#<!-- insert a/([A-Za-z0-9]*).*?here--># &readfile("../admin/$1.atxt");#ges;
$data =~ s#<!-- insert u/([A-Za-z0-9]*).*?here--># &readfile("../u_$username1/$1.utxt");#ges;
$data =~ s#<!-- insert s/([A-Za-z0-9]*).*?here--># &readfile("$1.stxt");#ges;
my ($lines) =1;
my ($data2) =$data;
$lines += ($data2 =~ tr/\n/\n/);
#print "appending $lines of $file. ";
print COMBO "\n<!BOF!$file $lines>\n";
print COMBO $data;
}
}
}
}
closedir COMBO;
chdir ('..');
}
else
{
print "\t";
}
print "\titem is currently $proxy\n";
}
print "\n";
# open(F, "$fname") ;
# undf $/ ;
# $ret= <F> ;
# close(F) ;
#
# return $ret ;
#
#
# If (1)
# {
# my $filename;
# my $file;
#
# $filename = "./ada1.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
# print"\n<!BOF!ada1>\n";
# print $file;
# }
#
#
# $filename = "./ada2.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
# print"\n<!BOF!ada2>\n";
# print $file;
# }
#
# $filename = "./ada3.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
# print"\n<!BOF!ada3>\n";
# print $file;
# }
#
# $filename = "./adb1.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
# print"\n<!BOF!adb1>\n";
# print $file;
# }
#
# $filename = "./adb2.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
# print"\n<!BOF!adb2>\n";
## print $file;
# }
##
# $filename = "./adb3.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
# print"\n<!BOF!adb3>\n";
# print $file;
# }
#
# $filename = "./adrotate.txt";
#
# $file = &readfile($filename);
## if ($file)
# {
# print"\n<!BOF!adrotate>\n";
# print $file;
# }
#
# $filename = "./f1.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
## print"\n<!BOF!f1>\n";
# print $file;
# }
#
# $filename = "./f2a.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
# print"\n<!BOF!f2a>\n";
# print $file;
# }
#
# $filename = "./f2b.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
# print"\n<!BOF!f2b>\n";
# print $file;
# }
#
# $filename = "./h1.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
# print"\n<!BOF!h1>\n";
# print $file;
# }
#
# $filename = "./top2.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
# print"\n<!BOF!top2>\n";
# print $file;
# }
#
## $filename = "./top.txt";
#
# $file = &readfile($filename);
# if ($file)
# {
# print"\n<!BOF!top>\n";
# print $file;
# }
#
# chdir("../") ||
# die("Could not change dir");
# }
# }