Skip to content

Commit 5e17464

Browse files
author
Артем
committed
remove apbct vars
1 parent f2feb0a commit 5e17464

File tree

7 files changed

+141
-154
lines changed

7 files changed

+141
-154
lines changed

.DS_Store

6 KB
Binary file not shown.

cleantalk.custom.php

Lines changed: 140 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,140 @@
1-
<?php
2-
require_once (dirname(__FILE__) . 'autoload.php');
3-
4-
/**
5-
* CleanTalk anti-spam script for any web form
6-
*
7-
* @version 1.1
8-
* @package CleanTalk
9-
* @subpackage Base
10-
* @author СleanTalk team ([email protected])
11-
* @copyright (C) 2014 СleanTalk team (http://cleantalk.org)
12-
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
13-
* @see https://github.com/CleanTalk/php-antispam
14-
*
15-
*/
16-
use lib\CleantalkRequest;
17-
use lib\Cleantalk;
18-
use lib\CleantalkHelper;
19-
/*
20-
CleanTalk's global vars
21-
*/
22-
$ct_server_url = 'http://moderate.cleantalk.org/api2.0/';
23-
$ct_pagetime_label = 'ct_pagetime';
24-
$ct_checkjs_label = 'ct_checkjs';
25-
26-
ct_init();
27-
28-
/**
29-
* Starts CleanTalk
30-
* @param null
31-
* @return boolean|null
32-
*/
33-
function ct_init() {
34-
global $ct_pagetime_label, $ct_checkjs_label;
35-
36-
if(session_id() === '') {
37-
@session_start();
38-
}
39-
40-
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
41-
ct_process_submission();
42-
} else {
43-
$_SESSION[$ct_pagetime_label] = time();
44-
$html = sprintf('
45-
<script type="text/javascript">
46-
function ctSetCookie() {
47-
var date = new Date();
48-
document.cookie = "%s=" + date.getFullYear() + "; path=/";
49-
}
50-
ctSetCookie();
51-
</script>
52-
',
53-
$ct_checkjs_label
54-
);
55-
$html = str_replace(array("\n","\r"),'', $html);
56-
echo $html;
57-
}
58-
59-
return null;
60-
}
61-
62-
/**
63-
* Catchs and preapres POST data
64-
* @param null
65-
* @return boolean|null
66-
*/
67-
function ct_process_submission() {
68-
global $ct_pagetime_label, $ct_server_url, $ct_checkjs_label;
69-
70-
$ct_checkjs = null;
71-
if (isset($_COOKIE[$ct_checkjs_label]) && $_COOKIE[$ct_checkjs_label] == date("Y")) {
72-
if ($_COOKIE[$ct_checkjs_label] == date("Y")) {
73-
$ct_checkjs = 1;
74-
} else {
75-
$ct_checkjs = 0;
76-
}
77-
}
78-
79-
$ct_submit_time = null;
80-
if (isset($_SESSION[$ct_pagetime_label])) {
81-
$ct_submit_time = time() - $_SESSION[$ct_pagetime_label];
82-
}
83-
84-
$sender_email = null;
85-
if (is_array($_POST)) {
86-
foreach ($_POST as $k => $v) {
87-
if ($sender_email === null && isset($v)) {
88-
if (is_string($v) && preg_match("/^\S+@\S+\.\S+$/", $v)) {
89-
$sender_email = $v;
90-
}
91-
92-
// Looking email address in arrays
93-
if (is_array($v)) {
94-
foreach ($v as $v2) {
95-
if ($sender_email) {
96-
continue;
97-
}
98-
99-
if (is_string($v2) && preg_match("/^\S+@\S+\.\S+$/", $v2)) {
100-
$sender_email = $v2;
101-
}
102-
}
103-
}
104-
}
105-
}
106-
}
107-
// Take params from config
108-
$config_url = 'http://moderate.cleantalk.ru';
109-
$auth_key = null; // Set Cleantalk auth key
110-
111-
112-
// The facility in which to store the query parameters
113-
$ct_request = new CleantalkRequest();
114-
115-
$ct_request->auth_key = $auth_key;
116-
$ct_request->sender_email = $sender_email;
117-
$ct_request->agent = 'php-api';
118-
$ct_request->sender_ip = CleantalkHelper::ip_get(array('real'), false);
119-
$ct_request->js_on = $ct_checkjs; # Site visitor has JavaScript
120-
$ct_request->submit_time = $ct_submit_time; # Seconds from start form filling till the form POST
121-
122-
$ct = new Cleantalk();
123-
$ct->server_url = $config_url;
124-
125-
// Check
126-
$ct_result = $ct->isAllowUser($ct_request);
127-
128-
if ($result->errno != 0) {
129-
error_log($result->errstr);
130-
return false;
131-
}
132-
133-
if ($result->allow == 0 && isset($result->comment)) {
134-
$message = sprintf("<br /><br /><br /><center><span>%s</span></center>", $result->comment);
135-
echo $message;
136-
exit;
137-
}
138-
139-
return null;
140-
}
1+
<?php
2+
require "vendor/autoload.php";
3+
4+
/**
5+
* CleanTalk anti-spam script for any web form
6+
*
7+
* @version 1.1
8+
* @package CleanTalk
9+
* @subpackage Base
10+
* @author СleanTalk team ([email protected])
11+
* @copyright (C) 2014 СleanTalk team (http://cleantalk.org)
12+
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
13+
* @see https://github.com/CleanTalk/php-antispam
14+
*
15+
*/
16+
use lib\CleantalkRequest;
17+
use lib\Cleantalk;
18+
use lib\CleantalkHelper;
19+
/*
20+
CleanTalk's global vars
21+
*/
22+
$ct_server_url = 'http://moderate.cleantalk.org/api2.0/';
23+
$ct_pagetime_label = 'ct_pagetime';
24+
$ct_checkjs_label = 'ct_checkjs';
25+
26+
ct_init();
27+
28+
/**
29+
* Starts CleanTalk
30+
* @param null
31+
* @return boolean|null
32+
*/
33+
function ct_init() {
34+
global $ct_pagetime_label, $ct_checkjs_label;
35+
36+
if(session_id() === '') {
37+
@session_start();
38+
}
39+
40+
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
41+
ct_process_submission();
42+
} else {
43+
$_SESSION[$ct_pagetime_label] = time();
44+
$html = sprintf('
45+
<script type="text/javascript">
46+
function ctSetCookie() {
47+
var date = new Date();
48+
document.cookie = "%s=" + date.getFullYear() + "; path=/";
49+
}
50+
ctSetCookie();
51+
</script>
52+
',
53+
$ct_checkjs_label
54+
);
55+
$html = str_replace(array("\n","\r"),'', $html);
56+
echo $html;
57+
}
58+
59+
return null;
60+
}
61+
62+
/**
63+
* Catchs and preapres POST data
64+
* @param null
65+
* @return boolean|null
66+
*/
67+
function ct_process_submission() {
68+
global $ct_pagetime_label, $ct_server_url, $ct_checkjs_label;
69+
70+
$ct_checkjs = null;
71+
if (isset($_COOKIE[$ct_checkjs_label]) && $_COOKIE[$ct_checkjs_label] == date("Y")) {
72+
if ($_COOKIE[$ct_checkjs_label] == date("Y")) {
73+
$ct_checkjs = 1;
74+
} else {
75+
$ct_checkjs = 0;
76+
}
77+
}
78+
79+
$ct_submit_time = null;
80+
if (isset($_SESSION[$ct_pagetime_label])) {
81+
$ct_submit_time = time() - $_SESSION[$ct_pagetime_label];
82+
}
83+
84+
$sender_email = null;
85+
if (is_array($_POST)) {
86+
foreach ($_POST as $k => $v) {
87+
if ($sender_email === null && isset($v)) {
88+
if (is_string($v) && preg_match("/^\S+@\S+\.\S+$/", $v)) {
89+
$sender_email = $v;
90+
}
91+
92+
// Looking email address in arrays
93+
if (is_array($v)) {
94+
foreach ($v as $v2) {
95+
if ($sender_email) {
96+
continue;
97+
}
98+
99+
if (is_string($v2) && preg_match("/^\S+@\S+\.\S+$/", $v2)) {
100+
$sender_email = $v2;
101+
}
102+
}
103+
}
104+
}
105+
}
106+
}
107+
// Take params from config
108+
$config_url = 'http://moderate.cleantalk.ru';
109+
$auth_key = null; // Set Cleantalk auth key
110+
111+
112+
// The facility in which to store the query parameters
113+
$ct_request = new CleantalkRequest();
114+
115+
$ct_request->auth_key = $auth_key;
116+
$ct_request->sender_email = $sender_email;
117+
$ct_request->agent = 'php-api';
118+
$ct_request->sender_ip = CleantalkHelper::ip_get(array('real'), false);
119+
$ct_request->js_on = $ct_checkjs; # Site visitor has JavaScript
120+
$ct_request->submit_time = $ct_submit_time; # Seconds from start form filling till the form POST
121+
122+
$ct = new Cleantalk();
123+
$ct->server_url = $config_url;
124+
125+
// Check
126+
$ct_result = $ct->isAllowUser($ct_request);
127+
128+
if ($result->errno != 0) {
129+
error_log($result->errstr);
130+
return false;
131+
}
132+
133+
if ($result->allow == 0 && isset($result->comment)) {
134+
$message = sprintf("<br /><br /><br /><center><span>%s</span></center>", $result->comment);
135+
echo $message;
136+
exit;
137+
}
138+
139+
return null;
140+
}

