Skip to content

Commit

Permalink
1.5 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
VladCleantalk committed Nov 12, 2015
1 parent 91caf1b commit 8d87ecf
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
37 changes: 35 additions & 2 deletions CleanTalk/Base/CleanTalk.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
<?php

class CleanTalk_Base_CleanTalk {

static public function getCheckjsName() {
return 'ct_checkjs';
}

public static function hookAdminSettings(XenForo_Visitor &$visitor )
{
$options = XenForo_Application::getOptions();
if ($options->get('cleantalk', 'enabled') && sizeof($_POST)>0 && isset($_POST['options']) && isset($_POST['options']['cleantalk']))
{
require_once 'CleanTalk/Base/cleantalk.class.php';
$ct_ws = array(
'work_url' => 'http://moderate.cleantalk.org',
'server_url' => 'http://moderate.cleantalk.org',
'server_ttl' => 0,
'server_changed' => 0
);
$ct = new Cleantalk();
$ct->work_url = $ct_ws['work_url'];
$ct->server_url = $ct_ws['server_url'];
$ct->server_ttl = $ct_ws['server_ttl'];
$ct->server_changed = $ct_ws['server_changed'];

$options = XenForo_Application::getOptions();

$ct_request = new CleantalkRequest();
$ct_request->auth_key = $_POST['options']['cleantalk']['apikey'];
$ct_request->agent = 'xenforo-144';
$ct_request->response_lang = 'en';
$ct_request->js_on = 1;
$ct_request->sender_email = "good@cleantalk.org";
$ct_request->sender_nickname = "CleanTalk";
$ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
$ct_request->submit_time = 0;
$ct_request->message = "This message is a test to check the connection to the CleanTalk servers.";

$ct_result = $ct->isAllowMessage($ct_request);
}
}

/** Return Array of JS-keys for checking
*
* @return Array
Expand Down
1 change: 0 additions & 1 deletion CleanTalk/Listener/LoadClassController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

class CleanTalk_Listener_LoadClassController {

public static function loadClassListener($class, &$extend) {
Expand Down
1 change: 0 additions & 1 deletion CleanTalk/Listener/LoadClassModel.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

class CleanTalk_Listener_LoadClassModel {

public static function loadClassListener($class, &$extend) {
Expand Down
1 change: 0 additions & 1 deletion CleanTalk/Model/CleanTalk.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

class CleanTalk_Model_CleanTalk extends XFCP_CleanTalk_Model_CleanTalk {

protected function _allowRegistration(array $user, Zend_Controller_Request_Http $request) {
Expand Down
1 change: 1 addition & 0 deletions CleanTalk/addon-CleanTalk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<code_event_listeners>
<listener event_id="load_class_controller" execute_order="10" callback_class="CleanTalk_Listener_LoadClassController" callback_method="loadClassListener" active="1" hint="XenForo_ControllerPublic_Register" description="Listens for XenForo_ControllerPublic_Register class"/>
<listener event_id="load_class_model" execute_order="10" callback_class="CleanTalk_Listener_LoadClassModel" callback_method="loadClassListener" active="1" hint="XenForo_Model_SpamPrevention" description="Listens for XenForo_Model_SpamPrevention class"/>
<listener event_id="visitor_setup" execute_order="10" callback_class="CleanTalk_Base_CleanTalk" callback_method="hookAdminSettings" active="1" hint="" description="Hook settings saving"/>
</code_event_listeners>
<cron/>
<email_templates>
Expand Down
1 change: 1 addition & 0 deletions addon-CleanTalk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<code_event_listeners>
<listener event_id="load_class_controller" execute_order="10" callback_class="CleanTalk_Listener_LoadClassController" callback_method="loadClassListener" active="1" hint="XenForo_ControllerPublic_Register" description="Listens for XenForo_ControllerPublic_Register class"/>
<listener event_id="load_class_model" execute_order="10" callback_class="CleanTalk_Listener_LoadClassModel" callback_method="loadClassListener" active="1" hint="XenForo_Model_SpamPrevention" description="Listens for XenForo_Model_SpamPrevention class"/>
<listener event_id="visitor_setup" execute_order="10" callback_class="CleanTalk_Base_CleanTalk" callback_method="hookAdminSettings" active="1" hint="" description="Hook settings saving"/>
</code_event_listeners>
<cron/>
<email_templates>
Expand Down

0 comments on commit 8d87ecf

Please sign in to comment.