-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathindex.php
127 lines (112 loc) · 4.26 KB
/
index.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
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* Copyright 2015, Google, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
include "constants.php";
// Set defaults
$name = '';
$img = '';
$active = 0;
$total = 0;
// If GETINFO is set to true in constants.php,
// get the name and image from the Slack API
if($GETINFO){
$slackUrl = 'https://'.SUBDOMAIN.'.slack.com/api/rtm.start?simple_latest=true&no_unreads=true&token='.TOKEN;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $slackUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$reply = json_decode(curl_exec($ch), true);
curl_close($ch);
// Get team data from slack
if($reply['ok']){
$img = $reply['team']['icon']['image_68'];
$name = $reply['team']['name'];
foreach($reply['users'] as $val) {
$total = $total + 1;
if('active' == $val['presence']) {
$active = $active + 1;
}
}
}
} else {
$name = NAME;
$img = IMAGE;
}
?>
<html>
<head>
<title>Join <?php echo $name; ?> on Slack!</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,user-scalable=no">
<link rel="shortcut icon" href="https://slack.global.ssl.fastly.net/272a/img/icons/favicon-32.png">
<link rel="stylesheet" href="style.css" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<div style="text-align: center; margin-top: 75px">
<div style="margin-bottom: 40px;">
<img src="<?php echo $img; ?>" class="logo" />
<span class="plus">+</span>
<img src="https://upload.wikimedia.org/wikipedia/commons/7/76/Slack_Icon.png" class="logo" />
</div>
<div style="margin:5px;">Join <b><?php echo $name; ?></b> on Slack.</div>
<?php
// Display Active User Counts if GETINFO is active
if($GETINFO){
echo '<div style="margin:5px;"> <b style="color: #E01563;">';
echo $active;
echo '</b> users online now of <b>';
echo $total;
echo '</b> registered.</div>';
} else {
echo '<div style="margin:5px;"> Join over <b>';
echo USERCOUNT;
echo '+</b> users.';
}
?>
<form class="form" id="user_info" action="signup.php" method="POST">
<input type="email" class="form-item" placeholder="[email protected]" autofocus="true" name="email">
<button class="button form-item" id='button' type="submit"> Get my Invite </button>
<p class="muted"> <a href="https://<?php echo SUBDOMAIN; ?>.slack.com">Already have an account? Click here to go to Slack.<a> </p>
<div class="g-recaptcha" data-sitekey="<?php echo SITEKEY; ?>"></div>
<p class="muted note"> <b>Note:</b> <?php echo NOTE; ?></p>
</form>
</div>
<script>
$('#user_info').submit(function(e) {
e.preventDefault();
var button = document.getElementById('button');
button.style.background = "#D6D6D6";
button.innerHTML = "Please Wait...";
$this = $(this);
$.ajax({
type: "POST",
url: "signup.php",
data: $this.serialize()
}).done(function(response) {
response = JSON.parse(response);
if(response.ok)
button.style.background = "#68C200";
else
button.style.background = "#F4001E";
button.innerHTML = response.message;
}).fail(function( jqXHR, textStatus ) {
button.style.background = "#F4001E";
button.innerHTML = "Backend Failure"
});
});
</script>
</body>
<footer><a href="https://github.com/thesandlord/SlackEngine">SlackEngine</a>, powered by <a href="https://cloud.google.com/appengine/" target="_blank">App Engine</a></footer>
</html>