Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // private labels GlobiFlow external link flow on your own domain
- // eg https://workflow-automation.podio.com/external.php?id=xxxxxxxxx
- // expects to be in a sub-directory /gf and called the same way
- // eg http://yourdomain.com/gf/?id=xxxxxxxx
- // make sure the server supports CURL
- if ( ! function_exists("curl_init") ) die("This server does not support CURL");
- // direct call - ajax not set - show template page
- if ( ! isset($_GET['ajax']) ) {
- include(__DIR__."/page.html");
- $id = (isset($_GET['id'])?(urlencode($_GET['id'])):(""));
- echo '<noscript>';
- echo '<p>This site requires Javascript. Else <a href="http://https://workflow-automation.podio.com/external.php?id='.$id.'">click here</a>.</p>';
- echo '</noscript>';
- echo '<script>';
- echo 'Http = new XMLHttpRequest();';
- echo 'xnow = new Date().getTime();';
- echo 'url="/gf/?ajax=1&id='.$id.'&cb="+xnow;'; // cb is for cache busting because some nginx hosts auto-cache
- echo 'Http.open("GET", url);';
- echo 'Http.send();';
- echo 'Http.onreadystatechange=(e)=>{';
- echo ' document.getElementById("gfcontent").innerHTML = Http.responseText';
- echo '}';
- echo '</script>';
- exit();
- }
- // ajax flag has been passed so fetch the page from GF
- if ( ! isset($_GET['id']) || empty($_GET['id']) ) {
- $msg = "<p>Error: Invalid Link</p>";
- } else {
- $url = "https://workflow-automation.podio.com/external.php?id=".$_GET['id'];
- $ret = curl_get_url($url);
- $msg = preg_replace('/.*?\("foo"\)[^<]*<\/script>/ism', '', $ret);
- $msg = preg_replace('/<div[^>]*>Powered by\s*<a [^>]*>Citrix Podio.*/ism', '', $msg);
- if ( empty($msg) ) $msg = '<p>Ooops - something unexpected went wrong.</p><script>console.log('.json_encode($ret).');</script>';
- else $msg = '<div>' . $msg; // above get_between leaves a closing div on end
- }
- // output result
- echo $msg;
- exit();
- // some helper functions below
- function curl_get_url($url) {
- $crl = curl_init();
- curl_setopt ($crl, CURLOPT_URL, $url);
- curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, 30);
- 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');
- $ret = curl_exec($crl);
- if ( curl_errno($crl) ) {
- die("CURL ERROR " . curl_errno($crl) . " - " . curl_error($crl));
- }
- curl_close($crl);
- return $ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement