Complex PHP uploader script defect, help needed!!

Discussion in 'PHP' started by Avatar, Oct 24, 2005.

  1. #1
    Hey,
    I have a website, http://www.webmastergalaxy.net its about sharing webmaster experience and advice and obviously, part of the thing I'm sharing are PHP and java scripts.

    However, in the case of PHP (not sure of the Javascripts I have a big problem)

    My PHP uploader script, allows the user to add a script onto my website.

    The user puts in the script and the "<" is turned into a "&lt;" so that it can be read by the end user, however there is a problem.

    lets say the user puts in the script

    
    <?php
    header("location:http://www.eselfhypnosis.com/self-help");
    exit;
    ?> 
    
    PHP:
    it then becomes
    <?phpheader("location:http://www.eselfhypnosis.com/self-help");exit;?> 
    PHP:
    rendering it useless to the end user.

    This means I have to edit the script manually, which is a right pain in the arse, anyone have any idea of how I can overcome this?

    thanks a lot.
     
    Avatar, Oct 24, 2005 IP
  2. smo

    smo Well-Known Member

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #2
    There is a function in PHP to take care of line breaks, nl2br()

    $text=nl2br($text);

    Then you print $text , you will have all line breaks.
     
    smo, Oct 24, 2005 IP
  3. Avatar

    Avatar Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    @smo, your a genious, thnx.

    If there's anything I can ever do to help you, just PM me.
     
    Avatar, Oct 24, 2005 IP
  4. smo

    smo Well-Known Member

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #4
    You're welcome! :)
     
    smo, Oct 28, 2005 IP