-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.php
89 lines (87 loc) · 2.25 KB
/
process.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
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('span[id="filename"]').click(function() {
$(this).next("#files").slideToggle('slow');
});
});
</script>
<style>
body {
padding: 0px;
margin: 0px;
}
#added {
background-color: #ddffde;
display: block;
padding-left: 4px;
}
#deleted {
background-color: #ffdddc;
display: block;
padding-left: 4px;
}
#nochange {
display: block;
padding-left: 4px;
}
#filename {
display: block;
border-top: 1px dashed;
padding-left: 4px;
cursor:pointer;
}
#filename:hover {
background-color: #EDEDED;
}
#filename a {
float: right;
text-decoration: none;
color: red;
border-left: 1px solid black;
padding-left: 4px;
padding-right: 4px;
}
#files {
font-size: 9pt;
padding: 0px;
display: none;
background-color: #FAFAFA;
}
</style>
</head>
<body>
<?php
$urlbase = "http://github.com/api/v2/json/commits/show";
$username = htmlspecialchars(stripslashes(addslashes($_POST['username'])));
$project = htmlspecialchars(stripslashes(addslashes($_POST['projectname'])));
$hash = htmlspecialchars(stripslashes(addslashes($_POST['hash'])));
$urlfull = preg_replace("/ /", "-", "$urlbase/$username/$project/$hash");
$response = get_headers($urlfull);
if ( $response[0] == "HTTP/1.1 404 Not Found") {
die("<center><br><br>somthing went wrong. did you enter the right info?<br><br>$response[0]<br>username - $username<br>project - $project<br>hash - $hash<br><br>$urlfull</center>");
}
else {
echo "username: $username | project name: $project <br>";
$contents = file_get_contents($urlfull);
$decode = json_decode($contents);
$getfilecount = count($decode->commit->modified);
for ($i = 0; $i <= $getfilecount - 1; $i++) {
$filename = $decode->commit->modified[$i]->filename;
$diff = $decode->commit->modified[$i]->diff;
$lines = explode("\n", $diff);
echo "<span id=\"filename\">$filename</span><div id=\"files\"><pre>";
foreach ($lines as $line) {
$getsymbol = substr($line, 0, 1);
if ($getsymbol == "+") { echo "<span id=\"added\">$line</span>"; }
else if ($getsymbol == "-") { echo "<span id=\"deleted\">$line</span>"; }
else { echo "<span id=\"nochange\">$line</span>"; }
}
echo "</pre></div>";
}
}
?>
</body>
</html>