Esempio n. 1
0
function syndicate($content)
{
    //gets data from an rss- or atom-feed and builds an unordered list
    //This is based on MagPieRSS and a nice php-script by Richard Eriksson
    $att = getattributes($content);
    if (isset($att['number'])) {
        $number = $att['number'];
    } else {
        $number = 10;
    }
    if (isset($att['url'])) {
        $return = "<ul>";
        require_once "loudblog/inc/magpierss/rss_fetch.inc";
        $yummy = fetch_rss($att['url']);
        $yummyitems = array_slice($yummy->items, 0, $number);
        foreach ($yummyitems as $yummyitem) {
            $return .= '<li>';
            $return .= '<a href="';
            $return .= $yummyitem['link'];
            $return .= '">';
            $return .= $yummyitem['title'];
            $return .= '</a>';
            $return .= '</li>';
        }
        $return .= "</ul>";
    }
    return $return;
}
function bloglines($content)
{
    //calls external service Bloglines.com for generating a blogroll
    $att = getattributes($content);
    if (isset($att['username'])) {
        $remote = "http://rpc.bloglines.com/blogroll?html=1&id={$att['username']}";
        if (isset($att['folder'])) {
            $remote .= "&folder={$att['folder']}";
        }
    } else {
        $remote = "";
    }
    if (ini_get('allow_url_fopen')) {
        //copy the file from the url to variable
        $sourcefile = fopen($remote, "rb") or die("not successfully!");
        $eof = false;
        $return = "";
        do {
            $temp = fread($sourcefile, 1024) or $eof = true;
            $return .= $temp;
        } while ($eof == false);
        fclose($sourcefile);
    } else {
        $return = "<script language=\"javascript\"";
        $return .= "type=\"text/javascript\" src=\"{$remote}\"></script>";
        $return = str_replace("?html=1&", "?", $return);
    }
    return $return;
}
function delicious($content)
{
    //calls external service del.icio.us for generating a linklist
    //This is based on MagPieRSS and a nice php-script by Richard Eriksson
    $att = getattributes($content);
    if (isset($att['number'])) {
        $number = $att['number'];
    } else {
        $number = 10;
    }
    $user = "";
    $tag = "";
    if (isset($att['username'])) {
        $user = "******" . $att['username'];
    }
    if (isset($att['tag'])) {
        if ($user == "") {
            $tag = "/tag";
        }
        $tag .= "/" . $att['tag'];
    }
    $return = "<ul>";
    require_once "loudblog/inc/magpierss/rss_fetch.inc";
    $url = "http://del.icio.us/rss{$user}{$tag}";
    $yummy = fetch_rss($url);
    $maxitems = $number;
    $yummyitems = array_slice($yummy->items, 0, $maxitems);
    foreach ($yummyitems as $yummyitem) {
        $return .= '<li>';
        $return .= '<a href="';
        $return .= $yummyitem['link'];
        $return .= '">';
        $return .= $yummyitem['title'];
        $return .= '</a>';
        $return .= '</li>';
    }
    $return .= "</ul>";
    return $return;
}
Esempio n. 4
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;
}
Esempio n. 5
0
function archive($context)
{
    $attributes = getattributes($context);
    $content = '';
    // define something
    $displayMonth['01'] = 'January';
    $displayMonth['02'] = 'February';
    $displayMonth['03'] = 'March';
    $displayMonth['04'] = 'April';
    $displayMonth['05'] = 'May';
    $displayMonth['06'] = 'June';
    $displayMonth['07'] = 'July';
    $displayMonth['08'] = 'August';
    $displayMonth['09'] = 'September';
    $displayMonth['10'] = 'October';
    $displayMonth['11'] = 'November';
    $displayMonth['12'] = 'December';
    // parse attributes
    if (isset($attributes['begin'])) {
        $startlist = $attributes['begin'];
    } else {
        $startlist = "1900-01";
    }
    if (isset($attributes['end'])) {
        $stoplist = $attributes['end'];
    } else {
        $stoplist = "2020-12";
    }
    //define data for db-query
    // start the archive on ...
    $month = (int) substr($startlist, 5, 2);
    $year = substr($startlist, 0, 4);
    $firstDay = mktime(0, 0, 0, $month, 1, $year);
    // end the archive on ...
    $month = (int) substr($stoplist, 5, 2);
    $year = substr($stoplist, 0, 4);
    $lastDay = mktime(23, 59, 59, $month + 1, 0, $year);
    // get post dates
    $dosql = "SELECT posted FROM " . $GLOBALS['prefix'] . "lb_postings WHERE posted >= '" . date("Y-m-d H:i:s", $firstDay) . "' AND posted < '" . date("Y-m-d H:i:s", $lastDay) . "' AND status = '3' ORDER BY posted";
    $result = $GLOBALS['lbdata']->Execute($dosql);
    $rows = $result->GetArray();
    //show all months where postings exist
    $content .= "\n<ul id=\"archive\">\n";
    $prevmonth = "foobar";
    if (isset($_GET['date'])) {
        $activemonth = substr($_GET['date'], 0, 7);
    } else {
        $activemonth = "";
    }
    foreach ($rows as $row) {
        $thismonth = date("Y-m", strtotime($row['posted']));
        if ($thismonth != $prevmonth) {
            $moncode = substr($thismonth, 5, 2);
            $year = substr($thismonth, 0, 4);
            if ($thismonth == $activemonth) {
                $class = " class=\"active\"";
            } else {
                $class = "";
            }
            $content .= "    <li" . $class . "><a href=\"?date=" . $thismonth . "\">";
            $content .= $displayMonth[$moncode] . " " . $year . "</a></li>\n";
        }
        $prevmonth = $thismonth;
    }
    $content .= "</ul>\n\n";
    return $content;
}
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);
}
Esempio n. 7
0
function loop_tags($content)
{
    //returns a loop-routine for all existing tags
    global $currenttag;
    global $alltags;
    $att = getattributes($content);
    $content = stripcontainer($content);
    $tags = gettaglist();
    $return = '';
    foreach ($tags as $tag) {
        $currenttag = $tag;
        $alltags[$currenttag] = $tag;
        $return .= fullparse($content);
    }
    return trim($return);
}
Esempio n. 8
0
function calendar($context)
{
    // Please change the following lines to display the calendar in your language!
    // ---------------------------------------------------------------------------
    $displayDay[0] = 'mon';
    $displayDay[1] = 'tue';
    $displayDay[2] = 'wed';
    $displayDay[3] = 'thu';
    $displayDay[4] = 'fri';
    $displayDay[5] = 'sat';
    $displayDay[6] = 'sun';
    $displayMonth[0] = 'january';
    $displayMonth[1] = 'february';
    $displayMonth[2] = 'march';
    $displayMonth[3] = 'april';
    $displayMonth[4] = 'may';
    $displayMonth[5] = 'june';
    $displayMonth[6] = 'july';
    $displayMonth[7] = 'august';
    $displayMonth[8] = 'september';
    $displayMonth[9] = 'october';
    $displayMonth[10] = 'november';
    $displayMonth[11] = 'december';
    // -------------------------------------------------------------------------------
    // Loudblog plugin
    // month-by-month Calendar
    //
    // Written by André Neubauer
    //      http://www.digitalesdenken.de
    //      andre.neubauer@gmx.de
    //
    // Configure #calendar in your style-sheet file to
    // style this component
    //
    // Available attributes
    //      firstDayOfWeek = defines the first day of the week
    //                       use 0 for sunday, 1 for monday, ...
    //      decoration = 0 for no decoration
    //                   1 for displaying abbrevations of days and current month, year
    //
    // Released under the Gnu General Public License
    // http://www.gnu.org/copyleft/gpl.html
    // -------------------------------------------------------------------------------
    $attributes = getattributes($context);
    $content = '';
    // parse attributes
    if (isset($attributes['firstDayOfWeek'])) {
        $firstDayOfWeek = $attributes['firstDayOfWeek'];
    } else {
        $firstDayOfWeek = 0;
    }
    if (isset($attributes['decoration'])) {
        $decoration = $attributes['decoration'];
    } else {
        $decoration = 1;
    }
    // lookup for special request
    if (isset($_GET['date'])) {
        $date = $_GET['date'];
        $seperator = strpos($date, '-');
        $year = substr($date, 0, $seperator);
        $month = substr($date, $seperator + 1);
    } else {
        $month = date('m');
        $year = date('Y');
    }
    // first day of month
    $firstDay = mktime(0, 0, 0, $month, 1, $year);
    $dayOfWeek = (date('w', $firstDay) + 7 - $firstDayOfWeek) % 7;
    // last day of month
    $lastDay = mktime(0, 0, 0, $month + 1, 0, $year);
    $maxDays = date('d', $lastDay);
    // previous month
    $previousMonth = mktime(0, 0, 0, $month - 1, 1, $year);
    // next month
    $nextMonth = mktime(0, 0, 0, $month + 1, 1, $year);
    // get posts
    $sql = "SELECT title, posted FROM " . $GLOBALS['prefix'] . "lb_postings WHERE posted >= '" . date("Y-m-d H:i:s", $firstDay) . "' AND posted < '" . date("Y-m-d H:i:s", $nextMonth) . "';";
    $result = mysql_query($sql) or die(mysql_error());
    // merge results
    $posts = array();
    while ($row = mysql_fetch_assoc($result)) {
        $key = str_replace("0", "", substr($stripped = strrchr($row['posted'], "-"), 1, strpos($stripped, ' ') - 1));
        if (array_key_exists($key, $posts)) {
            $posts[$key] = $posts[$key] . ", " . $row['title'];
        } else {
            $posts[$key] = $row['title'];
        }
    }
    $i = 1;
    $content .= "<table id=\"calendar\">\n<thead>\n";
    if ($decoration == 1) {
        $content .= "<tr>\n<th colspan=\"7\">" . $displayMonth[$month - 1] . " " . $year . "</th></tr>\n<tr>\n";
        foreach ($displayDay as $singleDay) {
            $content .= "<th>" . $singleDay . "</th>";
        }
    }
    $content .= "</thead>\n<tbody>\n";
    while ($i <= $maxDays + $dayOfWeek) {
        $content .= "<tr>\n";
        for ($j = 0; $j < 7; $j++) {
            if ($i > $dayOfWeek && $i <= $maxDays + $dayOfWeek) {
                $current = $i - $dayOfWeek;
                if (array_key_exists($current, $posts)) {
                    $content .= "<td><a href=index.php?date=" . date("Y-m-d", mktime(0, 0, 0, $month, $current, $year)) . " title=\"" . $posts[$current] . "\">" . $current . "</td>";
                } else {
                    $content .= "<td>" . $current . "</td>";
                }
            } else {
                $content .= "<td>&nbsp;</td>";
            }
            $i++;
        }
        $content .= "</tr>";
    }
    $content .= "</tbody>\n<tfoot>\n";
    $content .= "<tr>\n";
    $content .= "<th colspan=3><a href=index.php?date=" . date("Y-m", $previousMonth) . "><<</a></th><th>&nbsp;</th>";
    $content .= "<th colspan=3><a href=index.php?date=" . date("Y-m", $nextMonth) . ">>></a></th>";
    $content .= "</tr>\n";
    $content .= "</tfoot>\n</table>\n";
    return $content;
}
function if_category($content)
{
    //parse content only if a (certain) category is being shown
    $att = getattributes($content);
    $return = "";
    if (isset($_GET['cat'])) {
        if (!isset($att['category'])) {
            $return = fullparse(stripcontainer($content));
        } else {
            if ($_GET['cat'] == $att['category']) {
                $return = fullparse($content);
            }
        }
    }
    return trim($return);
}