hhyttppd 2005年03月15日
php/perl(CGI)问题。
为何在如下文件中加入一空行都不能运行?十分郁闷ING。。。。。。。。。。。。
////////////////////////////////////////////////////////////////////////////////////////
$data_dir = 'data';
$accounts_dir = 'accounts';
$adminkey = $ENV{'SCRIPT_FILENAME'};


sub detectbadcountry
{
my ($checkip) = @_;
if($ENV{HTTP_X_FORWARDED_FOR} ne '') { $checkip = $ENV{HTTP_X_FORWARDED_FOR}; $checkip =~ s/[\n\r]//eg; }

$badcountry = 0;

use LWP::Simple;

if (! -e "ip2country/$checkip")
{
$gcountry = get "http://$settings{ss_pro_login}:$settings{ss_pro_password}\@www.bestonsearch.com/country/?ip=$checkip";

if($gcountry ne '')
{
open(DATA,">ip2country/$checkip");
print DATA "$gcountry";
close(DATA);
chmod 0777, "ip2country/$checkip";
}
}else{
open(DATA, "ip2country/$checkip");
$gcountry = <DATA>;
close(DATA);
}

($geoip{code}, $geoip{full}) = split(/\t/,$gcountry);

foreach (split(/\|/, $settings{'country_filter_codes'}))
{
if($geoip{code} eq $_)
{ $badcountry = 1; last; }
}
return $badcountry;
}

sub savelink
{
my ($u, $k, $url, $b, $a, $t, $ext) = @_;

undef %linkdata;

$linkdata{u} = $u;
$linkdata{k} = $k;
$linkdata{url} = $url;
$linkdata{b} = $b;
$linkdata{a} = $a;
$linkdata{t} = $t;
$linkdata{ext} = $ext;

@filea = ('1'..'10'); $fa = @filea; $ffa = (int rand($fa));
@fileb = ('a'..'zz','A'..'ZZ'); $fb = @fileb; $ffb = (int rand($fb));
@filec = ('1'..'10'); $fc = @filec; $ffc = (int rand($fc));
@filed = ('a'..'zz','A'..'ZZ'); $fd = @filed; $ffd = (int rand($fd));

$filerand = $filea[$ffa] . $fileb[$ffb] . $filec[$ffc] . $filed[$ffd] . '.' . $time;

local (*DATA);

$time = time;

open(DATA, "> temp/$filerand");
flock(DATA, $LOCK_EX);

foreach(keys %linkdata)
{
print DATA "$_\|$linkdata{$_}\n";
}

flock(DATA, $LOCK_UN);
close(DATA);

return $filerand;
}


1;
////////////////////////////////////////////////////////////////////////////
...全文
90 点赞 收藏 3
写回复
3 条回复

还没有回复,快来抢沙发~

发动态
发帖子
脚本语言(Perl/Python)
创建于2007-08-27

1.5w+

社区成员

3.3w+

社区内容

其他开发语言 脚本语言(Perl ,Python)
社区公告
暂无公告