-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathslack.php
115 lines (112 loc) · 3.78 KB
/
slack.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?PHP
include_once('/var/www/secure.php');
include_once('bots.php');
function slack_general_admin($msg,$room){
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
//if ($ip == '69.250.28.138'){
// return 'developer';
// die();
//}
global $slack_api;
global $time_on_site;
$room = str_replace("'",'-',strtolower(str_replace(' ','-',$room)));
$thisroom = $room;
$add = "[".$time_on_site." seconds]";
//$add = "[".$ip."][".$_SERVER['HTTP_USER_AGENT']."][".$_SERVER['PHP_SELF']."] ";
$msg = $add.$msg;
//$msg = str_replace('http://','_______',$msg);
//$msg = str_replace('https://','________',$msg);
//$msg = str_replace('.net','____',$msg);
//$msg = str_replace('.com','____',$msg);
$msg = urlencode($msg);
$token = $slack_api;
if (isset($_COOKIE['name'])){
$name = str_replace("'",'-',strtolower(str_replace(' ','-',$_COOKIE['name'])));
}else{
$name = '';
}
/*
$url = "https://slack.com/api/channels.create?token=$token&name=$thisroom&pretty=1";
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt ($curl, CURLOPT_TIMEOUT,"2");
curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("McGuire/%d.0",rand(18,40)));
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
$html = curl_exec ($curl);
curl_close ($curl);
*/
$url = "https://slack.com/api/chat.postMessage?token=$token&channel=$thisroom&text=$msg";
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt ($curl, CURLOPT_TIMEOUT,"2");
curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("McGuire/%d.0",rand(18,40)));
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
$html = curl_exec ($curl);
curl_close ($curl);
if (empty($html)){
//return $url;
}
//return $html;
}
function slack_general($msg,$room){
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
//if ($ip == '69.250.28.138'){
// return 'developer';
// die();
//}
global $time_on_site;
global $slack_api;
$room = str_replace("'",'-',strtolower(str_replace(' ','-',$room)));
$thisroom = $room;
$add = "[".$time_on_site." seconds][".$ip."][".$_SERVER['HTTP_USER_AGENT']."][".$_SERVER['PHP_SELF']."] ";
$msg = $add.$msg;
//$msg = str_replace('http://','_______',$msg);
//$msg = str_replace('https://','________',$msg);
//$msg = str_replace('.net','____',$msg);
//$msg = str_replace('.com','____',$msg);
$msg = urlencode($msg);
$token = $slack_api;
if (isset($_COOKIE['name'])){
$name = str_replace("'",'-',strtolower(str_replace(' ','-',$_COOKIE['name'])));
}else{
$name = '';
}
/*
$url = "https://slack.com/api/channels.create?token=$token&name=$thisroom&pretty=1";
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt ($curl, CURLOPT_TIMEOUT,"2");
curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("McGuire/%d.0",rand(18,40)));
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
$html = curl_exec ($curl);
curl_close ($curl);
*/
$url = "https://slack.com/api/chat.postMessage?token=$token&channel=$thisroom&text=$msg";
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt ($curl, CURLOPT_TIMEOUT,"2");
curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("McGuire/%d.0",rand(18,40)));
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
$html = curl_exec ($curl);
curl_close ($curl);
if (empty($html)){
//return $url;
}
//return $html;
}