/**
 * retrieve HTML summary for a set page
 *
 * @param int $id ID of the page
 *
 * @return string HTML summary for a set page
 */
function PageSummaries_getHtml($id)
{
    $PAGEDATA = Page::getInstance($id);
    global $sitedomain;
    $r = dbRow('select * from page_summaries where page_id="' . $PAGEDATA->id . '"');
    if (!count($r)) {
        return '<em>This page is marked as a page summary, but there is no ' . 'information on how to handle it.</em>';
    }
    if ($r['rss']) {
        return PageSummaries_rssToHtml($r['rss']);
    }
    // { build rss
    $title = $PAGEDATA->title == '' ? $sitedomain : htmlspecialchars($PAGEDATA->title);
    $rss = '<' . '?xml version="1.0" ?' . '><rss version="2.0"><channel><title>' . $title . '</title>';
    $rss .= '<link>' . $_SERVER['REQUEST_URI'] . '</link><description>RSS for ' . $PAGEDATA->name . '</description>';
    $category = $PAGEDATA->category ? ' and category="' . $PAGEDATA->category . '"' : '';
    $containedpages = PageSummaries_getContainedPages($r['parent_id']);
    if (count($containedpages)) {
        $q2 = dbAll('select edate,name,title,body from pages where id in (' . join(',', $containedpages) . ')' . $category . ' order by cdate desc limit 20');
        foreach ($q2 as $r2) {
            $rss .= '<item>';
            if (!$r2['title']) {
                $r2['title'] = $r2['name'];
            }
            $rss .= '<title>' . htmlspecialchars($r2['title']) . '</title>';
            $rss .= '<pubDate>' . date_m2h($r2['edate']) . '</pubDate>';
            // { build body
            if ($r['amount_to_show'] == 0 || $r['amount_to_show'] == 1) {
                $length = $r['amount_to_show'] == 0 ? 300 : 600;
                $body = str_replace('  ', ' ', preg_replace('/<[^>]*>/', ' ', str_replace(array('&amp;', '&nbsp;', '&lsquo;'), array('&', ' ', '&apos;'), $r2['body'])));
                $body = substr($body, 0, $length) . '...';
            } else {
                $body = $r2['body'];
            }
            $body = str_replace('&euro;', '&#8364;', $body);
            // }
            $rss .= '<description>' . $body . '</description>';
            $rss .= '<link>http://' . $_SERVER['HTTP_HOST'] . '/' . urlencode(str_replace(' ', '-', $r2['name'])) . '</link>';
            $rss .= '</item>';
        }
    }
    $rss .= '</channel></rss>';
    dbQuery('update page_summaries set rss="' . addslashes($rss) . '" where page_id="' . $PAGEDATA->id . '"');
    // }
    return PageSummaries_rssToHtml($rss);
}
Example #2
0
}
// }
// { list all users
$users = dbAll('select id,email,last_login,last_view from user_accounts order by last_view desc,last_login desc,email');
echo '<table style="min-width:50%"><tr><th>User</th><th>Groups</th><th>Last Login</th><th>Last View</th><th>Actions</th></tr>';
foreach ($users as $user) {
    echo '<tr><th><a href="siteoptions.php?page=users&amp;id=' . $user['id'] . '">' . htmlspecialchars($user['email']) . '</a></th>';
    // { groups
    echo '<td>';
    $grs = dbAll("select * from users_groups where user_accounts_id={$user['id']}");
    $garr = array();
    foreach ($grs as $gr) {
        if (!isset($groups[$gr['groups_id']])) {
            $groups[$gr['groups_id']] = dbOne("select name from groups where id={$gr['groups_id']} limit 1", 'name');
        }
        $garr[] = $groups[$gr['groups_id']];
    }
    echo join(', ', $garr);
    echo '</td>';
    // }
    // { last login
    echo '<td>' . ($user['last_login'] == '0000-00-00 00:00:00' ? 'never' : date_m2h($user['last_login'])) . '</td>';
    // }
    // { last view
    echo '<td>' . ($user['last_view'] == '0000-00-00 00:00:00' ? 'never' : date_m2h($user['last_view'])) . '</td>';
    // }
    echo '<td><a href="siteoptions.php?page=users&amp;id=' . $user['id'] . '">edit</a> <a href="siteoptions.php?page=users&amp;id=' . $user['id'] . '&amp;action=delete" onclick="return confirm(\'are you sure you want to delete this user?\')">[x]</a></td></tr>';
}
echo '<tr><td colspan="2"></td><td><a href="siteoptions.php?page=users&amp;id=-1">Create User</a></td></tr>';
echo '</table>';
// }