I"m trying to update / run an old script on PHP 7.2 and having an issue.. I don't think it's a PHP7 issue more just a regex issue, maybe (question mark).
This part of the script is throwing a "Domain in siteurl does not match entered sitedomain" error.. Any idea what is wrong with it?
// Parse siteurl and compare to sitedomain
preg_match('/^(http|https):\\/\\/[a-z0-9_]+([\\-\\.]{1}[a-z_0-9]+)*\\.[_a-z]{2,5}'.'((:[0-9]{1,5})?\\/.*)?$/i', $siteurl, $match);
if(isset($match[2])) {
if ($sitedomain != $match[2]) { $error[] = "Domain in siteurl does not match entered sitedomain"; }
} else {
$error[] = "Invalid siteurl";
}
// Set status of trade
if ($admin == 1) { $status = 1; }
elseif ($EPTSETTINGS["signuppage"] == 1) { $status = 1; }
else { $status = 0; }
All it is doing is compairing the siteurl with the domain, but every time I try to process the form I get "Domain in siteurl does not match entered sitedomain" error...
Here is the full script:
<?php
require_once("functions.php");
function add_domain($sitedomain, $siteurl, $sitename, $email, $icq, $webmasterip, $ratio, $mainpagegroup_id, $exit_id, $group_id, $trade_type, $admin = 0) {
global $EPTSETTINGS;
if ($sitedomain == "") { $error[] = "Please type in a site domain"; }
if ($siteurl == "") { $error[] = "Please type in a site url"; }
if (!strstr($sitedomain, ".") OR strstr($sitedomain, ":") OR strstr($sitedomain, "?")) { $error[] = "Not a valid sitedomain"; }
// Parse siteurl and compare to sitedomain
preg_match('/^(http|https):\\/\\/[a-z0-9_]+([\\-\\.]{1}[a-z_0-9]+)*\\.[_a-z]{2,5}'.'((:[0-9]{1,5})?\\/.*)?$/i', $siteurl, $match);
if (isset($match[2])) {
if ($sitedomain != $match[2]) { $error[] = "Domain in siteurl does not match entered sitedomain"; }
} else {
$error[] = "Invalid siteurl";
}
// Set status of trade
if ($admin == 1) { $status = 1; }
elseif ($EPTSETTINGS["signuppage"] == 1) { $status = 1; }
else { $status = 0; }
// Check for findtrades settings and max trades if trade not entered by admin
if ($admin == 0) {
//check for protect X
if ($EPTSETTINGS["protectx_only"] == 1 OR $EPTSETTINGS["protectx_bl"] == 1) {
$protectx = @trim(@implode("",@file("http://www.protect-x.com/ept/?domain={$sitedomain}&full=1")));
//http://www.protect-x.com/ept/?domain=domain.com&full=1
$protdata=explode('||',$protectx);
if($protdata[1]==1){
$error[] = "You are blacklisted by <a href='http://www.protect-x.com/info/{$sitedomain}' target=_blank>protect-x.com!</a>";
}
if(($protdata[2] == 0 || $protdata[2]== 4) && $EPTSETTINGS["protectx_only"] == 1 ){
$error[] = "Sorry you are not in the protect X database please register at
<a href='http://www.protect-x.com/info/{$sitedomain}' target=_blank>protect-x.com</a>";
}
}
// Check for findtrades
if ($EPTSETTINGS["findtrades_only"] == 1 OR $EPTSETTINGS["findtrades_bl"] == 1) {
$findtrades = @implode("",@file("http://www.findtrades.com/ttt.php?d=$sitedomain"));
if ($findtrades != "2" AND $EPTSETTINGS["findtrades_only"] == 1) { $error[] = "You are not in findtrades.com's database<br>You need to add your site before you can trade with this site<br>Go to <a href='http://www.findtrades.com/'>http://www.findtrades.com/</a>"; }
elseif ($findtrades == "1" AND $EPTSETTINGS["findtrades_bl"] == 1) { $error[] = "You are blacklisted by findtrades.com!"; }
}
// Check for max trades
$row = mysqli_fetch_array(mysqli_query($mysqlilink, "SELECT count(*) FROM ept_sites WHERE trade_id NOT IN (1,2,3)"));
if ($row[0] >= $EPTSETTINGS["max_trades"]) { $error[] = "Max number of trades has been reached - Contact webmaster for trade"; }
}
// Is domain already in database?
global $mysqlilink;
$res = mysqli_query($mysqlilink, "SELECT sitedomain FROM ept_sites WHERE sitedomain='$sitedomain'") or print_error("MySQL Error");
if (mysqli_num_rows($res) > 0) { $error[] = "The sitedomain already exists in database"; }
//Check blacklist
$res = mysqli_query($mysqlilink, "SELECT * FROM ept_blacklist WHERE sitedomain='$sitedomain' && !(reason like '%whitelist%' ) ") or print_error("MySQL Error");
if (mysqli_num_rows($res) > 0) { $error[] = "Domain is blacklisted!"; }
if (isset($error)) { return $error; }
else {
$date = date("Y-m-d");
$temp = preg_replace("/[\.\-]/","_",$sitedomain);
mysqli_query($mysqlilink, "INSERT INTO ept_sites (sitedomain, siteurl, sitename, email, icq, webmasterip, added) VALUES ('$sitedomain', '$siteurl', '$sitename', '$email', '$icq', '$webmasterip','$date')") or print_error("MySQL Error");
mysqli_query($mysqlilink, "INSERT INTO ept_trades (trade_id, ratio, mainpagegroup_id, exit_id, trade_type, status, group_id, ac_use, min_prod, max_prod, max_pxy, min_uniq, max_ip, as_use, as_hits, as_mins) VALUES (LAST_INSERT_ID(), '$ratio', '$mainpagegroup_id', '$exit_id', '$trade_type', '$status','$group_id','$EPTSETTINGS[default_ac_use]','$EPTSETTINGS[default_min_prod]','$EPTSETTINGS[default_max_prod]','$EPTSETTINGS[default_max_pxy]','$EPTSETTINGS[default_min_uniq]','$EPTSETTINGS[default_max_ip]','$EPTSETTINGS[default_as_use]','$EPTSETTINGS[default_as_hits]','$EPTSETTINGS[default_as_mins]')") or print_error("MySQL Error");
mysqli_query($mysqlilink, "INSERT INTO ept_forces (trade_id) VALUES (LAST_INSERT_ID())") or print_error("MySQL Error");
mysqli_query($mysqlilink, "INSERT INTO ept_values (trade_id, prio) VALUES (LAST_INSERT_ID(),0)") or print_error("MySQL Error");
// Add to Watchlist
if ($admin == 0) {
mysqli_query($mysqlilink, "INSERT INTO ept_watchlist VALUES (LAST_INSERT_ID(),".time().")") or print_error("MySQL Error");
}
mysqli_query($mysqlilink, "DROP TABLE IF EXISTS min_$temp") or print_error("MySQL Error");
mysqli_query($mysqlilink, "DROP TABLE IF EXISTS iplogin_$temp") or print_error("MySQL Error");
mysqli_query($mysqlilink, "DROP TABLE IF EXISTS iplogout_$temp") or print_error("MySQL Error");
mysqli_query($mysqlilink, "CREATE TABLE min_$temp (
min smallint(4) NOT NULL default '0',
hits_in smallint(3) NOT NULL default '0',
hits_out smallint(3) NOT NULL default '0',
clicks smallint(3) NOT NULL default '0',
gclicks smallint(3) NOT NULL default '0',
uniq smallint(3) NOT NULL default '0',
PRIMARY KEY (min)
) ENGINE=MyISAM") or print_error("MySQL Error");
mysqli_query($mysqlilink, "CREATE TABLE iplogin_$temp (
ip int(10) unsigned NOT NULL default '0',
type enum('pxy','ip') NOT NULL default 'pxy',
hour0 smallint(4) NOT NULL default '0',
hour1 smallint(4) NOT NULL default '0',
hour2 smallint(4) NOT NULL default '0',
hour3 smallint(4) NOT NULL default '0',
hour4 smallint(4) NOT NULL default '0',
hour5 smallint(4) NOT NULL default '0',
hour6 smallint(4) NOT NULL default '0',
hour7 smallint(4) NOT NULL default '0',
hour8 smallint(4) NOT NULL default '0',
hour9 smallint(4) NOT NULL default '0',
hour10 smallint(4) NOT NULL default '0',
hour11 smallint(4) NOT NULL default '0',
hour12 smallint(4) NOT NULL default '0',
hour13 smallint(4) NOT NULL default '0',
hour14 smallint(4) NOT NULL default '0',
hour15 smallint(4) NOT NULL default '0',
hour16 smallint(4) NOT NULL default '0',
hour17 smallint(4) NOT NULL default '0',
hour18 smallint(4) NOT NULL default '0',
hour19 smallint(4) NOT NULL default '0',
hour20 smallint(4) NOT NULL default '0',
hour21 smallint(4) NOT NULL default '0',
hour22 smallint(4) NOT NULL default '0',
hour23 smallint(4) NOT NULL default '0',
UNIQUE KEY ip (ip)
) ENGINE=MyISAM") or print_error("MySQL Error");
mysqli_query($mysqlilink, "CREATE TABLE iplogout_$temp (
ip int(10) unsigned NOT NULL default '0',
type enum('pxy','ip') NOT NULL default 'pxy',
hour0 smallint(4) NOT NULL default '0',
hour1 smallint(4) NOT NULL default '0',
hour2 smallint(4) NOT NULL default '0',
hour3 smallint(4) NOT NULL default '0',
hour4 smallint(4) NOT NULL default '0',
hour5 smallint(4) NOT NULL default '0',
hour6 smallint(4) NOT NULL default '0',
hour7 smallint(4) NOT NULL default '0',
hour8 smallint(4) NOT NULL default '0',
hour9 smallint(4) NOT NULL default '0',
hour10 smallint(4) NOT NULL default '0',
hour11 smallint(4) NOT NULL default '0',
hour12 smallint(4) NOT NULL default '0',
hour13 smallint(4) NOT NULL default '0',
hour14 smallint(4) NOT NULL default '0',
hour15 smallint(4) NOT NULL default '0',
hour16 smallint(4) NOT NULL default '0',
hour17 smallint(4) NOT NULL default '0',
hour18 smallint(4) NOT NULL default '0',
hour19 smallint(4) NOT NULL default '0',
hour20 smallint(4) NOT NULL default '0',
hour21 smallint(4) NOT NULL default '0',
hour22 smallint(4) NOT NULL default '0',
hour23 smallint(4) NOT NULL default '0',
UNIQUE KEY ip (ip)
) ENGINE=MyISAM") or print_error("MySQL Error");
for ($i=0; $i<=1439; $i++) { mysqli_query($mysqlilink, "INSERT INTO min_$temp (min) VALUES ($i)"); }
// email admin
if ($EPTSETTINGS["emailwebmaster"] == 1 AND $admin == 0) {
$today = date("F j, Y, g:i a");
$content = "<html><head></head><body bgcolor='#FFFFFF'><p><font size='2' face='Verdana'>Hi.<br><br>
The site <a href='$siteurl'>$sitename</a> just signed up on your site $EPTSETTINGS[my_sitename].<br><br>";
if ($EPTSETTINGS["signuppage"] == 2) { $content .= "You need to approve this trade before it receives any hits.<br><br>"; }
$content .= "Here is the webmaster's contact information:<br>
Nickname: $nickname<br>
Email: <a href='mailto:$email'>$email<br>
</a>ICQ: $icq<br>
<br>
You can reply this email to contact the webmaster.<br>
<br>
------------------------------------------------<br>
</font><font face='Verdana' size='1'>This email was generated by <a href='http://www.epowerscripts.com/'><font color='#336699'>ePower
Trader</font></a></font></p>
</body>
</html>";
$headers = "From: $email\r\n" . "Reply-To: $email\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
mail($EPTSETTINGS["admin_email"], "New Trade On ".$EPTSETTINGS["my_sitename"], $content, $headers);
}
return true;
}
}
// End of add domain
function check_bad_countries($code) {
$warning = Array("CN","KR","HK","JP","MY","RU","TW","TH","SG","PK","EG","OM","KW","VN","MX","DZ");
if (in_array($code, $warning)) { return true; }
else { return false; }
}
?>
This is a very old script that I'm attempting to get working again, the script was a traffic trading script back in the date, but has been abandoned long ago.
It is being called in a simple 5 text, 5 drop-down menu form.
Thanks