This repository has been archived by the owner on Jun 25, 2020. It is now read-only.
forked from rbraband/LouCes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
igm.php
98 lines (82 loc) · 3.05 KB
/
igm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/*
PHPLoU_bot - an LoU bot writen in PHP
Copyright (C) 2012 Roland Braband / rbraband
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
define('IGMPART', 2950);
class Igm {
private $lou;
static function factory($lou) {
// New Igm Object
$igm = new Igm($lou);
// Return the object
return $igm;
}
public function __construct($lou) {
$this->lou =& $lou;
}
public function send($target, $subject, $body, $maxlength = 3000) {
$length = IGMPART;
$maxlength = abs((int)$maxlength);
$rounded = ceil(strlen($body) / $length) -1;
if(strlen($body) > $maxlength) {
$texts = array();
$parts = $rounded + 1;
for($i = 0; $i <= $rounded; $i++) {
$texts[$i] .= preg_replace("/^(.{1,$length})(\n.*|$)/s", '\\1', $body);
$part = $i+1;
$body = substr($body, strlen($texts[$i]));
if ($part != 1) $texts[$i] = "✂ - - - - -\n" . $texts[$i];
$texts[$i] .= "\n\nTeil: [i]{$part}/{$parts}[/i]";
$subjects = $subject." - Teil: {$part}";
$this->doSendMsg($target, $subjects, $texts[$i]);
}
} else $this->doSendMsg($target, $subject, $body);
$ok = ($this->stack) ? @$this->stack : null;
if($ok === true) {
$this->output("LoU send igm");
return true;
}
return false;
}
private function doSendMsg($target, $title, $message, $cc = '') {
$bulk = (count(explode(";", $target)) > 1 || !empty($cc)) ? true : false;
if ($bulk) {
$d = array(
"session" => $this->session,
"targets" => $target,
"subject" => $title,
"ccTargets" => $cc,
"body" => $message
);
$this->get("IGMBulkSendMsg", $d);
} else {
$d = array(
"session" => $this->session,
"target" => $target,
"subject" => $title,
"ccTargets" => "",
"body" => $message
);
$this->get("IGMSendMsg", $d);
}
}
public function __call($name, $args) {
return call_user_func_array(array($this->lou, $name), $args);
//return $this->lou->$name($args);
}
static function __callStatic($name, $args) {
return call_user_func_array("Lou::$name", $args);
//return Lou::$name($args);
}
public function __set($name, $val) {
$this->lou->$name = $val;
}
public function __get($name) {
return $this->lou->$name;
}
}
?>