How to only accept absolute url submission?

Discussion in 'PHP' started by Blockout, Jan 5, 2014.

  1. #1
    Hi,

    I have a link submission website in php (Pligg) and I wonder how to force a user to only submit the absolute url -for example http://example.com and not http://example.com/page or http://subdir.example.com.

    Grateful for any help. Thanks.
     
    Blockout, Jan 5, 2014 IP
  2. BeltHosting

    BeltHosting Greenhorn

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #2
    if ($_POST['submit'] && $_SERVER['REQUEST_URI'] == '/something') {
    //exec code
    }else {
    //bad
    }
    PHP:
     
    BeltHosting, Jan 5, 2014 IP
  3. SubediK

    SubediK Active Member

    Messages:
    63
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    83
    #3
    <?php
    if(isset($_GET['url'])){
        $url = parse_url($_GET['url']);
        if($url['path'] != '"){
            echo "invalid";
        }else{
            echo "valid";
        }
    }
    ?>
    PHP:
    save this as check.php and ifyou open yourdomain.com/check.php?url=<url> it will say valid or invalid
     
    SubediK, Jan 5, 2014 IP
  4. Blockout

    Blockout Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    Hello, Thanks for the replies!

    Ok, how can I now make it work for/together with the script I am using? My PHP knowledge is really bad..

    Thanks.
     
    Blockout, Jan 5, 2014 IP
  5. SubediK

    SubediK Active Member

    Messages:
    63
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    83
    #5
    Now that would totally depend on the script you are using. PM me with details maybe i could help/
     
    SubediK, Jan 5, 2014 IP
  6. Blockout

    Blockout Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    Ok, PM sent, thanks.
     
    Blockout, Jan 5, 2014 IP