NameSilo

PHP/MySQL Help

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

freeflow

Established Member
Impact
13
I have a link directory and the traffic has increased a lot, so I
would like to add the submitted links directly to a TS, where
I will check them before they are published. At the moment I
receive an email with the link submissions.


What I Would like to do:

1. Check if the link=($variable) starts with http://

2. If it starts with http:// delete the http://

3. Add the link to the TS.

4. If it doesn't contain http:// add it the way it is.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Define TS?
 
0
•••
Yeah, can't say I'm sure what you mean by TS, but when parsing the link do this:

PHP:
str_replace("http://","",$_POST['LINK_URL']);

-RageD
 
1
•••
Sorry, I meant Tablespace with TS.
 
0
•••
PHP:
// Check to see that both: it contains http://, and that the string isn't JUST http://
if (strpos($link, 'http://') !== false AND $link != 'http://')
{
    $link = substr($link, 7);
}
 
0
•••
I got a similar question if anyone can help
I am considering three cases

1. User enters "www.google.com"
2. User enters "http://www.google.com"
3. User enters "google.com"

in each case, I want to remove the "http://www." part so the final url looks like
"google.com"

Now the tricky part is that the user can enter
"blog.google.com"
or
"http://wwww.blog.google.com"
in which case the final url still should be only
"blog.google.com"
 
0
•••
PHP:
preg_match('/[^.]+\.[^.]+$/', 'http://www.blog.google.com/', $matches);
echo $matches[0]; // google.com/
 
0
•••
PHP:
preg_match('/[^.]+\.[^.]+$/', 'http://www.blog.google.com/', $matches);
echo $matches[0]; // google.com/

i want it to show blog.google.com
just strip off http:// and www. if they are entered
 
0
•••
This is how I would do it:

PHP:
$url = str_replace(array("https://","http://","www."),"",strtolower($url));

PHP5:
PHP:
$url = str_ireplace(array("https://","http://","www."),"",$url);
 
Last edited:
0
•••
I wouldn't recommend using str_replace for www., what if the domain was: blehwww.com

PHP:
if ($link != 'http://')
{
	$link = preg_replace('#http[s]?://#i', '', $link);
	$link = preg_replace('#^www\.#i', '', $link);
}
 
0
•••
Or just:

PHP:
$link = preg_replace('#^(https?://)?(www\.)?#i', '', $link);
 
0
•••
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back