Ejemplo n.º 1
0
function addShow($id)
{
    global $db, $user;
    $id = $db->escape_string($id);
    $res = $db->query("SELECT show_id FROM `show` WHERE imdb_id = '{$id}'");
    if ($res->num_rows == 1) {
        $show_id = $res->fetch_assoc()['show_id'];
    } else {
        $data = @file_get_contents("http://thetvdb.com/api/GetSeriesByRemoteID.php?imdbid={$id}");
        if ($data === FALSE) {
            http_response_code(502);
            return "API Error";
        }
        $xml = simplexml_load_string($data);
        $json = json_encode($xml);
        $obj = json_decode($json, TRUE);
        if (!isset($obj['Series'])) {
            http_response_code(404);
            return "Show not found";
        }
        $show_id = $obj['Series']['seriesid'];
        getShow($show_id, TRUE, TRUE);
    }
    $stm = $db->prepare('INSERT INTO user_shows (user_id, show_id) VALUES(?,?)');
    $stm->bind_param('ii', $user, $show_id);
    $stm->execute();
    return $show_id;
}
Ejemplo n.º 2
0
if (isset($_SESSION['userid'])) {
    $user = $_SESSION['userid'];
} elseif (isset($_COOKIE['usertoken'])) {
    $res = login2($_COOKIE['usertoken']);
    if ($res['msg'] == 'OK') {
        $user = $_SESSION['userid'];
    }
}
$postdata = file_get_contents("php://input");
if (!empty($postdata)) {
    $_POST = json_decode($postdata, TRUE);
}
if (!empty($_GET['search'])) {
    $res = search(urldecode($_GET['search']));
} elseif (!empty($_GET['show'])) {
    $res = getShow($_GET['show'], isset($_GET['force']), isset($_GET['q']));
} elseif (isset($_GET['usershows'])) {
    $res = getUserShows();
} elseif (!empty($_POST['addshow'])) {
    $res = addShow($_POST['addshow']);
} elseif (!empty($_POST['delshow'])) {
    $res = delShow($_POST['delshow']);
} elseif (!empty($_POST['updateshow'])) {
    $res = updateShow($_POST['updateshow']);
} elseif (!empty($_POST['username']) && !empty($_POST['password'])) {
    $res = login($_POST['username'], $_POST['password'], isset($_POST['stay']) && $_POST['stay']);
} elseif (!empty($_POST['token'])) {
    $res = login2($_POST['password']);
} elseif (isset($_POST['logout'])) {
    $res = logout();
} elseif (!empty($_POST['registername']) && !empty($_POST['password'])) {
Ejemplo n.º 3
0
            return "Other";
            break;
        case stristr($titleEnd, "Table Flip") !== false:
            return "Table Flip";
            break;
        default:
            return "Other";
            break;
    }
}
for ($i = 0; $i < sizeof($uploads); $i++) {
    $id = $uploads[$i]["contentDetails"]["videoId"];
    $snippet = $uploads[$i]["snippet"];
    $title = $snippet["title"];
    $publishedAt = $snippet["publishedAt"];
    $show = getShow($title, $publishedAt);
    $videosFormatted[] = array($id, $title, $snippet["publishedAt"], $show);
    //echo('<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=' . $playlists[$i]["id"] . '" frameborder="0" allowfullscreen></iframe>');
}
$dbh->beginTransaction();
foreach ($videosFormatted as $video => $array) {
    $stmt = $dbh->prepare("INSERT INTO video (video_id, title, published_date, show) VALUES (:video_id, :title, :published_date, :show)");
    $stmt->bindParam(':video_id', $array[0]);
    $stmt->bindParam(':title', $array[1]);
    $stmt->bindParam(':published_date', $array[2]);
    $stmt->bindParam(':show', $array[3]);
    $stmt->execute();
}
$dbh->commit();
$videoEndTime = microtime(true);
echo "Finished loading videos. Runtime: " . date("i:s", $videoEndTime - $videoStartTime) . "<br>";