Skip to content

Instantly share code, notes, and snippets.

@roderik
Last active December 11, 2015 08:18
Show Gist options
  • Select an option

  • Save roderik/4572208 to your computer and use it in GitHub Desktop.

Select an option

Save roderik/4572208 to your computer and use it in GitHub Desktop.
<?php
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1', 'xx.xx.xx.xx'))
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file.');
}
function logToFile($filename, $msg){
// open file
$fd = fopen($filename, "a");
// append date/time to message
$str = "[" . date("Y/m/d h:i:s", mktime()) . "] " . $msg;
// write string
fwrite($fd, $str . "\n");
// close file
fclose($fd);
}
logToFile("docbuilder.log", "Payload received");
$folder=$_GET["project"];
logToFile("docbuilder.log", " - Folder: $folder");
$payload=json_decode($HTTP_RAW_POST_DATA, true);
logToFile("docbuilder.log", " - Payload: " . print_r($payload, true));
logToFile("docbuilder.log", " - Set: " . shell_exec("set 2>&1"));
$output = shell_exec('/home/projects/kumadocs/data/kumadocs/performPostRecieve.sh ' . $folder . ' ' . $payload["repository"]["url"] . ' 2>&1');
logToFile("docbuilder.log", " - Output: " . $output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment