How to protect X-cart from spambots  

 

       1. Download CleanTalk API  from Github.com.

       2. Unzip the downloaded archive to your <root directory>/include/func/. You will see the folder with the name "php-antispam-master". Rename it to "cleantalk".

       3. Go to <root directory>/include/func/ and open func.mail.php. Add the following function to this script:  

function func_spamcheck_email($name, $email) { session_start(); //Sessions is required require_once (dirname(__FILE__) . '/cleantalk/cleantalk.class.php'); $config_url = 'http://moderate.cleantalk.org'; //server adress $auth_key = ''; //access key $sender_nickname = 'John Dow'; if ($name!='') $sender_nickname = $name; $sender_email = 's@cleantalk.org'; if ($email!='') $sender_email = $email; $sender_ip = null; if (isset($_SERVER['REMOTE_ADDR'])) $sender_ip = $_SERVER['REMOTE_ADDR']; $js_on = 0; if (isset($_POST['js_on']) && $_POST['js_on'] == date("Y")) $js_on = 1; // The facility in which to store the query parameters $ct_request = new CleantalkRequest(); $ct_request->auth_key = $auth_key; $ct_request->agent = 'php-api'; $ct_request->sender_email = $sender_email; $ct_request->sender_ip = $sender_ip; $ct_request->sender_nickname = $sender_nickname; $ct_request->js_on = $js_on; $ct_request->submit_time = time() - (int) $_SESSION['ct_submit_time']; $ct = new Cleantalk(); $ct->server_url = $config_url; // Check $ct_result = $ct->isAllowUser($ct_request); return $ct_result; }

function func_spamcheck_message($name, $email, $message) { session_start(); //Sessions is required require_once (dirname(__FILE__) . '/cleantalk/cleantalk.class.php'); $config_url = 'http://moderate.cleantalk.org'; //server adress $auth_key = ''; //access key $sender_nickname = 'John Dow'; if ($name!='') $sender_nickname = $name; $sender_email = 's@cleantalk.org'; if ($email!='') $sender_email = $email; $sender_ip = null; if (isset($_SERVER['REMOTE_ADDR'])) $sender_ip = $_SERVER['REMOTE_ADDR']; $js_on = 0; if (isset($_POST['js_on']) && $_POST['js_on'] == date("Y")) $js_on = 1; $sender_message = null; if ($message != '') $sender_message = $message; // The facility in which to store the query parameters $ct_request = new CleantalkRequest(); $ct_request->auth_key = $auth_key; $ct_request->agent = 'php-api'; $ct_request->sender_email = $sender_email; $ct_request->sender_ip = $sender_ip; $ct_request->sender_nickname = $sender_nickname; $ct_request->js_on = $js_on; $ct_request->message = $sender_message; $ct_request->submit_time = time() - (int) $_SESSION['ct_submit_time']; $ct = new Cleantalk(); $ct->server_url = $config_url; // Check $ct_result = $ct->isAllowMessage($ct_request); return $ct_result; }

 

 

      4. Go to <root directory>/skin/common_files/customer/main and open register_account.tpl    

Add the following field:

<tr>
<td>
<input type="hidden" name="js_on" id="js_on" value="0" />
</td>
</tr>

 

      5. To protect X-Cart registration form from spam, go to <root directory>/include and open register.php.  

Paste the following code:

  $spamCheckResult = func_spamcheck_email($uname, $email);
// Check spam
if ($spamCheckResult->allow == 0) {
echo 'User forbidden. Reason: '.$spamCheckResult->comment;
}

After this line (#563):

  if (!func_check_email($email)) {
$errors[] = func_reg_error(2);
}

 

   6. To protect X-Cart reviews from spam, go to <root directory> and open add_review.php.

Paste the following code:

$spamCheckResult = func_spamcheck_message($review['author'], $review['email'],$review['message'] );
}

After (#124):

  $antibot_reviews_err = (
!empty($active_modules['Image_Verification'])
&& func_validate_image('on_reviews', $antibot_input_str)
);
}

And 

if ($spamCheckResult->allow == 0) { $top_message['content'] .= '<br /> Message forbidden. Reason: ' .$spamCheckResult->comment; }

After (#132)

$stored_review = func_stripslashes($review);

Use the blacklisted e-mail s@cleantalk.org to register an account. As a result, you will see the blocking message.

 

Learn more about X-Cart.