Exemplo n.º 1
0
<?php

if (!empty($_POST)) {
    session_start();
    if (isset($_POST['form']) && (!isset($_SESSION['form']) || $_SESSION['form'] !== $_POST['form'])) {
        $_SESSION['form'] = $_POST['form'];
        if (!empty($_POST['name']) && !empty($_POST['id']) && !empty($_POST['type'])) {
            $name = $_POST['name'];
            $id = $_POST['id'];
            $type = $_POST['type'] === 'user' ? 'user' : 'channel';
            if (strlen($name) <= 20 && strlen($id) <= 48) {
                $ws = new Scraper();
                if ($ws->addChannel($id, 'new', $type)) {
                    $ws->fetch();
                    $response = $ws->fetchChannel($id);
                    unset($ws);
                    if (!empty($response)) {
                        $db = new Datastore();
                        $query = 'INSERT INTO channels VALUES
                                  (
                                      NULL,
                                      ?,
                                      ?,
                                      ?
                                   )';
                        $options = array('sss', &$name, &$id, &$type);
                        $db->query($query, $options);
                        unset($db);
                        echo 'Successfully added channel ' . htmlentities($name);
                    } else {
                        echo 'Channel ' . htmlentities($name) . ' does not exist or the page is down';
Exemplo n.º 2
0
            <option value="2" ' . ($max === '2' ? 'selected="selected"' : '') . '>2</option>
            <option value="3" ' . ($max === '3' ? 'selected="selected"' : '') . '>3</option>
            <option value="4" ' . ($max === '4' ? 'selected="selected"' : '') . '>4</option>
            <option value="30" ' . ($max === '30' ? 'selected="selected"' : '') . '>All</option>
        </select>
    </div>';
echo '</div>';
echo '<iframe style="display: none;width: 560px;height:315px;" id="frame" allowfullscreen></iframe><div id="frame-hover"></div>';
$db = new Datastore();
$db->tables();
$db->query("SELECT id, name, channel, type FROM channels ORDER BY name");
$channels = $db->fetch();
unset($db);
$ws = new Scraper();
foreach ($channels as $channel) {
    $ws->addChannel($channel['channel'], $sort, $channel['type']);
}
$ws->fetch();
foreach ($channels as $channel) {
    $counter = 0;
    $maxVideos = 1;
    $videos = $ws->fetchChannel($channel['channel'], !empty($auto));
    echo "<div class=\"channel\"><button class=\"channel-button\" onclick=\"hideshow('channel-{$channel['id']}', 200);\">{$channel['name']}</button></div>";
    echo "<div id=\"channel-{$channel['id']}\">";
    foreach ($videos as $video) {
        // User already watched video
        if (!empty($hide) && !empty($watched) && strpos($watched, '|' . $video['id']) !== false) {
            continue;
        }
        if ($maxVideos++ > intval($max)) {
            break;