// Start Page $dispBreadCrumb = "<a href='" . $MAIN_ROOT . "'>Home</a> > Log In"; include $prevFolder . "themes/" . $THEME . "/_header.php"; if (constant("LOGGED_IN")) { echo "\n\t\t<script type='text/javascript'>\n\t\t\twindow.location = '" . $MAIN_ROOT . "members'\n\t\t</script>\n\t"; exit; } if (isset($_GET['code']) && $_GET['state'] == $_SESSION['btYoutubeNonce'] && !isset($_GET['error'])) { $arrURLInfo = parse_url($dispHTTP . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); $response = $ytObj->getAccessToken($_GET['code'], $arrURLInfo['scheme'] . "://" . $arrURLInfo['host'] . $arrURLInfo['path']); if (isset($response['access_token'])) { $ytObj->accessToken = $response['access_token']; $ytObj->refreshToken = $response['refresh_token'] != "" ? $response['refresh_token'] : 1; $channelInfo = $ytObj->getChannelInfo(); $channelID = $channelInfo['items'][0]['id']; if ($ytObj->authorizeLogin($channelID)) { $ytInfo = $ytObj->get_info(); $memberObj = new Member($mysqli); $memberObj->select($ytInfo['member_id']); $memberInfo = $memberObj->get_info(); $_SESSION['btUsername'] = $memberInfo['username']; $_SESSION['btPassword'] = $memberInfo['password']; $newLastLogin = time(); $newTimesLoggedIn = $memberInfo['timesloggedin'] + 1; $newIP = $_SERVER['REMOTE_ADDR']; $memberObj->update(array("lastlogin", "timesloggedin", "ipaddress", "loggedin"), array($newLastLogin, $newTimesLoggedIn, $newIP, 1)); $memberObj->autoPromote(); echo "\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\twindow.location = '" . $MAIN_ROOT . "members';\n\t\t\t\t</script>\n\t\t\t"; exit; } else { $dispError = "There is no user associated with this Youtube account. You must connect your Youtube account while logged in before using this feature.";