Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2009
    Posts
    72
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Allow only 3 URLS to execute my .cgi

    Hi

    I want to allow only 3 URLS to execute my .cgi for security reasons

    Trying the code below

    ######################################################
    $ValidURL = 0;

    if ($referer =~ /^http:\/\/www.acrisoft.com/) {
    $ValidURL = 1;
    }

    if ($referer =~ /^http:\/\/www.mundomaq.com/) {
    $ValidURL = 1;
    }



    if ($referer =~ /www.mundomec.com/) {
    $ValidURL = 1;
    }
    ##########################################################


    The problems is that it always returns 1, regardless of $referer contains or not the piece
    of the URL.

    Please let me know how to rearrange my code, or a better way apply this filter to allow only my 3 websites.

    Moises

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by moisesbr View Post
    Hi

    I want to allow only 3 URLS to execute my .cgi for security reasons

    Trying the code below

    ######################################################
    $ValidURL = 0;

    if ($referer =~ /^http:\/\/www.acrisoft.com/) {
    $ValidURL = 1;
    }

    if ($referer =~ /^http:\/\/www.mundomaq.com/) {
    $ValidURL = 1;
    }



    if ($referer =~ /www.mundomec.com/) {
    $ValidURL = 1;
    }
    ##########################################################


    The problems is that it always returns 1, regardless of $referer contains or not the piece
    of the URL.

    Please let me know how to rearrange my code, or a better way apply this filter to allow only my 3 websites.

    Moises
    add a return $ValidURL after last if. But i'm not sure this will solve the problem, referer can be changed by the user before calling your script.

    best regards and happy holidays


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •