Exemplo n.º 1
0
// Get 50 newest poems
$cPoem = new CPoem($db, $_SESSION);
$cUsers = new CUsers($db, $_SESSION);
$poems = $cPoem->getNewestPoems($_GET['num_poems']);
echo '<table>';
echo '<tr>';
echo '<td><b>Runoilija</b></td>';
echo '<td><b>Runon nimi</b></td>';
echo '<td><b>Lisätty</b></td>';
echo '</tr>';
$poems_per_page = $cPoem->getPoemsPerPage();
foreach ($poems as $poem) {
    echo '<tr>';
    echo '<td>';
    echo '<a href="poet.php?id=' . $poem['user_id'] . '">';
    echo $cUsers->getUsername($poem['user_id']);
    echo '</a>';
    echo '</td>';
    echo '<td><a href="poet.php?id=' . $poem['user_id'];
    // Count how many poems this writer has written
    // since this poem. This is necessary so we can
    // create link to correct poem even if that poem
    // is on another page than the first one.
    $q = 'SELECT COUNT(*) FROM rs_poem WHERE added > "' . $poem['added'] . '" AND user_id=' . $poem['user_id'];
    try {
        $ret = $db->query($q);
        if ($db->numRows($ret) > 0) {
            $ret = $db->fetchAssoc($ret);
            $num_after = $ret[0]['COUNT(*)'];
            // In which page poem will be
            $correct_page = ceil(($num_after + 1) / $poems_per_page);
Exemplo n.º 2
0
    $cPoem = new CPoem($db, $_SESSION);
    if ($type == 'newest') {
        $poems = $cPoem->getNewestPoems(10);
        create_rss($poems, 'Uusimmat runot', 'http://www.runosydan.net/rss.php?special=newest');
    }
}
require 'general_functions.php';
// We must get poet ID OR special-action, so we have something to show.
if (!isset($_GET['poet_id']) && !isset($_GET['special'])) {
    header('Location: index.php');
}
// In special feeds (newest poems) call function which will create
// correct RSS-feed for this.
if (isset($_GET['special'])) {
    create_special_feed($db, $_GET['special']);
} else {
    // Get poet username
    $cUsers = new CUsers($db);
    $poet_username = $cUsers->getUsername($_GET['poet_id']);
    if ($poet_username == '') {
        header('Location: index.php');
    }
    // Get poet poems on first page
    require 'CPoem.php';
    $cPoems = new CPoem($db, $_SESSION);
    $poems = $cPoems->getPoems($_GET['poet_id'], 1, false);
    // Feed title
    $RSS_feed_title = 'Runoilijan ' . $poet_username . ' uusimmat runot';
    $RSS_feed_url = 'http://www.runosydan.net/rss.php?poet_id=' . $_GET['poet_id'];
    create_rss($poems, $RSS_feed_title, $url);
}