Jump to content
MakeWebGames

How would i use preg match or replace to change any links posted to my link validation script url?


Recommended Posts

Guest Drizzle
Posted

Well basically, Ive seen how myspace and facebook and everything replace links with validation urls, basically i want to be able to make the same kind of effect. Can anyone help me?

Posted

I'd suggest something like so:

out.php

<?php
//cleanse input with some function
$url = clean($_GET['url']);

print"
Note! You clicked a link that is taking you off-site to

$url



To continue, <a href=$url>click here</a>
";

?>

 

Then in your user input that may contain links to outside scripts, do something like:

$usertext = str_replace("http://", "out.php?url=http://", $usertext);

Since, to get a user to click a link that leads out of your domain, it has to have the http (I believe). If they just made a link in a private message something like <a href=mwg.com>click me</a> that would direct them to http://mygame.com/mwg.com

Just for starters. Somebody else will make this more elegant.

Guest Drizzle
Posted

Thanks it helps a little but not quite what im looking for.

Guest Drizzle
Posted

what im trying to get at is like how would i be able to turn the url into an id instead of the regular url?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...