File: delete.php

package info (click to toggle)
php-horde-feed 2.0.2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,552 kB
  • ctags: 203
  • sloc: xml: 21,637; php: 786; jsp: 410; perl: 231; sh: 3; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 861 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/**
 * Example of deleting Atom posts with Horde_Feed.
 *
 * @package Feed
 */

/* Get a Horde framework include_path set up. */
require 'Horde/Autoloader.php';

/* Load the feed we want to delete something from. */
try {
    $feed = Horde_Feed::readUri('http://www.example.com/Feed/');
} catch (Horde_Feed_Exception $e) {
    die('An error occurred loading the feed: ' . $e->getMessage() . "\n");
}

/* We want to delete all entries that are two weeks old. */
$twoWeeksAgo = strtotime('-2 weeks');
foreach ($feed as $entry) {
    /* Check the updated timestamp. */
    if (strtotime($entry->updated) >= $twoWeeksAgo) {
        continue;
    }

    /* Deleting the old posts is easy. */
    try {
        $entry->delete();
    } catch (Horde_Feed_Exception $e) {
        die('An error occurred deleting feed entries: ' . $e->getMessage() . "\n");
    }
}