コード例 #1
0
ファイル: post.php プロジェクト: jakebesworth/uMinimal
<?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';
コード例 #2
0
ファイル: body.php プロジェクト: jakebesworth/uMinimal
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;
        }
        if ($video['date'] <= intval($date)) {
            echo '<div class="' . ($counter++ % 2 ? 'even' : 'odd') . '">';
            //Title
            echo "<div class=\"title\">{$video['title']}</div>";
            //Thumbnail