예제 #1
0
파일: lib.php 프로젝트: yfix/deploy-webhook
function bitbucket_get_app_conf($config)
{
    $raw_payload = get_payload($raw = true);
    if (!$raw_payload) {
        return false;
    }
    $webhook_id = get_webhook_id();
    if (!preg_match('~^[a-z0-9]{32}$~ims', $webhook_id) || !isset($config['webhooks'][$webhook_id])) {
        _log('404: wrong webhook');
        return false;
    }
    $headers = getallheaders();
    $webhook_conf = $config['webhooks'][$webhook_id];
    $secret = $webhook_conf['secret'];
    if (!bitbucket_validate_payload($raw_payload, $headers, $secret)) {
        _log('403: secret not valid');
        return false;
    }
    if (!isset($webhook_conf['app']) || !isset($config['apps'][$webhook_conf['app']])) {
        _log('404: no such app');
        return false;
    }
    return $config['apps'][$webhook_conf['app']] + array('name' => $webhook_conf['app']);
}
function get_webhook_url($regenerate)
{
    $webhook = get_option('admin-url') . 'admin-ajax.php?action=remote_css_listener&remote-css-update=' . get_webhook_id($regenerate);
}