Commit | Line | Data |
---|---|---|
5a3e5203 PM |
1 | <?PHP |
2 | include_once('/var/www/secure.php'); | |
3 | function slack_general($msg,$room){ | |
4 | global $slack_api; | |
5 | $room = str_replace("'",'-',strtolower(str_replace(' ','-',$room))); | |
6 | $thisroom = $room; | |
7 | $add = "[".$_SERVER['PHP_SELF']."] "; | |
8 | ||
9 | $msg = $add.$msg; | |
10 | //$version = "[".getenv('RELEASE')."] "; | |
11 | //$msg = $version.$msg; | |
12 | $msg = str_replace('http://','_______',$msg); | |
13 | $msg = str_replace('https://','________',$msg); | |
14 | $msg = str_replace('.net','____',$msg); | |
15 | $msg = str_replace('.com','____',$msg); | |
16 | $msg = urlencode($msg); | |
17 | $token = $slack_api; | |
18 | ||
19 | if (isset($_COOKIE['name'])){ | |
20 | $name = str_replace("'",'-',strtolower(str_replace(' ','-',$_COOKIE['name']))); | |
21 | }else{ | |
22 | $name = ''; | |
23 | } | |
24 | /* | |
25 | $url = "https://slack.com/api/channels.create?token=$token&name=$thisroom&pretty=1"; | |
26 | $curl = curl_init(); | |
27 | curl_setopt ($curl, CURLOPT_URL, $url); | |
28 | curl_setopt ($curl, CURLOPT_TIMEOUT,"2"); | |
29 | curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("McGuire/%d.0",rand(18,40))); | |
30 | curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); | |
31 | curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0); | |
32 | $html = curl_exec ($curl); | |
33 | curl_close ($curl); | |
34 | */ | |
35 | ||
36 | ||
37 | $url = "https://slack.com/api/chat.postMessage?token=$token&channel=$thisroom&text=$msg"; | |
38 | $curl = curl_init(); | |
39 | curl_setopt ($curl, CURLOPT_URL, $url); | |
40 | curl_setopt ($curl, CURLOPT_TIMEOUT,"2"); | |
41 | curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("McGuire/%d.0",rand(18,40))); | |
42 | curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); | |
43 | curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0); | |
44 | $html = curl_exec ($curl); | |
45 | curl_close ($curl); | |
46 | if (empty($html)){ | |
47 | return $url; | |
48 | } | |
49 | return $html; | |
50 | } |