Detect current url

Discussion in 'PHP' started by sunnymonkey, Nov 17, 2007.

  1. #1
    Hey, I am having trouble coding the following. I want to end up with

    IF current web url contains "domain.com/photos/*" then print x else print y

    So I want to know if the current url has domain.com/photos/*

    The * denotes that anything could be after the slash and should be ignored.

    If anyone can help I would be most thankful.
     
    sunnymonkey, Nov 17, 2007 IP
  2. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $url = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
    if (stripos($url, 'domain.com/photos/') !== false) {
    	true, contains it
    } else {
            false
    }
    PHP:
    Try that out
     
    decepti0n, Nov 17, 2007 IP
  3. sunnymonkey

    sunnymonkey Peon

    Messages:
    623
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you, I will try it right now
     
    sunnymonkey, Nov 17, 2007 IP
  4. sunnymonkey

    sunnymonkey Peon

    Messages:
    623
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hmmm, doesn't want to take the code into the template

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

    in /home/fhlinux159/s/EDITED-FOR-PRIVACY.com/user/htdocs/includes/adminfunctions_template.php(3596) : eval()'d code on line 99

    This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
     
    sunnymonkey, Nov 17, 2007 IP
  5. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #5
    What's all the code surrounding it? Might be something before or the way you added it into the page
     
    decepti0n, Nov 17, 2007 IP
  6. sunnymonkey

    sunnymonkey Peon

    Messages:
    623
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I have attached the file and at the bottom I have put a comment in CAPS where I am trying to put the code.

    I really appreciate you taking the time to look at this :)
     

    Attached Files:

    sunnymonkey, Nov 17, 2007 IP
  7. sunnymonkey

    sunnymonkey Peon

    Messages:
    623
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    if you dont / wont do let me know so I can go searching elsewhere :)

    Thanks :D
     
    sunnymonkey, Nov 17, 2007 IP
  8. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I can't really tell, it looks like some special sort of markup (at a wild guess - vbulletin). I'm not sure how to put raw php code into there.
     
    decepti0n, Nov 17, 2007 IP
  9. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #9
    You will need to enter the above code as a plugin first.

    Peace,
     
    Barti1987, Nov 17, 2007 IP
  10. sunnymonkey

    sunnymonkey Peon

    Messages:
    623
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thank you, not really sure what you mean though :)

    Will try and find an alternate route :)
     
    sunnymonkey, Nov 18, 2007 IP