Proxies, Free Proxies, Proxy Servers, CGIProxy, PHProxy, Proxy Sites, Proxy List and New Proxy Sites by ProxySphere
Proxies, Free Proxies, Proxy Servers, CGIProxy, PHProxy, Proxy Sites, Proxy List, and New Proxies by ProxySphere Link Auction Software
Home Proxies Top Proxies Articles Community Proxy KB CGIProxy PHProxy

CGIProxy Ban Extensions Hack

A simple hack to ban only specified extensions in CGIProxy

I figured out a hacky way to ban on extensions based on the TEXT_ONLY thing. Unfortunately text only strips images and everything else, which is unacceptable for most common uses.

Open nph-proxy.pl for editing.

Find "use vars qw(". After, add:

$MY_BANNED_EXTENSIONS

Find "$NON_TEXT_EXTENSIONS=". After the file types for NON_TEXT_EXTENSIONS, add:

$MY_BANNED_EXTENSIONS=
      '|mp2|mp3|wav|aif|aiff|au|snd'            # audios
	. '|avi|qt|mov|mpeg|mpg|mpe'                # videos
	. '|gz|Z|exe|gtar|tar|zip|sit|hqx|pdf'      # applications
	. '|ram|rm|ra|swf' ;                        # others[/code]

Find "if ($TEXT_ONLY)". Before, add:

# Forbid requests for filenames with non-text-type extensions
&my_die if ($path=~ /\.($MY_BANNED_EXTENSIONS)(;|\?|$)/i);

Find "sub non_text_die {". After, add:

# If images are forbidden, return either a "403 Forbidden" message or a
#   1x1 transparent GIF.
sub my_die {

    my($date_header)= &rfc1123_date($now, 0) ;

    print <<EOF ;
    $HTTP_1_X 403 Forbidden
    $Date: $date_header
    Content-type: text/html

    <html>
    <head><title>Proxy cannot forward media files</title></head>
    <body>
    <h1>Proxy cannot forward media files</h1>
    <p>Due to bandwidth limitations, the owner of this proxy has disallowed media files.
    EOF
    goto EXIT ;
}

You can customize the file types set for $MY_BANNED_EXTENSIONS, as well as the message/response in sub my_die.


boy million
ProxySphere is the place for proxies, free proxies, proxy forums, proxy servers, CGIProxy, PHProxy, working proxy sites,
info and much, much more! We focus on proxy information and resources for proxy users and proxy owners.