login.php
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Tenzing Communications Inc.</title>
<style type="text/css">
body {
margin:0;
padding:0;
background-color: #3b0d32;
color: #777;
}
#login{
display: table;
margin: 0 auto;
}
</style>
<script type="text/javascript">
// document.domain = 'gotenzing.com';
</script>
<?php session_start(); ?>
</head>
<body><div id="login"><?php
include_once("./config.php");
include_once("includes/functions.php");
//print_r($_GET);die;
if(isset($_REQUEST['code'])){
$gClient->authenticate();
$_SESSION['token'] = $gClient->getAccessToken();
header('Location: ' . filter_var($redirect_url, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['token'])) {
$gClient->setAccessToken($_SESSION['token']);
}
if ($gClient->getAccessToken()) {
$userProfile = $google_oauthV2->userinfo->get();
//DB Insert
$gUser = new Users();
$gUser->checkUser('google',$userProfile['id'],$userProfile['given_name'],$userProfile['family_name'],$userProfile['email'],$userProfile['gender'],$userProfile['locale'],$userProfile['link'],$userProfile['picture']);
$_SESSION['google_data'] = $userProfile; // Storing Google User Data in Session
header("location: account.php");
$_SESSION['token'] = $gClient->getAccessToken();
} else {
$authUrl = $gClient->createAuthUrl();
}
echo '<img src="tenzing.gif" width="259" alt="Tenzing" /></br>';
if(isset($authUrl)) {
echo '<a href="'.$authUrl.'"><img width="259" style="padding:20px;" src="./images/glogin.png" alt=""/></a>';
} else {
}
?>
</div>
</body>
</html>