require_once 'ringside/web/config/RingsideWebConfig.php'; require_once 'ringside/web/session/RingsideWebSession.php'; require_once 'ringside/social/client/RingsideSocialClientLocal.php'; /** * This is SOCIAL render integration page. * This enables a third party site to point to this page and * get back an application. * * To render through we need to know which network is making the request. * NETWORK: * AUTHENTICATED USER: * */ $webSession = new RingsideWebSession(); $social = new RingsideSocialClientLocal(RingsideWebConfig::$networkKey, null, $webSession->getSocial()); $inSession = $social->inSession(); $pathInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; $canvas = ''; $trailingSlash = false; if (!empty($pathInfo)) { if ($str[strlen($str) - 1] == "/") { $trailingSlash = true; } $pathInfo = ltrim($pathInfo, "/"); $path_parts = explode('/', trim($pathInfo), 2); $canvas = $path_parts[0]; if (isset($path_parts[1])) { $pathInfo = $path_parts[1]; } else { $pathInfo = ''; }
******************************************************************************/ require_once 'ringside/social/client/RingsideSocialClientLocal.php'; require_once 'ringside/web/config/RingsideWebConfig.php'; require_once 'ringside/web/session/RingsideWebSession.php'; $webSession = new RingsideWebSession(); $social = new RingsideSocialClientLocal(RingsideWebConfig::$networkKey, null, $webSession->getSocial()); ?> <div id="widebar-header"> <div id="global-links"> <ul> <li><a href="<?php echo RingsideWebConfig::$webRoot; ?> /index.php">Home</a></li> <li><?php if ($social->inSession()) { ?> <a href="<?php echo RingsideWebConfig::$webRoot; ?> /logoff.php">Logout</a><?php } else { ?> <a href="<?php echo RingsideWebConfig::$webRoot; ?> /login.php">Login</a><?php } ?> </li> </ul>
public function execute($params) { $this->debug('Entering'); $this->debugVar($params); $network_session = null; /* foreach($params as $k => $v) { error_log("RingsideSocialServerRender: $k=$v"); } */ // Recreate Session if we have it error_log("Parameters for widget render are: " . var_export($params, true)); error_log("PHPSESSID=" . (isset($_COOKIE['PHPSESSID']) ? $_COOKIE['PHPSESSID'] : '<empty>')); if (array_key_exists('social_session_key', $params)) { $session_key = $params['social_session_key']; $network_session = new RingsideSocialSession($session_key); $uid = $network_session->getUserId(); if (null == $uid || strlen($uid) == 0) { setcookie('social_session_key', $network_session->getSessionKey()); $uid = $network_session->getUserId(); if (isset($_REQUEST['uid'])) { // TODO: SECURITY: I don't think we should just be able to override the uid. $uid = $_REQUEST['uid']; // TODO: SECURITY: This shouldn't be a valid way to log in. $network_session->setUserId($uid); $network_session->setLoggedIn(true); } } } else { if (isset($_COOKIE['PHPSESSID'])) { // Optimization if user is already logged into web front-end $network_session = new RingsideSocialSession($_COOKIE['PHPSESSID']); error_log("PHPSESSID says session is as follows: " . var_export($network_session, true)); $uid = $network_session->getUserId(); if (!isset($uid)) { // The user has a network session but is not logged in // Run as an anonymous user $trust = new RingsideSocialApiTrust($_REQUEST); $network_session = $trust->getAnonymousSession(); } } else { // Not logged in, so login via annonymous user $trust = new RingsideSocialApiTrust($_REQUEST); $network_session = $trust->getAnonymousSession(); } } $api_session_key = $network_session->getApiSessionKey($params['api_key']); if (null == $api_session_key) { $rest = RingsideSocialUtils::getAdminClient(); $app_props = $rest->admin_getAppProperties(array('secret_key'), null, null, $params['api_key'], $network_session->getNetwork()); error_log("Adding API key for " . $params['api_key'] . " to social session for user " . $network_session->getUserID()); RingsideSocialUtils::getApiSessionKey($params['api_key'], $app_props['secret_key'], $network_session); } else { error_log("Using API session key {$api_session_key} for user " . $network_session->getUserID()); } if (array_key_exists('method', $params)) { $method = $params['method']; if (strcasecmp($method, 'fbml') == 0 && array_key_exists('fbml', $params)) { $fbml = $params['fbml']; //error_log("fbml: $fbml"); $render = new RingsideSocialApiRenderFBML($params); $result = $render->render($network_session, $fbml); //error_log("content: ".$result['content']); return isset($result['content']) ? $result['content'] : $result['error']; } else { if (strcasecmp($method, 'app') == 0) { $social = new RingsideSocialClientLocal(RingsideWebConfig::$networkKey, null, $network_session->getSessionKey()); $inSession = $social->inSession(); error_log("User " . ($inSession ? 'is' : 'is not') . " in session"); if ($inSession) { $path = ''; if (array_key_exists('path', $params)) { $path = $params['path']; } $view = 'canvas'; if (array_key_exists('view', $params)) { $view = $params['view']; } //error_log("About to render: ".$params['app']." view: $view, path: $path"); $rest = RingsideSocialUtils::getAdminClient(); $app_props = $rest->admin_getAppProperties(array('application_id', 'canvas_url'), null, null, $params['api_key'], null, $network_session->getNetwork()); $domain_props = $rest->admin_getDomainProperties(array('resize_url'), null, $network_session->getNetwork()); $content = $social->render($view, $app_props['application_id'], $app_props['canvas_url'], $path); // TODO: Is this where error reporting should happen? //error_log("content: $content"); if (isset($domain_props['resize_url'])) { $content = "<html><head><script type=\"text/javascript\">\n function resizeIframe(id) {\n var iframe = document.getElementById( 'xdiframe' );\n var wrapper = document.getElementById( 'wrapper' );\n var height = Math.max( document.body.offsetHeight, document.body.scrollHeight );\n var width = Math.max( document.body.offsetWidth, document.body.scrollWidth );\n iframe.src = '{$domain_props['resize_url']}?height='+height+'&width='+width+'&id='+id;\n }\n</script></head><body onload=\"resizeIframe('if_" . $params['api_key'] . "');\">" . $content . "<iframe id='xdiframe' width='1' height='1' frameborder='0'/></body></html>"; } return $content; } else { echo "<error>User not Logged in!</error>"; } } } } else { error_log("No method specified for render request"); } }
* * skipcookie - if the session is created walk through the process all over again, but don't log the user out. * popup - don't select oneapp as the template, but choose skinless template by default */ $skipCookie = isset($_REQUEST['skipcookie']) ? true : false; $popUp = isset($_REQUEST['popup']) ? true : false; $webSession = new RingsideWebSession(); $social = new RingsideSocialClientLocal(RingsideWebConfig::$networkKey, null, $webSession->getSocial()); if ($skipCookie === true) { $canvas_content = $social->render('canvas', null, 'login', ''); if ($social->getRedirect()) { RingsideWebUtils::redirect($social->getRedirect()); return; } } else { if ($social->inSession() === false || !$social->getCurrentUser()) { $canvas_content = $social->render('canvas', null, 'login', ''); if ($social->inSession() !== false) { $webSession->setSocial($social->getNetworkSessionKey()); RingsideWebUtils::redirect($social->getRedirect()); return; } } else { // error_log("Already logged in as ".$social->getCurrentUser().' on '.$social->getCurrentNetwork()); $redirect_url = RingsideWebConfig::$webRoot . '/index.php'; if (isset($_GET['next'])) { $redirect_url = $_GET['next']; } else { if (isset($_POST['next'])) { $redirect_url = $_POST['next']; }
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. ******************************************************************************/ include_once 'include.php'; require_once 'ringside/web/RingsideWebUtils.php'; require_once 'ringside/web/config/RingsideWebConfig.php'; require_once 'ringside/web/session/RingsideWebSession.php'; require_once 'ringside/social/client/RingsideSocialClientLocal.php'; $webSession = new RingsideWebSession(); $social = new RingsideSocialClientLocal(RingsideWebConfig::$networkKey, null, $webSession->getSocial()); if ($social->inSession() === false) { RingsideWebUtils::redirect(RingsideWebConfig::$webRoot . "/index.php"); } else { $canvas = "Logout"; $canvas_content = $social->render('canvas', null, 'login', ''); $social->clearSession(); $webSession->clearSession(); session_destroy(); // Deleting the social session key is required // for rendering to stop identifying a user. if (array_key_exists('social_session_key', $_COOKIE)) { // Force this cookie to expire setcookie('social_session_key', "", time() - 3600); } // You may not always want to go to the home page // After logging off, espcially if you are widget