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

📄 check_referer.cgi

📁 嵌入式WEB
💻 CGI
字号:
#!/usr/bin/perl -wTuse strict;# The directory where images are stored; this shouldn't be in the # server's doc tree so users can't browse images except via this scriptmy $image_dir = "/usr/local/apache/data/images";my $referer  = $ENV{HTTP_REFERER};my $hostname = quotemeta( $ENV{HTTP_HOST} || $ENV{SERVER_NAME} );if ( $referer and $referer !~ m|^http://$hostname/| ) {    display_image( "copyright.gif" );}else {    # Verify that the image name doesn't contain any unsafe characters    my( $image_file ) = $ENV{PATH_INFO} =~ /^([\w+.]+)$/ or        not_found();    display_image( $image_file );}sub display_image {    my $file = shift;    my $full_path = "$image_dir/$file";        # We'll simply report that the file isn't found if we can't open it    open IMAGE, $full_path or not_found();        print "Pragma: no-cache\n";    print "Content-type: image/gif\n\n";        binmode STDOUT;    my $buffer = "";    while ( read( IMAGE, $buffer, 16_384 ) ) {        print $buffer;    }    close IMAGE;}sub not_found {    print <<END_OF_ERROR;Status: 404 Not FoundContent-type: text/html<html><head>  <title>File Not Found</title></head><body>  <h1>File Not Found</h1>    <p>Sorry, but you requested an image that could not be found.     Please check the URL you entered and try again.</p></body></html>END_OF_ERROR        exit;}

⌨️ 快捷键说明

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