Example #1
0
function is_fbconnect_enabled()
{
    if (!is_config_setup()) {
        return false;
    }
    // Change this if you want to turn off Facebook connect
    return true;
}
function render_header($user = null)
{
    // Might want to serve this out of a canvas sometimes to test
    // out fbml, so if so then don't serve the JS stuff
    if (isset($_POST['fb_sig_in_canvas'])) {
        return;
    }
    prevent_cache_headers();
    $html = '
		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
		<head>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
			<meta name="KEYWORDS" content="facebook connect php tutorial"/>
			<meta name="description" content="Demo of facebook connect using php and javascript"/>
			<title>Facebook Connect Demo</title>
			<link type="text/css" rel="stylesheet" href="' . CONNECT_CSS_PATH . 'style.css" />
		</head>
		<body>
	';
    if (is_fbconnect_enabled()) {
        ensure_loaded_on_correct_url();
    }
    $html .= '<div class="header">';
    if ($user) {
        // USER LOGGED IN
        if ($user->fbc_is_facebook_user()) {
            $html .= '<div id="header-profilepic">';
            $html .= $user->fbc_getProfilePic_xfbml(true);
            $html .= '</div>';
        }
        $html .= '<div id="header-account">';
        $html .= '<b>Welcome, ' . $user->fbc_getName() . '</b>';
        $html .= '<div class="account_links">';
        if ($user->fbc_is_facebook_user()) {
            $html .= sprintf('<a href="#" onClick="FB.Connect.logout(function() { refresh_page(); })">' . 'Logout of Facebook' . '</a>', $_SERVER['REQUEST_URI']);
        } else {
            // PUT YOUR SITES LOGOUT URL HERE
        }
        $html .= '</div>';
        $html .= '</div>';
    } else {
        // NOT LOGGED IN
        $html .= '<div id="header-account">';
        $html .= 'Hello Guest ';
        $html .= '</div>';
    }
    $html .= '</div>';
    // header & header_content
    $html .= '<div class="content">';
    $html .= "<div class='fbconnect_welcome'>";
    $html .= "<img src='" . CONNECT_IMG_PATH . "connect_logo.jpg' class='logo' />";
    $html .= "Welcome to a demo of the Quick Start Facebook Connect PHP API.  This is an optimized version of Facebook's Runaround demo that allows you to quickly implement the FB Connect PHP library onto your website.<br/><br/>";
    $html .= "You can also check out a FB Connect <a href='http://www.pakt.com/pakt/?id=5e17b48f5679ab47&t=How_to_add_Facebook_Connect_to_your_website_using_PHP_API' title='Facebook Connect Tutorial'>setup tutorial</a> as well as the <a href='http://code.google.com/p/facebook-connect-php5-library/downloads/list' title='Facebook Connect PHP library'>code library</a> used for this demo.";
    $html .= "</div>";
    // Catch misconfiguration errors.
    if (!is_config_setup()) {
        $html .= render_error('Your FB Connect configuration is not complete.');
        $html .= '</body>';
        echo $html;
        exit;
    }
    return $html;
}
Example #3
0
function render_header()
{
    // Might want to serve this out of a canvas sometimes to test
    // out fbml, so if so then don't serve the JS stuff
    if (isset($_POST['fb_sig_in_canvas'])) {
        return;
    }
    prevent_cache_headers();
    $html = '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
  <head>
   <title>The Run Around</title>
    <link type="text/css" rel="stylesheet" href="style.css" />
    <script type="text/javascript" src="base.js"></script>
  ';
    $html .= '
  </head>
  <body>';
    if (is_fbconnect_enabled()) {
        ensure_loaded_on_correct_url();
    }
    $html .= '

  <div id="header">
  <div class="header_content">
  <a href="index.php" class="title"><img src="./images/runaround_logo.gif" /></a>';
    // Show either "Welcome User Name" or "Welcome Guest"
    $user = User::getLoggedIn();
    if ($user) {
        if ($user->is_facebook_user()) {
            $html .= '<div id="header-profilepic">';
            $html .= $user->getProfilePic(true);
            $html .= '</div>';
        }
        $html .= '<div id="header-account">';
        $html .= '<b>Welcome, ' . $user->getName() . '</b>';
        $html .= '<div class="account_links">';
        $html .= '<a href="account.php">Account Settings</a> | ';
        if ($user->is_facebook_user()) {
            $html .= sprintf('<a href="#" onclick="FB.Connect.logout(function() { refresh_page(); })">' . 'Logout of Facebook' . '</a>', $_SERVER['REQUEST_URI']);
        } else {
            $html .= '<a href="logout.php">Logout</a>';
        }
        $html .= '<br /></div>';
        $html .= '</div>';
    } else {
        $html .= '<div class="account">';
        $html .= 'Hello Guest | ';
        $html .= '<a href="./register.php">Register for an account</a>';
        $html .= '</div>';
    }
    $html .= '</div></div>';
    // header & header_content
    $html .= '<div class="body_content">';
    // Catch misconfiguration errors.
    if (!is_config_setup()) {
        $html .= render_error('Your configuration is not complete. ' . 'Follow the directions in <tt><b>lib/config.php.sample</b></tt> to get set up');
        $html .= '</body>';
        echo $html;
        exit;
    }
    return $html;
}