<?php
$string = "This is a strpos() test";
$pos = strpos($string, "This");
if ($pos == false) {
print "Not found brah ! :/";
} else {
echo "Found! MOOLAH !";
}
?>
$invalidTLD = array(".blogspot.com", ". t k", ".c o . c c");
$urlchecks = NULL;
foreach ($urlchecks as $urlCheck) {
$urlCheck = strpos($surl, $invalidTLD);
}
if($urlCheck == FALSE) {
// Do whatever you want :D its not a free domain ;)
}
else {
// Its a free domain BOO !
}
Why are you using preg_match for just checking the URL ?
Do a string manipulation technique like,
PHP:<?php $string = "This is a strpos() test"; $pos = strpos($string, "This"); if ($pos == false) { print "Not found brah ! :/"; } else { echo "Found! MOOLAH !"; } ?>
if (preg_match('/http:\/\/[a-zA-Z0-9.]+\[b].blogspot[/b].[a-z]+/i')) {
// do this
} else if (preg_match('/http:\/\/[a-zA-Z0-9.]+\[b].t k[/b].[a-z]+/i')) {
// do this
} else if (preg_match('/http:\/\/[a-zA-Z0-9.]+\[b].c o . c c[/b].[a-z]+/i')) {
// do this
}
function checkdom($url) {
// Soft2050
return preg_match('@^(?:http:\/\/)?([^/]+)\.(blogspot\.com|co\.cc|tk)@i', $url);
}
<?php
function checkdom($url) {
// Soft2050
return preg_match('@^(?:http:\/\/)?([^/]+)\.(blogspot\.com|co\.cc|tk)@i', $url);
}
$url = 'http://google.******';
if (checkdom($url)) {
echo 'Oopz! The site is not allowed to submit!';
} else {
echo 'Yooo! U win, your site is allowed to submit. Dance around';
}
?>
$surl = $_POST['surl'];
$surl = str_ireplace("www.","",$surl['host']); //get host
function checkdom($surl) {
// Soft2050
$reason = NULL;
$freeTLDs = preg_match('@^(?:http:\/\/)?([^/]+)\.(co\.cc|tk)@i', $surl);
$blogspots = preg_match('@^(?:http:\/\/)?([^/]+)\.(blogspot\.com)@i', $surl);
if(!empty($freeTLD) $reason = "Please don't use a free TLD";
else if (!empty($blogspots)) $reason = "Please don't use blogspot";
return $reason
}
if (checkdom($surl) == TRUE) {
echo $reason;
mysql_query("INSERT INTO wcddl_blacklist (url,reason,dat,email) VALUES ('".mysql_real_escape_string($surl)."','".mysql_real_escape_string($reason2)."','".mysql_real_escape_string($date)."','".mysql_real_escape_string($email)."')");
}
<?php
if(!defined("WCDDL_GUTS")) exit;
// Config
$modEnabled = true;
$subBacklink = str_replace('http://www.', 'http://', 'http://www.warezrelease.org'); // Inlude http://www in the final url.
$reason1 = "Add our linkback, then <a href='/contact.php'>email us here</a>.";
$reason2 = "We dont allow free TLDs on our DDL, go buy yourself a real domain then you can submit downloads.";
$reason3 = "BlogSpot not allowed. Get a real host & domain, thanks.";
$date = date("d-m-Y");
$email = $_POST['email'];
$surl = $_POST['surl'];
$surl = parse_url(trim($surl));
$surl= str_replace("www.","",$surl['host']);
if ($modEnabled) {
function subBacklink($link, $subBacklink) {
global $subBacklink;
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'spider');
$page = curl_exec($ch);
curl_close($ch);
if (preg_match('#<a[^>]+href="http://(www\.)?warezrelease\.org/?"[^>]*>#i',$page))
return true;
else
return false;
}
function blacklistemail($email,$surl) {
global $core;
$to = $email; // note the comma
$from = $core->adminemail;
$subject = 'Your website is blacklisted at WarezRelease';
$message = 'Your website is blacklisted at '.$core->siteurl.'.<br />
<br />
Domain: '.$surl.'<br />
Email: '.$email.'<br />
<br />
Possible reasons are:<br />
<br />
1. Your domain/site does not contain a valid linkback or atleast our bot can not find one.<br />
2. You may have submitted before without a backlink but since then have added one.<br />
3. Our bot can not even access your domain/site due to a mod you have installed, crappy host, free domain/host, downtime etc.
<br />
<br />
In most cases you can rectify and solve the issue, then you can get un-blacklisted by either emailing us at:
chris-2k@live.co.uk or by visiting: '.$core->siteurl.'blacklist.php and un-blacklisting yourself...
<br /><br />
Regards, <a href="'.$core->siteurl.'">'.$core->siteurl.'</a> Team.';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$from.'' . "\r\n";
mail($to, $subject, $message, $headers);
}
$domcheck = true;
$blacklistdomreason = '';
if (preg_match('@^(?:http:\/\/)?([^/]+)\.(co\.cc|tk)@i', $surl)) $blacklistdomreason = $reason2;
elseif (preg_match('@^(?:http:\/\/)?([^/]+)\.(blogspot\.com)@i', $surl)) $blacklistdomreason = $reason3;
if ($domcheck and $blacklistdomreason != '') {
mysql_query("INSERT INTO wcddl_blacklist (url,reason,dat,email) VALUES ('".mysql_real_escape_string($surl)."','".mysql_real_escape_string($blacklistdomreason)."','".mysql_real_escape_string($date)."','".mysql_real_escape_string($email)."')");
}
if(subBacklink ($surl, $subBacklink) == false) {
mysql_query("INSERT INTO wcddl_blacklist (url,reason,dat,email) VALUES ('".mysql_real_escape_string($surl)."','".mysql_real_escape_string($reason1)."','".mysql_real_escape_string($date)."','".mysql_real_escape_string($email)."')");
blacklistemail($email,$surl);
}
}
$core->attachDataHook("submitChecksPass","subBacklink");
?>
Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.