-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgithook.php
More file actions
executable file
·27 lines (24 loc) · 890 Bytes
/
githook.php
File metadata and controls
executable file
·27 lines (24 loc) · 890 Bytes
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
<?php
//////////////////////////
//// MAN THE HARPOONS ////
//////////////////////////
include("site/dbcreds.php");
mysql_connect("localhost",$dbuser,$dbpass);
mysql_select_db("irc");
if (!isset($_POST['payload'])) die('Not a valid hook.');
file_put_contents('payload.txt',$_POST['payload']);
$payload = json_decode($_POST['payload']);
$commits = $payload->{'commits'};
function mrse($a) {
return mysql_real_escape_string($a);
}
$repo = $payload->{'repository'}->{'name'};
foreach ($commits as $commit) {
$url = $commit->{"url"};
$name = mrse($commit->{"author"}->{"name"});
$email = mrse($commit->{"author"}->{"email"});
$commit_id = mrse($commit->{'id'});
$ts = $commit->{"timestamp"};
$message = mrse($commit->{"message"});
mysql_query("INSERT INTO commits (url,name,email,ts,message,repo,commit_id) VALUES ('$url','$name','$email','$ts','$message','$repo','$commit_id')");
}