-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.php
More file actions
65 lines (41 loc) · 1.95 KB
/
github.php
File metadata and controls
65 lines (41 loc) · 1.95 KB
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
<?php
$projectName = 'website'; // Your project name
$email = 'nguyenkain@gmail.com'; // Email address you want pull notifcations to go to
// Copy and paste the results from `passgen` here
$pass = 'e72f48d5eab95e8966116234156e0a38';
$salt = '463749292';
// End copy and paste
// Don't need to edit these lines
$remoteIP = $_SERVER['REMOTE_ADDR'];
$msg = 'Request came form '.$remoteIP.' - http://whois.arin.net/rest/ip/'.$remoteIP;
if (isset($_GET['update'])) {
// We want to update the folder with the latest from the repo
$check = md5(crypt($_GET['update'], $salt));
if ($pass === $check) {
// what does the pull, don't change the backticks (`) as it tells PHP to execute a shell command
`git pull`;
// Email to say it's successful
mail($email, '['.$projectName.'] `GIT PULL` successful', $msg);
} else {
// Email to say the pull failed (due to wrong pass)
mail($email, '['.$projectName.'] `GIT PULL` password fail', $msg);
}
} elseif (isset($_GET['passgen'])) {
// We want to generate a salt and password
$password = $_GET['passgen'];
$randSalt = (string)rand();
$generate = crypt($password, $randSalt);
$genPass = md5($generate);
$html = '<body style="width: 70%; margin: 20px auto; text-align: center; font-family: arial; line-height: 3em">';
$html .= '<p><label>Add the following code to <code>'.$_SERVER['SCRIPT_FILENAME'].'</code><br /><textarea cols="50" rows="2" style="padding: 10px">';
$html .= '$salt = \''.$randSalt.'\';'."\n";
$html .= '$pass = \''.$genPass.'\';';
$html .= '</textarea></label></p>';
$callURL = 'http';
if (isset($_SERVER['HTTPS'])) $callURL .= 's';
$callURL .= '://'.$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'].'?update='.$_GET['passgen'];
$html .= '<p><label>Add this URL your project\'s "Post-Recieve URLs"<br /><input type="text" value="'.$callURL.'" style="width: 500px; text-align: center;" /></label></p>';
echo $html;
} else {
mail($email, '['.$projectName.'] `GIT PULL` failed', $msg);
}