Commit: 8724f9674722fed9060c044d5df6504f4db8d4ff Author: Nikita Popov <[email protected]> Wed, 21 Dec 2016 23:21:04 +0100 Parents: 6bd9ac552a382e63a14a4e03e9d91497a40b5bc0 Branches: master
Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=8724f9674722fed9060c044d5df6504f4db8d4ff Log: Retab file Changed paths: M github-webhook.php Diff: diff --git a/github-webhook.php b/github-webhook.php index e2ebd35..b1e7210 100644 --- a/github-webhook.php +++ b/github-webhook.php @@ -1,10 +1,10 @@ <?php function verify_signature($requestBody) { - if (isset($_SERVER['HTTP_X_HUB_SIGNATURE'])){ - $sig = 'sha1=' . hash_hmac('sha1', $requestBody, getenv('GITHUB_SECRET')); - return $sig === $_SERVER['HTTP_X_HUB_SIGNATURE']; - } - return false; + if (isset($_SERVER['HTTP_X_HUB_SIGNATURE'])){ + $sig = 'sha1=' . hash_hmac('sha1', $requestBody, getenv('GITHUB_SECRET')); + return $sig === $_SERVER['HTTP_X_HUB_SIGNATURE']; + } + return false; } function get_repo_email($repos, $repoName) { @@ -31,19 +31,19 @@ function prep_title($issue, $repoName) { $CONFIG = array( - 'repos' => array( - 'php-langspec' => '[email protected]', - 'php-src' => '[email protected]', - 'web-' => '[email protected]', - 'pecl-' => '[email protected]', - ), + 'repos' => array( + 'php-langspec' => '[email protected]', + 'php-src' => '[email protected]', + 'web-' => '[email protected]', + 'pecl-' => '[email protected]', + ), ); $body = file_get_contents("php://input"); if (!verify_signature($body)) { - header('HTTP/1.1 403 Forbidden'); - exit; + header('HTTP/1.1 403 Forbidden'); + exit; } $payload = json_decode($body); @@ -52,9 +52,9 @@ $repoName = $payload->repository->name; $event = $_SERVER['HTTP_X_GITHUB_EVENT']; switch ($event) { - case 'ping': - break; - case 'pull_request': + case 'ping': + break; + case 'pull_request': case 'issues': $issue = $event == 'issues' ? $payload->issue : $payload->pull_request; $htmlUrl = $issue->html_url; @@ -65,7 +65,7 @@ switch ($event) { $to = get_repo_email($CONFIG["repos"], $repoName); $subject = prep_title($issue, $repoName); - $message = sprintf("You can view the Pull Request on github:\r\n%s", $htmlUrl); + $message = sprintf("You can view the Pull Request on github:\r\n%s", $htmlUrl); switch ($action) { case 'opened': $message .= sprintf( @@ -90,9 +90,9 @@ switch ($event) { break 2; } - $headers = "From: [email protected]\r\nContent-Type: text/plain; charset=utf-8\r\n"; - mail($to, '=?utf-8?B?'.base64_encode($subject).'?=', $message, $headers, "[email protected]"); - break; + $headers = "From: [email protected]\r\nContent-Type: text/plain; charset=utf-8\r\n"; + mail($to, '=?utf-8?B?'.base64_encode($subject).'?=', $message, $headers, "[email protected]"); + break; case 'pull_request_review_comment': case 'issue_comment': @@ -100,11 +100,11 @@ switch ($event) { $htmlUrl = $issue->html_url; $username = $payload->comment->user->login; - $comment = $payload->comment->body; + $comment = $payload->comment->body; $to = get_repo_email($CONFIG["repos"], $repoName); $subject = prep_title($issue, $repoName); - $message = sprintf("You can view the Pull Request on github:\r\n%s", $htmlUrl); + $message = sprintf("You can view the Pull Request on github:\r\n%s", $htmlUrl); switch ($action) { case 'created': $message .= sprintf("\r\n\r\nComment by %s:\r\n%s", $username, $comment); @@ -115,11 +115,11 @@ switch ($event) { break 2; } - $headers = "From: [email protected]\r\nContent-Type: text/plain; charset=utf-8\r\n"; - mail($to, '=?utf-8?B?'.base64_encode($subject).'?=', $message, $headers, "[email protected]"); + $headers = "From: [email protected]\r\nContent-Type: text/plain; charset=utf-8\r\n"; + mail($to, '=?utf-8?B?'.base64_encode($subject).'?=', $message, $headers, "[email protected]"); break; - default: - header('HTTP/1.1 501 Not Implemented'); + default: + header('HTTP/1.1 501 Not Implemented'); } -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
