SHARE
TWEET

ppdemo_gf_external

globiws Mar 5th, 2019 (edited) 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. // private labels GlobiFlow external link flow on your own domain
  4. // eg https://www.globiflow.com/external.php?l=xxxxxxxxx
  5. // expects to be in a sub-directory /gf and called the same way
  6. // eg http://yourdomain.com/gf/?l=xxxxxxxx
  7.  
  8. // make sure the server supports CURL
  9. if ( ! function_exists("curl_init") ) die("This server does not support CURL");
  10.  
  11. // direct call - ajax not set - show template page
  12. if ( ! isset($_GET['ajax']) ) {
  13.     include(__DIR__."/page.html");
  14.     $l = (isset($_GET['l'])?(urlencode($_GET['l'])):(""));
  15.     echo '<noscript>';
  16.     echo '<p>This site requires Javascript. Else <a href="http://http://www.globiflow.com/external.php?l='.$l.'">click here</a>.</p>';
  17.     echo '</noscript>';
  18.     echo '<script>';
  19.     echo 'Http = new XMLHttpRequest();';
  20.     echo 'xnow = new Date().getTime();';
  21.     echo 'url="/gf/?ajax=1&l='.$l.'&cb="+xnow;'; // cb is for cache busting because some nginx hosts auto-cache
  22.     echo 'Http.open("GET", url);';
  23.     echo 'Http.send();';
  24.     echo 'Http.onreadystatechange=(e)=>{';
  25.     echo '  document.getElementById("gfcontent").innerHTML = Http.responseText';
  26.     echo '}';
  27.     echo '</script>';
  28.     exit();
  29. }
  30.  
  31. // ajax flag has been passed so fetch the page from GF
  32. if ( ! isset($_GET['l']) || empty($_GET['l']) ) {
  33.     $msg = "<p>Error: Invalid Link</p>";
  34. } else {
  35.     $url = "https://www.globiflow.com/external.php?l=".$_GET['l'];
  36.     $ret = curl_get_url($url);
  37.     $msg = get_string_between($ret,
  38.         'document.getElementById("foo2").innerHTML="";</script>',
  39.         '<br><div style="font-size:10px; color: #aaa;">Powered by <a href="https://www.globiflow.com" style="color:#aaa" target="_blank">GlobiFlow for Podio</a>.</div>');
  40.     if ( empty($msg) ) $msg = '<p>Ooops - something unexpected went wrong.</p>';
  41.     else $msg = '<div>' . $msg; // above get_between leaves a closing div on end
  42. }
  43.  
  44. // output result
  45. echo $msg;
  46. exit();
  47.  
  48. // some helper functions below
  49.  
  50. function get_string_between($string, $start, $end){
  51.     $string = ' ' . $string;
  52.     $ini = strpos($string, $start);
  53.     if ($ini == 0) return '';
  54.     $ini += strlen($start);
  55.     $len = strpos($string, $end, $ini) - $ini;
  56.     return substr($string, $ini, $len);
  57. }
  58.  
  59. function curl_get_url($url) {
  60.     $crl = curl_init();
  61.     curl_setopt ($crl, CURLOPT_URL, $url);
  62.     curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
  63.     curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, 30);
  64.     curl_setopt ($crl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
  65.     $ret = curl_exec($crl);
  66.     if ( curl_errno($crl) ) {
  67.         die("CURL ERROR " . curl_errno($crl) . " - " . curl_error($crl));
  68.     }
  69.     curl_close($crl);
  70.     return $ret;
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top