Results 1 to 8 of 8
-
21st Jul 2011, 12:51 PM #1OPBannedWebsite's:
WarezRelease.org ThatHosting.coValid URLs
Hi, I wanna adda valid url's c heck to my remote uploader.
I have an idea of how to do it, like
$url = "http://";
if ($url) {
//do this
}
but the end user cud add any url atm like warezscene.net/mypic.png or krazywarez.com/mypic.png or xtremeddl.net/mypic.png so i need to find some code for differnt url's.
any1 help?Chris2k Reviewed by Chris2k on . Valid URLs Hi, I wanna adda valid url's c heck to my remote uploader. I have an idea of how to do it, like $url = "http://"; if ($url) { //do this } Rating: 5
-
21st Jul 2011, 12:55 PM #2Respected MemberWebsite's:
DL4Everything.com Soft2050.inYou could use regex to validate urls
This function from: http://www.blog.highub.com/regular-e...idating-a-url/
PHP Code:function validateURL($url){$pattern = '/^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/';return preg_match($pattern, $url);}
-
21st Jul 2011, 01:12 PM #3OPBannedWebsite's:
WarezRelease.org ThatHosting.coThis seems a good yet clean function, however when i input a link i want a windows error msg to pop up if invalid url...
is it possible and do u no how?
-
21st Jul 2011, 01:17 PM #4Respected MemberWebsite's:
DL4Everything.com Soft2050.inIf in php, you can use this:
PHP Code:function addnvalidateurls($url){
// Modified By: Soft2050
if (!preg_match("@^[hf]tt?ps?://@", $url)) {
$url = "http://" . $url;
}
$pattern = '/^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/';
return preg_match($pattern, $url);
}
It will also add http if not in url and then check whether url is valid or not
However for displaying a error, you need to use javascript with it
-
21st Jul 2011, 01:20 PM #5OPBannedWebsite's:
WarezRelease.org ThatHosting.cook thx, where/after what line to add that?
-
21st Jul 2011, 01:31 PM #6Respected MemberWebsite's:
DL4Everything.com Soft2050.inCheck this code:
PHP Code:<?php
function addnvalidateurls($url){
// Modified By: Soft2050
if (!preg_match("@^[hf]tt?ps?://@", $url)) {
$url = "http://" . $url;
}
$pattern = '/^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/';
return preg_match($pattern, $url);
}
$result = addnvalidateurls('http://www.google.com');
echo '<script language="javascript">';
if ($result == 1)
echo "alert('Yes! The given url is validated')";
else {
echo "alert('No! the given url seems to be not working')";
}
echo '</script>';
?>
If Url is not valid, then you can break the function to end it
-
21st Jul 2011, 01:48 PM #7OPBannedWebsite's:
WarezRelease.org ThatHosting.cowe seem to have a problem, i tried uploading: C:\wamp\www\includes
and it said its valid lol when its not also i read ccomments on that blog saying it ddidnt work.
-
21st Jul 2011, 03:34 PM #8Respected MemberWebsite's:
DL4Everything.com Soft2050.inTry this now:
PHP Code:<?php
function addnvalidateurls($url){
// Modified By: Soft2050
if (!preg_match("@^[hf]tt?ps?://@", $url)) {
$url = "http://" . $url;
}
$pattern = '@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@';
return preg_match($pattern, $url);
}
$result = addnvalidateurls('google.com');
echo '<script language="javascript">';
if ($result == 1)
echo "alert('Yes! The given url is validated')";
else {
echo "alert('No! the given url seems to be not working')";
}
echo '</script>';
?>
Or have a search for some premade regex using google or you can code yourself if you are good at it
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
VBSEO Urls
By viruz99 in forum Technical Help Desk SupportReplies: 0Last Post: 13th Nov 2011, 02:15 PM -
Issues with Recaptcha API urls
By NewEraCracker in forum Feedback and SuggestionsReplies: 1Last Post: 19th May 2011, 02:50 PM -
Re-write some URLs
By Chris2k in forum Web Application/Script SupportReplies: 4Last Post: 27th Mar 2011, 12:59 AM -
Blocked URLs
By Sun!l in forum Legal IssuesReplies: 2Last Post: 28th Feb 2010, 09:54 AM -
Legit DepositFiles Valid Accounts 1$ valid for 1 day
By piratebay in forum Completed TransactionsReplies: 2Last Post: 23rd Oct 2009, 01:56 PM
themaCreator - create posts from...
Version 3.22 released. Open older version (or...