Example #1
0
function lastpostings($content)
{
    //returns a list of postings starting with the most recent
    global $currentid;
    global $postings;
    global $settings;
    //lb:lastpostings can have 5 attributes - number (no of postings to show),
    //cat (category), alpha (to show list in alphabetical order of titles),
    //posted (to show posting date/time alongside post title), and
    //author (to show author name)
    //so lets get those attributes
    $att = "";
    $att = getattributes($content);
    //some initial values
    $return = "";
    $start = 0;
    $order = "DESC";
    //possible attributes and default-values
    if (isset($att['number'])) {
        $loops = $att['number'];
    } else {
        $loops = 5;
    }
    if (isset($att['cat'])) {
        $cat = $att['cat'];
    }
    if (isset($att['alpha'])) {
        $alpha = $att['alpha'];
    } else {
        $alpha = "false";
    }
    if (isset($att['posted'])) {
        $posted = $att['posted'];
    } else {
        $posted = "false";
    }
    if (isset($att['author'])) {
        $author = $att['author'];
    } else {
        $author = "false";
    }
    //start building the data-base query
    $dosql = "SELECT * FROM " . $GLOBALS['prefix'] . "lb_postings WHERE ";
    //posting must be "live" to be displayed
    $dosql .= "status = '3' ";
    //posting must not be published in the future
    $dosql .= "AND posted < '" . date("Y-m-d H:i:s") . "' ";
    //if category is set, filter postings which don't fit
    if (isset($att['cat'])) {
        //which category-id do we request?
        $tempcatid = getcategoryidshort($cat);
        if ($tempcatid != "") {
            $dosql .= "AND (category1_id = " . $tempcatid . " ";
            $dosql .= "OR category2_id = " . $tempcatid . " ";
            $dosql .= "OR category3_id = " . $tempcatid . " ";
            $dosql .= "OR category4_id = " . $tempcatid . ") ";
        }
    }
    //if alpha is "true", order the output alphabetically
    if ($alpha == "true") {
        $dosql .= "ORDER BY title " . 'ASC';
    } else {
        $dosql .= "ORDER BY posted " . $order;
    }
    //we get the data and put it in an array
    $tempp = $GLOBALS['lbdata']->SelectLimit($dosql, $loops, $start);
    $allrows = $tempp->GetArray();
    //make html for post titles as an unstructured list
    $return = "<ul>";
    //loop through the array
    foreach ($allrows as $temp) {
        $currentid = $temp['id'];
        $postings[$currentid] = $temp;
        //each list item starts with the posting name with a link to the posting
        $return .= "<li><a href=\"?id=";
        $return .= $currentid;
        $return .= "\">";
        $return .= $postings[$currentid]['title'];
        $return .= "</a>";
        //if posted is "true", add the posting date
        if ($posted == "true") {
            $format = $settings['dateformat'];
            $date = date($format, strtotime($postings[$currentid]['posted']));
            $return .= " posted " . $date;
        }
        //if author is "true", add the author name
        if ($author == "true") {
            $name = getnickname($postings[$currentid]['author_id']);
            $return .= ", by " . $name;
        }
        $return .= "</li>";
    }
    //and close the unstructured list
    $return .= "</ul>";
    return $return;
}
        $dosql .= "OR category3_id = " . $tempcatid . " ";
        $dosql .= "OR category4_id = " . $tempcatid . ") ";
    }
}
//limiting number
$dosql .= "ORDER BY posted DESC LIMIT 0, {$settings['rss_postings']};";
$result = mysql_query($dosql) or die(mysql_error());
$i = 0;
while ($rows[$i] = mysql_fetch_assoc($result)) {
    $i += 1;
}
$lasttime = strtotime($rows[0]['posted']);
unset($rows[$i]);
//build category string
if (isset($_GET['cat'])) {
    $catname = ": " . getcategory(getcategoryidshort($_GET['cat']));
} else {
    $catname = "";
}
//build single posting string
if (isset($_GET['id'])) {
    $postname = ": " . $rows[0]['title'];
} else {
    $urlpost = "";
    $postname = "";
}
//Ready to rock'n'roll? Let's start building the feed!
echo "<rss version=\"2.0\" xmlns:itunes=\"http://www.itunes.com/DTDs/Podcast-1.0.dtd\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n\n";
echo "<channel>\n\n";
//building the right title for our little feed
echo "<title>" . chars($settings['sitename']);
Example #3
0
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
//getting data from postings-table
$dosql = "SELECT * FROM {$GLOBALS['prefix']}lb_postings WHERE ";
//do we have only a single posting to show?
if (isset($_GET['id'])) {
    $requested_id = (int) $_GET['id'];
    $dosql .= "id = '" . $requested_id . "' AND ";
}
//posting must be "live" to be displayed
$dosql .= "status = '3' ";
//posting must not be published in the future
$dosql .= "AND posted < '" . date("Y-m-d H:i:s") . "' ";
//if category is set, filter postings which don't fit
if (isset($_GET['cat'])) {
    //which category-id do we request via url?
    $tempcatid = getcategoryidshort($_GET['cat']);
    if (filled($tempcatid)) {
        $dosql .= "AND (category1_id = " . $tempcatid . " ";
        $dosql .= "OR category2_id = " . $tempcatid . " ";
        $dosql .= "OR category3_id = " . $tempcatid . " ";
        $dosql .= "OR category4_id = " . $tempcatid . ") ";
    }
}
// if tag is set .....
if (isset($_GET['tag'])) {
    $tagsToShow = explode('+', $_GET['tag']);
    $tagSQL = array();
    $taglist = array();
    foreach ($tagsToShow as $tagToShow) {
        $taglist[] = $tagToShow;
        $tagSQL[] = ' tags LIKE \'%' . $tagToShow . '%\'';
function if_category($content)
{
    //parse content only if a (certain) category or no category is being shown
    $att = getattributes($content);
    $return = "";
    $nocat = true;
    //checking the url for a category list request
    if (isset($_GET['cat'])) {
        if (!isset($att['category'])) {
            $return = fullparse(stripcontainer($content));
        } else {
            $att['category'] = htmlentities($att['category'], ENT_QUOTES, "UTF-8");
            if (getcategoryidshort($_GET['cat']) == getcategoryid($att['category'])) {
                $return = fullparse(stripcontainer($content));
            }
        }
        $nocat = false;
    }
    //checking url for single posting
    if (isset($_GET['id'])) {
        //checking if category is available
        $dosql = "SELECT category1_id, category2_id, category3_id, category4_id \n              FROM " . $GLOBALS['prefix'] . "lb_postings \n              WHERE id='" . $_GET['id'] . "';";
        $result = mysql_query($dosql) or die(mysql_error());
        $row = mysql_fetch_assoc($result);
        $show = false;
        foreach ($row as $c => $id) {
            if (!isset($att['category'])) {
                if ($id != 0) {
                    $return = fullparse(stripcontainer($content));
                    $nocat = false;
                    break;
                }
            } else {
                $att['category'] = htmlentities($att['category'], ENT_QUOTES, "UTF-8");
                if ($id == getcategoryid($att['category'])) {
                    $return = fullparse(stripcontainer($content));
                    $nocat = false;
                    break;
                }
            }
        }
    }
    //the "no category" option at the end
    if ($nocat and isset($att['category']) and $att['category'] == "false") {
        $return = fullparse(stripcontainer($content));
    }
    return trim($return);
}