当前位置: 首页>>代码示例>>PHP>>正文


PHP Content::l方法代码示例

本文整理汇总了PHP中Content::l方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::l方法的具体用法?PHP Content::l怎么用?PHP Content::l使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Content的用法示例。


在下文中一共展示了Content::l方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUserIdFromApi

 protected function getUserIdFromApi()
 {
     // Create a LinkedIn object
     $linkedInApiConfig = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => APP_URL . '/' . Content::l() . '/login/linkedincallback/' . (!empty($_GET['nextPage']) ? $_GET['nextPage'] : ''));
     $linkedIn = new LinkedIn($linkedInApiConfig);
     try {
         $response = $linkedIn->retrieveTokenAccess($_GET['oauth_token'], $_SESSION['oauth']['linkedin']['request']['oauth_token_secret'], $_GET['oauth_verifier']);
     } catch (Error $e) {
         Debug::l('Error. Could not retrieve LinkedIn access token. ' . $e);
         header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
         exit;
     }
     if ($response['success'] === TRUE) {
         // The request went through without an error, gather user's access tokens
         $_SESSION['oauth']['linkedin']['access'] = $response['linkedin'];
         // Set the user as authorized for future quick reference
         $_SESSION['oauth']['linkedin']['authorized'] = true;
     } else {
         $this->exitWithMessage('Error. The OAuth access token was not retrieved. ' . print_r($response, 1));
     }
     $this->accessToken = serialize($response['linkedin']);
     /*
     Retrieve the user ID
     The XML response will look like one of these:
     
     <person>
       <id>8GhzNjjaOi</id>
     </person>
     
     <error>
       <status>401</status>
       <timestamp>1288518358054</timestamp>
       <error-code>0</error-code>
       <message>[unauthorized]. The token used in the OAuth request is not valid.</message>
     </error>
     */
     try {
         $response = $linkedIn->profile('~:(id,first-name,last-name)');
         if ($response['success'] === TRUE) {
             $response['linkedin'] = new SimpleXMLElement($response['linkedin']);
             if ($response['linkedin']->getName() != 'person') {
                 Debug::l('Error. Could not retrieve person data from LinkedIn. ' . print_r($response, 1));
                 header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
                 exit;
             }
         } else {
             Debug::l('Error. Could not retrieve person data from LinkedIn. ' . print_r($response, 1));
             header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
             exit;
         }
         $this->linkedInId = (string) $response['linkedin']->id;
         $this->name = $response['linkedin']->{'first-name'} . ' ' . $response['linkedin']->{'last-name'};
     } catch (Error $e) {
         Debug::l('Error. Could not retrieve person ID from LinkedIn. ' . $e);
         header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
         exit;
     }
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:58,代码来源:LoginLinkedInCallback.php

