Facebook crawler redirect to force displaying own opengraph meta-tags For my website, I use the opengraph to send the right data to the crawler.

On the top of all pages on my website, I include the opengraph-script, like this: 

if (preg_match("/facebookexternalhit/is", $_SERVER['HTTP_USER_AGENT'])) {
    include("./facebook-crawler.php");
    exit();
}


facebook-crawler.php:

        ## Infos for Crawling
        $server_path                = $_SERVER['REQUEST_URI']; 
        $expl_path                  = explode("/", $server_path);
        $page_title                 = $expl_path[1];
        $page_data                  = "";
        $page_path_display          = "";

        if (isset($expl_path[2]) &amp;&amp; $expl_path[2]!="") {
            $page_data              = $expl_path[2];
            $page_path_display      = "/".$page_title."/".$page_data;   
        } elseif ($page_title!="") {
            $page_path_display      = "/".$page_title."/"; 
        } else {
            $page_path_display      = "/";  
        }

function show_fbmeta_home() {

        global $site_url, $site_url_displayname, $fb_app_id, $fb_admins, $page_path_display, $count_cars, $count_member, $count_ps;

        get_statistics_general(); 

        $use_title      = "Lunatics Car Club Austria - est. 2014 - {Beta}";
        $use_text       = $count_member." Mitglieder, ".$count_cars." Autos, ".$count_ps."PS. Besuch unsere Website um mehr zu Erfahren!";
        $use_type       = "article";
        $use_pic        = $site_url."/images/home/r32-gruppenbild.jpg";

        $meta_string = 
        '&lt;meta property="og:title" content="'.$use_title.'" /&gt;
        &lt;meta property="fb:app_id" content="'.$fb_app_id.'"/&gt;
        &lt;meta property="fb:admins" content="'.$fb_admins.'"/&gt;
        &lt;meta property="og:type" content="article" /&gt;
        &lt;meta property="og:url" content="'.$site_url.'/" /&gt;
        &lt;meta property="og:image" content="'.$use_pic.'" /&gt;
        &lt;meta property="og:site_name" content="'.$site_url_displayname.'" /&gt;
        &lt;meta property="og:description" content="'.$use_text.'" /&gt;
        ';

        return $meta_string;

}


        // Meta Cases
        switch($page_title) {
            case "": case "home": 
                echo show_fbmeta_home();
                exit();
            break;
        }

        show_fbmeta_home();


Of course, the script would be extended for each link. If no function for the actual website is present, the home-page would be used.

Is this a legacy-style method, or, could this cause some problems in the future?
It would be better to assign $page_path_display this value ("/") from the beginning as all the cases use that as a prefix.
You're missing whitespace in this statement ($expl_path[2]!=""),  it should be $expl_path[2] != "".
In the following code block, you don't need to assign $meta_string as you return it straight away.



    return
    '&lt;meta property="og:title" content="'.$use_title.'" /&gt;
    &lt;meta property="fb:app_id" content="'.$fb_app_id.'"/&gt;
    &lt;meta property="fb:admins" content="'.$fb_admins.'"/&gt;
    &lt;meta property="og:type" content="article" /&gt;
    &lt;meta property="og:url" content="'.$site_url.'/" /&gt;
    &lt;meta property="og:image" content="'.$use_pic.'" /&gt;
    &lt;meta property="og:site_name" content="'.$site_url_displayname.'" /&gt;
    &lt;meta property="og:description" content="'.$use_text.'" /&gt;
    ';




In the following code block, you could just use an if-else instead of a switch





    switch($page_title) {
        case "": case "home": 
            echo show_fbmeta_home();
            exit();
        break;
    }



for example:

if ($page_title == "" || $page_title == "home"){
    echo show_fbmeta_home();
    exit();
}



global, you should avoid using globals, because they're bad practice.