-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathslack.php
80 lines (79 loc) · 2.58 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
<?PHP
include_once('/var/www/secure.php');
function slack_bypass($msg,$room){
global $slack_api;
$room = str_replace("'",'-',strtolower(str_replace(' ','-',$room)));
$thisroom = $room;
$msg = urlencode($msg);
$token = $slack_api;
$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'];
}
global $slack_api;
$room = str_replace("'",'-',strtolower(str_replace(' ','-',$room)));
$thisroom = $room;
/*
if ($ip != '69.250.28.138'){
if (isset($_SERVER['HTTP_USER_AGENT'])){
$add = "[".$ip."][".$_SERVER['HTTP_USER_AGENT']."][".$_SERVER['PHP_SELF']."] ";
}else{
header('Location: callback.php?msg=Missing HTTP_USER_AGENT');
}
$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;
}