Exemplo n.º 1
0
     echo "        </table>\n";
     echo "      </td>\n";
     echo "    </tr>\n";
     echo "    <tr>\n";
     echo "      <td align=\"left\">&nbsp;</td>\n";
     echo "    </tr>\n";
     echo "    <tr>\n";
     echo "      <td align=\"center\">", form_submit("updatefeedsubmit", gettext("Save")), "&nbsp;", form_submit("delete", gettext("Delete")), "&nbsp;", form_submit("cancel", gettext("Cancel")), "</td>\n";
     echo "    </tr>\n";
     echo "  </table>\n";
     echo "  </form>\n";
     echo "</div>\n";
     html_draw_bottom();
 } else {
     html_draw_top(sprintf('title=%s', gettext("Admin - RSS Feeds")), 'search.js', 'class=window_title');
     $rss_feeds = rss_feed_get_feeds($page);
     echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("RSS Feeds"), "</h1>\n";
     if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
         html_display_error_array($error_msg_array, '70%', 'center');
     } else {
         if (isset($_GET['added'])) {
             html_display_success_msg(gettext("Successfully added new feed"), '70%', 'center');
         } else {
             if (isset($_GET['edited'])) {
                 html_display_success_msg(gettext("Successfully edited feed"), '70%', 'center');
             } else {
                 if (isset($_GET['deleted'])) {
                     html_display_success_msg(gettext("Successfully removed selected feeds"), '70%', 'center');
                 } else {
                     if (sizeof($rss_feeds['rss_feed_array']) < 1) {
                         html_display_warning_msg(gettext("No existing RSS Feeds found. To add a feed click the 'Add New' button below"), '70%', 'center');
Exemplo n.º 2
0
function rss_feed_get_feeds($page = 1)
{
    if (!($db = db::get())) {
        return false;
    }
    if (!is_numeric($page) || $page < 1) {
        $page = 1;
    }
    $offset = calculate_page_offset($page, 10);
    if (!($table_prefix = get_table_prefix())) {
        return false;
    }
    if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) {
        return false;
    }
    $rss_feed_array = array();
    $sql = "SELECT SQL_CALC_FOUND_ROWS RSS_FEEDS.RSSID, RSS_FEEDS.NAME, USER.LOGON, ";
    $sql .= "USER.NICKNAME, USER_PEER.PEER_NICKNAME, RSS_FEEDS.FID, RSS_FEEDS.URL, ";
    $sql .= "RSS_FEEDS.PREFIX, RSS_FEEDS.FREQUENCY, RSS_FEEDS.MAX_ITEM_COUNT ";
    $sql .= "FROM `{$table_prefix}RSS_FEEDS` RSS_FEEDS ";
    $sql .= "LEFT JOIN USER USER ON (USER.UID = RSS_FEEDS.UID) ";
    $sql .= "LEFT JOIN `{$table_prefix}USER_PEER` USER_PEER ";
    $sql .= "ON (USER_PEER.PEER_UID = RSS_FEEDS.UID ";
    $sql .= "AND USER_PEER.UID = '{$_SESSION['UID']}') ";
    $sql .= "LIMIT {$offset}, 10";
    if (!($result = $db->query($sql))) {
        return false;
    }
    $sql = "SELECT FOUND_ROWS() AS ROW_COUNT";
    if (!($result_count = $db->query($sql))) {
        return false;
    }
    list($rss_feed_count) = $result_count->fetch_row();
    if ($result->num_rows == 0 && $rss_feed_count > 0 && $page > 1) {
        return rss_feed_get_feeds($page - 1);
    }
    while (($rss_feed_data = $result->fetch_assoc()) !== null) {
        if (isset($rss_feed_data['LOGON']) && isset($rss_feed_data['PEER_NICKNAME'])) {
            if (!is_null($rss_feed_data['PEER_NICKNAME']) && strlen($rss_feed_data['PEER_NICKNAME']) > 0) {
                $rss_feed_data['NICKNAME'] = $rss_feed_data['PEER_NICKNAME'];
            }
        }
        if (!isset($rss_feed_data['LOGON'])) {
            $rss_feed_data['LOGON'] = gettext("Unknown user");
        }
        if (!isset($rss_feed_data['NICKNAME'])) {
            $rss_feed_data['NICKNAME'] = "";
        }
        $rss_feed_array[] = $rss_feed_data;
    }
    return array('rss_feed_array' => $rss_feed_array, 'rss_feed_count' => $rss_feed_count);
}