Skip to content

Commit

Permalink
Merge pull request #3 from VladCleantalk/master
Browse files Browse the repository at this point in the history
added logging
  • Loading branch information
CleanTalk committed Jan 25, 2016
2 parents 0ecdbaf + 3d62986 commit dd79bc8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cleantalk/cleantalk.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function cleantalk_config() {
$configarray = array(
"name" => "CleanTalk anti-spam addon",
"description" => 'Protect your website against spam bots. Anti-spam for comments, registrations, orders, bookings and contacts. <a href="http://cleantalk.org/publicoffer">License agreement</a>.',
"version" => "1.0",
"version" => "1.1",
"author" => "CleanTalk",
"language" => "english",
"fields" => array(
Expand Down
41 changes: 38 additions & 3 deletions cleantalk/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@

require_once(dirname(__FILE__)."/JSON.php");
require_once(dirname(__FILE__)."/cleantalk.class.php");
define("CLEANTALK_LOG", false);

function cleantalk_addlog($message)
{
if(CLEANTALK_LOG)
{
$command = "logactivity";
$adminuser = "admin";
$values["description"] = $message;
$results = localAPI($command,$values,$adminuser);
}
}

function send_request($url,$data,$isJSON)
{
Expand Down Expand Up @@ -65,17 +77,18 @@ function send_request($url,$data,$isJSON)

function cleantalk_hook_order($vars)
{
//addlog("activate!");
cleantalk_addlog("Hooked order activation");

$command = "getorders";
$values=Array();
$values["id"] = $vars['orderid'];
$values["responsetype"] = "json";
$result = localAPI($command,$values);
//addlog("result:\n".print_r($result,true)."\n\n");
cleantalk_addlog("Called GetOrders");

if($result['result']=='success')
{
cleantalk_addlog("API call success");
$userid=$result['orders']['order'][0]['userid'];
$items=$result['orders']['order'][0]['lineitems']['lineitem'];
$is_cleantalk=false;
Expand All @@ -91,17 +104,38 @@ function cleantalk_hook_order($vars)
$is_cleantalk=true;
}
}
if($domain!=''&&$is_cleantalk)
if($is_cleantalk)
{
cleantalk_addlog("CleanTalk added to order");
}
else
{
cleantalk_addlog("CleanTalk not added to order");
}
if($domain=='')
{
cleantalk_addlog("Domain not added!");
}
else
{
cleantalk_addlog("Domain added!");
}

//if($domain!=''&&$is_cleantalk)
if($is_cleantalk)
{
$command = "getclientsdetails";
$values["clientid"] = $userid;
$values["stats"] = true;
$values["responsetype"] = "json";
$uresult = localAPI($command,$values);
//addlog("uresult:\n".print_r($uresult,true)."\n\n");
cleantalk_addlog("Called GetClientsDetails");
if($uresult['result']=='success')
{
cleantalk_addlog("API call success");
$email=$uresult['client']['email'];
cleantalk_addlog("User email: ".$email);

$cfg=full_query("SELECT value from tbladdonmodules where module='cleantalk' and setting='partner_api_key'");
$cfg=mysql_fetch_array($cfg);
Expand All @@ -117,6 +151,7 @@ function cleantalk_hook_order($vars)
$data['hoster_api_key'] = $cfg['value'];
$data['locale'] = 'en-US';
$auth=send_request($url,$data,false);
cleantalk_addlog("Sending request to CleanTalk servers");
if($auth!==null)
{
$auth=json_decode($auth);
Expand Down

0 comments on commit dd79bc8

Please sign in to comment.