Ejemplo n.º 1
0
if (trim($_SERVER['HTTPS']) == "" || $_SERVER['HTTPS'] == "off") {
    $dispHTTP = "http://";
} else {
    $dispHTTP = "https://";
}
$ytObj = new Youtube($mysqli);
if (!$ytObj->hasYoutube($memberInfo['member_id'])) {
    $countErrors = 0;
    $dispError = "";
    if ($accessedByConsole && !isset($_GET['error'])) {
        echo "\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\twindow.location = '" . $MAIN_ROOT . "plugins/youtube/youtubeconnect.php';\n\t\t\t\t</script>\n\t\t\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'];
            $channelInfo = $ytObj->getChannelInfo();
            $channelSnippet = $ytObj->getChannelInfo("snippet");
            $channelStats = $ytObj->getChannelInfo("statistics");
            // Add User
            $arrColumns = array("member_id", "channel_id", "uploads_id", "thumbnail", "access_token", "refresh_token", "lastupdate", "subscribers", "title", "videocount", "viewcount", "loginhash");
            $arrValues = array($memberInfo['member_id'], $channelInfo['items'][0]['id'], $channelInfo['items'][0]['contentDetails']['relatedPlaylists']['uploads'], $channelSnippet['items'][0]['snippet']['thumbnails']['medium']['url'], $response['access_token'], $response['refresh_token'], time(), $channelStats['items'][0]['statistics']['subscriberCount'], $channelSnippet['items'][0]['snippet']['title'], $channelStats['items'][0]['statistics']['videoCount'], $channelStats['items'][0]['statistics']['viewCount'], md5($channelInfo['items'][0]['id']));
            $ytObj->addNew($arrColumns, $arrValues);
            $ytObj->updateVideos();
            echo "\n\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\twindow.location = '" . $MAIN_ROOT . "members/console.php?cID=" . $cID . "';\n\t\t\t\t\t</script>\n\t\t\t\t";
            exit;
        } else {
            echo "\n\t\t\t\t\n\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\twindow.location = '" . $MAIN_ROOT . "members/console.php?cID=" . $cID . "&error=1';\n\t\t\t\t\t</script>\n\t\t\t\t\t\n\t\t\t\t";