Esempio n. 1
0
     set_array_value($arr_to_save, $ignore_if_blank, 'title', $_POST['title']);
     set_array_value($arr_to_save, $ignore_if_blank, 'pubDate', $_POST['pubDate']);
     set_array_value($arr_to_save, $ignore_if_blank, 'description', $_POST['description']);
     set_array_value($arr_to_save, $ignore_if_blank, 'sparkle:releaseNotesLink', $_POST['sparkle:releaseNotesLink']);
     set_array_value($arr_to_save['enclosure']['_params'], $ignore_if_blank, 'url', $_POST['url']);
     set_array_value($arr_to_save['enclosure']['_params'], $ignore_if_blank, 'sparkle:version', $_POST['version']);
     set_array_value($arr_to_save['enclosure']['_params'], $ignore_if_blank, 'sparkle:shortVersionString', $_POST['sparkle:shortVersionString']);
     set_array_value($arr_to_save['enclosure']['_params'], $ignore_if_blank, 'sparkle:dsaSignature', $_POST['sparkle:dsaSignature']);
     set_array_value($arr_to_save['enclosure']['_params'], $ignore_if_blank, 'sparkleDotNET:primaryInstallationFile', $_POST['sparkleDotNET:primaryInstallationFile']);
     set_array_value($arr_to_save['enclosure']['_params'], $ignore_if_blank, 'sparkleDotNET:executableType', $_POST['sparkleDotNET:executableType']);
     if (!isset($_GET['title'])) {
         $items = array_insert($items, 0, $arr_to_save);
     } else {
         $items[$working_id] = $arr_to_save;
     }
     save_items($items, $_GET['id']);
     break;
 }
 $title = urldecode($_GET['title']);
 echo '<h2>Appcasts - ' . ($title ? 'Edit item' : 'Add item') . '</h2>';
 $item = array();
 foreach ($items as $it) {
     if ($it['title'] == urldecode($_GET['title'])) {
         $item = $it;
         break;
     }
 }
 echo '
 <form action="' . curPageURL() . '" method="post">
     <p><strong>Title (must be unique):</strong>
         <input type="text" style="width: 200px;" name="title" value="' . $item['title'] . '" required>
Esempio n. 2
0
    if ($s = $i->prepare("UPDATE ITEMS SET ARCHIVED = 1 WHERE ID = ? AND OWNER = ?")) {
        foreach ($ids as $i) {
            $s->bind_param('is', $i, $_SESSION['user-id']);
            if (!$s->execute()) {
                $errors[] = $i->error;
            }
        }
        $s->close();
        if (count($errors)) {
            error_log("Encountered errors while archiving items: " . print_r($errors, true));
        }
    } else {
        error_log("There was an error while preparing the item archive statement: {$i->error}");
    }
    json_error("There was actually no error...");
}
$action = array_get($_POST, "a", "dump");
switch ($action) {
    case 'dump':
        echo get_items($i);
        break;
    case 'add':
        echo add_item($i, $_POST['title'], $_POST['parent']);
        break;
    case 'save':
        echo save_items($i, $_POST['items']);
        break;
    case 'archive':
        echo archive_items($i, $_POST['ids']);
        break;
}
    $channel->save();
}
function parse_rss($data)
{
    $dom = new DomDocument();
    $dom->loadXML($data);
    $feeds = array();
    $xpath = new DOMXpath($dom);
    foreach ($xpath->query("/rss/channel/item") as $item) {
        $pub_date = $xpath->query("pubDate/text()", $item)->item(0)->wholeText;
        $pub_date = DateTime::createFromFormat(DateTime::RSS, $pub_date);
        array_push($feeds, array("title" => $xpath->query("title/text()", $item)->item(0)->wholeText, "description" => $xpath->query("description/text()", $item)->item(0)->wholeText, "link" => $xpath->query("link/text()", $item)->item(0)->wholeText, "pub_date" => $pub_date));
    }
    return $feeds;
}
function fetch_items($channel)
{
    $opts = array();
    if (ENABLE_PROXY) {
        $opts = array("http" => array("proxy" => "tcp://" . PROXY_SERVER . ":" . PROXY_PORT, "request_fulluri" => true));
    }
    $context = stream_context_create($opts);
    $data = file_get_contents($channel->get_url(), false, $context);
    $items = parse_rss($data);
    return $items;
}
foreach (RSSChannel::list_all() as $channel) {
    print "Fecthing feeds for " . $channel->get_name() . "\n";
    $items = fetch_items($channel);
    save_items($channel, $items);
}