setHtml($html);
20 | }
21 | if(strpos($html,'%LINK_TEXT%')!==false)
22 | {
23 | $api_key = Mage::getStoreConfig('general/cleantalk/api_key');
24 | if(trim($api_key)=='')
25 | {
26 | Mage::app()->cleanCache();
27 | $user = Mage::getSingleton('admin/session');
28 | $admin_email = $user->getUser()->getEmail();
29 | $button="
Click here to get access key manuallyAdmin e-mail (".$admin_email.") will be used for registration
License agreement";
30 | $html=str_replace('%LINK_TEXT%',$button,$html);
31 | }
32 | else
33 | {
34 | $html=str_replace('%LINK_TEXT%',"
Click here to get anti-spam statistics",$html);
35 | }
36 | $transport->setHtml($html);
37 | }
38 |
39 | }
40 | public function interceptQuery(Varien_Event_Observer $observer)
41 | {
42 | if (strpos($_SERVER['PHP_SELF'],'/downloader/') === false)
43 | {
44 | Mage::getSingleton('core/session', array('name'=>'adminhtml'));
45 | $key=Mage::getStoreConfig('general/cleantalk/api_key');
46 | if ($key !== '')
47 | {
48 | Cleantalk_Antispam_Model_Observer::apbct_cookie();
49 | }
50 |
51 | if(Mage::getSingleton('admin/session')->isLoggedIn() && strpos($_SERVER['PHP_SELF'],'system_config') !== false)
52 | {
53 | $last_checked=intval(Mage::getStoreConfig('general/cleantalk/last_checked'));
54 | $last_status=intval(Mage::getStoreConfig('general/cleantalk/is_paid'));
55 | $new_checked=time();
56 |
57 | if($key!='')
58 | {
59 | $new_status=$last_status;
60 | if($new_checked-$last_checked>3600)
61 | {
62 | require_once 'lib/cleantalk.class.php';
63 | $url = 'https://api.cleantalk.org';
64 | $dt=Array(
65 | 'auth_key'=>$key,
66 | 'method_name'=> 'get_account_status');
67 | $result=sendRawRequest($url,$dt,false);
68 | if($result!==null)
69 | {
70 | $result=json_decode($result);
71 | if(isset($result->data)&&isset($result->data->paid))
72 | {
73 | $new_status=intval($result->data->paid);
74 | if($last_status!=1&&$new_status==1)
75 | {
76 | $config = new Mage_Core_Model_Config();
77 | $config->saveConfig('general/cleantalk/is_paid', '1', 'default', 0);
78 | $config->saveConfig('general/cleantalk/show_notice', '1', 'default', 0);
79 | Mage::app()->cleanCache();
80 | }
81 | }
82 | }
83 | $config = new Mage_Core_Model_Config();
84 | $config->saveConfig('general/cleantalk/last_checked', $new_checked, 'default', 0);
85 | }
86 | }
87 | if(Mage::app()->getRequest()->getParam('close_notice'))
88 | {
89 | $config = new Mage_Core_Model_Config();
90 | $config->saveConfig('general/cleantalk/show_notice', 0, 'default', 0);
91 | Mage::app()->cleanCache();
92 | header('Location: .');
93 | return false;
94 | }
95 | if(Mage::app()->getRequest()->getParam('get_auto_key'))
96 | {
97 | require_once 'lib/cleantalk.class.php';
98 | $user = Mage::getSingleton('admin/session');
99 | $admin_email = $user->getUser()->getEmail();
100 | $site=$_SERVER['HTTP_HOST'];
101 | $result = getAutoKey($admin_email,$site,'magento');
102 | if ($result)
103 | {
104 | $result = json_decode($result, true);
105 | if (isset($result['data']) && is_array($result['data']))
106 | {
107 | $result = $result['data'];
108 | }
109 | else if(isset($result['error_no']))
110 | {
111 | header('Location: ?cleantalk_message='.$result['error_message']);
112 | return false;
113 | }
114 | if(isset($result['auth_key']))
115 | {
116 | Mage::app()->cleanCache();
117 | $config = new Mage_Core_Model_Config();
118 | $config->saveConfig('general/cleantalk/api_key', $result['auth_key'], 'default', 0);
119 | Cleantalk_Antispam_Model_Observer::CleantalkTestMessage($result['auth_key']);
120 | }
121 | header('Location: .');
122 | return false;
123 |
124 | }
125 | }
126 | if(Mage::app()->getRequest()->getPost()['groups']['cleantalk']['fields']['api_key']['value'])
127 | {
128 | $new_key=Mage::app()->getRequest()->getPost()['groups']['cleantalk']['fields']['api_key']['value'];
129 | if($key!=$new_key&&$new_key!='')
130 | {
131 | Cleantalk_Antispam_Model_Observer::CleantalkTestMessage($new_key);
132 | }
133 | }
134 | }
135 |
136 |
137 | if(!Mage::getSingleton('admin/session')->isLoggedIn() && sizeof(Mage::app()->getRequest()->getPost())>0 && (strpos($_SERVER['PHP_SELF'],'/account/create') === false || strpos($_SERVER['REQUEST_URI'],'/account/forgotpassword') === false || strpos($_SERVER['PHP_SELF'],'/account/login') === false || strpos($_SERVER['REQUEST_URI'],'/account/login') === false || strpos($_SERVER['REQUEST_URI'],'/account/create') === false))
138 | {
139 |
140 | $isCustomForms = Mage::getStoreConfig('general/cleantalk/custom_forms');
141 | if($isCustomForms==1)
142 | {
143 | $ct_fields = Cleantalk_Antispam_Model_Observer::cleantalkGetFields($_POST);
144 | if($ct_fields)
145 | {
146 | $aMessage = array();
147 | $aMessage['type'] = 'comment';
148 | $aMessage['sender_email'] = ($ct_fields['email'] ? $ct_fields['email'] : '');
149 | $aMessage['sender_nickname'] = ($ct_fields['nickname'] ? $ct_fields['nickname'] : '');
150 | $aMessage['message_title'] = '';
151 | $aMessage['message_body'] =($ct_fields['message'] ? $ct_fields['message'] : '');
152 | $aMessage['example_title'] = '';
153 | $aMessage['example_body'] = '';
154 | $aMessage['example_comments'] = '';
155 | $aMessage['send_request'] = ($ct_fields['message'] || $ct_fields['email']) ? true: false;
156 | $model = Mage::getModel('antispam/api');
157 | if ($aMessage['send_request'])
158 | {
159 | $aResult = $model->CheckSpam($aMessage, FALSE);
160 |
161 | if(isset($aResult) && is_array($aResult))
162 | {
163 | if($aResult['errno'] == 0)
164 | {
165 | if($aResult['allow'] == 0)
166 | {
167 | if (preg_match('//u', $aResult['ct_result_comment']))
168 | {
169 | $comment_str = preg_replace('/^[^\*]*?\*\*\*|\*\*\*[^\*]*?$/iu', '', $aResult['ct_result_comment']);
170 | $comment_str = preg_replace('/<[^<>]*>/iu', '', $comment_str);
171 | }
172 | else
173 | {
174 | $comment_str = preg_replace('/^[^\*]*?\*\*\*|\*\*\*[^\*]*?$/i', '', $aResult['ct_result_comment']);
175 | $comment_str = preg_replace('/<[^<>]*>/i', '', $comment_str);
176 | }
177 | Mage::getModel('antispam/api')->CleantalkDie($comment_str);
178 | }
179 | }
180 | }
181 | }
182 |
183 | }
184 | }
185 | }
186 | }
187 |
188 | }
189 |
190 |
191 | /*
192 | * Sends test message when api key is changed
193 | */
194 | public function CleantalkTestMessage($key)
195 | {
196 | require_once 'lib/cleantalk.class.php';
197 | $url = 'http://moderate.cleantalk.org/api2.0';
198 | $dt=Array(
199 | 'auth_key'=>Mage::app()->getRequest()->getPost()['cleantalk_authkey'],
200 | 'method_name' => 'send_feedback',
201 | 'feedback' => 0 . ':' . 'magento-127');
202 | $result=sendRawRequest($url,$dt,true);
203 | return $result;
204 | }
205 |
206 | /**
207 | * Get all fields from array
208 | * @param string email variable
209 | * @param string message variable
210 | * @param array array, containing fields
211 | */
212 |
213 | static function cleantalkGetFields($arr, $message=array(), $email = null, $nickname = array('nick' => '', 'first' => '', 'last' => ''), $subject = null, $contact = true, $prev_name = '')
214 | {
215 | //Skip request if fields exists
216 | $skip_params = array(
217 | 'ipn_track_id', // PayPal IPN #
218 | 'txn_type', // PayPal transaction type
219 | 'payment_status', // PayPal payment status
220 | 'ccbill_ipn', // CCBill IPN
221 | 'ct_checkjs', // skip ct_checkjs field
222 | 'api_mode', // DigiStore-API
223 | 'loadLastCommentId' // Plugin: WP Discuz. ticket_id=5571
224 | );
225 |
226 | // Fields to replace with ****
227 | $obfuscate_params = array(
228 | 'password',
229 | 'password_confirmation',
230 | 'pass',
231 | 'pwd',
232 | 'pswd'
233 | );
234 |
235 | // Skip feilds with these strings and known service fields
236 | $skip_fields_with_strings = array(
237 | // Common
238 | 'ct_checkjs', //Do not send ct_checkjs
239 | 'nonce', //nonce for strings such as 'rsvp_nonce_name'
240 | 'security',
241 | // 'action',
242 | 'http_referer',
243 | 'timestamp',
244 | 'captcha',
245 | // Formidable Form
246 | 'form_key',
247 | 'submit_entry',
248 | // Custom Contact Forms
249 | 'form_id',
250 | 'ccf_form',
251 | 'form_page',
252 | // Qu Forms
253 | 'iphorm_uid',
254 | 'form_url',
255 | 'post_id',
256 | 'iphorm_ajax',
257 | 'iphorm_id',
258 | // Fast SecureContact Froms
259 | 'fs_postonce_1',
260 | 'fscf_submitted',
261 | 'mailto_id',
262 | 'si_contact_action',
263 | // Ninja Forms
264 | 'formData_id',
265 | 'formData_settings',
266 | 'formData_fields_\d+_id',
267 | 'formData_fields_\d+_files.*',
268 | // E_signature
269 | 'recipient_signature',
270 | 'output_\d+_\w{0,2}',
271 | // Contact Form by Web-Settler protection
272 | '_formId',
273 | '_returnLink',
274 | // Social login and more
275 | '_save',
276 | '_facebook',
277 | '_social',
278 | 'user_login-',
279 | 'submit',
280 | 'form_token',
281 | 'creation_time',
282 | 'uenc',
283 | 'product',
284 |
285 | );
286 |
287 | foreach($skip_params as $value){
288 | if(array_key_exists($value,$_POST))
289 | {
290 | $contact = false;
291 | }
292 | } unset($value);
293 |
294 | if(count($arr)){
295 | foreach($arr as $key => $value){
296 |
297 | if(gettype($value)=='string'){
298 | $decoded_json_value = json_decode($value, true);
299 | if($decoded_json_value !== null)
300 | {
301 | $value = $decoded_json_value;
302 | }
303 | }
304 |
305 | if(!is_array($value) && !is_object($value)){
306 |
307 | if (in_array($key, $skip_params, true) && $key != 0 && $key != '' || preg_match("/^ct_checkjs/", $key))
308 | {
309 | $contact = false;
310 | }
311 |
312 | if($value === '')
313 | {
314 | continue;
315 | }
316 |
317 | // Skipping fields names with strings from (array)skip_fields_with_strings
318 | foreach($skip_fields_with_strings as $needle){
319 | if (preg_match("/".$needle."/", $prev_name.$key) == 1){
320 | continue(2);
321 | }
322 | }unset($needle);
323 | // Obfuscating params
324 | foreach($obfuscate_params as $needle){
325 | if (strpos($key, $needle) !== false){
326 | $value = Cleantalk_Antispam_Model_Observer::obfuscate_param($value);
327 | }
328 | }unset($needle);
329 |
330 |
331 | // Decodes URL-encoded data to string.
332 | $value = urldecode($value);
333 |
334 | // Email
335 | if (!$email && preg_match("/^\S+@\S+\.\S+$/", $value)){
336 | $email = $value;
337 |
338 | // Names
339 | }elseif (preg_match("/name/i", $key)){
340 |
341 | preg_match("/(first.?name)?(name.?first)?(forename)?/", $key, $match_forename);
342 | preg_match("/(last.?name)?(family.?name)?(second.?name)?(surname)?/", $key, $match_surname);
343 | preg_match("/(nick.?name)?(user.?name)?(nick)?/", $key, $match_nickname);
344 |
345 | if(count($match_forename) > 1)
346 | {
347 | $nickname['first'] = $value;
348 | }
349 | elseif(count($match_surname) > 1)
350 | {
351 | $nickname['last'] = $value;
352 | }
353 | elseif(count($match_nickname) > 1)
354 | {
355 | $nickname['nick'] = $value;
356 | }
357 | else
358 | {
359 | $message[$prev_name.$key] = $value;
360 | }
361 |
362 | // Subject
363 | }elseif ($subject === null && preg_match("/subject/i", $key)){
364 | $subject = $value;
365 |
366 | // Message
367 | }else{
368 | $message[$prev_name.$key] = $value;
369 | }
370 |
371 | }elseif(!is_object($value)){
372 |
373 | $prev_name_original = $prev_name;
374 | $prev_name = ($prev_name === '' ? $key.'_' : $prev_name.$key.'_');
375 |
376 | $temp = Cleantalk_Antispam_Model_Observer::cleantalkGetFields($value, $message, $email, $nickname, $subject, $contact, $prev_name);
377 |
378 | $message = $temp['message'];
379 | $email = ($temp['email'] ? $temp['email'] : null);
380 | $nickname = ($temp['nickname'] ? $temp['nickname'] : null);
381 | $subject = ($temp['subject'] ? $temp['subject'] : null);
382 | if($contact === true)
383 | {
384 | $contact = ($temp['contact'] === false ? false : true);
385 | }
386 | $prev_name = $prev_name_original;
387 | }
388 | } unset($key, $value);
389 | }
390 |
391 | //If top iteration, returns compiled name field. Example: "Nickname Firtsname Lastname".
392 | if($prev_name === ''){
393 | if(!empty($nickname)){
394 | $nickname_str = '';
395 | foreach($nickname as $value){
396 | $nickname_str .= ($value ? $value." " : "");
397 | }unset($value);
398 | }
399 | $nickname = $nickname_str;
400 | }
401 |
402 | $return_param = array(
403 | 'email' => $email,
404 | 'nickname' => $nickname,
405 | 'subject' => $subject,
406 | 'contact' => $contact,
407 | 'message' => $message
408 | );
409 | return $return_param;
410 | }
411 | /**
412 | * Masks a value with asterisks (*)
413 | * @return string
414 | */
415 | static function obfuscate_param($value = null) {
416 | if ($value && (!is_object($value) || !is_array($value))) {
417 | $length = strlen($value);
418 | $value = str_repeat('*', $length);
419 | }
420 | return $value;
421 | }
422 | public function apbct_cookie()
423 | {
424 |
425 | // Cookie names to validate
426 | $cookie_test_value = array(
427 | 'cookies_names' => array(),
428 | 'check_value' => Mage::getStoreConfig('general/cleantalk/api_key'),
429 | );
430 |
431 | // Submit time
432 | $apbct_timestamp = time();
433 | setcookie('apbct_timestamp', $apbct_timestamp, 0, '/');
434 | $cookie_test_value['cookies_names'][] = 'apbct_timestamp';
435 | $cookie_test_value['check_value'] .= $apbct_timestamp;
436 |
437 | //Previous referer
438 | if(!empty($_SERVER['HTTP_REFERER'])){
439 | setcookie('apbct_prev_referer', $_SERVER['HTTP_REFERER'], 0, '/');
440 | $cookie_test_value['cookies_names'][] = 'apbct_prev_referer';
441 | $cookie_test_value['check_value'] .= $_SERVER['HTTP_REFERER'];
442 | }
443 |
444 | // Cookies test
445 | $cookie_test_value['check_value'] = md5($cookie_test_value['check_value']);
446 | setcookie('apbct_cookies_test', json_encode($cookie_test_value), 0, '/');
447 |
448 | }
449 | }
450 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/Model/Resource/Server.php:
--------------------------------------------------------------------------------
1 | _init('antispam/server', 'server_id');
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/Model/Resource/Timelabels.php:
--------------------------------------------------------------------------------
1 | _init('antispam/timelabels', 'ct_key');
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/Model/Review.php:
--------------------------------------------------------------------------------
1 | getNickname();
19 | $aMessage['message_title'] = $this->getTitle();
20 | $aMessage['message_body'] = $this->getDetail();
21 | $aMessage['example_title'] = '';
22 | $aMessage['example_body'] = '';
23 | $aMessage['example_comments'] = '';
24 |
25 | $model = Mage::getModel('antispam/api');
26 | $aResult = $model->CheckSpam($aMessage, FALSE);
27 |
28 | if(isset($aResult) && is_array($aResult)){
29 | if($aResult['errno'] == 0){
30 | if($aResult['allow'] == 0){
31 | // Spammer - fill errors
32 | // Note: 'stop_queue' is ignored in user checking
33 | if (preg_match('//u', $aResult['ct_result_comment'])){
34 | $comment_str = preg_replace('/^[^\*]*?\*\*\*|\*\*\*[^\*]*?$/iu', '', $aResult['ct_result_comment']);
35 | $comment_str = preg_replace('/<[^<>]*>/iu', '', $comment_str);
36 | }else{
37 | $comment_str = preg_replace('/^[^\*]*?\*\*\*|\*\*\*[^\*]*?$/i', '', $aResult['ct_result_comment']);
38 | $comment_str = preg_replace('/<[^<>]*>/i', '', $comment_str);
39 | }
40 | $errors[] = $comment_str;
41 | }
42 | }
43 | }
44 |
45 | if (empty($errors)) {
46 | return true;
47 | }
48 | return $errors;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/Model/Server.php:
--------------------------------------------------------------------------------
1 | _init('antispam/server');
9 | }
10 |
11 | }// class Cleantalk_Antispam_Model_Server
12 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/Model/Timelabels.php:
--------------------------------------------------------------------------------
1 | _init('antispam/timelabels');
9 | }
10 |
11 | }// class Cleantalk_Antispam_Model_Timelabels
12 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/Model/error.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
Blacklisted
8 |
48 |
49 |
50 |
CleanTalk. Spam protection
51 | %ERROR_TEXT%
52 |
53 |
« Back
54 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/Model/lib/cleantalk.class.php:
--------------------------------------------------------------------------------
1 | 0) {
131 | foreach ($response as $param => $value) {
132 | $this->{$param} = $value;
133 | }
134 | } else {
135 | $this->errno = $obj->errno;
136 | $this->errstr = $obj->errstr;
137 |
138 | $this->errstr = preg_replace("/.+(\*\*\*.+\*\*\*).+/", "$1", $this->errstr);
139 |
140 | $this->stop_words = isset($obj->stop_words) ? utf8_decode($obj->stop_words) : null;
141 | $this->comment = isset($obj->comment) ? utf8_decode($obj->comment) : null;
142 | $this->blacklisted = (isset($obj->blacklisted)) ? $obj->blacklisted : null;
143 | $this->allow = (isset($obj->allow)) ? $obj->allow : 0;
144 | $this->id = (isset($obj->id)) ? $obj->id : null;
145 | $this->fast_submit = (isset($obj->fast_submit)) ? $obj->fast_submit : 0;
146 | $this->spam = (isset($obj->spam)) ? $obj->spam : 0;
147 | $this->js_disabled = (isset($obj->js_disabled)) ? $obj->js_disabled : 0;
148 | $this->sms_allow = (isset($obj->sms_allow)) ? $obj->sms_allow : null;
149 | $this->sms = (isset($obj->sms)) ? $obj->sms : null;
150 | $this->sms_error_code = (isset($obj->sms_error_code)) ? $obj->sms_error_code : null;
151 | $this->sms_error_text = (isset($obj->sms_error_text)) ? $obj->sms_error_text : null;
152 | $this->stop_queue = (isset($obj->stop_queue)) ? $obj->stop_queue : 0;
153 | $this->inactive = (isset($obj->inactive)) ? $obj->inactive : 0;
154 | $this->account_status = (isset($obj->account_status)) ? $obj->account_status : -1;
155 |
156 | if ($this->errno !== 0 && $this->errstr !== null && $this->comment === null)
157 | $this->comment = '*** ' . $this->errstr . ' Antispam service cleantalk.org ***';
158 | }
159 | }
160 |
161 | }
162 |
163 | /**
164 | * Request class
165 | */
166 | class CleantalkRequest {
167 |
168 | /**
169 | * All http request headers
170 | * @var string
171 | */
172 | public $all_headers = null;
173 |
174 | /**
175 | * User message
176 | * @var string
177 | */
178 | public $message = null;
179 |
180 | /**
181 | * Post example with last comments
182 | * @var string
183 | */
184 | public $example = null;
185 |
186 | /**
187 | * Auth key
188 | * @var string
189 | */
190 | public $auth_key = null;
191 |
192 | /**
193 | * Engine
194 | * @var string
195 | */
196 | public $agent = null;
197 |
198 | /**
199 | * Is check for stoplist,
200 | * valid are 0|1
201 | * @var int
202 | */
203 | public $stoplist_check = null;
204 |
205 | /**
206 | * Language server response,
207 | * valid are 'en' or 'ru'
208 | * @var string
209 | */
210 | public $response_lang = null;
211 |
212 | /**
213 | * User IP
214 | * @var strings
215 | */
216 | public $sender_ip = null;
217 |
218 | /**
219 | * User email
220 | * @var strings
221 | */
222 | public $sender_email = null;
223 |
224 | /**
225 | * User nickname
226 | * @var string
227 | */
228 | public $sender_nickname = null;
229 |
230 | /**
231 | * Sender info JSON string
232 | * @var string
233 | */
234 | public $sender_info = null;
235 |
236 | /**
237 | * Post info JSON string
238 | * @var string
239 | */
240 | public $post_info = null;
241 |
242 | /**
243 | * Is allow links, email and icq,
244 | * valid are 1|0
245 | * @var int
246 | */
247 | public $allow_links = null;
248 |
249 | /**
250 | * Time form filling
251 | * @var int
252 | */
253 | public $submit_time = null;
254 |
255 | /**
256 | * Is enable Java Script,
257 | * valid are 0|1|2
258 | * Status:
259 | * null - JS html code not inserted into phpBB templates
260 | * 0 - JS disabled at the client browser
261 | * 1 - JS enabled at the client broswer
262 | * @var int
263 | */
264 | public $js_on = null;
265 |
266 | /**
267 | * user time zone
268 | * @var string
269 | */
270 | public $tz = null;
271 |
272 | /**
273 | * Feedback string,
274 | * valid are 'requset_id:(1|0)'
275 | * @var string
276 | */
277 | public $feedback = null;
278 |
279 | /**
280 | * Phone number
281 | * @var type
282 | */
283 | public $phone = null;
284 |
285 | /**
286 | * Method name
287 | * @var string
288 | */
289 | public $method_name = 'check_message';
290 |
291 | /**
292 | * Fill params with constructor
293 | * @param type $params
294 | */
295 | public function __construct($params = null) {
296 | if (is_array($params) && count($params) > 0) {
297 | foreach ($params as $param => $value) {
298 | $this->{$param} = $value;
299 | }
300 | }
301 | }
302 |
303 | }
304 |
305 | /**
306 | * Cleantalk class create request
307 | */
308 | class Cleantalk {
309 |
310 | /**
311 | * Debug level
312 | * @var int
313 | */
314 | public $debug = 0;
315 |
316 | /**
317 | * Maximum data size in bytes
318 | * @var int
319 | */
320 | private $dataMaxSise = 32768;
321 |
322 | /**
323 | * Data compression rate
324 | * @var int
325 | */
326 | private $compressRate = 6;
327 |
328 | /**
329 | * Server connection timeout in seconds
330 | * @var int
331 | */
332 | private $server_timeout = 15;
333 |
334 | /**
335 | * Cleantalk server url
336 | * @var string
337 | */
338 | public $server_url = null;
339 |
340 | /**
341 | * Last work url
342 | * @var string
343 | */
344 | public $work_url = null;
345 |
346 | /**
347 | * WOrk url ttl
348 | * @var int
349 | */
350 | public $server_ttl = null;
351 |
352 | /**
353 | * Time wotk_url changer
354 | * @var int
355 | */
356 | public $server_changed = null;
357 |
358 | /**
359 | * Flag is change server url
360 | * @var bool
361 | */
362 | public $server_change = false;
363 |
364 | /**
365 | * Use TRUE when need stay on server. Example: send feedback
366 | * @var bool
367 | */
368 | public $stay_on_server = false;
369 |
370 | /**
371 | * Codepage of the data
372 | * @var bool
373 | */
374 | public $data_codepage = null;
375 |
376 | /**
377 | * API version to use
378 | * @var string
379 | */
380 | public $api_version = '/api2.0';
381 |
382 | /**
383 | * Use https connection to servers
384 | * @var bool
385 | */
386 | public $ssl_on = false;
387 |
388 | /**
389 | * Minimal server response in miliseconds to catch the server
390 | *
391 | */
392 | public $min_server_timeout = 50;
393 |
394 | /**
395 | * Function checks whether it is possible to publish the message
396 | * @param CleantalkRequest $request
397 | * @return type
398 | */
399 | public function isAllowMessage(CleantalkRequest $request) {
400 | $this->filterRequest($request);
401 | $msg = $this->createMsg('check_message', $request);
402 | return $this->httpRequest($msg);
403 | }
404 |
405 | /**
406 | * Function checks whether it is possible to publish the message
407 | * @param CleantalkRequest $request
408 | * @return type
409 | */
410 | public function isAllowUser(CleantalkRequest $request) {
411 | $this->filterRequest($request);
412 | $msg = $this->createMsg('check_newuser', $request);
413 | return $this->httpRequest($msg);
414 | }
415 |
416 | /**
417 | * Function sends the results of manual moderation
418 | *
419 | * @param CleantalkRequest $request
420 | * @return type
421 | */
422 | public function sendFeedback(CleantalkRequest $request) {
423 | $this->filterRequest($request);
424 | $msg = $this->createMsg('send_feedback', $request);
425 | return $this->httpRequest($msg);
426 | }
427 |
428 | /**
429 | * Filter request params
430 | * @param CleantalkRequest $request
431 | * @return type
432 | */
433 | private function filterRequest(CleantalkRequest &$request) {
434 | // general and optional
435 | foreach ($request as $param => $value) {
436 | if (in_array($param, array('message', 'example', 'agent',
437 | 'sender_info', 'sender_nickname', 'post_info', 'phone')) && !empty($value)) {
438 | if (!is_string($value) && !is_integer($value)) {
439 | $request->$param = NULL;
440 | }
441 | }
442 |
443 | if (in_array($param, array('stoplist_check', 'allow_links')) && !empty($value)) {
444 | if (!in_array($value, array(1, 2))) {
445 | $request->$param = NULL;
446 | }
447 | }
448 |
449 | if (in_array($param, array('js_on')) && !empty($value)) {
450 | if (!is_integer($value)) {
451 | $request->$param = NULL;
452 | }
453 | }
454 |
455 | if ($param == 'sender_ip' && !empty($value)) {
456 | if (!is_string($value)) {
457 | $request->$param = NULL;
458 | }
459 | }
460 |
461 | if ($param == 'sender_email' && !empty($value)) {
462 | if (!is_string($value)) {
463 | $request->$param = NULL;
464 | }
465 | }
466 |
467 | if ($param == 'submit_time' && !empty($value)) {
468 | if (!is_int($value)) {
469 | $request->$param = NULL;
470 | }
471 | }
472 | }
473 | }
474 |
475 | /**
476 | * Compress data and encode to base64
477 | * @param type string
478 | * @return string
479 | */
480 | private function compressData($data = null){
481 |
482 | if (strlen($data) > $this->dataMaxSise && function_exists('gzencode') && function_exists('base64_encode')){
483 |
484 | $localData = gzencode($data, $this->compressRate, FORCE_GZIP);
485 |
486 | if ($localData === false)
487 | return $data;
488 |
489 | $localData = base64_encode($localData);
490 |
491 | if ($localData === false)
492 | return $data;
493 |
494 | return $localData;
495 | }
496 |
497 | return $data;
498 | }
499 |
500 | /**
501 | * Create msg for cleantalk server
502 | * @param type $method
503 | * @param CleantalkRequest $request
504 | * @return \xmlrpcmsg
505 | */
506 | private function createMsg($method, CleantalkRequest $request) {
507 | switch ($method) {
508 | case 'check_message':
509 | // Convert strings to UTF8
510 | $request->message = $this->stringToUTF8($request->message, $this->data_codepage);
511 | $request->example = $this->stringToUTF8($request->example, $this->data_codepage);
512 | $request->sender_email = $this->stringToUTF8($request->sender_email, $this->data_codepage);
513 | $request->sender_nickname = $this->stringToUTF8($request->sender_nickname, $this->data_codepage);
514 |
515 | $request->message = $this->compressData($request->message);
516 | $request->example = $this->compressData($request->example);
517 | break;
518 |
519 | case 'check_newuser':
520 | // Convert strings to UTF8
521 | $request->sender_email = $this->stringToUTF8($request->sender_email, $this->data_codepage);
522 | $request->sender_nickname = $this->stringToUTF8($request->sender_nickname, $this->data_codepage);
523 | break;
524 |
525 | case 'send_feedback':
526 | if (is_array($request->feedback)) {
527 | $request->feedback = implode(';', $request->feedback);
528 | }
529 | break;
530 | }
531 |
532 | $request->method_name = $method;
533 |
534 | //
535 | // Removing non UTF8 characters from request, because non UTF8 or malformed characters break json_encode().
536 | //
537 | foreach ($request as $param => $value) {
538 | if (!preg_match('//u', $value)) {
539 | $request->{$param} = 'Nulled. Not UTF8 encoded or malformed.';
540 | }
541 | }
542 |
543 | return $request;
544 | }
545 |
546 | /**
547 | * Send JSON request to servers
548 | * @param $msg
549 | * @return boolean|\CleantalkResponse
550 | */
551 | private function sendRequest($data = null, $url, $server_timeout = 15) {
552 | // Convert to array
553 | $data = json_decode(json_encode($data), true);
554 |
555 | // Convert to JSON
556 | $data = json_encode($data);
557 |
558 | if (isset($this->api_version)) {
559 | $url = $url . $this->api_version;
560 | }
561 |
562 | // Switching to secure connection
563 | if ($this->ssl_on && !preg_match("/^https:/", $url)) {
564 | $url = preg_replace("/^(http)/i", "$1s", $url);
565 | }
566 |
567 | $result = false;
568 | $curl_error = null;
569 | if(function_exists('curl_init')) {
570 | $ch = curl_init();
571 | curl_setopt($ch, CURLOPT_URL, $url);
572 | curl_setopt($ch, CURLOPT_TIMEOUT, $server_timeout);
573 | curl_setopt($ch, CURLOPT_POST, 1);
574 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
575 | // receive server response ...
576 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
577 | // resolve 'Expect: 100-continue' issue
578 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
579 | // see http://stackoverflow.com/a/23322368
580 | curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
581 |
582 | // Disabling CA cert verivication
583 | // Disabling common name verification
584 | if ($this->ssl_on) {
585 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
586 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
587 | }
588 |
589 | $result = curl_exec($ch);
590 | if (!$result) {
591 | $curl_error = curl_error($ch);
592 | }
593 |
594 | curl_close($ch);
595 | }
596 |
597 | if (!$result) {
598 | $allow_url_fopen = ini_get('allow_url_fopen');
599 | if (function_exists('file_get_contents') && isset($allow_url_fopen) && $allow_url_fopen == '1') {
600 | $opts = array('http' =>
601 | array(
602 | 'method' => 'POST',
603 | 'header' => "Content-Type: text/html\r\n",
604 | 'content' => $data,
605 | 'timeout' => $server_timeout
606 | )
607 | );
608 |
609 | $context = stream_context_create($opts);
610 | $result = @file_get_contents($url, false, $context);
611 | }
612 | }
613 |
614 | if (!$result) {
615 | $response = null;
616 | $response['errno'] = 1;
617 | if ($curl_error) {
618 | $response['errstr'] = sprintf("CURL error: '%s'", $curl_error);
619 | } else {
620 | $response['errstr'] = 'No CURL support compiled in';
621 | }
622 | $response['errstr'] .= ' or disabled allow_url_fopen in php.ini.';
623 | $response = json_decode(json_encode($response));
624 |
625 | return $response;
626 | }
627 |
628 | $errstr = null;
629 | $response = json_decode($result);
630 | if ($result !== false && is_object($response)) {
631 | $response->errno = 0;
632 | $response->errstr = $errstr;
633 | } else {
634 | $errstr = 'Unknown response from ' . $url . '.' . ' ' . $result;
635 |
636 | $response = null;
637 | $response['errno'] = 1;
638 | $response['errstr'] = $errstr;
639 | $response = json_decode(json_encode($response));
640 | }
641 |
642 |
643 | return $response;
644 | }
645 |
646 | /**
647 | * httpRequest
648 | * @param $msg
649 | * @return boolean|\CleantalkResponse
650 | */
651 | private function httpRequest($msg) {
652 | $result = false;
653 | $msg->all_headers=json_encode(apache_request_headers());
654 | if (((isset($this->work_url) && $this->work_url !== '') && ($this->server_changed + $this->server_ttl > time()))
655 | || $this->stay_on_server == true) {
656 |
657 | $url = (!empty($this->work_url)) ? $this->work_url : $this->server_url;
658 |
659 | $result = $this->sendRequest($msg, $url, $this->server_timeout);
660 | }
661 |
662 | if (($result === false || $result->errno != 0) && $this->stay_on_server == false) {
663 | // Split server url to parts
664 | preg_match("@^(https?://)([^/:]+)(.*)@i", $this->server_url, $matches);
665 | $url_prefix = '';
666 | if (isset($matches[1]))
667 | $url_prefix = $matches[1];
668 |
669 | $pool = null;
670 | if (isset($matches[2]))
671 | $pool = $matches[2];
672 |
673 | $url_suffix = '';
674 | if (isset($matches[3]))
675 | $url_suffix = $matches[3];
676 |
677 | if ($url_prefix === '')
678 | $url_prefix = 'http://';
679 |
680 | if (empty($pool)) {
681 | return false;
682 | } else {
683 | // Loop until find work server
684 | foreach ($this->get_servers_ip($pool) as $server) {
685 | if ($server['host'] === 'localhost' || $server['ip'] === null) {
686 | $work_url = $server['host'];
687 | } else {
688 | $server_host = $server['ip'];
689 | $work_url = $server_host;
690 | }
691 | $host = filter_var($work_url,FILTER_VALIDATE_IP) ? gethostbyaddr($work_url) : $work_url;
692 | $work_url = $url_prefix . $host;
693 | if (isset($url_suffix))
694 | $work_url = $work_url . $url_suffix;
695 |
696 | $this->work_url = $work_url;
697 | $this->server_ttl = $server['ttl'];
698 |
699 | $result = $this->sendRequest($msg, $this->work_url, $this->server_timeout);
700 |
701 | if ($result !== false && $result->errno === 0) {
702 | $this->server_change = true;
703 | break;
704 | }
705 | }
706 | }
707 | }
708 |
709 | $response = new CleantalkResponse(null, $result);
710 |
711 | if (!empty($this->data_codepage) && $this->data_codepage !== 'UTF-8') {
712 | if (!empty($response->comment))
713 | $response->comment = $this->stringFromUTF8($response->comment, $this->data_codepage);
714 | if (!empty($response->errstr))
715 | $response->errstr = $this->stringFromUTF8($response->errstr, $this->data_codepage);
716 | if (!empty($response->sms_error_text))
717 | $response->sms_error_text = $this->stringFromUTF8($response->sms_error_text, $this->data_codepage);
718 | }
719 |
720 | return $response;
721 | }
722 |
723 | /**
724 | * Function DNS request
725 | * @param $host
726 | * @return array
727 | */
728 | public function get_servers_ip($host) {
729 | $response = null;
730 | if (!isset($host))
731 | return $response;
732 |
733 | if (function_exists('dns_get_record')) {
734 | $records = dns_get_record($host, DNS_A);
735 |
736 | if ($records !== FALSE) {
737 | foreach ($records as $server) {
738 | $response[] = $server;
739 | }
740 | }
741 | }
742 |
743 | if (count($response) == 0 && function_exists('gethostbynamel')) {
744 | $records = gethostbynamel($host);
745 |
746 | if ($records !== FALSE) {
747 | foreach ($records as $server) {
748 | $response[] = array("ip" => $server,
749 | "host" => $host,
750 | "ttl" => $this->server_ttl
751 | );
752 | }
753 | }
754 | }
755 |
756 | if (count($response) == 0) {
757 | $response[] = array("ip" => null,
758 | "host" => $host,
759 | "ttl" => $this->server_ttl
760 | );
761 | } else {
762 | // $i - to resolve collisions with localhost
763 | $i = 0;
764 | $r_temp = null;
765 | $fast_server_found = false;
766 | foreach ($response as $server) {
767 |
768 | // Do not test servers because fast work server found
769 | if ($fast_server_found) {
770 | $ping = $this->min_server_timeout;
771 | } else {
772 | $ping = $this->httpPing($server['ip']);
773 | $ping = $ping * 1000;
774 | }
775 |
776 | // -1 server is down, skips not reachable server
777 | if ($ping != -1) {
778 | $r_temp[$ping + $i] = $server;
779 | }
780 | $i++;
781 |
782 | if ($ping < $this->min_server_timeout) {
783 | $fast_server_found = true;
784 | }
785 | }
786 | if (count($r_temp)){
787 | ksort($r_temp);
788 | $response = $r_temp;
789 | }
790 | }
791 |
792 | return $response;
793 | }
794 |
795 | /**
796 | * Function to get the message hash from Cleantalk.org comment
797 | * @param $message
798 | * @return null
799 | */
800 | public function getCleantalkCommentHash($message) {
801 | $matches = array();
802 | if (preg_match('/\n\n\*\*\*.+([a-z0-9]{32}).+\*\*\*$/', $message, $matches))
803 | return $matches[1];
804 | else if (preg_match('/\
[\n]{0,1}\[\n]{0,1}\*\*\*.+([a-z0-9]{32}).+\*\*\*$/', $message, $matches))
805 | return $matches[1];
806 |
807 | return NULL;
808 | }
809 |
810 | /**
811 | * Function adds to the post comment Cleantalk.org
812 | * @param $message
813 | * @param $comment
814 | * @return string
815 | */
816 | public function addCleantalkComment($message, $comment) {
817 | $comment = preg_match('/\*\*\*(.+)\*\*\*/', $comment, $matches) ? $comment : '*** ' . $comment . ' ***';
818 | return $message . "\n\n" . $comment;
819 | }
820 |
821 | /**
822 | * Function deletes the comment Cleantalk.org
823 | * @param $message
824 | * @return mixed
825 | */
826 | public function delCleantalkComment($message) {
827 | $message = preg_replace('/\n\n\*\*\*.+\*\*\*$/', '', $message);
828 |
829 | // DLE sign cut
830 | $message = preg_replace('/
\*\*\*.+\*\*\*$/', '', $message);
831 |
832 | $message = preg_replace('/\[\n]{0,1}\[\n]{0,1}\*\*\*.+\*\*\*$/', '', $message);
833 |
834 | return $message;
835 | }
836 |
837 | /**
838 | * Get user IP behind proxy server
839 | */
840 | public function ct_session_ip( $data_ip ) {
841 | if (!$data_ip || !preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $data_ip)) {
842 | return $data_ip;
843 | }
844 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
845 |
846 | $forwarded_ip = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
847 |
848 | // Looking for first value in the list, it should be sender real IP address
849 | if (!preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $forwarded_ip[0])) {
850 | return $data_ip;
851 | }
852 |
853 | $private_src_ip = false;
854 | $private_nets = array(
855 | '10.0.0.0/8',
856 | '127.0.0.0/8',
857 | '176.16.0.0/12',
858 | '192.168.0.0/16',
859 | );
860 |
861 | foreach ($private_nets as $v) {
862 |
863 | // Private IP found
864 | if ($private_src_ip) {
865 | continue;
866 | }
867 |
868 | if ($this->net_match($v, $data_ip)) {
869 | $private_src_ip = true;
870 | }
871 | }
872 | if ($private_src_ip) {
873 | // Taking first IP from the list HTTP_X_FORWARDED_FOR
874 | $data_ip = $forwarded_ip[0];
875 | }
876 | }
877 |
878 | return $data_ip;
879 | }
880 |
881 | /**
882 | * From http://php.net/manual/en/function.ip2long.php#82397
883 | */
884 | public function net_match($CIDR,$IP) {
885 | list ($net, $mask) = explode ('/', $CIDR);
886 | return ( ip2long ($IP) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($net);
887 | }
888 |
889 | /**
890 | * Function to check response time
891 | * param string
892 | * @return int
893 | */
894 | function httpPing($host){
895 |
896 | // Skip localhost ping cause it raise error at fsockopen.
897 | // And return minimun value
898 | if ($host == 'localhost')
899 | return 0.001;
900 |
901 | $starttime = microtime(true);
902 | $file = @fsockopen ($host, 80, $errno, $errstr, $this->server_timeout);
903 | $stoptime = microtime(true);
904 | $status = 0;
905 | if (!$file) {
906 | $status = -1; // Site is down
907 | } else {
908 | fclose($file);
909 | $status = ($stoptime - $starttime);
910 | $status = round($status, 4);
911 | }
912 |
913 | return $status;
914 | }
915 |
916 | /**
917 | * Function convert string to UTF8 and removes non UTF8 characters
918 | * param string
919 | * param string
920 | * @return string
921 | */
922 | function stringToUTF8($str, $data_codepage = null){
923 | if (!preg_match('//u', $str) && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
924 |
925 | if ($data_codepage !== null)
926 | return mb_convert_encoding($str, 'UTF-8', $data_codepage);
927 |
928 | $encoding = mb_detect_encoding($str);
929 | if ($encoding)
930 | return mb_convert_encoding($str, 'UTF-8', $encoding);
931 | }
932 |
933 | return $str;
934 | }
935 |
936 | /**
937 | * Function convert string from UTF8
938 | * param string
939 | * param string
940 | * @return string
941 | */
942 | function stringFromUTF8($str, $data_codepage = null){
943 | if (preg_match('//u', $str) && function_exists('mb_convert_encoding') && $data_codepage !== null) {
944 | return mb_convert_encoding($str, $data_codepage, 'UTF-8');
945 | }
946 |
947 | return $str;
948 | }
949 | }
950 |
951 | /**
952 | * Function gets access key automatically
953 | *
954 | * @param string website admin email
955 | * @param string website host
956 | * @param string website platform
957 | * @return type
958 | */
959 |
960 | function getAutoKey($email, $host, $platform)
961 | {
962 | $request=Array();
963 | $request['method_name'] = 'get_api_key';
964 | $request['email'] = $email;
965 | $request['website'] = $host;
966 | $request['platform'] = $platform;
967 | $url='https://api.cleantalk.org';
968 | $result=sendRawRequest($url,$request);
969 | return $result;
970 | }
971 |
972 | /**
973 | * Function gets information about renew notice
974 | *
975 | * @param string api_key
976 | * @return type
977 | */
978 |
979 | function noticePaidTill($api_key)
980 | {
981 | $request=Array();
982 | $request['method_name'] = 'notice_paid_till';
983 | $request['auth_key'] = $api_key;
984 | $url='https://api.cleantalk.org';
985 | $result=sendRawRequest($url,$request);
986 | return $result;
987 | }
988 |
989 | /*
990 | * If Apache web server is missing then making
991 | * Patch for apache_request_headers()
992 | */
993 | if(!function_exists('apache_request_headers'))
994 | {
995 | function apache_request_headers()
996 | {
997 | $headers = array();
998 | foreach($_SERVER as $key => $val){
999 | if(preg_match('/\AHTTP_/', $key)){
1000 | $server_key = preg_replace('/\AHTTP_/', '', $key);
1001 | $key_parts = explode('_', $server_key);
1002 | if(count($key_parts) > 0 and strlen($server_key) > 2){
1003 | foreach($key_parts as $part_index => $part){
1004 | $key_parts[$part_index] = function_exists('mb_strtolower') ? mb_strtolower($part) : strtolower($part);
1005 | $key_parts[$part_index][0] = strtoupper($key_parts[$part_index][0]);
1006 | }
1007 | $server_key = implode('-', $key_parts);
1008 | }
1009 | $headers[$server_key] = $val;
1010 | }
1011 | }
1012 | return $headers;
1013 | }
1014 | }
1015 |
1016 | /**
1017 | * Function sends raw request to API server
1018 | *
1019 | * @param string url of API server
1020 | * @param array data to send
1021 | * @param boolean is data have to be JSON encoded or not
1022 | * @param integer connect timeout
1023 | * @return type
1024 | */
1025 |
1026 | function sendRawRequest($url,$data,$isJSON=false,$timeout=15)
1027 | {
1028 | $result=null;
1029 | if(!$isJSON)
1030 | {
1031 | $data=http_build_query($data);
1032 | }
1033 | else
1034 | {
1035 | $data= json_encode($data);
1036 | }
1037 | if (function_exists('curl_init') && function_exists('json_decode'))
1038 | {
1039 |
1040 | $ch = curl_init();
1041 | curl_setopt($ch, CURLOPT_URL, $url);
1042 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
1043 | curl_setopt($ch, CURLOPT_POST, true);
1044 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
1045 |
1046 | // receive server response ...
1047 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1048 | // resolve 'Expect: 100-continue' issue
1049 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
1050 |
1051 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1052 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
1053 |
1054 | $result = curl_exec($ch);
1055 | curl_close($ch);
1056 | }
1057 | else
1058 | {
1059 | $opts = array(
1060 | 'http'=>array(
1061 | 'method'=>"POST",
1062 | 'content'=>$data)
1063 | );
1064 | $context = stream_context_create($opts);
1065 | $result = @file_get_contents($url, 0, $context);
1066 | }
1067 | return $result;
1068 | }
1069 |
1070 | ?>
1071 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/controllers/Contacts/IndexController.php:
--------------------------------------------------------------------------------
1 | getRequest()->getPost();
9 | if ($post) {
10 |
11 | $aMessage = array();
12 | $aMessage['type'] = 'comment';
13 | $aMessage['sender_email'] = isset($post['email']) ? $post['email'] : '';
14 | $aMessage['sender_nickname'] = isset($post['name']) ? $post['name'] : '';
15 | $aMessage['message_title'] = isset($post['telephone']) ? $post['telephone'] : '';
16 | $aMessage['message_body'] = isset($post['comment']) ? $post['comment'] : '';
17 | $aMessage['example_title'] = '';
18 | $aMessage['example_body'] = '';
19 | $aMessage['example_comments'] = '';
20 |
21 | $model = Mage::getModel('antispam/api');
22 | $aResult = $model->CheckSpam($aMessage, FALSE);
23 |
24 | if(isset($aResult) && is_array($aResult)){
25 | if($aResult['errno'] == 0){
26 | if($aResult['allow'] == 0){
27 | if (preg_match('//u', $aResult['ct_result_comment'])){
28 | $comment_str = preg_replace('/^[^\*]*?\*\*\*|\*\*\*[^\*]*?$/iu', '', $aResult['ct_result_comment']);
29 | $comment_str = preg_replace('/<[^<>]*>/iu', '', $comment_str);
30 | }else{
31 | $comment_str = preg_replace('/^[^\*]*?\*\*\*|\*\*\*[^\*]*?$/i', '', $aResult['ct_result_comment']);
32 | $comment_str = preg_replace('/<[^<>]*>/i', '', $comment_str);
33 | }
34 | Mage::getSingleton('customer/session')->addError($comment_str);
35 | $this->_redirect('*/*/');
36 | return;
37 | }
38 | }
39 | }
40 | }
41 | parent::postAction();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/controllers/Customer/AccountController.php:
--------------------------------------------------------------------------------
1 | getRequest()->getPost();
9 | if ($post) {
10 | $aUser = array();
11 | $aUser['type'] = 'register';
12 | $aUser['sender_email'] = isset($post['email']) ? $post['email'] : '';
13 | $aUser['sender_nickname'] = isset($post['firstname']) ? $post['firstname'] : '';
14 | $aUser['sender_nickname'] .= isset($post['lastname']) ? ' ' . $post['lastname'] : '';
15 |
16 | $model = Mage::getModel('antispam/api');
17 | $aResult = $model->CheckSpam($aUser, FALSE);
18 |
19 | if(isset($aResult) && is_array($aResult)){
20 | if($aResult['errno'] == 0){
21 | if($aResult['allow'] == 0){
22 | if (preg_match('//u', $aResult['ct_result_comment'])){
23 | $comment_str = preg_replace('/^[^\*]*?\*\*\*|\*\*\*[^\*]*?$/iu', '', $aResult['ct_result_comment']);
24 | $comment_str = preg_replace('/<[^<>]*>/iu', '', $comment_str);
25 | }else{
26 | $comment_str = preg_replace('/^[^\*]*?\*\*\*|\*\*\*[^\*]*?$/i', '', $aResult['ct_result_comment']);
27 | $comment_str = preg_replace('/<[^<>]*>/i', '', $comment_str);
28 | }
29 | Mage::getSingleton('customer/session')->addError($comment_str);
30 | //$this->_redirect('*/*/');
31 | $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
32 | return;
33 | }
34 | }
35 | }
36 | }
37 | parent::createPostAction();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/custom_config.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1.2.7
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | /antispam/customer_account/createpost
16 |
17 |
18 |
19 | /antispam/contacts_index/post$1
20 |
21 |
22 |
23 |
24 |
25 | Cleantalk_Antispam_Model
26 | antispam_resource
27 |
28 |
29 |
30 | Cleantalk_Antispam_Model_Resource
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | Cleantalk_Antispam_Model_Review
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | Cleantalk_Antispam
53 | Mage_Core_Model_Resource_Setup
54 |
55 |
56 |
57 |
58 |
59 |
60 | Cleantalk_Antispam_Block
61 |
62 |
63 |
64 |
65 |
66 |
67 | singleton
68 | antispam/observer
69 | interceptQuery
70 |
71 |
72 |
73 |
74 |
75 |
76 | singleton
77 | antispam/observer
78 | interceptOutput
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 | Cleantalk_Antispam
92 | antispam
93 |
94 |
95 |
96 |
97 |
98 |
99 | antispam.xml
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/etc/system.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | text
9 | 999
10 | 1
11 | 1
12 | 1
13 |
14 |
15 |
16 | text
17 | is_paid
18 | 1
19 | 0
20 | 0
21 | 0
22 |
23 |
24 |
25 | text
26 | last_checked
27 | 1
28 | 0
29 | 0
30 | 0
31 |
32 |
33 |
34 | text
35 | show_notice
36 | 1
37 | 0
38 | 0
39 | 0
40 |
41 |
42 |
43 | text
44 |
45 | 1
46 | 1
47 | 1
48 | 1
49 |
50 |
51 |
52 | select
53 | adminhtml/system_config_source_yesno
54 |
55 | 1
56 | 1
57 | 1
58 | 1
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/code/community/Cleantalk/Antispam/sql/cleantalk_antispam_setup/install-1.2.3.php:
--------------------------------------------------------------------------------
1 | startSetup();
7 |
8 | $installer->run("
9 | DROP TABLE IF EXISTS `{$this->getTable('cleantalk_server')}`;
10 | CREATE TABLE `{$this->getTable('cleantalk_server')}` (
11 | `server_id` int(11) NOT NULL default 1,
12 | `work_url` varchar(255),
13 | `server_url` varchar(255),
14 | `server_ttl` int(11),
15 | `server_changed` int(11),
16 | PRIMARY KEY (`server_id`)
17 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
18 | ");
19 |
20 | $installer->run("
21 | DROP TABLE IF EXISTS `{$this->getTable('cleantalk_timelabels')}`;
22 | CREATE TABLE `{$this->getTable('cleantalk_timelabels')}` (
23 | `ct_key` varchar(255) NOT NULL default 'mail_error',
24 | `ct_value` int(11),
25 | PRIMARY KEY (`ct_key`)
26 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
27 | ");
28 |
29 | $installer->endSetup();
30 |
--------------------------------------------------------------------------------
/app/design/adminhtml/default/default/layout/cleantalk/antispam.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/design/frontend/base/default/layout/antispam.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/design/frontend/base/default/template/cleantalk/antispam/page_addon.phtml:
--------------------------------------------------------------------------------
1 |
2 | PageAddon();
4 | ?>
5 |
6 |
--------------------------------------------------------------------------------
/app/etc/modules/Cleantalk_Antispam.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 | community
7 | 1.2.7
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Cleantalk_Antispam
4 | 1.2.7
5 | stable
6 | GPL
7 | community
8 |
9 | Cloud, CAPTCHA free, premium antispam for Magento.
10 | <p>
11 | CleanTalk cloud service provides automatic and invisible protection against spam for web sites.
12 | </p>
13 |
14 | <p>
15 | We have developed cloud antispam service that provides both maximum protection from spam bots and maximum convenient level for site visitors. No CAPTCHA, no questions, no counting animals, no puzzles, no math - just no spam at all.
16 | </p>
17 |
18 | <p>
19 | We provide detailed statistics. We provide free mobile app for you to see antispam statistics wherever whenever.
20 | </p>
21 |
22 | <p>
23 | The CleanTalk is premium antispam, please look at the <a href="https://cleantalk.org/price">pricing</a>. Paying for a year of service, you save a lot more and get:
24 | <ul>
25 | <li>100% protection against spambots</li>
26 | <li>Time and resources saving</li>
27 | <li>More registrations and visitors</li>
28 | <li>Protect several websites at once at different CMS</li>
29 | <li>Easy to install and use</li>
30 | <li>Traffic acquisition and user loyalty</li>
31 | <li>24/7 technical support</li>
32 | <li>Clear statistics</li>
33 | <li>No captcha, puzzles, etc.</li>
34 | <li>Free mobile app</li>
35 | </ul>
36 | </p>
37 |
38 | <p>
39 | Current Magento module details:
40 | <ul>
41 | <li>Stability - stable.</li>
42 | <li>Supported Mage releases - 1.7.*, 1.8.*, 1.9.*</li>
43 | <li>Support - <a href="https://cleantalk.org/forum/viewforum.php?f=40">https://cleantalk.org/forum/viewforum.php?f=40</a></li>
44 | <li>Settings in CP - System->Configuration->General->CleanTalk</li>
45 | </ul>
46 | </p>
47 |
48 | Fixed login form checking.
49 | Changed connection test method.
50 | CleanTalk.Orgcleantalkwelcome@cleantalk.org
51 | 2016-07-25
52 |
53 |
54 |
55 | 5.1.07.3.5
56 |
57 |
--------------------------------------------------------------------------------