desktop.ini

Lines changed: 0 additions & 6 deletions
This file was deleted.

example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
require_once 'autoload.php';
2+
require "vendor/autoload.php";
33

44
/**
55
* Cleantalk example

lib/CleantalkAPI.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,6 @@ static public function send_request($data, $url = self::URL, $timeout = 5, $ssl
354354
$data_string = http_build_query($data);
355355
$data_string = str_replace("&amp;", "&", $data_string);
356356

357-
// For debug purposes
358-
global $apbct_debug;
359-
$apbct_debug['sent_data'] = $data;
360-
$apbct_debug['request_string'] = $data_string;
361-
362357
if (function_exists('curl_init')){
363358

364359
$ch = curl_init();
@@ -375,7 +370,6 @@ static public function send_request($data, $url = self::URL, $timeout = 5, $ssl
375370
if ($ssl === true) {
376371
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
377372
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
378-
curl_setopt($ch, CURLOPT_CAINFO, APBCT_CASERT_PATH);
379373
}else{
380374
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
381375
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

lib/CleantalkHelper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ static public function http__request($url, $data = array(), $presets = null, $op
225225
case 'ssl':
226226
$opts[CURLOPT_SSL_VERIFYPEER] = true;
227227
$opts[CURLOPT_SSL_VERIFYHOST] = 2;
228-
$opts[CURLOPT_CAINFO] = APBCT_CASERT_PATH;
229228
break;
230229

231230
default:
File renamed without changes.

0 commit comments

Comments
 (0)