Last active
December 15, 2015 23:39
-
-
Save wokamoto/5342142 to your computer and use it in GitHub Desktop.
[PHP] github とか backlog git の web hook 用 PHP (update-website.sh と一緒に使ってね)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would really check the IP address before trusting something like this. It's a DoS dream.