login.php 1.95 KB
<!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>