Need someone to repair a script for me

Discussion in 'PHP' started by Mr.Bill, Feb 18, 2008.

  1. #1
    So I have script that works on some server and not on others. It doesnt work on mine so I am thinking this has to do with the coding I tried to enable magic quotes using this in htaccess
    <IfModule mod_php5.c>
    php_flag magic_quotes_gpc on
    php_flag magic_quotes_runtime on
    </IfModule>
    <IfModule mod_php4.c>
    php_flag magic_quotes_gpc on
    php_flag magic_quotes_runtime on
    </IfModule>
    Code (markup):
    didnt help what is happening is when you input a single word tag or no tag it works fine. BUT if you but in multiple words without a _ or - it will generate a url but the url is a 404. So I need someone to

    A) make it so it returns a error saying only _ and - can be used no spaces or other characters for tags only.

    OR

    B) create a default url like it does when no tag is used and ignoring the tags all together if a space or other character is used except for the _ and -

    you can view the site in question HERE and try it with a single word tag no tag and multiple tags with spaces to see what I mean.


    This is a free script. I will give the person access to my cpanel so they can do the repairs.

    Give me some quotes and this is payable by paypal
     
    Mr.Bill, Feb 18, 2008 IP
  2. daman371

    daman371 Peon

    Messages:
    121
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I can't get it to work. It keeps saying tag unavailable.
     
    daman371, Feb 18, 2008 IP
  3. Mr.Bill

    Mr.Bill Well-Known Member

    Messages:
    2,818
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    160
    #3
    For any tag you try?
     
    Mr.Bill, Feb 18, 2008 IP
  4. stoli

    stoli Peon

    Messages:
    69
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The form validation in your PHP isn't very thorough.

    It is possible to submit the form successfully (clicking on "Generate") with spaces in the "Tag it" field. The redirect however clearly doesn't work with spaces in the tag.

    This should be a simple fix in your index.php code. Post it or PM me and I can take a look.

    A question you might want to ask yourself though is whether allowing tagging like this is a good idea at all. Allowing anyone to create URLs of the form "http://urluda.com/anything" to me seems instinctively like a bad idea. I dread to think what people might put and where they might redirect it.
     
    stoli, Feb 19, 2008 IP
  5. Mr.Bill

    Mr.Bill Well-Known Member

    Messages:
    2,818
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    160
    #5
    Since this was not clear and I don't know how to explain this any better I have just removed the tagging option until I can find someone that understands what I am saying and wanting to achieve.
     
    Mr.Bill, Feb 19, 2008 IP
  6. stoli

    stoli Peon

    Messages:
    69
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I understand what it is you want to achieve. Either of your A or B options would require an edit to your index.php file. I'm sure it would be a simple fix if I could see the code.

    There is a third option which would be to continue to allow the spaces in the tag but edit your .htaccess file so that the redirect works. I'm sure that would be a simple fix too, if I could see the contents of the file.
     
    stoli, Feb 19, 2008 IP
  7. Mr.Bill

    Mr.Bill Well-Known Member

    Messages:
    2,818
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    160
    #7
    current htaccess

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^urluda\.com$
    RewriteRule (.*) http://urluda.com/$1 [R=301,L]
    RewriteRule ^([0-9]+)[/]*$ index.php?action=redirect&id=$1
    RewriteRule ^([a-z0-9-]+)[/]*$ index.php?action=redirect&tag=$1
    Code (markup):
    I think it will be fine as is though.
     
    Mr.Bill, Feb 19, 2008 IP
  8. stoli

    stoli Peon

    Messages:
    69
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #8
    This should do it:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^urluda\.com$
    RewriteRule (.*) http://urluda.com/$1 [R=301,L]
    RewriteRule ^([0-9]+)[/]*$ index.php?action=redirect&id=$1
    RewriteRule ^([-\ a-z0-9_]+)[/]*$ index.php?action=redirect&tag=$1
    Code (markup):
    Though as you say it is probably fine as it is.
     
    stoli, Feb 19, 2008 IP