Skip to content

Commit

Permalink
Fix: update lib folder name.
Browse files Browse the repository at this point in the history
  • Loading branch information
ardavydov committed May 3, 2021
1 parent 27f22ab commit 2b3ce48
Show file tree
Hide file tree
Showing 26 changed files with 6,144 additions and 0 deletions.
795 changes: 795 additions & 0 deletions CleanTalk/lib/CleanTalk/Antispam/Cleantalk.php

Large diffs are not rendered by default.

172 changes: 172 additions & 0 deletions CleanTalk/lib/CleanTalk/Antispam/CleantalkRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<?php

namespace CleanTalk\Antispam;

/**
* Request class
*/
class CleantalkRequest {

/**
* All http request headers
* @var string
*/
public $all_headers = null;

/**
* IP address of connection
* @var string
*/
//public $remote_addr = null;

/**
* Last error number
* @var integer
*/
public $last_error_no = null;

/**
* Last error time
* @var integer
*/
public $last_error_time = null;

/**
* Last error text
* @var string
*/
public $last_error_text = null;

/**
* User message
* @var string
*/
public $message = null;

/**
* Post example with last comments
* @var string
*/
public $example = null;

/**
* Auth key
* @var string
*/
public $auth_key = null;

/**
* Engine
* @var string
*/
public $agent = null;

/**
* Is check for stoplist,
* valid are 0|1
* @var int
*/
public $stoplist_check = null;

/**
* Language server response,
* valid are 'en' or 'ru'
* @var string
*/
public $response_lang = null;

/**
* User IP
* @var strings
*/
public $sender_ip = null;

/**
* User email
* @var strings
*/
public $sender_email = null;

/**
* User nickname
* @var string
*/
public $sender_nickname = null;

/**
* Sender info JSON string
* @var string
*/
public $sender_info = null;

/**
* Post info JSON string
* @var string
*/
public $post_info = null;

/**
* Is allow links, email and icq,
* valid are 1|0
* @var int
*/
public $allow_links = null;

/**
* Time form filling
* @var int
*/
public $submit_time = null;

public $x_forwarded_for = '';
public $x_real_ip = '';

/**
* Is enable Java Script,
* valid are 0|1|2
* Status:
* null - JS html code not inserted into phpBB templates
* 0 - JS disabled at the client browser
* 1 - JS enabled at the client broswer
* @var int
*/
public $js_on = null;

/**
* user time zone
* @var string
*/
public $tz = null;

/**
* Feedback string,
* valid are 'requset_id:(1|0)'
* @var string
*/
public $feedback = null;

/**
* Phone number
* @var type
*/
public $phone = null;

/**
* Method name
* @var string
*/
public $method_name = 'check_message';

/**
* Fill params with constructor
* @param type $params
*/
public function __construct($params = null) {
if (is_array($params) && count($params) > 0) {
foreach ($params as $param => $value) {
$this->{$param} = $value;
}
}
}

}
158 changes: 158 additions & 0 deletions CleanTalk/lib/CleanTalk/Antispam/CleantalkResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?php

namespace CleanTalk\Antispam;

