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


PHP Debug::l方法代码示例

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


在下文中一共展示了Debug::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: __construct

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

示例3: 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

示例4: __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

示例5: __construct

 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)) {
         Debug::l('No user logged in');
         header('Location: ' . Content::getInstance()->getRootUrl());
         exit;
     }
     $userDetailsQ = $this->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' => $this->userId));
     $this->userDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC);
     $top = new Top('', 'settingsPage');
     echo $top->getOutput();
     echo '<h1>' . Content::c()->settings->title . '</h1>' . '<h2>' . Content::c()->settings->profiles . '</h2>' . $this->showConnectedProfiles() . '<h2>' . Content::c()->settings->email . '</h2>' . '<form id="formEmail" class="clearfix">' . '<input type="email" name="email" id="email" value="' . $this->userDetails['email'] . '" placeholder="' . Content::c()->view->email_request->placeholder . '" />' . '<input id="submitEmail" class="button" type="submit" value="' . Content::c()->settings->submit . '" />' . '</form>' . '';
     $script = '<script>' . 'var introduceme = (function (module) {' . 'module.content = module.content || {};' . 'module.content.success = "' . Content::c()->settings->success . '";' . 'module.content.saved = "' . Content::c()->settings->saved . '";' . 'return module;' . '}(introduceme || {}));' . '</script>';
     $bottom = new Bottom($script);
     echo $bottom->getOutput();
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:22,代码来源:PageSettings.php

示例6: checkSessionsForUser

 private function checkSessionsForUser()
 {
     // Check the session for a logged in user
     if (!empty($_SESSION['loggedInPersonId'])) {
         return $_SESSION['loggedInPersonId'];
     }
     $db = Database::getInstance();
     // See if there is a Facebook session
     $facebookUser = $this->getFacebook()->getUser();
     if (!empty($facebookUser)) {
         // See if this Facebook user is already in the database
         $userDetailsQ = $db->prepare('SELECT p.id FROM person p, facebook f WHERE p.id = f.person_id AND f.id = :facebook_id');
         $userDetailsQ->execute(array(':facebook_id' => $facebookUser));
         $userDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC);
         if ($userDetails) {
             // Save the user's person_id to the session
             Debug::l('SessionManager :: Got the active session from Facebook.');
             $_SESSION['loggedInPersonId'] = $userDetails['id'];
             return $_SESSION['loggedInPersonId'];
         }
     }
     // No session was found so return null
     return null;
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:24,代码来源:SessionManager.php

示例7: __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

示例8: exitWithMessage

 private function exitWithMessage($message)
 {
     Debug::l($message);
     echo $message;
     exit;
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:6,代码来源:LoginTwitter.php

示例9: loadProfiles

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

示例10: __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

示例11: exitWithMessage

 protected function exitWithMessage($message)
 {
     Debug::l($message);
     echo $message;
     exit;
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:6,代码来源:LoginGeneralCallback.php

示例12: __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

示例13: validateIntroductionParams

 private function validateIntroductionParams()
 {
     if (empty($_GET['base62IntroductionId']) && empty($_GET['base62LinkId'])) {
         Debug::l('No introduction id or link id');
         header('Location: ' . APP_URL . '/' . Content::l() . '/');
         exit;
     }
     if (!empty($_GET['base62IntroductionId'])) {
         // The page has been passed an introduction ID
         if (preg_match('/^[0-9a-zA-Z]+$/', $_GET['base62IntroductionId']) == 0) {
             Debug::l('Invalid introduction id. Not base 62 compatible.');
             header('Location: ' . APP_URL . '/' . Content::l() . '/');
             exit;
         }
         // Convert the ID from base 62 to base 10
         $password = substr($_GET['base62IntroductionId'], 0, 3);
         $this->id = BaseConvert::base62ToBase10(substr($_GET['base62IntroductionId'], 3));
         // Make sure this introduction ID exists and the password is correct
         $introDetailsQ = $this->db->prepare('SELECT link_password FROM introduction WHERE id = :id');
         $introDetailsQ->execute(array(':id' => $this->id));
         $introDetails = $introDetailsQ->fetch(PDO::FETCH_ASSOC);
         if (empty($introDetails['link_password']) || $introDetails['link_password'] != $password) {
             Debug::l("That introduction id '{$this->id}' does not exist or the password '{$password}' is incorrect.");
             header('Location: ' . APP_URL . '/' . Content::l() . '/');
             exit;
         }
     } else {
         // The page has been passed a base 62 encoded link ID
         if (preg_match('/^[0-9a-zA-Z]+$/', $_GET['base62LinkId']) == 0) {
             Debug::l('Invalid link id. Not base 62 compatible.');
             header('Location: ' . APP_URL . '/' . Content::l() . '/');
             exit;
         }
         // Convert the ID from base 62 to base 10
         $password = substr($_GET['base62LinkId'], 0, 3);
         $linkId = BaseConvert::base62ToBase10(substr($_GET['base62LinkId'], 3));
         // Make sure this link ID exists
         $introDetailsQ = $this->db->prepare('SELECT introduction_id, person_id, link_password FROM link WHERE id = :id');
         $introDetailsQ->execute(array(':id' => $linkId));
         $introDetails = $introDetailsQ->fetch(PDO::FETCH_ASSOC);
         if (empty($introDetails['link_password']) || $introDetails['link_password'] != $password) {
             Debug::l("That link id '{$linkId}' does not exist or the password '{$password}' is incorrect.");
             header('Location: ' . APP_URL . '/' . Content::l() . '/');
             exit;
         }
         $this->id = $introDetails['introduction_id'];
         $this->targetUser = $introDetails['person_id'];
     }
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:49,代码来源:PageViewIntroduction.php

示例14: printAccessTokenError

 private function printAccessTokenError($e)
 {
     Debug::l('Error loading ' . $this->network . ' friends ' . $e);
     $json['result'] = 'false';
     $json['redirect'] = 'true';
     $json['title'] = (string) Content::c()->errors->auth->title;
     $json['message'] = str_replace('SOCIAL_NETWORK_NAME', $this->network, Content::c()->errors->auth->invalid_access_token);
     echo json_encode($json);
     exit;
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:10,代码来源:AjaxLoadFriends.php

示例15: finishPublishToFacebook

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


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