aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Polak <polak@gnu.org>2010-04-19 21:18:30 +0200
committerWojciech Polak <polak@gnu.org>2010-04-19 21:18:30 +0200
commitc57c769f0969717ba5da6551ddf3947b27b84dd7 (patch)
tree29fed57e70456f1bea6cebc1b5d78beeecf5adda
parent2794f6e7eea5a170738263458c44e43b16282343 (diff)
downloadcheetah-c57c769f0969717ba5da6551ddf3947b27b84dd7.tar.gz
cheetah-c57c769f0969717ba5da6551ddf3947b27b84dd7.tar.bz2
Remove GFC. Add Facebook Connect support.
-rw-r--r--.gitignore1
-rw-r--r--css/v2/style1.css2
-rw-r--r--frontend/canvas.html114
-rw-r--r--frontend/fb_connect.php127
-rw-r--r--frontend/fetch.php6
-rw-r--r--frontend/index.php21
-rw-r--r--frontend/lib/config-sample.php7
-rw-r--r--frontend/lib/session.class.php83
-rw-r--r--frontend/login.php40
-rw-r--r--frontend/reader.php23
-rw-r--r--frontend/rpc_relay.html1
-rw-r--r--frontend/xd_receiver.html9
-rw-r--r--js/v2/boot.js10
-rw-r--r--js/v2/core.js30
-rw-r--r--js/v2/gui.js56
-rw-r--r--js/v2/login.js11
-rw-r--r--sql/cheetah.sql1
17 files changed, 324 insertions, 218 deletions
diff --git a/.gitignore b/.gitignore
index c77dfd8..9a0ae5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
*.so
.htaccess
errorlog
+frontend/facebook-platform/
frontend/lib/config.php
frontend/lib/d-sigs.php
frontend/trs/*
diff --git a/css/v2/style1.css b/css/v2/style1.css
index db18c9e..27994d0 100644
--- a/css/v2/style1.css
+++ b/css/v2/style1.css
@@ -1117,7 +1117,7 @@ span.outlink:hover {
#menuOpenSWindow img {background: transparent url(images/master-icons.png?v=0) no-repeat -251px 0px;} /* mstuff */
#menuOpenNotes img {background: transparent url(images/master-icons.png?v=0) no-repeat -235px 0px;} /* mnotes */
#menuOpenWeather img {background: transparent url(images/master-icons.png?v=0) no-repeat -283px 0px;} /* mweather */
-#menuOpenGFConnect img {background: transparent url(images/master-icons.png?v=0) no-repeat -203px 0px;} /* gfc */
+#menuOpenFanbox img {background: transparent url(images/master-icons.png?v=0) no-repeat -203px 0px;} /* fanbox */
#menuOpenCWindow1 img {background: transparent url(images/master-icons.png?v=0) no-repeat -155px 0px;} /* madd */
#menuOpenCWindow2 img {background: transparent url(images/master-icons.png?v=0) no-repeat -267px 0px;} /* msubs */
#menuOpenCWindow3 img {background: transparent url(images/master-icons.png?v=0) no-repeat -187px 0px;} /* mfolders */
diff --git a/frontend/canvas.html b/frontend/canvas.html
deleted file mode 100644
index ab642d0..0000000
--- a/frontend/canvas.html
+++ /dev/null
@@ -1,114 +0,0 @@
-<html>
-
-<head>
-<style type="text/css">
- /*
- These styles are customizable.
- Provide .canvas-gadget (the div that holds the canvas mode gadget)
- at least 500px width so that the gadget has sufficient screen real estate
-*/
-body {
- margin: 0;
- font-family:arial, sans-serif;
- text-align:center;
-}
-.container {
- width:652px;
- margin:0 auto;
- text-align:left;
-}
-.fc-sign-in-header {
- text-align:left;
- font-size: 13px;
- padding:3px 10px;
- border-bottom:1px solid #000000;
-}
-.signin {
- text-align:left;
- float:right;
- font-size: 13px;
- height: 32px;
-}
-.go-back {
- text-align:left;
- margin:5px auto 15px auto;
-}
-.go-back a, .go-back a:visited {
- font-weight:bold;
-}
-.canvas-gadget {
- text-align:left;
- width:650px; /* ALLOW AT LEAST 500px WIDTH*/
- margin:10px auto 10px auto;
- border:1px solid #cccccc;
-}
-.site-header {
- margin-top: 10px;
-}
-.section-title {
- font-size: 2em;
-}
-.clear {
- clear:both;
- font-size:1px;
- height:1px;
- line-height:0;
- margin:0;
- padding:0;
-}
-</style>
-<script type="text/javascript" src="http://www.google.com/friendconnect/script/friendconnect.js"></script>
-</head>
-<body>
-<div class="container">
- <div class="fc-sign-in-header">
- <!--REQUIRED SO VISITORS CAN SIGN IN-->
- <div class="signin" id="gadget-signin"></div>
- <script type="text/javascript">
- var skin = {};
- skin['BORDER_COLOR'] = '#cccccc';
- skin['ENDCAP_BG_COLOR'] = '#e0ecff';
- skin['ENDCAP_TEXT_COLOR'] = '#333333';
- skin['ENDCAP_LINK_COLOR'] = '#0000cc';
- skin['ALTERNATE_BG_COLOR'] = '#ffffff';
- skin['CONTENT_BG_COLOR'] = '#ffffff';
- skin['CONTENT_LINK_COLOR'] = '#0000cc';
- skin['CONTENT_TEXT_COLOR'] = '#333333';
- skin['CONTENT_SECONDARY_LINK_COLOR'] = '#7777cc';
- skin['CONTENT_SECONDARY_TEXT_COLOR'] = '#666666';
- skin['CONTENT_HEADLINE_COLOR'] = '#333333';
- skin['ALIGNMENT'] = 'right';
- google.friendconnect.container.renderCanvasSignInGadget({'id': 'gadget-signin'}, skin);
- </script>
- <!--END REQUIRED-->
- <div class="clear"></div>
- </div>
-
- <div class="site-header"><span class="section-title">Site Name</span></div>
- <div class="go-back">
- <!--REQUIRED SO VISITORS CAN RETURN TO REFERRING PAGE-->
- <a href="javascript:google.friendconnect.container.goBackToSite();">
- &lsaquo;&lsaquo; Return home</a>
- <!--END REQUIRED-->
- </div>
- <!-- REQUIRED - THIS IS WHERE THE GADGET IS PRESENTED. ALLOW AT LEAST 500px WIDTH -->
- <div id="gadget-canvas" class="canvas-gadget"></div>
- <script type="text/javascript">
- var skin = {};
- skin['BORDER_COLOR'] = '#cccccc';
- skin['ENDCAP_BG_COLOR'] = '#e0ecff';
- skin['ENDCAP_TEXT_COLOR'] = '#333333';
- skin['ENDCAP_LINK_COLOR'] = '#0000cc';
- skin['ALTERNATE_BG_COLOR'] = '#ffffff';
- skin['CONTENT_BG_COLOR'] = '#ffffff';
- skin['CONTENT_LINK_COLOR'] = '#0000cc';
- skin['CONTENT_TEXT_COLOR'] = '#333333';
- skin['CONTENT_SECONDARY_LINK_COLOR'] = '#7777cc';
- skin['CONTENT_SECONDARY_TEXT_COLOR'] = '#666666';
- skin['CONTENT_HEADLINE_COLOR'] = '#333333';
- google.friendconnect.container.renderUrlCanvasGadget({'id': 'gadget-canvas'}, skin);
- </script>
- <!--END REQUIRED-->
-</div>
-</body>
-</html> \ No newline at end of file
diff --git a/frontend/fb_connect.php b/frontend/fb_connect.php
new file mode 100644
index 0000000..603f9b5
--- /dev/null
+++ b/frontend/fb_connect.php
@@ -0,0 +1,127 @@
+<?php
+
+/*
+ Cheetah News fb_connect.php
+ Copyright (C) 2010 Wojciech Polak.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require 'facebook-platform/facebook.php';
+require_once 'lib/include.php';
+
+start_session (null, true);
+$session->auth ('iflogged');
+$message = '';
+$auth = true;
+
+getvars ('link');
+
+if ($session->status['afterlogged'] != 'yes' ||
+ $session->email == 'guest')
+{
+ $message = _('You are using a guest account. You must register in order to do this.');
+ $auth = false;
+}
+else if ($link == '1')
+{
+ try {
+ $fb = new Facebook ($CONF['fb.api_key'], $CONF['fb.secret_key']);
+ $fb_user = $fb->get_loggedin_user ();
+ if ($fb_user) {
+ $db = new Database ();
+ $db->query ("UPDATE user SET fbUID=".$fb_user." WHERE id='".
+ $session->id."'");
+ }
+ else {
+ $fb->set_user (null, null);
+ }
+ }
+ catch (Exception $e) {
+ echo $e->getMessage ();
+ }
+}
+else if ($link == '0')
+{
+ $db->query ("UPDATE user SET fbUID=0 WHERE id='".$session->id."'");
+}
+
+if ($auth) {
+ $profile_url = null;
+
+ $db = new Database ();
+ $db->query ("SELECT fbUID FROM user WHERE id='".$session->id."'");
+ if ($db->next_record ()) {
+ $fbUID = $db->f ('fbUID');
+
+ $fb = new Facebook ($CONF['fb.api_key'], $CONF['fb.secret_key']);
+ $fb_user = $fb->get_loggedin_user ();
+ if ($fb_user) {
+ $ud = $fb->api_client->users_getInfo ($fb_user, array ('profile_url'));
+ if ($ud && isset ($ud[0]['profile_url']))
+ $profile_url = $ud[0]['profile_url'];
+ }
+ }
+}
+
+?>
+<!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>Cheetah News</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<meta name="robots" content="noindex,nofollow" />
+<link rel="stylesheet" href="d?q=css.changepassword" type="text/css" />
+<link rel="icon" href="images/favicon.png" type="image/png" />
+</head>
+<body>
+
+<?php
+
+if (!empty ($message)) {
+?>
+<div id="box">
+ <h2><?php echo $message; ?></h2>
+</div>
+<?php }
+
+if ($auth) {
+ if ($fbUID) {
+ echo '<p>Your account is connected with Facebook UID: ';
+ if ($profile_url)
+ echo '<a href="'.$profile_url.'" target="_blank">'.$fbUID.'</a>';
+ else
+ echo $fbUID;
+ echo '</p>';
+ }
+ else {
+ echo '<p>Your account is not connected with Facebook</p>'."\n";
+ echo '<p><fb:login-button length="long" background="light" size="medium" onlogin="fb_link()"></fb:login-button></p>'."\n";
+ }
+?>
+
+<?php if (isset ($CONF['fb.api_key'])) { ?>
+<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"></script>
+<script type="text/javascript">
+ function fb_link () { window.location = 'fb_connect?link=1'; }
+ FB_RequireFeatures (['XFBML'], function () {
+ FB.init ('<?=$CONF["fb.api_key"]?>', 'xd_receiver.html',
+ {'permsToRequestOnConnect': 'email'});
+ });
+</script>
+<?php } }?>
+
+</body>
+</html>
diff --git a/frontend/fetch.php b/frontend/fetch.php
index 6270ade..a967a60 100644
--- a/frontend/fetch.php
+++ b/frontend/fetch.php
@@ -47,14 +47,17 @@ if ($session->status['afterlogged'] == 'yes')
$safs = 0;
$oldestFirst = 0;
$refresh = 0;
+ $fbUID = 0;
$lucid = '';
- $db->query ("SELECT showActive,oldestFirst,refresh,lastUC ".
+
+ $db->query ("SELECT showActive,oldestFirst,refresh,lastUC,fbUID ".
"FROM user WHERE id='".$session->id."'");
if ($db->next_record ()) {
$safs = $db->f ('showActive');
$oldestFirst = $db->f ('oldestFirst');
$refresh = $db->f ('refresh');
$lucid = $db->f ('lastUC');
+ $fbUID = $db->f ('fbUID');
if (!empty ($lucid)) $lucid = md5 ($lucid);
}
@@ -81,6 +84,7 @@ if ($session->status['afterlogged'] == 'yes')
echo "cheetahData = new function () {
this.lucid = '$lucid';
this.lang = '".$session->lang."';
+ this.fbUID = '$fbUID';
this.safs = $safs;
this.oldf = $oldestFirst;
this.frequency = $refresh;\n";
diff --git a/frontend/index.php b/frontend/index.php
index 1116435..80be5f7 100644
--- a/frontend/index.php
+++ b/frontend/index.php
@@ -2,7 +2,7 @@
/*
Cheetah News index.php
- Copyright (C) 2005, 2006, 2007, 2008, 2009 Wojciech Polak.
+ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Wojciech Polak.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -23,14 +23,6 @@ require_once 'lib/include.php';
start_session (null);
$session->auth ('iflogged');
-if (isset ($_GET['psinvite']) && $_GET['psinvite'] != '') {
- redirect ('http://'.$CONF['site'].'/canvas.html#url='.
- 'http://www.google.com/friendconnect/gadgets/members.xml'.
- '&canvas=1&site='.$CONF['google.fcid'].
- '&caller=http://'.$CONF['site'].'/'.
- '&psinvite='.strip_tags ($_GET['psinvite']));
-}
-
if ($session->status['afterlogged'] != 'yes') {
$insideLogin = true;
include 'login.php';
@@ -39,14 +31,11 @@ else {
if (isset ($_SERVER['HTTPS'])) {
redirect ('http://'.$CONF['site'].'/');
}
+ getvars ('fb_sig_in_iframe');
+ if ($fb_sig_in_iframe == '1')
+ redirect ('http://'.$CONF['site'].'/reader?insideFB=1');
- getvars ('v');
- if ($v == '1')
- $v = 'reader1';
- else
- $v = 'reader';
-
header ("Content-Type: text/html; charset=UTF-8");
?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"><html><head><title>Cheetah News</title><meta name="description" content="Web-based Personal News Aggregator. The Google Reader Alternative."><meta name="keywords" content="cheetah news, web-based personal news aggregator, feeds, feedreader, rss, atom, rdf, web 2.0"><meta name="robots" content="index,nofollow"><link rel="icon" href="images/favicon.png" type="image/png"><link rel="alternate" type="application/atom+xml" title="Atom" href="notes/<?php echo $session->email; ?>"></head><noscript>JavaScript is required.</noscript><frameset id="fs" rows='100%,*' border="0" onload="if (!(top==self)) top.location.href='./'; document.getElementById('fs').rows='0,100%'"><frame name="wait" src="html/loading" frameborder="0" noresize scrolling="no"><frame name="main" src="<?=$v?>" frameborder="0" noresize></frameset></html>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"><html><head><title>Cheetah News</title><meta name="description" content="Web-based Personal News Aggregator. The Google Reader Alternative."><meta name="keywords" content="cheetah news, web-based personal news aggregator, feeds, feedreader, rss, atom, rdf, web 2.0"><meta name="robots" content="index,nofollow"><link rel="icon" href="images/favicon.png" type="image/png"><link rel="alternate" type="application/atom+xml" title="Atom" href="notes/<?php echo $session->email; ?>"></head><noscript>JavaScript is required.</noscript><frameset id="fs" rows='100%,*' border="0" onload="if (!(top==self)) top.location.href='./'; document.getElementById('fs').rows='0,100%'"><frame name="wait" src="html/loading" frameborder="0" noresize scrolling="no"><frame name="main" src="reader" frameborder="0" noresize></frameset></html>
<?php } ?>
diff --git a/frontend/lib/config-sample.php b/frontend/lib/config-sample.php
index 7942adc..f4ff687 100644
--- a/frontend/lib/config-sample.php
+++ b/frontend/lib/config-sample.php
@@ -24,7 +24,12 @@ $CONF['trsExpireDays'] = 7;
$CONF['feedEngine'] = 'cth';
$CONF['google.key'] = 'GOOGLE-API-KEY';
$CONF['google.mapkey'] = 'GOOGLE-MAP-KEY';
-$CONF['google.fcid'] = 'FC-CODE';
$CONF['google.analytics'] = 'GA-CODE';
+$CONF['fb.app_id'] = 'FACEBOOK-APP-ID';
+$CONF['fb.api_key'] = 'FACEBOOK-API-KEY';
+$CONF['fb.secret_key'] = 'FACEBOOK-SECRET-KEY';
+
+$CONF['whatsnew'] = false;
+
?>
diff --git a/frontend/lib/session.class.php b/frontend/lib/session.class.php
index ce32624..8a18f18 100644
--- a/frontend/lib/session.class.php
+++ b/frontend/lib/session.class.php
@@ -41,7 +41,7 @@ function start_session ($persistentCookie, $noCache = true, $age = 30)
session_start ();
}
- if (!isset($_SESSION['session']))
+ if (!isset($_SESSION['session']))
$_SESSION['session'] = new Session ();
$session = $_SESSION['session'];
@@ -87,7 +87,7 @@ class Session
$this->status['iflogged'] = '';
}
- function login ($email, $pass, $feedurl = '')
+ function login ($email, $pass, $feedurl='')
{
global $CONF;
@@ -145,7 +145,7 @@ class Session
}
}
- function openid1 ($openid_identifier, $feedurl = '')
+ function openid1 ($openid_identifier, $feedurl='')
{
global $CONF;
@@ -180,7 +180,7 @@ class Session
redirect ($redirect_url);
}
- function openid2 ($identity, $email, $feedurl = '')
+ function openid2 ($identity, $email, $feedurl='')
{
global $CONF;
@@ -243,15 +243,80 @@ class Session
return _("New OpenID accounts without email address are not supported.");
}
+ function fb_login (&$fb, $fb_uid, $insideFB=false, $feedurl='')
+ {
+ global $CONF;
+
+ $db = new Database ();
+ $db->query ("SELECT id,email,pass,lang,fbUID FROM user ".
+ "WHERE fbUID=".$fb_uid." AND active != 'no'");
+ if ($db->next_record ())
+ {
+ $this->id = $db->f('id');
+ $this->email = $db->f('email');
+ $this->pass = $db->f('pass');
+ $this->lang = $db->f('lang');
+ $this->status['afterlogged'] = 'yes';
+ $this->status['iflogged'] = 'yes';
+
+ $db->query ("UPDATE user SET lastLog='".gmdate ('Y-m-d H:i:s')."', ".
+ "active='yes' WHERE id='".$this->id."'");
+
+ if ($insideFB) {
+ $r = 'http://'.$CONF['site'].'/reader?insideFB=1';
+ }
+ else {
+ if (!empty ($feedurl))
+ $r = 'http://'.$CONF['site'].'/rd?feedurl='.urlencode ($feedurl);
+ else
+ $r = 'http://'.$CONF['site'].'/';
+ }
+ redirect ($r);
+ }
+ else
+ {
+ $user_details = $fb->api_client->users_getInfo ($fb_uid,
+ array ('email'));
+ if ($user_details && isset ($user_details[0]['email']))
+ $email = $user_details[0]['email'];
+ else
+ return _('E-mail address is required.');
+
+ $db->query ("SELECT id FROM user WHERE email='".$db->escape($email)."'");
+ if ($db->next_record ()) {
+ return _('To link your Facebook account, please visit Menu/User Settings');
+ }
+
+ $pass = uniqid (rand(), true);
+ $db->query ("INSERT INTO user SET email='".$email.
+ "', pass='".$pass."', fbUID=".$fb_uid);
+ $db->query ("SELECT LAST_INSERT_ID() as last_id FROM user");
+ if ($db->next_record ()) {
+ $last_id = $db->f ('last_id');
+ $this->id = $last_id;
+ $this->email = $email;
+ $this->pass = $pass;
+ $this->lang = 'null';
+ $this->status['afterlogged'] = 'yes';
+ $this->status['iflogged'] = 'yes';
+
+ if ($insideFB)
+ redirect ('http://'.$CONF['site'].'/reader?insideFB=1');
+ else
+ redirect ('http://'.$CONF['site'].'/');
+ }
+ }
+ }
+
function logout ()
{
global $CONF;
- $this->id = 0;
- $this->email = '';
- $this->pass = '';
- $this->lang = '';
- $this->status = array ();
+ $this->id = 0;
+ $this->email = '';
+ $this->pass = '';
+ $this->lang = '';
+ $this->status = array ();
$this->status['public'] = 'yes';
$this->status['afterlogged'] = '';
$this->status['iflogged'] = '';
diff --git a/frontend/login.php b/frontend/login.php
index 3b92ea7..bce0377 100644
--- a/frontend/login.php
+++ b/frontend/login.php
@@ -23,10 +23,11 @@ require_once 'lib/d-sigs.php';
require_once 'lib/register.php';
require_once 'Auth/OpenID/Consumer.php';
require_once 'Auth/OpenID/FileStore.php';
-require_once "Auth/OpenID/SReg.php";
+require_once 'Auth/OpenID/SReg.php';
-getvars ('cEmail,cPassword,openid_identifier,SignIn');
-postvars ('feedurl,regPassword,regRPassword,PersistentCookie,SignUp,RecoverPassword');
+getvars ('cEmail,cPassword,openid_identifier,PersistentCookie,SignIn');
+getvars ('fbConnect,fb_sig_in_iframe');
+postvars ('feedurl,regPassword,regRPassword,SignUp,RecoverPassword');
if (empty ($feedurl) && isset ($_SERVER['QUERY_STRING']))
{
@@ -76,6 +77,20 @@ if (isset ($_GET['openid_mode']) && !empty ($_GET['openid_mode']))
$email);
}
}
+else if ($fbConnect && isset ($CONF['fb.api_key']) &&
+ isset ($CONF['fb.secret_key'])) {
+ require 'facebook-platform/facebook.php';
+ $fb = new Facebook ($CONF['fb.api_key'], $CONF['fb.secret_key']);
+ $fb_uid = $fb->get_loggedin_user ();
+ if ($fb_uid) {
+ $insideFB = $fb_sig_in_iframe == '1' ? true : false;
+ $message = $_SESSION['session']->fb_login ($fb, $fb_uid, $insideFB,
+ $feedurl);
+ }
+ else {
+ $fb->set_user (null, null);
+ }
+}
else if ($SignIn)
{
if (!empty ($openid_identifier)) {
@@ -149,7 +164,8 @@ else
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php
-echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$CHEETAH_LANG.'" lang="'.$CHEETAH_LANG.'">';
+echo '<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:fb="http://www.facebook.com/2008/fbml">';
?>
<head>
@@ -186,6 +202,12 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$CHEETAH_LANG.'" la
class="openid_identifier" style="width:90%" maxlength="255" />
</td>
</tr>
+ <tr id="trFBConnect">
+ <td align="right"><?php echo 'Facebook: '; ?></td>
+ <td align="left">
+ <fb:login-button length="long" background="light" size="medium" onlogin="fb_login()"></fb:login-button>
+ </td>
+ </tr>
<tr>
<td align="right"></td>
<td align="left">
@@ -335,6 +357,16 @@ if ($message)
</div>
+<?php if (isset ($CONF['fb.api_key'])) { ?>
+<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"></script>
+<script type="text/javascript">
+FB_RequireFeatures (['XFBML'], function () {
+ FB.init ('<?=$CONF["fb.api_key"]?>', 'xd_receiver.html',
+ {'permsToRequestOnConnect': 'email'});
+});
+</script>
+<?php } ?>
+
<?php if (isset ($CONF['google.analytics']) && !isset ($_GET['openid_mode'])) { ?>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
diff --git a/frontend/reader.php b/frontend/reader.php
index a90a83f..370895b 100644
--- a/frontend/reader.php
+++ b/frontend/reader.php
@@ -25,24 +25,29 @@ start_session (null);
$session->auth ('afterlogged');
if ($session->status['afterlogged'] == 'yes')
{
+ getvars ('insideFB');
+
$db = new Database;
$db->query ("UPDATE user SET lastAccess=UTC_TIMESTAMP(), logCount=logCount+1 WHERE id='".$session->id."'");
header ('Content-Type: text/html; charset=UTF-8');
header ('Last-Modified: ' . gmdate ('D, d M Y H:i:s T'));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
+<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" />
<link id="style" rel="stylesheet" type="text/css" href="<?=dsp('css')?>" />
<?php if ($CONF['feedEngine'] != 'cthonly') { ?><script type="text/javascript" src="http://www.google.com/jsapi?key=<?=$CONF['google.key']?>"></script>
<? } ?>
<script type="text/javascript">
-var fbe = '<?=$CONF['feedEngine']?>';
-var LANG = '<?=$session->lang?>';
-var SIGS = {'js':'<?=$SIGS["js"]?>', 'tr':'<?=$SIGS["tr"]?>', 'wt':'<?=$SIGS["wt"]?>', 'op':'<?=$SIGS["op"]?>', 'dir':'<?=$SIGS["dir"]?>'};
+<?php echo "var CONF = {'fbe': '".($insideFB ? 'google' : $CONF['feedEngine']).
+ "', 'lang': '".$session->lang."', 'whatsnew': ".(int)$CONF['whatsnew']."};
+var SIGS = {'js':'".$SIGS["js"]."', 'tr':'".$SIGS["tr"]."', 'wt':'".
+ $SIGS["wt"]."', 'op':'".$SIGS["op"]."', 'dir':'".$SIGS["dir"]."'};\n"; ?>
</script>
<script type="text/javascript" src="<?=dsp('bt')?><?php if (!empty ($session->lang)) echo '&amp;lang='.$session->lang; ?>"></script>
+<?php if ($insideFB) { ?><style type="text/css">body { font-size: 75%; }</style><?php } ?>
<title>Cheetah News</title>
</head>
@@ -172,6 +177,7 @@ var SIGS = {'js':'<?=$SIGS["js"]?>', 'tr':'<?=$SIGS["tr"]?>', 'wt':'<?=$SIGS["wt
<tr><td colspan="2"><div class="cth-separator"></div></td></tr>
<tr><td id="cWindowLabel_4_System"></td></tr>
<tr><td><span id="cWindowLabel_4_OpenID" class="link"></span></td></tr>
+ <tr><td><span id="cWindowLabel_4_LinkFB" class="link"></span></td></tr>
<tr><td><span id="cWindowLabel_4_ChangePassword" class="link"></span></td></tr>
</table>
</div>
@@ -341,7 +347,7 @@ var SIGS = {'js':'<?=$SIGS["js"]?>', 'tr':'<?=$SIGS["tr"]?>', 'wt':'<?=$SIGS["wt
<span id="menuOpenSWindow" class="ilinkCM">&nbsp;<img src="images/t.gif" width="16" height="16" alt="" /></span>
<span id="menuOpenNotes" class="linkCM">&nbsp;<img src="images/t.gif" width="16" height="16" alt="" /></span>
<span id="menuOpenWeather" class="linkCM">&nbsp;<img src="images/t.gif" width="16" height="16" alt="" /></span>
- <span id="menuOpenGFConnect" class="linkCM">&nbsp;<img src="images/t.gif" width="16" height="16" alt="" /></span><hr />
+ <span id="menuOpenFanbox" class="linkCM">&nbsp;<img src="images/t.gif" width="16" height="16" alt="" /></span><hr />
<span id="menuOpenCWindow1" class="linkCM">&nbsp;<img src="images/t.gif" width="16" height="16" alt="" /></span>
<span id="menuOpenCWindow2" class="linkCM">&nbsp;<img src="images/t.gif" width="16" height="16" alt="" /></span>
<span id="menuOpenCWindow3" class="linkCM">&nbsp;<img src="images/t.gif" width="16" height="16" alt="" /></span>
@@ -349,6 +355,13 @@ var SIGS = {'js':'<?=$SIGS["js"]?>', 'tr':'<?=$SIGS["tr"]?>', 'wt':'<?=$SIGS["wt
<hr /><span id="logout" class="linkCM">&nbsp;<img src="images/t.gif" width="16" height="16" alt="" /></span>
</div>
+<?php if (isset ($CONF['fb.api_key'])) { ?>
+<script type="text/javascript">CONF.fb_api_key = '<?=$CONF["fb.api_key"]?>';</script>
+<div id="fbFanbox" style="display:none">
+ <fb:fan profile_id="<?=$CONF['fb.app_id']?>" stream="0" connections="10" logobar="1" width="500" height="300"></fb:fan>
+</div>
+<?php } ?>
+
<?php if (isset ($CONF['google.analytics'])) { ?>
<script type="text/javascript">
var tracker;
diff --git a/frontend/rpc_relay.html b/frontend/rpc_relay.html
deleted file mode 100644
index c602043..0000000
--- a/frontend/rpc_relay.html
+++ /dev/null
@@ -1 +0,0 @@
-<html><head><script type="text/javascript" src="http://www.google.com/friendconnect/script/rpc_relay.js"></script></head></html> \ No newline at end of file
diff --git a/frontend/xd_receiver.html b/frontend/xd_receiver.html
new file mode 100644
index 0000000..e00b664
--- /dev/null
+++ b/frontend/xd_receiver.html
@@ -0,0 +1,9 @@
+<!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" >
+<head>
+ <title>Cross-Domain Receiver Page</title>
+</head>
+<body>
+ <script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js?2"></script>
+</body>
+</html>
diff --git a/js/v2/boot.js b/js/v2/boot.js
index 8bdb199..4f4f38e 100644
--- a/js/v2/boot.js
+++ b/js/v2/boot.js
@@ -31,7 +31,7 @@ if (typeof google != 'undefined') {
google.load ('feeds', '1', {'nocss': true});
}
else {
- fbe = 'cth';
+ CONF.fbe = 'cth';
}
function reader () {
@@ -51,7 +51,7 @@ function reader () {
window.location = 'html/noactivex';
if (!xh) return;
try {
- xh.open ('GET', dsp ('js', '&lang=' + LANG), true);
+ xh.open ('GET', dsp ('js', '&lang=' + CONF.lang), true);
xh.onreadystatechange = function () {
if (xh.readyState == 4) {
if (xh.status == 200) {
@@ -80,4 +80,10 @@ function dsp (res, p) {
return d;
}
+function load_fb () {
+ $.getScript ('http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php',
+ function () { FB.init (CONF.fb_api_key, 'xd_receiver.html'); });
+}
+
+setTimeout (load_fb, 2500);
window.onload = reader;
diff --git a/js/v2/core.js b/js/v2/core.js
index bf5f478..827d98f 100644
--- a/js/v2/core.js
+++ b/js/v2/core.js
@@ -317,7 +317,7 @@ function timeoutAXML (xh, feedid) {
}
}
-if ((!hasXSLT || fbe == 'google') && typeof google != 'undefined') {
+if ((!hasXSLT || CONF.fbe == 'google') && typeof google != 'undefined') {
var fetchAXML = function (feedid, latest, expand, url) {
var feed = new google.feeds.Feed (url);
feed.setNumEntries (20);
@@ -2516,34 +2516,6 @@ function registerCheetahHandler () {
alert (_('Sorry, but this operation is not supported by your browser.'));
}
-function dload (src, cb) {
- var c = document.getElementsByTagName ('head')[0];
- var script = document.createElement ('script');
- script.type = 'text/javascript';
- script.src = src;
- var f = function () {
- script.onload = null;
- var p = script.parentNode;
- p.removeChild (script);
- delete script;
- if (typeof cb == 'function')
- cb ();
- };
- var g = function (h) {
- var s = (h ? h : window.event).target ? (h ? h : window.event).target
- : (h ? h : window.event).srcElement;
- if (s.readyState == 'loaded' || s.readyState == 'complete') {
- s.onreadystatechange = null;
- f ();
- }
- };
- if (navigator.product == 'Gecko')
- script.onload = f;
- else
- script.onreadystatechange = g;
- c.appendChild (script);
-}
-
var hParser = new function () {
var stack;
var tags_empty = {'area':1,'base':1,'basefont':1,'br':1,'col':1,'frame':1,
diff --git a/js/v2/gui.js b/js/v2/gui.js
index f468f13..df9e7b4 100644
--- a/js/v2/gui.js
+++ b/js/v2/gui.js
@@ -115,7 +115,7 @@ function initGui () {
'menuOpenCWindow2' : '&nbsp;' + _('Manage Subscriptions') + '&nbsp;',
'menuOpenCWindow3' : '&nbsp;' + _('Manage Folders') + '&nbsp;',
'menuOpenCWindow4' : '&nbsp;' + _('User Settings') + '&nbsp;',
- 'menuOpenGFConnect': '&nbsp;Google Friend Connect&nbsp;',
+ 'menuOpenFanbox': '&nbsp;' + _('Facebook Fanbox') + '&nbsp;',
'logout' : '&nbsp;' + _('Logout') + '&nbsp;'}, true);
initMenu ();
@@ -128,7 +128,7 @@ function initGui () {
$('#addURLForm,#addFolderForm,#weLocationForm,#nbForm').attr ('autocomplete', 'off');
var whatsnew = GID ('whatsnew');
- if (false && whatsnew) {
+ if (CONF.whatsnew && whatsnew) {
whatsnew.className = 'link';
whatsnew.onmousedown = function () {
openFeedPreview ('http://blog.cheetah-news.com/feed', 'Cheetah News Blog');
@@ -344,8 +344,21 @@ function initMenu () {
menuLink.oncontextmenu = showMenu;
}
- setCmhLink (GID ('logout'), function () { window.location = 'logout'; });
- setCmhLink (GID ('menuOpenGFConnect'),function () { this.className = 'linkCM'; openFriendConnect (); });
+ setCmhLink (GID ('logout'), function () {
+ if (cheetahData.fbUID && typeof FB != 'undefined') {
+ if (confirm (_('Log out also from Facebook?'))) {
+ FB.Connect.get_status ().waitUntilReady (function (status) {
+ if (status == FB.ConnectState.connected)
+ FB.Connect.logoutAndRedirect ('logout');
+ else
+ window.location = 'logout';
+ });
+ return;
+ }
+ }
+ window.location = 'logout';
+ });
+ setCmhLink (GID ('menuOpenFanbox'),function () { this.className = 'linkCM'; openFanbox (); });
setCmhLink (GID ('menuOpenCWindow1'), function () { this.className = 'linkCM'; openCWindow (1); });
setCmhLink (GID ('menuOpenCWindow2'), function () { this.className = 'linkCM'; openCWindow (2); });
setCmhLink (GID ('menuOpenCWindow3'), function () { this.className = 'linkCM'; openCWindow (3); });
@@ -848,40 +861,13 @@ function openAWindow () {
return false;
}
-function openFriendConnect () {
+function openFanbox () {
hideMenu ();
- Greybox.open ({type: 'empty', width:500, height:300,
- title: 'Google Friend Connect'});
- if (!window.loaded_gfc) {
- dload ('http://www.google.com/friendconnect/script/friendconnect.js',
- runFriendConnect);
- }
- else
- runFriendConnect ();
+ Greybox.open ({type: 'inline', content: 'fbFanbox',
+ width:500, height:300, title: 'Facebook Fanbox'});
return false;
}
-function runFriendConnect () {
- if (typeof google.friendconnect == 'undefined') return;
- window.loaded_gfc = true;
- var skin = {};
- skin['HEIGHT'] = '300';
- skin['BORDER_COLOR'] = '#cccccc';
- skin['ENDCAP_BG_COLOR'] = '#e0ecff';
- skin['ENDCAP_TEXT_COLOR'] = '#333333';
- skin['ENDCAP_LINK_COLOR'] = '#0000cc';
- skin['ALTERNATE_BG_COLOR'] = '#ffffff';
- skin['CONTENT_BG_COLOR'] = '#ffffff';
- skin['CONTENT_LINK_COLOR'] = '#0000cc';
- skin['CONTENT_TEXT_COLOR'] = '#333333';
- skin['CONTENT_SECONDARY_LINK_COLOR'] = '#7777cc';
- skin['CONTENT_SECONDARY_TEXT_COLOR'] = '#666666';
- skin['CONTENT_HEADLINE_COLOR'] = '#333333';
- google.friendconnect.container.set