space vs tabs

This commit is contained in:
Sándor 2021-01-31 21:10:13 +01:00
parent a38d02a0f7
commit 64792c630f
1 changed files with 79 additions and 79 deletions

View File

@ -3,41 +3,41 @@
class ninjaMail class ninjaMail
{ {
private $host; private $host;
private $key; private $key;
public $data; public $data;
public function __construct($host, $key = false) public function __construct($host, $key = false)
{ {
$this->host = $host; $this->host = $host;
if ($key) $this->key = $key; if ($key) $this->key = $key;
} }
public function check() public function check()
{ {
if (!$this->host || !$this->key) if (!$this->host || !$this->key)
return false; return false;
return true; return true;
} }
public function process($f, $data, $post_method = true) public function process($f, $data, $post_method = true)
{ {
$ch = curl_init($this->host.'/a/'.$f.'/?key='.$this->key); $ch = curl_init($this->host.'/a/'.$f.'/?key='.$this->key);
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8'); curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$data = curl_exec($ch); $data = curl_exec($ch);
curl_close($ch); curl_close($ch);
$data = @(object)json_decode($data); $data = @(object)json_decode($data);
$this->data = $data; $this->data = $data;
return $data; return $data;
} }
public function login() public function login()
{ {
return $this->process('login', ['rkey' => md5(time().rand(0,65500).rand(0,10))]); return $this->process('login', ['rkey' => md5(time().rand(0,65500).rand(0,10))]);
} }
} }
@ -53,33 +53,33 @@ class ninjaMailSend extends ninjaMail
public function to($to) public function to($to)
{ {
$this->to = $to; $this->to = $to;
return true; return true;
} }
public function subject($s) public function subject($s)
{ {
$this->subject = $s; $this->subject = $s;
return true; return true;
} }
public function message($m, $t = false) public function message($m, $t = false)
{ {
$this->message = $m; $this->message = $m;
if (!$t) $this->message_text = trim(strip_tags($m)); if (!$t) $this->message_text = trim(strip_tags($m));
else $this->message_text = $t; else $this->message_text = $t;
return true; return true;
} }
public function send() public function send()
{ {
$post = [ $post = [
'to' => $this->to, 'to' => $this->to,
'subject' => $this->subject, 'subject' => $this->subject,
'message' => $this->message, 'message' => $this->message,
'message_text' => $this->message_text 'message_text' => $this->message_text
]; ];
return $this->process('send', $post, true)->status == 'message_queued' ? true : false; return $this->process('send', $post, true)->status == 'message_queued' ? true : false;
} }
} }
@ -93,45 +93,45 @@ class ninjaMailSubscription extends ninjaMail
public function list($id) public function list($id)
{ {
if (is_numeric($id)) if (is_numeric($id))
{ {
$this->list = $id; $this->list = $id;
return true; return true;
} }
return false; return false;
} }
public function activated($s) public function activated($s)
{ {
if ($s) $this->activated = 1; if ($s) $this->activated = 1;
else $this->activated = 0; else $this->activated = 0;
return true; return true;
} }
public function subscribe($email, $name = '') public function subscribe($email, $name = '')
{ {
if (!$this->list || !is_numeric($this->activated)) if (!$this->list || !is_numeric($this->activated))
return false; return false;
$post = [ $post = [
'list' => $this->list, 'list' => $this->list,
'name' => $name, 'name' => $name,
'email' => $email, 'email' => $email,
'activated' => $this->activated 'activated' => $this->activated
]; ];
return $this->process('subscribe', $post, true)->status == 'success' ? true : false; return $this->process('subscribe', $post, true)->status == 'success' ? true : false;
} }
public function unsubscribe($email) public function unsubscribe($email)
{ {
if (!$this->list) if (!$this->list)
return false; return false;
$post = [ $post = [
'list' => $this->list, 'list' => $this->list,
'email' => $email 'email' => $email
]; ];
return $this->process('unsubscribe', $post, true)->status == 'success' ? true : false; return $this->process('unsubscribe', $post, true)->status == 'success' ? true : false;
} }
} }
@ -158,16 +158,16 @@ class ninjaMailNewsletter extends ninjaMail
public function subject($s) public function subject($s)
{ {
$this->subject = $s; $this->subject = $s;
return true; return true;
} }
public function message($m, $t = false) public function message($m, $t = false)
{ {
$this->message = $m; $this->message = $m;
if (!$t) $this->message_text = trim(strip_tags($m)); if (!$t) $this->message_text = trim(strip_tags($m));
else $this->message_text = $t; else $this->message_text = $t;
return true; return true;
} }
public function query($update = false) public function query($update = false)
@ -176,8 +176,8 @@ class ninjaMailNewsletter extends ninjaMail
return false; return false;
$post = [ $post = [
'new' => true, 'new' => true,
'id' => $update ? $this->newsletter : false, 'id' => $update ? $this->newsletter : false,
'subject' => $this->subject, 'subject' => $this->subject,
'message' => $this->message, 'message' => $this->message,
'message_text' => $this->message_text 'message_text' => $this->message_text
@ -211,7 +211,7 @@ class ninjaMailNewsletter extends ninjaMail
$post = [ $post = [
'send' => true, 'send' => true,
'id' => $this->newsletter, 'id' => $this->newsletter,
'start' => $time ? $time : 0 'start' => $time ? $time : 0
]; ];
$data = $this->process('newsletter', $post, true); $data = $this->process('newsletter', $post, true);
@ -291,7 +291,7 @@ class ninjaMailCampaign extends ninjaMail
$post = [ $post = [
'relations' => true, 'relations' => true,
'id' => $this->campaign, 'id' => $this->campaign,
'newsletter' => $newsletter 'newsletter' => $newsletter
]; ];
return $this->process('campaign', $post, true)->status == 'success' ? true : false; return $this->process('campaign', $post, true)->status == 'success' ? true : false;