Jump to content

Need help with proxy script please

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
I have a proxy script and I want that the user inserts http:// before he surfs, but let's say he doesn't enter it I want it to be added, but if he doesn't I don't want to end up with http://http://www.website.com

So please can anyone help me? I have a text box in index.html to write the URL and then a php script to surf the website in a frame.

Can anyone help please?

Thanks.

#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
What about putting "http://" as standard value in the inputbox? Then the user will probably right the URL after the "http://". It can easily be done by setting a value-attribute at the tag.
<input ... value="http://" />
Then of course some users will probably remove the "http://", so you still have to find away of checking for "http://". For this you can use the PHP-function strpos. The function will return false if the string didn't got found, and else the position.
$input    = $_GET["input_from_user"];
$haystack = strtolower($input);
$needle   = "http://";
$position = strpos($haystack, $needle);

// Check if "http://" wasn't in the page
if($position === false)
  $page = "http://" . $haystack;
else
  $page = $haystack;

// Continue with the job to be done


#3
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
I have already done the one with the value, now I will try the other bit of code..
Will let you know, I'm trying it.

*EDIT* Wow man, it works perfectly. if no URL is given it always displays that the URL is wrong, Thanks! I had to edit it a little bit, although I don't know any PHP, but I figured it out as I know some programming. Anyways thanks!!

#4
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
I'm glad, you could use it.

To make the validation for the input even more secure, try look into some Regular Expressions. It's a short, clean - but also a bit hard way to validate your input in only a line, or maybe a little more. There's tons of information about Regular Expressions "out there", and also for many different languages.

A good place to start, would be here:
Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns

#5
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts

v0id said:

I'm glad, you could use it.

To make the validation for the input even more secure, try look into some Regular Expressions. It's a short, clean - but also a bit hard way to validate your input in only a line, or maybe a little more. There's tons of information about Regular Expressions "out there", and also for many different languages.

A good place to start, would be here:
Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns
Well I don't need to verifiy if it is a real URL or not, it's up to the user!!
Discovered one problem, it clashes with the Google Search of Adwords!! it displays invalid URL!!