示例2: getUserIdFromApi

 protected function getUserIdFromApi()
 {
     // If the oauth_token is old redirect to the connect page
     if (!isset($_SESSION['twitterOAuthToken']) || !isset($_REQUEST['oauth_token']) || $_SESSION['twitterOAuthToken'] !== $_REQUEST['oauth_token']) {
         Debug::l('Bad Twitter OAuth token');
         header('Location: ' . APP_URL . '/' . Content::l() . '/login/twitter/');
         exit;
     }
     // Create TwitterOAuth object with app key/secret and token key/secret from default phase
     $this->twitter = new TwitterOAuth(TW_CONSUMER, TW_SECRET, $_SESSION['twitterOAuthToken'], $_SESSION['twitterOAuthTokenSecret']);
     // Request access tokens from twitter
     $twitterAccessToken = $this->twitter->getAccessToken($_REQUEST['oauth_verifier']);
     // Remove no longer needed request tokens
     unset($_SESSION['twitterOAuthToken']);
     unset($_SESSION['twitterOAuthTokenSecret']);
     // If HTTP response is 200 continue otherwise send to connect page to retry
     if ($this->twitter->http_code != 200) {
         Debug::l('Error logging in to Twitter. Could not retrieve access token.');
         header('Location: ' . APP_URL . '/' . Content::l() . '/login/twitter/');
         exit;
     }
     // The user has been verified and the access tokens can be saved for future use
     $this->twitterId = $twitterAccessToken['user_id'];
     $this->accessToken = serialize($twitterAccessToken);
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:25,代码来源:LoginTwitterCallback.php

示例3: previousIntroductions

    private function previousIntroductions()
    {
        $output = '';
        $introductionsQ = $this->db->prepare('SELECT i.id, i.introducer_id, introducer.name as introducer_name, i.introducee1_id, in1.name as introducee1_name, i.introducee2_id, in2.name as introducee2_name, i.time, i.link_password
			FROM introduction i
			LEFT JOIN person introducer ON introducer.id = i.introducer_id
			LEFT JOIN person in1 ON in1.id = i.introducee1_id
			LEFT JOIN person in2 ON in2.id = i.introducee2_id
			WHERE (i.introducer_id = :id OR i.introducee1_id = :id OR i.introducee2_id = :id)
			ORDER BY time DESC');
        $introductionsQ->execute(array(':id' => $this->userId));
        $introductions = $introductionsQ->fetchAll(PDO::FETCH_ASSOC);
        if (!empty($introductions)) {
            $you = (string) Content::c()->home->you;
            $youCapital = (string) Content::c()->home->you_capital;
            $story = (string) Content::c()->home->story;
            $output .= '<div id="previousIntroductions"><h2>' . Content::c()->home->history . '</h2>';
            foreach ($introductions as $introd) {
                $url = APP_URL . '/' . Content::l() . '/A' . $introd['link_password'] . BaseConvert::base10ToBase62($introd['id']);
                if ($this->userId == $introd['introducer_id']) {
                    $output .= '<p><a href="' . $url . '">' . str_replace('INTRODUCEE1_NAME', '<strong>' . $introd['introducee1_name'] . '</strong>', str_replace('INTRODUCEE2_NAME', '<strong>' . $introd['introducee2_name'] . '</strong>', str_replace('INTRODUCER_NAME', $youCapital, $story))) . '</a></p>';
                } elseif ($this->userId == $introd['introducee1_id']) {
                    $output .= '<p><a href="' . $url . '">' . str_replace('INTRODUCEE1_NAME', $you, str_replace('INTRODUCEE2_NAME', '<strong>' . $introd['introducee2_name'] . '</strong>', str_replace('INTRODUCER_NAME', '<strong>' . $introd['introducer_name'] . '</strong>', $story))) . '</a></p>';
                } else {
                    $output .= '<p><a href="' . $url . '">' . str_replace('INTRODUCEE1_NAME', $you, str_replace('INTRODUCEE2_NAME', '<strong>' . $introd['introducee1_name'] . '</strong>', str_replace('INTRODUCER_NAME', '<strong>' . $introd['introducer_name'] . '</strong>', $story))) . '</a></p>';
                }
                $output .= $this->formatTime(strtotime($introd['time']));
            }
            $output .= '</div>';
        }
        return $output;
    }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:32,代码来源:PageIndex.php

示例4: showConnectedProfiles

 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;
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:30,代码来源:PageSettings.php

示例5: __construct

 public function __construct()
 {
     session_start();
     // Log the user out
     new Logout();
     // Redirect to the home page
     header('Location: ' . APP_URL . '/' . Content::l() . '/');
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:8,代码来源:PageLogout.php

示例6: __construct

 public function __construct()
 {
     session_start();
     // Create a LinkedIn object
     $linkedInApiConfig = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => APP_URL . '/' . Content::l() . '/login/linkedincallback/' . (!empty($_GET['nextPage']) ? $_GET['nextPage'] : ''));
     $linkedIn = new LinkedIn($linkedInApiConfig);
     // Send a request for a LinkedIn access token
     $response = $linkedIn->retrieveTokenRequest();
     if ($response['success'] === TRUE) {
         // Split up the response and stick the LinkedIn portion in the user session
         $_SESSION['oauth']['linkedin']['request'] = $response['linkedin'];
         // Redirect the user to the LinkedIn authentication/authorisation page to initiate validation.
         header('Location: ' . LINKEDIN::_URL_AUTH . $_SESSION['oauth']['linkedin']['request']['oauth_token']);
     } else {
         $this->exitWithMessage('Unable to retrieve access token for LinkedIn');
     }
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:17,代码来源:LoginLinkedIn.php

示例7: insertOrUpdateUser

 protected final function insertOrUpdateUser()
 {
     // Is there an existing user with this profile?
     if (!empty($this->userDetails)) {
         // Is this profile used by a different user?
         if (!empty($_SESSION['loggedInPersonId']) && $_SESSION['loggedInPersonId'] != $this->userDetails['person_id']) {
             Debug::l('That ' . $this->network . ' profile is already linked to a different user account');
             $_SESSION['mergeNetwork'] = $this->network;
             $_SESSION['mergeOtherAccount'] = $this->userDetails['person_id'];
             $this->updateAccessToken();
             header('Location: ' . APP_URL . '/' . Content::l() . '/merge-accounts/');
             exit;
         } else {
             Debug::l('Returning user has logged in with ' . $this->network . ' again');
             $this->updateAccessToken();
             // Update the person's name if it has been loaded
             if (!empty($this->name)) {
                 $updateNameQ = $this->db->prepare('UPDATE person SET name = :name WHERE id = :id');
                 $updateNameQ->execute(array(':name' => $this->name, ':id' => $this->userDetails['person_id']));
             }
             // Save the user's id to the session
             $_SESSION['loggedInPersonId'] = $this->userDetails['person_id'];
         }
     } else {
         // This profile hasn't been added to the database before
         // Save the network name to the session so we can display a thankyou message
         $_SESSION['connectedWithNewNetwork'] = $this->network;
         // Is a user already logged in?
         if (!empty($_SESSION['loggedInPersonId'])) {
             Debug::l('Returning user connected ' . $this->network . ' to their account for the first time');
             $this->insertProfile();
         } else {
             Debug::l('New user has logged in with ' . $this->network);
             if (empty($this->name)) {
                 $this->loadName();
             }
             $this->insertPerson();
             $this->insertProfile();
         }
     }
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:41,代码来源:LoginGeneralCallback.php

示例8: __construct

 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);
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:41,代码来源:PageSendIntroduction.php

示例9: __construct

 public function __construct()
 {
     session_start();
     // Create TwitterOAuth object with app key/secret
     $twitter = new TwitterOAuth(TW_CONSUMER, TW_SECRET);
     $callback = APP_URL . '/' . Content::l() . '/login/twittercallback/' . (!empty($_GET['nextPage']) ? $_GET['nextPage'] : '');
     // Get temporary credentials
     $requestToken = $twitter->getRequestToken($callback);
     // Save temporary credentials to session
     $_SESSION['twitterOAuthToken'] = $token = $requestToken['oauth_token'];
     $_SESSION['twitterOAuthTokenSecret'] = $requestToken['oauth_token_secret'];
     // If last connection failed don't display authorization link
     if ($twitter->http_code == 200) {
         // Build authorize URL and redirect user to Twitter
         $url = $twitter->getAuthorizeURL($token);
         header('Location: ' . $url);
         exit;
     } else {
         $this->exitWithMessage('Could not connect to Twitter. Refresh the page or try again later.');
     }
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:21,代码来源:LoginTwitter.php

示例10: __construct

 public function __construct()
 {
     session_start();
     $this->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;
     }
     $this->mergeNetwork = $_SESSION['mergeNetwork'];
     $mergeOtherAccount = $_SESSION['mergeOtherAccount'];
     // Get the website user
     $userId = SessionManager::getInstance()->getUserId();
     if (!isset($userId)) {
         // No user logged in
         Debug::l('No user logged in');
         header('Location: ' . APP_URL . '/' . Content::l() . '/');
         exit;
     }
     // Load user data
     $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' => $userId));
     $userDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC);
     $profiles = $this->loadProfiles($userDetails, true);
     // Load data for other account
     $userDetailsQ->execute(array(':id' => $mergeOtherAccount));
     $otherAccount = $userDetailsQ->fetch(PDO::FETCH_ASSOC);
     array_merge($profiles, $this->loadProfiles($otherAccount, false));
     $top = new Top('', 'mergeAccountsPage');
     echo $top->getOutput();
     echo '<h1>' . str_replace('SOCIAL_NETWORK_NAME', $this->mergeNetwork, Content::c()->merge_accounts->notice) . '</h1>' . '<p class="question">' . (count($profiles) == 2 ? Content::c()->merge_accounts->question_two_profiles : Content::c()->merge_accounts->question_more_profiles) . '</p>';
     foreach ($profiles as $profile) {
         echo $profile;
     }
     echo '<form action="/' . Content::l() . '/logout/" method="post" class="no">' . '<input type="submit" class="button" value="' . Content::c()->merge_accounts->n . '" />' . '</form>' . '<form action="/' . Content::l() . '/ajax/merge-accounts/" method="post" class="yes">' . '<input type="submit" class="button" value="' . Content::c()->merge_accounts->y . '" />' . '</form>' . '<p class="note">' . Content::c()->merge_accounts->note . '</p>';
     $bottom = new Bottom('');
     echo $bottom->getOutput();
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:38,代码来源:PageMergeAccounts.php

示例11: __construct

 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/');
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:36,代码来源:AjaxDisconnect.php

示例12: __construct

 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>';
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:5,代码来源:Bottom.php

示例13: __construct

 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));
                         }
                     }
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:chitrakojha,项目名称:introduceme,代码行数:101,代码来源:AjaxIntroduce.php

示例14: __construct

 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() . '/');
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:71,代码来源:AjaxMergeAccounts.php

示例15: displayLoginOptions

 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;
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:90,代码来源:PageViewIntroduction.php


注:本文中的Content::l方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。