Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Last active December 15, 2015 23:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wokamoto/5342142 to your computer and use it in GitHub Desktop.
Save wokamoto/5342142 to your computer and use it in GitHub Desktop.
[PHP] github とか backlog git の web hook 用 PHP (update-website.sh と一緒に使ってね)
<?php
define('UPDATE_WEBSITE_SH', '/path/to/update-website.sh');
if (!(isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/GitHub Hookshot/i', $_SERVER['HTTP_USER_AGENT']))) {
die();
}
if (!file_exists(UPDATE_WEBSITE_SH)) {
die();
}
if ( !isset($_POST['payload']) ) {
die();
}
$payload = json_decode($_POST['payload']);
$dirname = dirname(__FILE__);
$output = exec( '/bin/sh ' . UPDATE_WEBSITE_SH . ' ' . $dirname );
echo $output . "\n";
@xeoncross
Copy link

I would really check the IP address before trusting something like this. It's a DoS dream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment