Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Access-Control-Allow-Origin: *');
- header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
- header('Access-Control-Allow-Headers: Origin, Content-Type, Accept, Authorization, X-Request-With');
- header('Access-Control-Allow-Credentials: true');
- $verified=false;
- $ip= ip2long($_SERVER['REMOTE_ADDR']);
- $headers=getallheaders();
- $signature=$headers['User-Agent'];
- if(strpos($signature,'Bitbucket-Webhooks')!==false)
- $verified=true;
- // Bitbucket IPs
- $ip1= ip2long('34.198.178.64');
- $ip2= ip2long('34.198.203.127');
- $ip3= ip2long('34.198.32.85');
- $ip4_from= ip2long('104.192.136.0');
- $ip4_to= ip2long('104.192.143.255');
- if($verified || $ip==$ip1 || $ip==$ip2 || $ip== $ip3 || ( $ip>$ip4_from && $ip< $ip4_to)){
- $dir=dirname(__FILE__);
- $type=substr(dirname(__FILE__),-3);
- if($type=='app')
- $branch='production';
- else if($type=='dev')
- $branch='master';
- exec("cd ".$dir,$output) ;
- exec("/usr/bin/git reset --hard",$output);
- print_r($output);
- exec("/usr/bin/git pull origin ".$branch." 2>&1",$output);
- print_r($output);
- }
- else{
- echo 'Error. Unknown IP';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement