コード例 #1
0
function cc_whmcs_bridge_output($page = null)
{
    global $post;
    global $wpdb;
    global $wordpressPageName;
    global $cc_whmcs_bridge_loaded, $cc_whmcs_bridge_to_include;
    $ajax = false;
    $ref = rand(100, 999);
    cc_whmcs_log(0, '[URL ' . $ref . '] Remote fetch started');
    // contribution northgatewebhosting.co.uk
    if (isset($post)) {
        $post_id = $post->ID;
    } else {
        $post_id = 1;
    }
    // contribution northgatewebhosting.co.uk
    $cf = get_post_custom($post_id);
    if ($page) {
        $cc_whmcs_bridge_to_include = $page;
    } elseif (isset($_REQUEST['ccce']) && (isset($_REQUEST['ajax']) && $_REQUEST['ajax'])) {
        $cc_whmcs_bridge_to_include = $_REQUEST['ccce'];
        $ajax = intval($_REQUEST['ajax']);
    } elseif (isset($_REQUEST['ccce'])) {
        $cc_whmcs_bridge_to_include = $_REQUEST['ccce'];
    } elseif (isset($cf['cc_whmcs_bridge_page']) && $cf['cc_whmcs_bridge_page'][0] == WHMCS_BRIDGE_PAGE) {
        $cc_whmcs_bridge_to_include = "index";
    } else {
        $cc_whmcs_bridge_to_include = "index";
    }
    $http = cc_whmcs_bridge_http($cc_whmcs_bridge_to_include);
    cc_whmcs_log(0, '[URL ' . $ref . '] HTTP Request initiated');
    $news = new bridgeHttpRequest($http, 'whmcs-bridge-sso');
    $news->debugFunction = 'cc_whmcs_log';
    if (function_exists('cc_whmcs_bridge_sso_httpHeaders')) {
        $news->httpHeaders = cc_whmcs_bridge_sso_httpHeaders($news->httpHeaders);
    }
    if (isset($news->post['whmcsname'])) {
        $news->post['name'] = $news->post['whmcsname'];
        unset($news->post['whmcsname']);
    }
    $news = apply_filters('bridge_http', $news);
    cc_whmcs_log(0, '[URL ' . $ref . '] Filters applied');
    $news->forceWithRedirect['systpl'] = get_option('cc_whmcs_bridge_template') ? get_option('cc_whmcs_bridge_template') : 'five';
    if (!function_exists('cc_whmcs_bridge_parser_with_permalinks') && !in_array($news->forceWithRedirect['systpl'], array('portal', 'five'))) {
        $news->forceWithRedirect['systpl'] = 'five';
    }
    if ($cc_whmcs_bridge_to_include == 'dologin') {
        $news->post['rememberme'] = 'on';
    }
    cc_whmcs_log(0, '[URL ' . $ref . '] Filters applied [2]');
    if (!$news->curlInstalled()) {
        cc_whmcs_log('Error', 'CURL not installed');
        return "cURL not installed";
    } elseif (!$news->live()) {
        cc_whmcs_log('Error', 'A HTTP Error occurred');
        return "A HTTP Error occurred";
    } else {
        //@cc_whmcs_log(0, '[URL '.$ref.'] Headers: '.$news->headers['content-type'].' - Disposition: '.$news->headers['content-disposition']);
        cc_whmcs_log(0, '[URL ' . $ref . '] Processing...');
        if ($cc_whmcs_bridge_to_include == 'verifyimage' || isset($_REQUEST['showqrimage']) && $_REQUEST['showqrimage'] == 1 || isset($_REQUEST['js']) && (stristr($_REQUEST['js'], '.jpg') !== false || stristr($_REQUEST['js'], '.png') !== false || stristr($_REQUEST['js'], '.jpeg') !== false || stristr($_REQUEST['js'], '.gif') !== false)) {
            $output = $news->DownloadToString();
            while (count(ob_get_status(true)) > 0) {
                ob_end_clean();
            }
            header("Content-Type: image");
            echo $news->body;
            die;
        } elseif (stristr($cc_whmcs_bridge_to_include, 'announcementsrss') !== false || stristr($cc_whmcs_bridge_to_include, 'networkissuesrss') !== false) {
            while (count(ob_get_status(true)) > 0) {
                ob_end_clean();
            }
            $output = $news->DownloadToString();
            header('Content-Type: application/rss+xml; charset=utf-8');
            echo $news->body;
            die;
        } elseif ($cc_whmcs_bridge_to_include == 'dl' || isset($_REQUEST['a']) && $_REQUEST['a'] == 'CreateEmailAccount' || stristr($cc_whmcs_bridge_to_include, 'wbteampro') !== false && isset($_REQUEST['view']) && $_REQUEST['view'] == 'raw' || stristr($cc_whmcs_bridge_to_include, 'wbteampro') !== false && isset($_REQUEST['act']) && $_REQUEST['act'] == 'download' || stristr($cc_whmcs_bridge_to_include, 'project_management') !== false && isset($_REQUEST['action']) && $_REQUEST['action'] == 'dl' || stristr($cc_whmcs_bridge_to_include, 'project_management') !== false && stristr($cc_whmcs_bridge_to_include, '.css') !== false) {
            while (count(ob_get_status(true)) > 0) {
                ob_end_clean();
            }
            $output = $news->DownloadToString();
            header("Content-Disposition: " . $news->headers['content-disposition']);
            header("Content-Type: " . $news->headers['content-type']);
            echo $news->body;
            die;
        } elseif ($ajax == 1 || stristr($cc_whmcs_bridge_to_include, 'serverstatus') !== false && isset($_REQUEST['num']) || isset($_REQUEST['action']) && $_REQUEST['action'] == 'getcustomfields' || isset($_REQUEST['check'], $_REQUEST['addtocart'], $_REQUEST['domain']) || isset($_REQUEST['responseType']) && $_REQUEST['responseType'] == 'json' || isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
            $output = $news->DownloadToString();
            if (!$news->redirect) {
                while (count(ob_get_status(true)) > 0) {
                    ob_end_clean();
                }
                $body = $news->body;
                $body = cc_whmcs_bridge_parser_ajax1($body, $cc_whmcs_bridge_to_include);
                if (stristr($_REQUEST['js'], '.css') !== false) {
                    header('Content-Type: text/css');
                    if (get_option('cc_whmcs_bridge_prefix')) {
                        $bl = explode("\n", $body);
                        //split css into lines
                        foreach ($bl as $line) {
                            if (strpos($line, "{") !== false) {
                                $line = str_replace(",", ",#bridge ", $line);
                                //Add #bridge to styles
                                $line = str_replace("}#", "}#bridge #", $line);
                                // Minified files
                                $line = str_replace("}.", "}#bridge .", $line);
                                // Minified files
                                if (substr($line, 0, 1) !== "@") {
                                    $line = "#bridge {$line}";
                                }
                                //do not break responsiveness
                                echo $line . "\n";
                            } else {
                                if (substr(trim($line), -1) == ',' && substr($line, 0, 1) !== "@") {
                                    echo "#bridge {$line}\n";
                                } else {
                                    echo $line . "\n";
                                }
                            }
                        }
                    } else {
                        echo $body;
                    }
                    die;
                } else {
                    if (stristr($_REQUEST['js'], '.js') !== false) {
                        header('Content-Type: application/javascript');
                    }
                }
                echo $body;
                die;
            } else {
                header('Location:' . $output);
                die;
            }
        } elseif ($ajax == 2) {
            while (count(ob_get_status(true)) > 0) {
                ob_end_clean();
            }
            $output = $news->DownloadToString();
            $body = $news->body;
            $body = cc_whmcs_bridge_parser_ajax2($body);
            if (stristr($_REQUEST['js'], '.css') !== false) {
                header('Content-Type: text/css');
            } else {
                if (stristr($_REQUEST['js'], '.js') !== false) {
                    header('Content-Type: application/javascript');
                } else {
                    header('HTTP/1.1 200 OK');
                }
            }
            echo $body;
            die;
        } elseif ($news->redirect) {
            $output = $news->DownloadToString();
            if ($wordpressPageName) {
                $p = $wordpressPageName;
            } else {
                $p = '/';
            }
            $f[] = '/.*\\/([a-zA-Z\\_]*?).php.(.*?)/';
            $r[] = get_option('home') . $p . '?ccce=$1&$2';
            $f[] = '/([a-zA-Z\\_]*?).php.(.*?)/';
            $r[] = get_option('home') . $p . '?ccce=$1&$2';
            $output = preg_replace($f, $r, $news->location, -1, $count);
            cc_whmcs_log('Notification', 'Redirect to: ' . $output);
            header('Location:' . $output);
            die;
        } else {
            if (isset($_REQUEST['aff'])) {
                $news->follow = false;
            }
            $output = $news->DownloadToString();
            if ($news->redirect) {
                header('Location:' . $output);
                die;
            }
            if (isset($_REQUEST['aff']) && isset($news->headers['location'])) {
                if ($wordpressPageName) {
                    $p = $wordpressPageName;
                } else {
                    $p = '/';
                }
                $f[] = '/.*\\/([a-zA-Z\\_]*?).php.(.*?)/';
                $r[] = get_option('home') . $p . '?ccce=$1&$2';
                $f[] = '/([a-zA-Z\\_]*?).php.(.*?)/';
                $r[] = get_option('home') . $p . '?ccce=$1&$2';
                $output = preg_replace($f, $r, $news->headers['location'], -1, $count);
                cc_whmcs_log('Notification', 'Redirect to: ' . $output);
                header('Location:' . $output);
                //if (strstr($news->headers['location'],get_option('home')))
                //    header('Location:'.$news->headers['location']);
                //else header('Location:'.get_option('home'));
                die;
            }
            cc_whmcs_log(0, '[URL ' . $ref . '] Remote fetch completed (standard content)');
            return $output;
        }
    }
}
コード例 #2
0
function cc_whmcs_bridge_output($page = null)
{
    global $post;
    global $wpdb;
    global $wordpressPageName;
    global $cc_whmcs_bridge_loaded, $cc_whmcs_bridge_to_include;
    $ajax = false;
    // contribution northgatewebhosting.co.uk
    if (isset($post)) {
        $post_id = $post->ID;
    } else {
        $post_id = 1;
    }
    // contribution northgatewebhosting.co.uk
    $cf = get_post_custom($post_id);
    if ($page) {
        $cc_whmcs_bridge_to_include = $page;
    } elseif (isset($_REQUEST['ccce']) && (isset($_REQUEST['ajax']) && $_REQUEST['ajax'])) {
        $cc_whmcs_bridge_to_include = $_REQUEST['ccce'];
        $ajax = intval($_REQUEST['ajax']);
    } elseif (isset($_REQUEST['ccce'])) {
        $cc_whmcs_bridge_to_include = $_REQUEST['ccce'];
    } elseif (isset($cf['cc_whmcs_bridge_page']) && $cf['cc_whmcs_bridge_page'][0] == WHMCS_BRIDGE_PAGE) {
        $cc_whmcs_bridge_to_include = "index";
    } else {
        $cc_whmcs_bridge_to_include = "index";
    }
    $http = cc_whmcs_bridge_http($cc_whmcs_bridge_to_include);
    $news = new bridgeHttpRequest($http, 'whmcs-bridge-sso');
    $news->debugFunction = 'cc_whmcs_log';
    if (function_exists('cc_whmcs_bridge_sso_httpHeaders')) {
        $news->httpHeaders = cc_whmcs_bridge_sso_httpHeaders($news->httpHeaders);
    }
    if (isset($news->post['whmcsname'])) {
        $news->post['name'] = $news->post['whmcsname'];
        unset($news->post['whmcsname']);
    }
    $news = apply_filters('bridge_http', $news);
    $news->forceWithRedirect['systpl'] = get_option('cc_whmcs_bridge_template') ? get_option('cc_whmcs_bridge_template') : 'five';
    if (!function_exists('cc_whmcs_bridge_parser_with_permalinks') && !in_array($news->forceWithRedirect['systpl'], array('portal', 'five'))) {
        $news->forceWithRedirect['systpl'] = 'five';
    }
    if ($cc_whmcs_bridge_to_include == 'dologin') {
        $news->post['rememberme'] = 'on';
    }
    if (!$news->curlInstalled()) {
        cc_whmcs_log('Error', 'CURL not installed');
        return "cURL not installed";
    } elseif (!$news->live()) {
        cc_whmcs_log('Error', 'A HTTP Error occurred');
        return "A HTTP Error occurred";
    } else {
        @cc_whmcs_log(0, 'Headers: ' . $news->headers['content-type'] . ' - Disposition: ' . $news->headers['content-disposition']);
        if ($cc_whmcs_bridge_to_include == 'verifyimage' || isset($_REQUEST['showqrimage']) && $_REQUEST['showqrimage'] == 1) {
            $output = $news->DownloadToString();
            while (count(ob_get_status(true)) > 0) {
                ob_end_clean();
            }
            header("Content-Type: image");
            echo $news->body;
            die;
        } elseif ($cc_whmcs_bridge_to_include == 'dl' || isset($_REQUEST['a']) && $_REQUEST['a'] == 'CreateEmailAccount' || stristr($cc_whmcs_bridge_to_include, 'wbteampro') !== false && isset($_REQUEST['act']) && $_REQUEST['act'] == 'download' || stristr($cc_whmcs_bridge_to_include, 'project_management') !== false && isset($_REQUEST['action']) && $_REQUEST['action'] == 'dl' || stristr($cc_whmcs_bridge_to_include, 'project_management') !== false && stristr($cc_whmcs_bridge_to_include, '.css') !== false) {
            while (count(ob_get_status(true)) > 0) {
                ob_end_clean();
            }
            $output = $news->DownloadToString();
            header("Content-Disposition: " . $news->headers['content-disposition']);
            header("Content-Type: " . $news->headers['content-type']);
            echo $news->body;
            die;
        } elseif ($ajax == 1 || stristr($cc_whmcs_bridge_to_include, 'serverstatus') !== false && isset($_REQUEST['num']) || isset($_REQUEST['action']) && $_REQUEST['action'] == 'getcustomfields' || isset($_REQUEST['check'], $_REQUEST['addtocart'], $_REQUEST['domain']) || isset($_REQUEST['responseType']) && $_REQUEST['responseType'] == 'json') {
            $output = $news->DownloadToString();
            if (!$news->redirect) {
                while (count(ob_get_status(true)) > 0) {
                    ob_end_clean();
                }
                $body = $news->body;
                $body = cc_whmcs_bridge_parser_ajax1($body);
                if (stristr($_REQUEST['js'], '.css') !== false) {
                    header('Content-Type: text/css');
                } else {
                    if (stristr($_REQUEST['js'], '.js') !== false) {
                        header('Content-Type: application/javascript');
                    }
                }
                echo $body;
                die;
            } else {
                header('Location:' . $output);
                die;
            }
        } elseif ($ajax == 2) {
            while (count(ob_get_status(true)) > 0) {
                ob_end_clean();
            }
            $output = $news->DownloadToString();
            $body = $news->body;
            $body = cc_whmcs_bridge_parser_ajax2($body);
            if (stristr($_REQUEST['js'], '.css') !== false) {
                header('Content-Type: text/css');
            } else {
                if (stristr($_REQUEST['js'], '.js') !== false) {
                    header('Content-Type: application/javascript');
                } else {
                    header('HTTP/1.1 200 OK');
                }
            }
            echo $body;
            die;
        } elseif ($news->redirect) {
            $output = $news->DownloadToString();
            if ($wordpressPageName) {
                $p = $wordpressPageName;
            } else {
                $p = '/';
            }
            $f[] = '/.*\\/([a-zA-Z\\_]*?).php.(.*?)/';
            $r[] = get_option('home') . $p . '?ccce=$1&$2';
            $f[] = '/([a-zA-Z\\_]*?).php.(.*?)/';
            $r[] = get_option('home') . $p . '?ccce=$1&$2';
            $output = preg_replace($f, $r, $news->location, -1, $count);
            cc_whmcs_log('Notification', 'Redirect to: ' . $output);
            header('Location:' . $output);
            die;
        } else {
            if (isset($_REQUEST['aff'])) {
                $news->follow = false;
            }
            $output = $news->DownloadToString();
            if ($news->redirect) {
                header('Location:' . $output);
                die;
            }
            if (isset($_REQUEST['aff']) && isset($news->headers['location'])) {
                if ($wordpressPageName) {
                    $p = $wordpressPageName;
                } else {
                    $p = '/';
                }
                $f[] = '/.*\\/([a-zA-Z\\_]*?).php.(.*?)/';
                $r[] = get_option('home') . $p . '?ccce=$1&$2';
                $f[] = '/([a-zA-Z\\_]*?).php.(.*?)/';
                $r[] = get_option('home') . $p . '?ccce=$1&$2';
                $output = preg_replace($f, $r, $news->headers['location'], -1, $count);
                cc_whmcs_log('Notification', 'Redirect to: ' . $output);
                header('Location:' . $output);
                //if (strstr($news->headers['location'],get_option('home')))
                //    header('Location:'.$news->headers['location']);
                //else header('Location:'.get_option('home'));
                die;
            }
            return $output;
        }
    }
}