⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smain_old.pm

📁 稀饭伊人相册系统继承了新天堂多用户相册系统的功能
💻 PM
字号:
# package SMain;# require 5.004;# # use strict;## # Module export stuff# BEGIN {#         use Exporter ();#         use vars qw($VERSION @ISA @EXPORT);#         $VERSION = "0.1";#         @ISA = qw(Exporter);#         @EXPORT = qw(#                 $dbh $CRLF#         );# }# use vars qw(%conf $dbh $CRLF);## # Imports# use CGI::Carp qw(fatalsToBrowser);# use DBI;sub db_con{$dbh=DBI->connect("DBI:mysql:$conf{dataname}:$conf{server}:$conf{port}",$conf{user},$conf{mysql_password});# #对象的使用# # Connect#         $SMain::dbh = DBI->connect("DBI:mysql:$conf{dataname}:$conf{server}:$conf{port}",$conf{user},$conf{mysql_password}) or dbError();# # Disable warnings#         $SMain::dbh->{'Warn'} = 0;}sub readallfile{undef $/;open FILE,"$_[0]";$$allfile = <FILE>;close FILE;$/="\n";}sub reda_oneline {   my $data;   open (FILE,"$_[0]");   $$data = <FILE>;   close(FILE);   return $$data;}sub textclean {    my $textclean = $_[0];    study($textclean);    $textclean =~ s/[\a\f\e\0\r\t]//isg;    $textclean =~ s/\&nbsp;/ /g;    $textclean =~ s/\@ARGV/\&\#64\;ARGV/isg;    $textclean =~ s/\;/\&\#59\;/isg;    $textclean =~ s/\&/\&amp;/g;    $textclean =~ s/\&amp;\#/\&\#/isg;    $textclean =~ s/\&amp\;(.{1,6})\&\#59\;/\&$1\;/isg;    $textclean =~ s/\&\#([0-9]{1,6})\&\#59\;/\&\#$1\;/isg;    $textclean =~ s/"/\&quot;/g;    $textclean =~ s/  / \&nbsp;/g;    $textclean =~ s/</\&lt;/g;    $textclean =~ s/>/\&gt;/g;    $textclean =~ s/  / /g;    $textclean =~ s/\n\n/<p>/g;    $textclean =~ s/\n/<br>/g;    $textclean =~ s/document.cookie/documents\&\#46\;cookie/isg;    $textclean =~ s/'/\&\#039\;/g;    $textclean =~ s/\$/&#36;/isg;    $textclean =~ s/#/&#35;/isg;    $textclean =~ s/&&#35;/&#/isg;    return $textclean;}sub lockedfile {return if ($_[0] eq"");while (-e "$_[0].lock") {$i++;        select(undef,undef,undef,0.1);    if ($i >10){             my $locktime=(-M"$_[0].lock");             if ($locktime > 0.001){unlink"$_[0].lock";}             $_[0]=~s/$_data_path//;            er('Too busy,please wait!')}    }}#读取文件,入口:文件的地址。结果:返回数组的引用sub readfile{my $filepath=$_[0]; my @x_data;open(DATA,"$filepath")||die return 0;while(<DATA>)  {chomp;   push(@x_data,$_);}close DATA;return \@x_data;}sub close{print qq~<script language="JavaScript">  <!--  setTimeout('window.close();',2000);  --></script>~;}sub usetimes {        if ( $_[0] eq 0 ) {                ( $user, $system ) = times();        }        elsif ( $_[0] eq 1 ) {                ( $user_1, $system_1 ) = times();                $usertimes   = $user_1 - $user;                $systemtimes = $system_1 - $system;                if ( $usertimes != 0 ) {                        $usertimes = int( $usertimes * 1000 );                }                if ( $systemtimes != 0 ) {                        $systemtimes = int( $systemtimes * 1000 );                }                if ($systemtimes==0){$systemtimes=1;}                $totltimes  = $usertimes + $systemtimes;                $view_times =                qq~<center><table border=0><tr><td><font color=midnightblue>Processed in cpu:$systemtimes ms,  webpage:$totltimes ms</td></tr></table><br></center>~;        }}sub checkadmincook{  my $cookusername = $query->cookie('rootname');  my $cookuserpassword = $query->cookie("rootpass");     $cookusername =~ s/[\a\f\n\e\0\r\t\`\~\!\@\#\$\%\^\&\*\(\)\+\=\\\{\}\;\'\:\"\,\.\/\<\>\?]//isg;     $cookuserpassword =~ s/[\a\f\n\e\0\r\t\|\@\;\#\{\}\$]//isg;     $cookusername =~ y/ /_/;  if(!$cookusername || !$cookuserpassword)     {     print "Location: rootlogin.cgi\n\n";     }     print "Location: rootlogin.cgi\n\n" if(!-e "$conf{base_path}/$conf{cgi_path}/$conf{database_name}/temp/$cookusername\.pl");  if(-M "$conf{base_path}/$conf{cgi_path}/$conf{database_name}/temp/$cookusername\.pl" > 0.02)    {unlink("$conf{base_path}/$conf{cgi_path}/$conf{database_name}/temp/$cookusername\.pl");     er_html('登陆超时!','rootlogin.cgi?er=2');    }  my $thisip=&checkip;     $data=reda_oneline("$conf{base_path}/$conf{cgi_path}/$conf{database_name}/temp/$cookusername\.pl");     chomp $data;    ($un,$up,$lv,$disksize,$ip,$rootname)=split(/\t/,$data);  if(("$thisip" ne "$ip") || ("$cookuserpassword" ne "$up"))  {  er_html("用户已锁定",'rootlogin.cgi?er=3');  }}sub checkcook{  my $mustname  =shift;  my $needpass  =shift;  my $usrdirname=shift;  my $albumid   =shift;  my $cookusername     = $query->cookie("$usrdirname-$albumid-username");  my $cookuserpassword = $query->cookie("$usrdirname-$albumid-password");  if($cookusername eq "" || $cookuserpassword eq "" )  {  print "Location: login.cgi?username=$usrdirname&name=$albumid\n\n";  #调试模式  #er("请先登陆","login.cgi?username=$usrdirname&name=$albumid",'1');  }     $cookusername =~ s/[\a\f\n\e\0\r\t\`\~\!\@\#\$\%\^\&\*\(\)\+\=\\\{\}\;\'\:\"\,\.\/\<\>\?]//isg;     $cookuserpassword =~ s/[\a\f\n\e\0\r\t\|\@\;\#\{\}\$]//isg;     $cookusername =~ y/ /_/;  if(("$cookusername" ne "$mustname") || ("$cookuserpassword" ne "$needpass"))  {  print "Location: login.cgi?username=$usrdirname&name=$albumid\n\n";  #调试模式  #er('用户名或密码错误',"login.cgi?username=$usrdirname&name=$albumid",'1');  }}sub checkip{  my $ipaddress = $ENV{'REMOTE_ADDR'};  my $trueipaddress = $ENV{'HTTP_X_FORWARDED_FOR'};     $ipaddress = $trueipaddress if ($trueipaddress ne "" && $trueipaddress ne "unknown" && $trueipaddress !~ m/^192\.168\./ && $trueipaddress !~ m/^10\./);     $trueipaddress = $ENV{'HTTP_CLIENT_IP'};     $ipaddress = $trueipaddress if ($trueipaddress ne "" && $trueipaddress ne "unknown" && $trueipaddress !~ m/^192\.168\./ && $trueipaddress !~ m/^10\./);     return $ipaddress;}sub loginout{my $usrdirname=$_[0];my $albumid=$_[1];my $cookie= cookie(-name => "$usrdirname-$albumid-username" , -value =>'-1', -expires=>'-1',);my $cookie1= cookie(-name =>"$usrdirname-$albumid-password" , -value =>'-1',-expires=>'-1',);print header(-cookie=>[$cookie, $cookie1],);er("$lan_loginout1",'index.cgi');}1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -