Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2.  
  3. header('Access-Control-Allow-Origin: *');
  4. header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
  5. header('Access-Control-Allow-Headers: Origin, Content-Type, Accept, Authorization, X-Request-With');
  6. header('Access-Control-Allow-Credentials: true');
  7.  
  8.  
  9. $verified=false;
  10.  
  11. $ip= ip2long($_SERVER['REMOTE_ADDR']);
  12. $headers=getallheaders();
  13. $signature=$headers['User-Agent'];
  14.  
  15.  
  16. if(strpos($signature,'Bitbucket-Webhooks')!==false)
  17. $verified=true;
  18.  
  19. // Bitbucket IPs
  20. $ip1= ip2long('34.198.178.64');
  21. $ip2= ip2long('34.198.203.127');
  22. $ip3= ip2long('34.198.32.85');
  23. $ip4_from= ip2long('104.192.136.0');
  24. $ip4_to= ip2long('104.192.143.255');
  25.  
  26.  
  27. if($verified || $ip==$ip1 || $ip==$ip2 || $ip== $ip3 || ( $ip>$ip4_from && $ip< $ip4_to)){
  28.  
  29. $dir=dirname(__FILE__);
  30. $type=substr(dirname(__FILE__),-3);
  31.  
  32. if($type=='app')
  33. $branch='production';
  34. else if($type=='dev')
  35. $branch='master';
  36.  
  37.  
  38. exec("cd ".$dir,$output) ;
  39. exec("/usr/bin/git reset --hard",$output);
  40. print_r($output);
  41. exec("/usr/bin/git pull origin ".$branch." 2>&1",$output);
  42. print_r($output);
  43. }
  44. else{
  45. echo 'Error. Unknown IP';
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement