Mercurial > hg > ywww
view facebook/facebookLogin.php @ 49:a67bf725e87b
put both paths in include_path and depend on that
| author | Charlie Root |
|---|---|
| date | Wed, 16 Jan 2019 13:42:15 -0500 |
| parents | 077b0a0a3e6d |
| children |
line wrap: on
line source
<?PHP header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); require 'facebook.php'; // Create our Application instance. $facebook = new Facebook(array( 'appId' => '128245333876633', 'secret' => 'f51afc7e04289db62448edd8b70d83bf', 'cookie' => true, )); $session = $facebook->getSession(); $me = null; sleep(2); // Session based API call. if ($session) { try { $uid = $facebook->getUser(); $me = $facebook->api('/me'); include "db.php"; $Email = $me['email']; $FirstName = $me['first_name']; $Surname = $me['last_name']; //echo $Email; $sql1="SELECT FirstName, Surname, DisplayName, UserID from user WHERE Email ='$Email'"; //echo $sql1; $result1=mysqli_query($link,$sql1); // If successfully queried if($result1){ $count=mysqli_num_rows($result1); if($count==0){ //User doesn't already exist $add="CALL addNewUser('$Email', 'facebook', '$FirstName', '$Surname', 0, '', 0)"; //echo $add; $result2 = mysqli_query($link, $add); //reset connection mysqli_close($link); include "db.php"; $sql3="SELECT FirstName, Surname, DisplayName, UserID from user WHERE Email ='$Email'"; //echo $sql3; $resultFull=mysqli_query($link,$sql3); } else{ $resultFull = $result1; } if($resultFull){ //User Exists //echo "ResultFull!"; $line=mysqli_fetch_array($resultFull, MYSQLI_ASSOC); $firstName=$line['FirstName']; $surname=$line['Surname']; $displayName=$line['DisplayName']; $id=$line['UserID']; if($displayName == "") { if($firstName == "") $displayName=$Email; else $displayName = $firstName; } session_start(); $_SESSION['displayName']=$displayName; $_SESSION['email']=$Email; $_SESSION['surname']=$surname; $_SESSION['UserID']=$id; $_SESSION['receiveEmail']=$receiveEmail; $_SESSION['GRState']=$GRState; $_SESSION['Loc']=$LocID; echo session_id(); echo ":::" . $displayName . ":::" . $surname . ":::" . $receiveEmail . ":::" . $GRState . ":::" . $LocID . ":::" . $Email . ":::" . $id; } } } catch (FacebookApiException $e) { error_log($e); } } ?>