/**
* Response class
*/
class CleantalkResponse {

/**
* Received feedback nubmer
* @var int
*/
public $received = null;

/**
* Is stop words
* @var int
*/
public $stop_words = null;

/**
* Cleantalk comment
* @var string
*/
public $comment = null;

/**
* Is blacklisted
* @var int
*/
public $blacklisted = null;

/**
* Is allow, 1|0
* @var int
*/
public $allow = null;

/**
* Request ID
* @var int
*/
public $id = null;

/**
* Request errno
* @var int
*/
public $errno = null;

/**
* Error string
* @var string
*/
public $errstr = null;

/**
* Is fast submit, 1|0
* @var string
*/
public $fast_submit = null;

/**
* Is spam comment
* @var string
*/
public $spam = null;

/**
* Is JS
* @var type
*/
public $js_disabled = null;

/**
* Sms check
* @var type
*/
public $sms_allow = null;

/**
* Sms code result
* @var type
*/
public $sms = null;

/**
* Sms error code
* @var type
*/
public $sms_error_code = null;

/**
* Sms error code
* @var type
*/
public $sms_error_text = null;

/**
* Stop queue message, 1|0
* @var int
*/
public $stop_queue = null;

/**
* Account shuld by deactivated after registration, 1|0
* @var int
*/
public $inactive = null;

/**
* Account status
* @var int
*/
public $account_status = -1;

/**
* Create server response
*
* @param type $response
* @param type $obj
*/
function __construct($response = null, $obj = null) {
if ($response && is_array($response) && count($response) > 0) {
foreach ($response as $param => $value) {
$this->{$param} = $value;
}
} else {
$this->errno = $obj->errno;
$this->errstr = $obj->errstr;

$this->errstr = preg_replace("/.+(\*\*\*.+\*\*\*).+/", "$1", $this->errstr);
$this->stop_words = isset($obj->stop_words) ? utf8_decode($obj->stop_words) : null;
$this->comment = isset($obj->comment) ? utf8_decode($obj->comment) : null;
$this->blacklisted = (isset($obj->blacklisted)) ? $obj->blacklisted : null;
$this->allow = (isset($obj->allow)) ? $obj->allow : 0;
$this->id = (isset($obj->id)) ? $obj->id : null;
$this->fast_submit = (isset($obj->fast_submit)) ? $obj->fast_submit : 0;
$this->spam = (isset($obj->spam)) ? $obj->spam : 0;
$this->js_disabled = (isset($obj->js_disabled)) ? $obj->js_disabled : 0;
$this->sms_allow = (isset($obj->sms_allow)) ? $obj->sms_allow : null;
$this->sms = (isset($obj->sms)) ? $obj->sms : null;
$this->sms_error_code = (isset($obj->sms_error_code)) ? $obj->sms_error_code : null;
$this->sms_error_text = (isset($obj->sms_error_text)) ? $obj->sms_error_text : null;
$this->stop_queue = (isset($obj->stop_queue)) ? $obj->stop_queue : 0;
$this->inactive = (isset($obj->inactive)) ? $obj->inactive : 0;
$this->account_status = (isset($obj->account_status)) ? $obj->account_status : -1;
$this->received = (isset($obj->received)) ? $obj->received : -1;
if ($this->errno !== 0 && $this->errstr !== null && $this->comment === null)
$this->comment = '*** ' . $this->errstr . ' Antispam service cleantalk.org ***';
}
}

}
?>
60 changes: 60 additions & 0 deletions CleanTalk/lib/CleanTalk/ApbctXF2/Cron.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace CleanTalk\ApbctXF2;

class Cron extends \CleanTalk\Common\Cron {

public function saveTasks($tasks)
{
$cron_option_name = $this->cron_option_name;
if (isset(\CleanTalk\ApbctXF2\Funcs::getXF()->options()->$cron_option_name)) {
\CleanTalk\ApbctXF2\Funcs::getXF()->repository('XF:Option')->updateOption($cron_option_name, json_encode(array('last_start' => time(), 'tasks' => $tasks)));
}
}

/**
* Getting all tasks
*
* @return array
*/
public function getTasks()
{
// TODO: Implement getTasks() method.
$cron_option_name = $this->cron_option_name;
if (isset(\CleanTalk\ApbctXF2\Funcs::getXF()->options()->$cron_option_name)) {
$cron = json_decode(\CleanTalk\ApbctXF2\Funcs::getXF()->options()->$cron_option_name,true);
return (!empty($cron) && isset($cron['tasks'])) ? $cron['tasks'] : null;
}
return null;
}

/**
* Save option with tasks
*
* @return int timestamp
*/
public function getCronLastStart()
{
$cron_option_name = $this->cron_option_name;
if (isset(\CleanTalk\ApbctXF2\Funcs::getXF()->options()->$cron_option_name)) {
$cron = json_decode(\CleanTalk\ApbctXF2\Funcs::getXF()->options()->$cron_option_name,true);
return (!empty($cron) && isset($cron['last_start'])) ? $cron['last_start']: 0;
}
return 0;
}

/**
* Save timestamp of running Cron.
*
* @return bool
*/
public function setCronLastStart()
{
$cron_option_name = $this->cron_option_name;
if (isset(\CleanTalk\ApbctXF2\Funcs::getXF()->options()->$cron_option_name)) {
\CleanTalk\ApbctXF2\Funcs::getXF()->repository('XF:Option')->updateOption($cron_option_name, json_encode(array('last_start' => time(), 'tasks' => $this->getTasks())));
return true;
}
return false;
}
}
Loading

0 comments on commit 2b3ce48

Please sign in to comment.