commit | author | age
|
8bd4d9
|
1 |
<?php |
JK |
2 |
class GGapi { |
|
3 |
const STATUS_DOSTEPNY = 'back'; |
|
4 |
const STATUS_ZAJETY = 'away'; |
|
5 |
const STATUS_NIEWIDOCZNY = 'invisible'; |
|
6 |
|
|
7 |
protected static $color = '#000000'; |
|
8 |
protected static $msg = NULL; |
|
9 |
protected static $len = 0; |
|
10 |
|
|
11 |
static function init() { |
|
12 |
if(!self::$msg) { |
|
13 |
self::$msg = new BotMsg; |
|
14 |
} |
|
15 |
} |
|
16 |
|
|
17 |
static function getLength() { |
|
18 |
return self::$len; |
|
19 |
} |
|
20 |
|
|
21 |
static function putImage($image) { |
|
22 |
self::init(); |
|
23 |
|
|
24 |
if(!file_exists($image) OR !is_readable($image)) { |
|
25 |
return FALSE; |
|
26 |
} |
|
27 |
|
|
28 |
self::$msg->a('<img src="'.htmlspecialchars($image).'" />'); |
|
29 |
|
|
30 |
return TRUE; |
|
31 |
} |
|
32 |
|
|
33 |
static function putText($text) { |
|
34 |
self::init(); |
|
35 |
|
|
36 |
self::$msg->a(nl2br(htmlspecialchars($text))); |
|
37 |
self::$len += strlen($text); |
|
38 |
|
|
39 |
return TRUE; |
|
40 |
} |
|
41 |
|
|
42 |
static function putRichText($text, $bold=FALSE, $italic=FALSE, $underline=FALSE, $R=0, $G=0, $B=0) { |
|
43 |
self::init(); |
|
44 |
|
|
45 |
self::$len += strlen($text); |
|
46 |
$text = nl2br(htmlspecialchars($text)); |
|
47 |
|
|
48 |
if($bold) { |
|
49 |
$text = '<b>'.$text.'</b>'; |
|
50 |
} |
|
51 |
if($italic) { |
|
52 |
$text = '<i>'.$text.'</i>'; |
|
53 |
} |
|
54 |
if($underline) { |
|
55 |
$text = '<u>'.$text.'</u>'; |
|
56 |
} |
|
57 |
|
|
58 |
$color = '#'.sprintf('%02x%02x%02x', $R%256, $G%256, $B%256); |
|
59 |
|
|
60 |
if($color != self::$color) { |
|
61 |
$text = '<span color="'.$color.'">'.$text.'</span>'; |
|
62 |
} |
|
63 |
|
|
64 |
self::$msg->a($text); |
|
65 |
|
|
66 |
return TRUE; |
|
67 |
} |
|
68 |
|
|
69 |
static function getResponse() { |
|
70 |
return self::$msg; |
|
71 |
} |
|
72 |
|
|
73 |
static function setStatus($status=NULL, $desc='') {} |
|
74 |
static function getStatusResponse($status=NULL, $desc='') {} |
|
75 |
static function sendResponse() {} |
|
76 |
static function antiFlood($numer=NULL) {} |
|
77 |
|
|
78 |
static function getPublicData($number=NULL) { |
|
79 |
if($number === NULL) $number = $_GET['from']; |
|
80 |
if(!ctype_digit($number)) return FALSE; |
|
81 |
|
|
82 |
$data = @file_get_contents('http://api.gadu-gadu.pl/users/'.$number.'.xml'); |
|
83 |
if(!$data) return FALSE; |
|
84 |
|
|
85 |
$data = @simplexml_load_string($data); |
|
86 |
if(!$data) return FALSE; |
|
87 |
|
|
88 |
return (array)$data->users->user; |
|
89 |
} |
|
90 |
} |
|
91 |
?> |