public function __construct() { if (SessionManager::getInstance()->isAdmin()) { $aid = SessionManager::getInstance()->getAdminID(); $admin = DBManager::getInstance()->getAdmin($aid); $this->isGlobalAdmin = $admin['isGlobalAdmin']; $this->adminGroups = DBManager::getInstance()->getAdminGroupsByAdminID($aid); $this->servers = DBManager::getInstance()->getAdminGroupServersByAdminId($aid); $this->perms = array(); foreach ($this->adminGroups as $group) { foreach ($group['adminOnServers'] as $serverId) { foreach ($group['perms'] as $perm => $value) { if ($perm != 'serverID' && $perm != 'groupID') { if (!isset($this->perms[$serverId])) { $this->perms[$serverId] = array(); } $this->perms[$serverId][$perm] = $value; } } } } } else { $this->isGlobalAdmin = false; $this->perms = DBManager::$defaultAdminGroupPerms; $this->servers = array(); } }
private function showConnectedProfiles() { $output = '<div class="clearfix networks">'; $facebookLoginUrl = SessionManager::getInstance()->getFacebook()->getLoginUrl(array('redirect_uri' => APP_URL . '/' . Content::l() . '/login/facebookcallback/' . Content::l() . '/settings/', 'scope' => 'publish_stream')); $linkedInLoginUrl = APP_URL . '/' . Content::l() . '/login/linkedin/' . Content::l() . '/settings/'; $twitterLoginUrl = APP_URL . '/' . Content::l() . '/login/twitter/' . Content::l() . '/settings/'; // Facebook $output .= '<div class="clearfix">'; if ($this->userDetails['facebook_access_token']) { $output .= '<a href="' . $facebookLoginUrl . '" id="loginFacebook" class="ir loggedIn">Facebook</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=Facebook" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'Facebook', Content::c()->settings->disconnect) . '</a>'; } else { $output .= '<a href="' . $facebookLoginUrl . '" id="loginFacebook" class="ir">Facebook</a>' . '<a href="' . $facebookLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'Facebook', Content::c()->settings->connect) . '</a>'; } // LinkedIn $output .= '</div><div class="clearfix">'; if ($this->userDetails['linkedin_access_token']) { $output .= '<a href="' . $linkedInLoginUrl . '" id="loginLinkedIn" class="ir loggedIn">LinkedIn</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=LinkedIn" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'LinkedIn', Content::c()->settings->disconnect) . '</a>'; } else { $output .= '<a href="' . $linkedInLoginUrl . '" id="loginLinkedIn" class="ir">LinkedIn</a>' . '<a href="' . $linkedInLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'LinkedIn', Content::c()->settings->connect) . '</a>'; } // Twitter $output .= '</div><div class="clearfix">'; if ($this->userDetails['twitter_access_token']) { $output .= '<a href="' . $twitterLoginUrl . '" id="loginTwitter" class="ir loggedIn">Twitter</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=Twitter" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'Twitter', Content::c()->settings->disconnect) . '</a>'; } else { $output .= '<a href="' . $twitterLoginUrl . '" id="loginTwitter" class="ir">Twitter</a>' . '<a href="' . $twitterLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'Twitter', Content::c()->settings->connect) . '</a>'; } $output .= '</div></div>'; return $output; }
public function __construct() { session_start(); header('Content-type: text/json'); // Get the website user $userId = SessionManager::getInstance()->getUserId(); // Make sure a user is logged in if (empty($userId)) { Debug::l('No user logged in'); $json['result'] = 'false'; echo json_encode($json); exit; } // Validate input if (empty($_POST['email']) || !filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)) { Debug::l('Invalid email'); $json['result'] = 'false'; echo json_encode($json); exit; } // Update email address $db = Database::getInstance(); $sth = $db->prepare('UPDATE person SET email = :email WHERE id = :id'); $sth->execute(array(':email' => $_POST['email'], ':id' => $userId)); $json['result'] = 'true'; echo json_encode($json); }
public function __construct() { // Delete the cached friends. The user might be logging out to try to refresh the friend list $userId = SessionManager::getInstance()->getUserId(); if (isset($userId)) { $db = Database::getInstance(); $sth = $db->prepare('DELETE FROM temp_friends WHERE facebook_id=(SELECT id FROM facebook WHERE person_id = :person_id) OR linkedin_id=(SELECT id FROM linkedin WHERE person_id = :person_id) OR twitter_id=(SELECT id FROM twitter WHERE person_id = :person_id)'); $sth->execute(array(':person_id' => $userId)); } // Clear website session setcookie('PHPSESSID', '', time() - 3600); session_destroy(); }
private function loadProfiles($person, $personIsUser) { $profiles = array(); if (!empty($person['facebook_access_token']) && (!$personIsUser || $this->mergeNetwork != 'Facebook')) { try { //$params = array('access_token' => $user['facebook_access_token']); $facebookProfile = SessionManager::getInstance()->getFacebook()->api('/' . $person['facebook_id']); } catch (FacebookApiException $e) { Debug::l('Error loading Facebook profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e); } if (isset($facebookProfile)) { $profiles[] = '<a href="' . $facebookProfile['link'] . '" target="_blank" class="profile"><img src="https://graph.facebook.com/' . $person['facebook_id'] . '/picture?type=square" /> ' . $facebookProfile['name'] . ' on Facebook</a>'; } } if (!empty($person['linkedin_access_token']) && (!$personIsUser || $this->mergeNetwork != 'LinkedIn')) { $API_CONFIG = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => ''); $OBJ_linkedin = new LinkedIn($API_CONFIG); $OBJ_linkedin->setTokenAccess(unserialize($person['linkedin_access_token'])); try { $linkedInProfile = $OBJ_linkedin->profile('id=' . $person['linkedin_id'] . ':(first-name,last-name,public-profile-url,picture-url)'); } catch (ErrorException $e) { Debug::l('Error loading LinkedIn profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e); } if ($linkedInProfile['success'] === TRUE) { $linkedInProfile['linkedin'] = new SimpleXMLElement($linkedInProfile['linkedin']); if ($linkedInProfile['linkedin']->getName() == 'person') { $li_pr = (string) $linkedInProfile['linkedin']->{'public-profile-url'}; $li_pi = (string) $linkedInProfile['linkedin']->{'picture-url'}; $li_fn = (string) $linkedInProfile['linkedin']->{'first-name'}; $li_ln = (string) $linkedInProfile['linkedin']->{'last-name'}; $profiles[] = '<a href="' . $li_pr . '" target="_blank" class="profile"><img src="' . $li_pi . '" /> ' . $li_fn . ' ' . $li_ln . ' on LinkedIn</a>'; } } } if (!empty($person['twitter_access_token']) && ($personIsUser || $this->mergeNetwork != 'Twitter')) { try { $twitterAccessToken = unserialize($person['twitter_access_token']); $twitter = new TwitterOAuth(TW_CONSUMER, TW_SECRET, $twitterAccessToken['oauth_token'], $twitterAccessToken['oauth_token_secret']); $twitter->format = 'json'; $twitterProfile = $twitter->get('users/show', array('user_id' => $person['twitter_id'])); } catch (ErrorException $e) { Debug::l('Error loading Twitter profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e); } if (isset($twitterProfile)) { $profiles[] = '<a href="http://twitter.com/' . $twitterProfile->screen_name . '" target="_blank" class="profile"><img src="' . $twitterProfile->profile_image_url . '" /> @' . $twitterProfile->screen_name . ' on Twitter</a>'; } } return $profiles; }
public function hasAction($ch_action) { $ch_modulo = strtolower(Zend_Controller_Front::getInstance()->getRequest()->getModuleName()); $ch_controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $ch_action = $ch_action; $session = SessionManager::getInstance(); $id_usuario = $session->get('id_usuario'); $usuario = new Usuario(); if (!$this->config->inProduction() && $usuario->isRoot($id_usuario)) { $this->verificarAcao($ch_modulo, $ch_controller, $ch_action); } $action = new Action(); $permission = $action->getActionPermissao($ch_modulo, $ch_controller, $ch_action); return $permission || $usuario->isRoot($id_usuario); }
public function __construct() { $this->defaultLanguage = SettingsManager::getInstance()->getDefaultLanguage(); // get lang setting from URL param, session or use default if (!empty($_GET['lang'])) { $this->language = $_GET['lang']; } elseif (($ses_lang = SessionManager::getInstance()->getLanguage()) != null) { $this->language = $ses_lang; } else { $this->language = $this->defaultLanguage; } $txt = array(); // Parse Main lang file eval(self::parseLanguageFile($this->language)); // Parse Section lang file eval(self::parseLanguageFile($this->language, HelperFunctions::getActiveSection())); // Parse Page lang file (if exists) eval(self::parseLanguageFile($this->language, HelperFunctions::getActiveSection(), HelperFunctions::getActivePage())); $this->text = $txt; }
public function __construct() { session_start(); // Connect to the database $this->db = Database::getInstance(); // Get the website user $userId = SessionManager::getInstance()->getUserId(); if (empty($userId)) { Debug::l('No user logged in'); header('Location: ' . APP_URL . '/' . Content::l() . '/'); exit; } // Get the introduction that hasn't been sent yet $this->introductionQ = $this->db->prepare('SELECT id, introducee1_id, introducee2_id, introducee1_notified, introducee2_notified, link_password FROM introduction WHERE introducer_id = :id AND (introducee1_notified IS NULL OR introducee2_notified IS NULL) ORDER BY time DESC LIMIT 1'); $this->introductionQ->execute(array(':id' => $userId)); $this->introduction = $this->introductionQ->fetch(PDO::FETCH_ASSOC); if (empty($this->introduction)) { Debug::l('No unsent introductions found'); header('Location: ' . APP_URL . '/' . Content::l() . '/'); exit; } $introducee1 = new Person(array()); $introducee1->getDataFromId($this->introduction['introducee1_id']); $introducee2 = new Person(array()); $introducee2->getDataFromId($this->introduction['introducee2_id']); // Notify introducee 1 if (empty($this->introduction['introducee1_notified'])) { $notifyManager = new NotifyManager($this->introduction['id'], $introducee1, $introducee2); $updateQ = $this->db->prepare('UPDATE introduction SET introducee1_notified = :method WHERE id = :id'); $this->notifyPerson($notifyManager, $introducee1, $updateQ); } // Notify introducee 2 if (empty($this->introduction['introducee2_notified'])) { $notifyManager = new NotifyManager($this->introduction['id'], $introducee2, $introducee1); $updateQ = $this->db->prepare('UPDATE introduction SET introducee2_notified = :method WHERE id = :id'); $this->notifyPerson($notifyManager, $introducee2, $updateQ); } $base62 = BaseConvert::base10ToBase62($this->introduction['id']); // Redirect to introduction page header('Location: ' . APP_URL . '/' . Content::l() . '/A' . $this->introduction['link_password'] . $base62); }
public function __construct() { session_start(); // Connect to the database $this->db = Database::getInstance(); // Get the website user $this->userId = SessionManager::getInstance()->getUserId(); if (!empty($this->userId)) { $userDetailsQ = $this->db->prepare('SELECT f.id as facebook_id, f.access_token as facebook_access_token, l.id as linkedin_id, l.access_token as linkedin_access_token, t.id as twitter_id, t.access_token as twitter_access_token FROM person p LEFT JOIN facebook f ON p.id = f.person_id LEFT JOIN linkedin l ON p.id = l.person_id LEFT JOIN twitter t ON p.id = t.person_id WHERE p.id = :id'); $userDetailsQ->execute(array(':id' => $this->userId)); $this->userDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC); } $this->facebookLoginUrl = SessionManager::getInstance()->getFacebook()->getLoginUrl(array('redirect_uri' => APP_URL . '/' . Content::l() . '/login/facebookcallback/', 'scope' => 'publish_stream, offline_access')); $top = new Top('', 'homePage'); echo $top->getOutput(); echo '<div id="preloaderFriends" style="display: none;">' . Content::c()->home->loading . '</div>' . '<div id="info">' . '<p>' . Content::c()->home->desc . '</p>' . '</div>' . '<div id="formLogin" class="clearfix">' . '<p>' . Content::c()->introduce->login . '</p>' . '<a href="' . $this->facebookLoginUrl . '" id="loginFacebook" class="ir' . (!empty($this->userDetails['facebook_access_token']) ? ' loggedIn' : '') . '">Facebook</a>' . '<a href="/' . Content::l() . '/login/linkedin/" id="loginLinkedIn" class="ir' . (!empty($this->userDetails['linkedin_access_token']) ? ' loggedIn' : '') . '">LinkedIn</a>' . '<a href="/' . Content::l() . '/login/twitter/" id="loginTwitter" class="ir' . (!empty($this->userDetails['twitter_access_token']) ? ' loggedIn' : '') . '">Twitter</a>' . '<p id="loginFirst">' . Content::c()->introduce->login_here_first . '</p>' . '</div>' . '<form id="formIntroduce" class="clearfix" novalidate="novalidate" autocomplete="off">' . '<div class="friendSelector introduceeInput1">' . '<label for="introducee1">' . Content::c()->introduce->introduce . '</label>' . '<input type="text" id="introducee1" placeholder="' . Content::c()->introduce->enter_name . '" />' . '<ul class="filteredFriends"></ul>' . '</div>' . '<div class="friendSelector introduceeInput2">' . '<label for="introducee2">' . Content::c()->introduce->with . '</label>' . '<input type="text" id="introducee2" placeholder="' . Content::c()->introduce->enter_name . '" />' . '<ul class="filteredFriends"></ul>' . '</div>' . '<label for="message">' . Content::c()->introduce->why . '</label>' . '<textarea id="message" placeholder="' . Content::c()->introduce->message . '"></textarea>' . '<input id="submitIntroduce" class="button" type="submit" value="' . Content::c()->introduce->submit . '" />' . '<a href="/' . Content::l() . '/about/" class="help">' . Content::c()->introduce->help . '</a>' . '</form>'; if (!empty($this->userId)) { echo $this->previousIntroductions(); } $script = '<script>' . 'var introduceme = (function (module) {' . 'module.content = module.content || {};' . 'module.content.loginFirst = "' . Content::c()->introduce->login_first . '";' . 'module.personId = ' . (!empty($this->userId) ? '"' . $this->userId . '"' : 'null') . ';' . 'module.facebookId = ' . (!empty($this->userDetails['facebook_access_token']) ? '"' . $this->userDetails['facebook_id'] . '"' : 'null') . ';' . 'module.linkedInId = ' . (!empty($this->userDetails['linkedin_access_token']) ? '"' . $this->userDetails['linkedin_id'] . '"' : 'null') . ';' . 'module.twitterId = ' . (!empty($this->userDetails['twitter_access_token']) ? '"' . $this->userDetails['twitter_id'] . '"' : 'null') . ';' . 'return module;' . '}(introduceme || {}));' . '</script>'; $bottom = new Bottom($script); echo $bottom->getOutput(); }
public function __construct() { session_start(); // Get the website user $userId = SessionManager::getInstance()->getUserId(); // Require logged in user if (!isset($userId)) { Debug::l('No user logged in'); header('Location: ' . APP_URL . '/' . Content::l() . '/settings/'); exit; } // Make sure the network param is valid if (empty($_GET['network']) || !in_array($_GET['network'], array('Facebook', 'LinkedIn', 'Twitter'))) { Debug::l('Bad network param'); header('Location: ' . APP_URL . '/' . Content::l() . '/settings/'); exit; } // Connect to the database $db = Database::getInstance(); // Remove the network switch ($_GET['network']) { case 'Facebook': $update = $db->prepare('UPDATE facebook SET access_token="" WHERE person_id = :person_id'); $update->execute(array(':person_id' => $userId)); break; case 'LinkedIn': $update = $db->prepare('UPDATE linkedin SET access_token="" WHERE person_id = :person_id'); $update->execute(array(':person_id' => $userId)); break; case 'Twitter': $update = $db->prepare('UPDATE twitter SET access_token="" WHERE person_id = :person_id'); $update->execute(array(':person_id' => $userId)); break; } header('Location: ' . APP_URL . '/' . Content::l() . '/settings/'); }
<div id="menu"> <ul> <?php if (!SessionManager::getInstance()->isAdmin()) { ?> <li<?php if (HelperFunctions::getActivePage() == 'login') { echo ' class="active"'; } ?> > <a href="./?page=login">Login</a> </li> <?php } else { HelperFunctions::echoMenuEntry('meta'); HelperFunctions::echoMenuEntry('server'); if (PermissionManager::getInstance()->serverCanEditAdmins()) { HelperFunctions::echoMenuEntry('admins'); } HelperFunctions::echoMenuEntry('logout'); ?> <li style="height:10px; font-size:10px; line-height:10px; margin-top:10px; border-bottom:black;">Back to…</li> <?php } ?> <li><a href="../user/"><-- User</a></li> </ul> </div>
<div id="topline"> <div id="menu"> <ul> <?php function echoMenuEntry($link, $textIndex) { echo '<li><a href="' . $link . '">' . tr($textIndex) . '</a></li>'; } echoMenuEntry('./', 'home'); if (!SessionManager::getInstance()->isUser()) { echoMenuEntry('./?page=login', 'login'); echoMenuEntry('./?page=register', 'register'); } else { echoMenuEntry('./?page=profile', 'profile'); echoMenuEntry('./?page=logout', 'logout'); } if (SettingsManager::getInstance()->isShowAdminLink()) { echoMenuEntry('../admin/', 'admin_area'); } ?> </ul> </div> <?php if (isset($_SESSION['userid'])) { printf(tr('welcome_user'), ServerInterface::getInstance()->getUserName($_SESSION['serverid'], $_SESSION['userid'])); } else { echo tr('welcome_guest'); } ?> </div>
require_once MUMPHPI_MAINDIR . '/classes/PermissionManager.php'; if (SettingsManager::getInstance()->isDebugMode()) { error_reporting(E_ALL); } // Check for running Ice with Murmur try { ServerInterface::getInstance(); } catch (Ice_UnknownLocalException $ex) { MessageManager::addError(tr('error_noIce')); MessageManager::echoAll(); exit; } if (!SessionManager::getInstance()->isAdmin() && HelperFunctions::getActivePage() != 'login') { header('Location: ?page=login'); exit; } elseif (SessionManager::getInstance()->isAdmin() && isset($_GET['ajax'])) { require_once MUMPHPI_MAINDIR . '/ajax/admin.ajax.php'; // TODO: this should probably have a check, whether the function exists if (is_callable('Ajax_Admin::' . $_GET['ajax'])) { eval('Ajax_Admin::' . $_GET['ajax'] . '();'); } MessageManager::echoAll(); exit; } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title><?php
<?php $isLoggedIn = SessionManager::getInstance()->isAdmin(); if ($isLoggedIn) { echo 'You are already logged in!'; echo 'Were you looking for <a href="./?page=logout">logout</a>?'; } else { if (isset($_GET['action']) && $_GET['action'] == 'dologin') { // parse and handle login form data try { SessionManager::getInstance()->loginAsAdmin($_POST['username'], $_POST['password']); $isLoggedIn = true; echo '<script type="text/javascript">location.replace("?page=meta")</script>'; echo 'Login successfull.<br/> Go on to the <a href="?page=meta">Meta Page</a>.'; } catch (Exception $exc) { echo '<div class="infobox infobox_error">Login failed.</div>'; } } if (!$isLoggedIn) { // display login form if (!DBManager::getInstance()->doesAdminExist()) { echo '<div class="infobox infobox_info">'; echo 'No admin Account exists yet.<br/>'; echo 'To create an account, <b>just log in with your desired login-credentials</b>. The account will automatically created for you!<br/><br/>'; echo 'If you experience problems and the account is not created for you, please check that your webserver has write permissions to the data folder.'; echo '</div>'; } ?> <form class="mpi_login_form" action="?page=login&action=dologin" method="post" onsubmit=" if (jQuery('#mpi_login_username').attr('value').length == 0) {alert('You did not enter a username!'); return false;}
public function __construct() { session_start(); $db = Database::getInstance(); if (empty($_SESSION['mergeOtherAccount']) || empty($_SESSION['mergeNetwork'])) { Debug::l('Error merging account: missing session vars'); header('Location: ' . APP_URL . '/' . Content::l() . '/'); exit; } $mergeOtherAccount = $_SESSION['mergeOtherAccount']; $mergeNetwork = $_SESSION['mergeNetwork']; // Get the website user $userId = SessionManager::getInstance()->getUserId(); // Require logged in user if (empty($userId)) { Debug::l('Error merging account: No logged in user'); header('Location: ' . APP_URL . '/' . Content::l() . '/'); exit; } // Get user details $userDetailsQ = $db->prepare('SELECT p.email, f.id as facebook_id, f.access_token as facebook_access_token, l.id as linkedin_id, l.access_token as linkedin_access_token, t.id as twitter_id, t.access_token as twitter_access_token FROM person p LEFT JOIN facebook f ON p.id = f.person_id LEFT JOIN linkedin l ON p.id = l.person_id LEFT JOIN twitter t ON p.id = t.person_id WHERE p.id = :id'); $userDetailsQ->execute(array(':id' => $userId)); $userDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC); // Get merging account details $mergeId = $_SESSION['mergeOtherAccount']; $userDetailsQ->execute(array(':id' => $mergeId)); $mergeDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC); // Start the merge $update = $db->prepare('UPDATE link SET person_id = :new_id WHERE person_id = :old_id'); $update->execute(array(':new_id' => $userId, ':old_id' => $mergeId)); $update = $db->prepare('UPDATE message SET writer_id = :new_id WHERE writer_id = :old_id'); $update->execute(array(':new_id' => $userId, ':old_id' => $mergeId)); $update = $db->prepare('UPDATE introduction SET introducer_id = :new_id WHERE introducer_id = :old_id'); $update->execute(array(':new_id' => $userId, ':old_id' => $mergeId)); $update = $db->prepare('UPDATE introduction SET introducee1_id = :new_id WHERE introducee1_id = :old_id'); $update->execute(array(':new_id' => $userId, ':old_id' => $mergeId)); $update = $db->prepare('UPDATE introduction SET introducee2_id = :new_id WHERE introducee2_id = :old_id'); $update->execute(array(':new_id' => $userId, ':old_id' => $mergeId)); if (empty($userDetails['email']) && !empty($mergeDetails['email'])) { $update = $db->prepare('UPDATE person SET email = :email WHERE id = :id'); $update->execute(array(':id' => $userId, ':email' => $mergeDetails['email'])); } if (empty($userDetails['facebook_access_token']) && !empty($mergeDetails['facebook_access_token']) || empty($userDetails['facebook_id']) && !empty($mergeDetails['facebook_id'])) { // Copy the Facebook profile from the merge account, cascading down to the temp tables $delete = $db->prepare('DELETE FROM facebook WHERE person_id = :new_id'); $delete->execute(array(':new_id' => $userId)); $update = $db->prepare('UPDATE facebook SET person_id = :new_id WHERE person_id = :old_id'); $update->execute(array(':new_id' => $userId, ':old_id' => $mergeId)); } if (empty($userDetails['linkedin_access_token']) && !empty($mergeDetails['linkedin_access_token']) || empty($userDetails['linkedin_id']) && !empty($mergeDetails['linkedin_id'])) { // Copy the LinkedIn profile from the merge account, cascading down to the temp tables $delete = $db->prepare('DELETE FROM linkedin WHERE person_id = :new_id'); $delete->execute(array(':new_id' => $userId)); $update = $db->prepare('UPDATE linkedin SET person_id = :new_id WHERE person_id = :old_id'); $update->execute(array(':new_id' => $userId, ':old_id' => $mergeId)); } if (empty($userDetails['twitter_access_token']) && !empty($mergeDetails['twitter_access_token']) || empty($userDetails['twitter_id']) && !empty($mergeDetails['twitter_id'])) { // Copy the Twitter profile from the merge account, cascading down to the temp tables $delete = $db->prepare('DELETE FROM twitter WHERE person_id = :new_id'); $delete->execute(array(':new_id' => $userId)); $update = $db->prepare('UPDATE twitter SET person_id = :new_id WHERE person_id = :old_id'); $update->execute(array(':new_id' => $userId, ':old_id' => $mergeId)); } $delete = $db->prepare('DELETE FROM person WHERE id = :old_id'); $delete->execute(array(':old_id' => $mergeId)); unset($_SESSION['mergeOtherAccount']); unset($_SESSION['mergeNetwork']); // Redirect to home page $_SESSION['connectedWithNewNetwork'] = $mergeNetwork; header('Location: ' . APP_URL . '/' . Content::l() . '/'); }
public function __construct($script = '') { $this->userId = SessionManager::getInstance()->getUserId(); $this->output = '</div>' . '<div class="footer"><footer>' . '<a href="/' . Content::l() . '/" class="home">' . Content::c()->home->home . '</a>' . '<a href="/' . Content::l() . '/about/" class="about">' . Content::c()->about->about . '</a>' . '<a href="http://introduceme.uservoice.com/forums/99481-general" class="feedback">' . Content::c()->feedback . '</a>' . (!empty($this->userId) ? '<a href="/' . Content::l() . '/settings/" class="settings">' . Content::c()->settings->title . '</a>' . '<a href="/' . Content::l() . '/logout/" class="logout">' . Content::c()->logout . '</a>' : '') . '</footer></div>' . '<script src="/js/plugins.js"></script>' . '<script src="/js/introduceme.js"></script>' . $script . '<script>' . 'var _gaq = [["_setAccount", "UA-20937143-1"],["_trackPageview"]];' . '(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;g.src="//www.google-analytics.com/ga.js";s.parentNode.insertBefore(g,s);}(document,"script"));' . '</script>' . '</body>' . '</html>'; }
public function __construct() { session_start(); header('Content-type: text/json'); // Get the website user $userId = SessionManager::getInstance()->getUserId(); $json['result'] = 'true'; // Make sure a user is logged in if (!isset($userId)) { $json['result'] = 'false'; $json['title'] = (string) Content::c()->errors->session->title; $json['message'] = (string) Content::c()->errors->session->no_session; echo json_encode($json); exit; } // Validate input if (empty($_POST['introducee1Name']) || empty($_POST['introducee1FacebookId']) && empty($_POST['introducee1LinkedInId']) && empty($_POST['introducee1TwitterId']) || empty($_POST['introducee2Name']) || empty($_POST['introducee2FacebookId']) && empty($_POST['introducee2LinkedInId']) && empty($_POST['introducee2TwitterId'])) { $json['result'] = 'false'; $json['title'] = (string) Content::c()->errors->input->title; $json['message'] = (string) Content::c()->errors->input->introduction_not_created; echo json_encode($json); exit; } // Make sure the introducees are unique if (!empty($_POST['introducee1FacebookId']) && !empty($_POST['introducee2FacebookId']) && $_POST['introducee1FacebookId'] == $_POST['introducee2FacebookId'] || !empty($_POST['introducee1LinkedInId']) && !empty($_POST['introducee2LinkedInId']) && $_POST['introducee1LinkedInId'] == $_POST['introducee2LinkedInId'] || !empty($_POST['introducee1TwitterId']) && !empty($_POST['introducee2TwitterId']) && $_POST['introducee1TwitterId'] == $_POST['introducee2TwitterId']) { $json['result'] = 'false'; $json['title'] = (string) Content::c()->errors->input->title; $json['message'] = (string) Content::c()->errors->input->introduce_to_self; echo json_encode($json); exit; } // Connect to the database $db = Database::getInstance(); $introducee1 = new Person(array('name' => $_POST['introducee1Name'], 'facebookId' => !empty($_POST['introducee1FacebookId']) ? $_POST['introducee1FacebookId'] : '', 'linkedInId' => !empty($_POST['introducee1LinkedInId']) ? $_POST['introducee1LinkedInId'] : null, 'twitterId' => !empty($_POST['introducee1TwitterId']) ? $_POST['introducee1TwitterId'] : null)); $introducee2 = new Person(array('name' => $_POST['introducee2Name'], 'facebookId' => !empty($_POST['introducee2FacebookId']) ? $_POST['introducee2FacebookId'] : '', 'linkedInId' => !empty($_POST['introducee2LinkedInId']) ? $_POST['introducee2LinkedInId'] : null, 'twitterId' => !empty($_POST['introducee2TwitterId']) ? $_POST['introducee2TwitterId'] : null)); // See if the introducees are already in our database, that would be nice! if (!empty($_POST['introducee1FacebookId'])) { $introducee1->getDataFromFacebookId($_POST['introducee1FacebookId']); } elseif (!empty($_POST['introducee1LinkedInId'])) { $introducee1->getDataFromLinkedInId($_POST['introducee1LinkedInId']); } elseif (!empty($_POST['introducee1TwitterId'])) { $introducee1->getDataFromTwitterId($_POST['introducee1TwitterId']); } if (!empty($_POST['introducee2FacebookId'])) { $introducee2->getDataFromFacebookId($_POST['introducee2FacebookId']); } elseif (!empty($_POST['introducee2LinkedInId'])) { $introducee2->getDataFromLinkedInId($_POST['introducee2LinkedInId']); } elseif (!empty($_POST['introducee2TwitterId'])) { $introducee2->getDataFromTwitterId($_POST['introducee2TwitterId']); } // Make sure the introducees are still unique if ($introducee1->getFacebookId() != null && $introducee1->getFacebookId() == $introducee2->getFacebookId() || $introducee1->getLinkedInId() != null && $introducee1->getLinkedInId() == $introducee2->getLinkedInId() || $introducee1->getTwitterId() != null && $introducee1->getTwitterId() == $introducee2->getTwitterId()) { $json['result'] = 'false'; $json['title'] = (string) Content::c()->errors->input->title; $json['message'] = (string) Content::c()->errors->input->introduce_to_self; echo json_encode($json); exit; } // If the introducees aren't in the database yet, add them $introducee1->addToDatabase(); $introducee2->addToDatabase(); // If the introducees are on LinkedIn, add their public profile URL and picture to the DB if ($introducee1->getLinkedInId() != null || $introducee2->getLinkedInId() != null) { // Connect to LinkedIn API $sth = $db->prepare('SELECT id, access_token FROM linkedin WHERE person_id = :person_id'); $sth->execute(array(':person_id' => $userId)); $userDetails = $sth->fetch(PDO::FETCH_ASSOC); if (!empty($userDetails['access_token'])) { $linkedInAccessToken = $userDetails['access_token']; // Create LinkedIn object $API_CONFIG = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => ''); $OBJ_linkedin = new LinkedIn($API_CONFIG); $OBJ_linkedin->setTokenAccess(unserialize($linkedInAccessToken)); // Which introducees are on LinkedIn? $profilesToRequest = array(); if ($introducee1->getLinkedInId() != null) { $profilesToRequest[] = 'id=' . $introducee1->getLinkedInId(); } if ($introducee2->getLinkedInId() != null) { $profilesToRequest[] = 'id=' . $introducee2->getLinkedInId(); } try { $linkedInProfiles = $OBJ_linkedin->profileNew('::(' . implode(',', $profilesToRequest) . '):(id,public-profile-url,picture-url)'); } catch (ErrorException $e) { } if ($linkedInProfiles['success'] === TRUE) { $linkedInProfiles['linkedin'] = new SimpleXMLElement($linkedInProfiles['linkedin']); if ($linkedInProfiles['linkedin']->getName() == 'people') { foreach ($linkedInProfiles['linkedin']->person as $person) { $id = (string) $person->id; $url = (string) $person->{'public-profile-url'}; $pic = (string) $person->{'picture-url'}; if ($id && ($url || $pic)) { $update = $db->prepare('REPLACE INTO temp_linkedin SET linkedin_id = :linkedin_id, time=NOW(), profile_url = :profile_url, picture_url = :picture_url'); $update->execute(array(':linkedin_id' => $id, ':profile_url' => $url, ':picture_url' => $pic)); } } } } } } // If the introducees are on Twitter, add their screen name and picture to the DB if ($introducee1->getTwitterId() != null || $introducee2->getTwitterId() != null) { // Which introducees are on Twitter? $profilesToRequest = array(); if ($introducee1->getTwitterId() != null) { $profilesToRequest[] = $introducee1->getTwitterId(); } if ($introducee2->getTwitterId() != null) { $profilesToRequest[] = $introducee2->getTwitterId(); } // Connect to Twitter API $sth = $db->prepare('SELECT id, access_token FROM twitter WHERE person_id = :person_id'); $sth->execute(array(':person_id' => $userId)); $userDetails = $sth->fetch(PDO::FETCH_ASSOC); if (!empty($userDetails['access_token'])) { $twitterAccessToken = unserialize($userDetails['access_token']); try { $twitter = new TwitterOAuth(TW_CONSUMER, TW_SECRET, $twitterAccessToken['oauth_token'], $twitterAccessToken['oauth_token_secret']); $twitter->format = 'json'; $twitterProfiles = $twitter->get('users/lookup', array('user_id' => implode(',', $profilesToRequest))); foreach ($twitterProfiles as $friend) { $id = (string) $friend->id; $screenName = (string) $friend->screen_name; $pic = (string) $friend->profile_image_url; $protected = (string) $friend->protected; if ($id && ($screenName || $pic || $protected)) { $update = $db->prepare('REPLACE INTO temp_twitter SET twitter_id = :twitter_id, time=NOW(), screen_name = :screen_name, picture_url = :picture_url, protected = :protected'); $update->execute(array(':twitter_id' => $id, ':screen_name' => $screenName, ':picture_url' => $pic, ':protected' => $protected)); } } } catch (ErrorException $e) { // Could not post to Twitter. Bad access token? Debug::l('Error posting to Twitter ' . $e); } } } $linkPassword = BaseConvert::generatePassword(); // Add the introduction to the database $insert = $db->prepare('INSERT INTO introduction (introducer_id, introducee1_id, introducee2_id, time, link_password) VALUES (:introducer_id, :introducee1_id, :introducee2_id, NOW(), :link_password)'); $insert->execute(array(':introducer_id' => $userId, ':introducee1_id' => $introducee1->getId(), ':introducee2_id' => $introducee2->getId(), ':link_password' => $linkPassword)); $introId = $db->lastInsertId(); // Add the links for each introducee $linkPassword1 = BaseConvert::generatePassword(); $linkPassword2 = BaseConvert::generatePassword(); $insert = $db->prepare('INSERT INTO link (introduction_id, person_id, link_password) VALUES (:introduction_id, :person_id, :link_password)'); $insert->execute(array(':introduction_id' => $introId, ':person_id' => $introducee1->getId(), ':link_password' => $linkPassword1)); $insert->execute(array(':introduction_id' => $introId, ':person_id' => $introducee2->getId(), ':link_password' => $linkPassword2)); // If there is a message, add it to the database if (!empty($_POST["message"])) { $message = htmlentities(trim($_POST['message']), ENT_QUOTES, 'UTF-8'); if (!empty($message)) { $insert = $db->prepare('INSERT INTO message (body, time, introduction_id, writer_id) VALUES (:body, NOW(), :introduction_id, :writer_id)'); $insert->execute(array(':body' => $message, ':introduction_id' => $introId, ':writer_id' => $userId)); } } // Return the success message, which will tell the Javascript to redirect the user to the send-introduction page $json['result'] = 'true'; $json['link'] = APP_URL . '/' . Content::l() . '/send-introduction/'; $json['time'] = Debug::getInstance()->getTimeElapsed(); echo json_encode($json); }
private function finishPublishToFacebook() { // See if we can get a picture of the other introducee if ($this->other->getLinkedInId() != null) { $picture = $this->other->getLinkedInPicture(); } if (!isset($picture) && $this->other->getTwitterId() != null) { $picture = $this->other->getTwitterPicture(); } if (!isset($picture) && $this->other->getFacebookId() != null) { // Shorten the picture URL with BITLY so we can publish it on Facebook $results = bitly_v3_shorten('https://graph.facebook.com/' . $this->other->getFacebookId() . '/picture?type=normal', 'j.mp'); if (!empty($results['url'])) { $picture = $results['url']; } } try { $params = array('description' => ' ', 'caption' => str_replace('INTRODUCEE_NAME', $this->other->getName(), str_replace('INTRODUCER_NAME', $this->userName, Content::c()->introduce->notification)), 'link' => $this->introductionUrl, 'name' => $this->other->getName(), 'access_token' => $this->userDetails['facebook_access_token']); if (!empty($picture)) { $params['picture'] = $picture; } $statusUpdate = SessionManager::getInstance()->getFacebook()->api('/' . $this->introducee->getFacebookId() . '/feed', 'POST', $params); } catch (FacebookApiException $e) { // Could not post to Facebook. Debug::l('Error posting to Facebook ' . $e); return false; } return true; }
private function loadFacebookFriends() { // If we have loaded the user's Facebook friends already in the last 12 hours, just reuse them $cacheQ = $this->db->prepare('SELECT facebook_id, linkedin_id, twitter_id, name FROM temp_friend WHERE temp_friends_id = (SELECT id FROM temp_friends WHERE facebook_id = :facebook_id AND time > DATE_SUB(NOW(), INTERVAL 12 HOUR) ORDER BY time DESC LIMIT 1)'); $cacheQ->execute(array(':facebook_id' => $this->userDetails['id'])); $cache = $cacheQ->fetchAll(PDO::FETCH_ASSOC); $this->printCachedFriendsIfSet($cache); // Load Facebook friends try { $params = array('access_token' => $this->userDetails['access_token']); $facebookFriends = SessionManager::getInstance()->getFacebook()->api('/' . $this->userDetails['id'] . '/friends', $params); } catch (FacebookApiException $e) { $this->printAccessTokenError($e); } // No friends? :-( if (count($facebookFriends['data']) == 0) { $json['result'] = 'false'; echo json_encode($json); exit; } // Cache the Facebook friends so we don't have to query the Facebook API again soon $insert = $this->db->prepare('INSERT INTO temp_friends (time, facebook_id) VALUES (NOW(), :facebook_id)'); $insert->execute(array(':facebook_id' => $this->userDetails['id'])); $tempFriendsId = $this->db->lastInsertId(); $friendIds = array(); foreach ($facebookFriends['data'] as $friend) { $id = $friend['id']; $friendIds[] = $this->db->quote($id); $json['friends'][$id]['facebookId'] = $id; $json['friends'][$id]['name'] = $friend['name']; } $extraInfoQ = $this->db->prepare('SELECT f.id as facebookId, l.id as linkedInId, t.id as twitterId FROM facebook f, person p LEFT JOIN linkedin l ON p.id = l.person_id LEFT JOIN twitter t ON p.id = t.person_id WHERE p.id = f.person_id AND f.id IN (' . implode(',', $friendIds) . ')'); $extraInfoQ->execute(); $extraInfo = $extraInfoQ->fetchAll(PDO::FETCH_ASSOC); $json = $this->updateTemporaryFriends($json, $extraInfo, $tempFriendsId); // Delete old caches of friend list $clearQ = $this->db->prepare('DELETE FROM temp_friends WHERE facebook_id = :facebook_id AND time < DATE_SUB(NOW(), INTERVAL 12 HOUR)'); $clearQ->execute(array(':facebook_id' => $this->userDetails['id'])); // Output successful result $json['result'] = 'true'; $json['time'] = Debug::getInstance()->getTimeElapsed(); echo json_encode($json); exit; }
public static function getCurrentUser() { if (!is_null(self::$_current_user)) { return self::$_current_user; } $auth_token = null; if (isset($_GET["auth_token"])) { $auth_token = $_GET["auth_token"]; } else { if (isset($_POST["auth_token"])) { $auth_token = $_POST["auth_token"]; } else { if (isset($_GET["at"])) { $auth_token = $_GET["at"]; } else { if (isset($_POST["at"])) { $auth_token = $_POST["at"]; } else { $sm = SessionManager::getInstance(); $auth_token = $sm->GetCookie("at"); } } } } self::$_current_user = null; if (!is_null($auth_token)) { self::$_current_user = SesionDAO::getUserByAuthToken($auth_token); } /* //there is authtoken in the POST message if( isset($_POST["at"]) && !is_null($_POST["at"]) ){ //Logger::log("post"); self::$_current_user = SesionDAO::getUserByAuthToken( $_POST["at"] ); } //there is authtoken in the GET message if(isset($_GET["at"]) && !is_null($_GET["at"])){ //Logger::log("get"); self::$_current_user = SesionDAO::getUserByAuthToken( $_GET["at"] ); } */ return self::$_current_user; }
/** * Transfers control to module functions * * @param array $params * @param array $children */ public function transferControl($params, $children) { // dead lock protection for backend module if (isset($params['action']) && isset($_REQUEST['module']) && $_REQUEST['module'] == $this->name && $params['action'] == 'transfer_control') { $params['backend_action'] = fix_chars($_REQUEST['backend_action']); unset($_REQUEST['module']); unset($params['action']); } if (isset($params['action'])) { switch ($params['action']) { case 'login': case 'login_commit': case 'logout': case 'logout_commit': case 'json_login': case 'json_logout': $session_manager = SessionManager::getInstance(); $session_manager->transferControl(); break; case 'verify_account': $user_manager = Backend_UserManager::getInstance($this->event_handler); $user_manager->verifyAccount($params, $children); break; case 'save_unpriviledged_user': $user_manager = Backend_UserManager::getInstance($this->event_handler); $user_manager->saveUnpriviledgedUser($params, $children); break; case 'save_unpriviledged_password': $user_manager = Backend_UserManager::getInstance($this->event_handler); $user_manager->saveUnpriviledgedPassword($params, $children); break; case 'password_recovery': $user_manager = Backend_UserManager::getInstance($this->event_handler); $user_manager->recoverPasswordByEmail($params, $children); break; case 'password_recovery_save': $user_manager = Backend_UserManager::getInstance($this->event_handler); $user_manager->saveRecoveredPassword($params, $children); break; case 'draw_menu': $this->drawCompleteMenu(); break; case 'transfer_control': // if user is not logged, redirect him to a proper place if (!isset($_SESSION['logged']) || !$_SESSION['logged']) { $session_manager = SessionManager::getInstance($this); $session_manager->transferControl(); return; } // fix input parameters foreach ($_REQUEST as $key => $value) { $_REQUEST[$key] = $this->utf8_urldecode($_REQUEST[$key]); } // transfer control $action = fix_chars($_REQUEST['backend_action']); $module_name = fix_chars($_REQUEST['module']); $params['backend_action'] = $action; // add sub-action if specified if (isset($_REQUEST['sub_action'])) { $params['sub_action'] = fix_chars($_REQUEST['sub_action']); } if (class_exists($module_name)) { $module = call_user_func(array($module_name, 'getInstance')); $module->transferControl($params, $children); } break; default: // draw main backend as default $this->showBackend(); break; } } if (isset($params['backend_action'])) { switch ($params['backend_action']) { case 'modules': $this->showModules(); break; case 'module_activate': $this->activateModule(); break; case 'module_deactivate': $this->deactivateModule(); break; case 'module_initialise': $this->initialiseModule(); break; case 'module_initialise_commit': $this->initialiseModule_Commit(); break; case 'module_disable': $this->disableModule(); break; case 'module_disable_commit': $this->disableModule_Commit(); break; // --- // --- case 'users': case 'users_create': case 'users_change': case 'users_save': case 'users_delete': case 'users_delete_commit': case 'change_password': case 'save_password': case 'email_templates': case 'email_templates_save': $user_manager = Backend_UserManager::getInstance($this->event_handler); $user_manager->transferControl(); break; // --- // --- case 'logout': case 'logout_commit': $session_manager = SessionManager::getInstance($this); $session_manager->transferControl(); break; } } }
<?php SessionManager::getInstance()->adminLogOut(); ?> <script type="text/javascript">location.replace("?page=login")</script> <p>Logout successful</p>
public static function db_admins_echo() { if (!PermissionManager::getInstance()->serverCanEditAdmins()) { return; } echo '<table class="list_admins"><thead><tr class="head"><th>Username</th><th>global Admin</th><th>Groups</th><th>Actions</th></tr></thead>'; echo '<tbody>'; $admins = DBManager::getInstance()->getAdmins(); foreach ($admins as $admin) { $groups = DBManager::getInstance()->getAdminGroupsByAdminID($admin['id']); echo '<tr id="admin_list_item_' . $admin['id'] . '" class="list_admins_item">'; echo '<td>' . $admin['name'] . '</td>'; echo '<td>' . ($admin['isGlobalAdmin'] ? 'yes' : 'no') . '</td>'; echo '<td>'; echo '<ul class="list_groups">'; foreach ($groups as $group) { echo '<li>' . $group['name'] . '</li>'; } echo '</ul>'; echo '</td>'; echo '<td>'; echo '<ul>'; // TODO: I18N if (empty($groups)) { echo '<li><a title="add" class="jqlink" onclick="jq_admin_addToGroup_display(' . $admin['id'] . ');">addToGroup</a></li>'; } else { echo '<li><a title="add" class="jqlink" onclick="jq_admin_removeFromGroups(' . $admin['id'] . ');">removeFromGroups</a></li>'; } // TODO: I18N // if this is the account you're currently logged in as ask explicitly if (SessionManager::getInstance()->getAdminID() == $admin['id']) { echo '<li><a class="info" title="You can not remove your own account. Instead, use another super-admin account to remove it." style="font-style:strikethrough;"><s>delete</s></a></li>'; } else { echo '<li><a class="jqlink" onclick="jq_admin_remove(' . $admin['id'] . ');">delete</a></li>'; } echo '</ul>'; echo '</td>'; echo '</tr>'; } echo '</tbody>'; echo '</table>'; }
private function displayLoginOptions() { $output = ''; $ui = new ViewIntroduction(); if (isset($this->targetUser)) { // Get the details of the introducer $introducerDetailsQ = $this->db->prepare('SELECT p.name FROM person p, introduction i WHERE p.id=i.introducer_id AND i.id = :id'); $introducerDetailsQ->execute(array(':id' => $this->id)); $introducerDetails = $introducerDetailsQ->fetch(PDO::FETCH_ASSOC); $introducerName = $introducerDetails['name']; // Get the details of the target user $targetUserDetailsQ = $this->db->prepare('SELECT p.name, f.id as facebook_id, l.id as linkedin_id, t.id as twitter_id FROM person p LEFT JOIN facebook f ON p.id = f.person_id LEFT JOIN linkedin l ON p.id = l.person_id LEFT JOIN twitter t ON p.id = t.person_id WHERE p.id = :id'); $targetUserDetailsQ->execute(array(':id' => $this->targetUser)); $targetUserDetails = $targetUserDetailsQ->fetch(PDO::FETCH_ASSOC); $targetUserName = $targetUserDetails['name']; $acceptedLoginServices = array(); if (!empty($targetUserDetails['facebook_id'])) { $acceptedLoginServices[] = 'Facebook'; } if (!empty($targetUserDetails['linkedin_id'])) { $acceptedLoginServices[] = 'LinkedIn'; } if (!empty($targetUserDetails['twitter_id'])) { $acceptedLoginServices[] = 'Twitter'; } // Get the details of the other introducee $otherIntroduceeDetailsQ = $this->db->prepare('SELECT p.name, f.id as facebook_id, l.id as linkedin_id, t.id as twitter_id FROM introduction i, person p LEFT JOIN facebook f ON p.id = f.person_id LEFT JOIN linkedin l ON p.id = l.person_id LEFT JOIN twitter t ON p.id = t.person_id WHERE i.id = :introd_id AND ((i.introducee2_id = :id AND p.id = i.introducee1_id) OR (i.introducee1_id = :id AND p.id = i.introducee2_id))'); $otherIntroduceeDetailsQ->execute(array(':introd_id' => $this->id, ':id' => $this->targetUser)); $otherIntroduceeDetails = $otherIntroduceeDetailsQ->fetch(PDO::FETCH_ASSOC); $otherIntroduceeName = $otherIntroduceeDetails['name']; $picture = ''; if (!empty($otherIntroduceeDetails['facebook_id'])) { $picture = '<img src="https://graph.facebook.com/' . $otherIntroduceeDetails['facebook_id'] . '/picture?type=normal" alt="' . $otherIntroduceeName . '" />'; } if (empty($picture) && !empty($otherIntroduceeDetails['linkedin_id'])) { $linkedInPicQ = $this->db->prepare('SELECT picture_url FROM temp_linkedin WHERE linkedin_id = :linkedin_id'); $linkedInPicQ->execute(array(':linkedin_id' => $otherIntroduceeDetails['linkedin_id'])); $linkedInPic = $linkedInPicQ->fetch(PDO::FETCH_ASSOC); if (!empty($linkedInPic['picture_url'])) { $picture = '<img src="' . $linkedInPic['picture_url'] . '" alt="' . $otherIntroduceeName . '" />'; } } if (empty($picture) && !empty($otherIntroduceeDetails['twitter_id'])) { $twitterPicQ = $this->db->prepare('SELECT picture_url FROM temp_twitter WHERE twitter_id = :twitter_id'); $twitterPicQ->execute(array(':twitter_id' => $otherIntroduceeDetails['twitter_id'])); $twitterPic = $twitterPicQ->fetch(PDO::FETCH_ASSOC); if (!empty($twitterPic["picture_url"])) { $picture = '<img src="' . $twitterPic['picture_url'] . '" alt="' . $otherIntroduceeName . '" />'; } } $title = str_replace('OTHER_NAME', $otherIntroduceeName, str_replace('INTRODUCEE_NAME', $targetUserName, str_replace('INTRODUCER_NAME', $introducerName, Content::c()->view->login->title_targeted))); } else { // No target user. Generic login page with all login options. $title = Content::c()->view->login->title; $picture = ''; $acceptedLoginServices = array('Facebook', 'LinkedIn', 'Twitter'); } $output .= $ui->top(); $pleaseLogin = str_replace('SOCIAL_NETWORK_NAME', Words::arrayToList($acceptedLoginServices, Content::c()->or), Content::c()->view->login->login); $output .= '<div class="login clearfix">' . $picture . '<h1>' . $title . '</h1>' . '<p class="pleaseLogin">' . $pleaseLogin . '</p>' . '<div class="loginIcons">'; if (!empty($_GET['base62LinkId'])) { $nextPage = 'B' . $_GET['base62LinkId']; } else { $nextPage = 'A' . $_GET['base62IntroductionId']; } if (in_array('Facebook', $acceptedLoginServices)) { $facebookLoginUrl = SessionManager::getInstance()->getFacebook()->getLoginUrl(array('redirect_uri' => APP_URL . '/' . Content::l() . '/login/facebookcallback/' . $nextPage)); $output .= '<a id="loginFacebook" class="ir" href="' . $facebookLoginUrl . '">Facebook</a>'; } if (in_array('LinkedIn', $acceptedLoginServices)) { $output .= '<a id="loginLinkedIn" class="ir" href="/' . Content::l() . '/login/linkedin/' . $nextPage . '">LinkedIn</a>'; } if (in_array('Twitter', $acceptedLoginServices)) { $output .= '<a id="loginTwitter" class="ir" href="/' . Content::l() . '/login/twitter/' . $nextPage . '">Twitter</a>'; } $output .= '</div>'; if (!empty($this->targetUser)) { $output .= '<div class="faqsContainer">' . '<p id="btnFaqs"><a href="#">' . Content::c()->view->login->help . '</a></p>' . '<div id="faqs"><h2>' . Content::c()->view->login->faqs->what->title . '</h2>' . '<p>' . Content::c()->view->login->faqs->what->body . '</p>'; if (count($acceptedLoginServices) == 1) { $output .= '<h2>' . str_replace('SOCIAL_NETWORK_NAME', $acceptedLoginServices[0], Content::c()->view->login->faqs->why->title) . '</h2>' . '<p>' . str_replace('SOCIAL_NETWORK_NAME', $acceptedLoginServices[0], str_replace('TARGET_NAME', $targetUserName, str_replace('INTRODUCER_NAME', $introducerName, str_replace('INTRODUCEE_NAME', $otherIntroduceeName, Content::c()->view->login->faqs->why->body)))) . '</p>'; } $output .= '<h2>' . Content::c()->view->login->faqs->spam->title . '</h2>' . '<p>' . str_replace('INTRODUCER_NAME', $introducerName, str_replace('INTRODUCEE_NAME', $otherIntroduceeName, Content::c()->view->login->faqs->spam->body)) . '</p>'; $output .= '</div></div>'; } $output .= '</div>'; $script = '<script>' . '$(document).ready(function() {' . '_gaq.push(["_trackPageview", "/view-introduction/not-logged-in"]);' . '});' . '</script>'; $bottom = new Bottom($script); $output .= $bottom->getOutput(); return $output; }