}
    $feed .= "</channel>";
    $feed .= "</rss>";
    return $feed;
}
// ----------------------------------------------------------------------------
function item($title, $email, $link, $description, $date)
{
    $item = "<item>";
    $item .= "<author>{$email}</author>";
    $item .= "<title>{$title}</title>";
    if ($link) {
        $item .= "<link>{$link}</link>";
    }
    $item .= "<description>{$description}</description>";
    $item .= "<pubDate>{$date}</pubDate>";
    $item .= "</item>";
    return $item;
}
try {
    $description = "Comments left by users.";
    $url = "http://terminal.jcubic.pl/comments-rss.php";
    $feed = feed("JQuery Terminal Comments", $url, $description);
    header('Content-Type: application/rss+xml');
    //echo pretty_xml($feed);
    echo $feed;
} catch (Exception $e) {
    header("HTTP/1.1 500 Internal Server Error");
    echo "Server Error: " . $e->getMessage();
    exit(1);
}
Example #2
0
<?php

$app->get('/feed(/:startFrom)', function ($startFrom = 0) use($app, $config, $connection_name) {
    try {
        $app->response->headers->set('Content-Type', 'application/json');
        include '../app/functions.feed.php';
        echo feed($connection_name, $startFrom);
    } catch (\Exception $e) {
        $app->error($e);
    }
});
$app->get('/history/:startFrom', function ($startFrom) use($app, $config, $connection_name) {
    try {
        $app->response->headers->set('Content-Type', 'application/json');
        include '../app/functions.feed.php';
        echo feedhistory($connection_name, $startFrom);
    } catch (\Exception $e) {
        $app->error($e);
    }
});
$app->get('/resources/:id(/:maxWidth)', function ($id, $maxWidth = 0) use($app, $config, $connection_name) {
    try {
        include '../app/functions.image.php';
        $fp = getResources($config['uploads_dir'], $id, $maxWidth, $connection_name);
        if (!$fp) {
            $app->notFound();
        }
        $app->response->headers->set('Content-Type', $fp['mime']);
        $app->response->setBody($fp['data']);
    } catch (\Exception $e) {
        $app->error($e);
function latestFeed($numrows = 5)
{
    $output = feed($numrows);
    return $output;
}
Example #4
0
function preText($s, $prefs)
{
    extract($prefs);
    callback_event('pretext');
    if (gps('rss')) {
        include txpath . '/publish/feeds.php';
        exit(feed(false));
    }
    if (gps('atom')) {
        include txpath . '/publish/feeds.php';
        exit(feed(true));
    }
    // set messy variables
    $out = makeOut('id', 's', 'c', 'q', 'pg', 'p', 'month', 'author');
    // some useful vars for taghandlers, plugins
    $out['request_uri'] = preg_replace("|^https?://[^/]+|i", "", serverSet('REQUEST_URI'));
    $out['qs'] = serverSet('QUERY_STRING');
    // IIS fix
    if (!$out['request_uri'] and serverSet('SCRIPT_NAME')) {
        $out['request_uri'] = serverSet('SCRIPT_NAME') . (serverSet('QUERY_STRING') ? '?' . serverSet('QUERY_STRING') : '');
    }
    // another IIS fix
    if (!$out['request_uri'] and serverSet('argv')) {
        $argv = serverSet('argv');
        $out['request_uri'] = @substr($argv[0], strpos($argv[0], ';') + 1);
    }
    // define the useable url, minus any subdirectories.
    // this is pretty fugly, if anyone wants to have a go at it - dean
    $out['subpath'] = $subpath = preg_quote(preg_replace("/https?:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/");
    $out['req'] = $req = preg_replace("/^{$subpath}/i", "/", $out['request_uri']);
    $is_404 = 0;
    // if messy vars exist, bypass url parsing
    if (!$out['id'] && !$out['s'] && !(txpinterface == 'css') && !(txpinterface == 'admin')) {
        // return clean URL test results for diagnostics
        if (gps('txpcleantest')) {
            exit(show_clean_test($out));
        }
        extract(chopUrl($req));
        //first we sniff out some of the preset url schemes
        if (strlen($u1)) {
            switch ($u1) {
                case 'atom':
                    include txpath . '/publish/feeds.php';
                    exit(feed(true));
                case 'rss':
                    include txpath . '/publish/feeds.php';
                    exit(feed(false));
                    // urldecode(strtolower(urlencode())) looks ugly but is the only way to
                    // make it multibyte-safe without breaking backwards-compatibility
                // urldecode(strtolower(urlencode())) looks ugly but is the only way to
                // make it multibyte-safe without breaking backwards-compatibility
                case urldecode(strtolower(urlencode(gTxt('section')))):
                    $out['s'] = ckEx('section', $u2) ? $u2 : '';
                    $is_404 = empty($out['s']);
                    break;
                case urldecode(strtolower(urlencode(gTxt('category')))):
                    $out['c'] = ckEx('category', $u2) ? $u2 : '';
                    $is_404 = empty($out['c']);
                    break;
                case urldecode(strtolower(urlencode(gTxt('author')))):
                    $out['author'] = !empty($u2) ? $u2 : '';
                    break;
                    // AuthorID gets resolved from Name further down
                // AuthorID gets resolved from Name further down
                case urldecode(strtolower(urlencode(gTxt('file_download')))):
                    $out['s'] = 'file_download';
                    $out['id'] = !empty($u2) ? $u2 : '';
                    break;
                default:
                    // then see if the prefs-defined permlink scheme is usable
                    switch ($permlink_mode) {
                        case 'section_id_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
                                $is_404 = empty($out['s']);
                            } else {
                                $rs = lookupByIDSection($u2, $u1);
                                $out['s'] = @$rs['Section'];
                                $out['id'] = @$rs['ID'];
                                $is_404 = (empty($out['s']) or empty($out['id']));
                            }
                            break;
                        case 'year_month_day_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
                                $is_404 = empty($out['s']);
                            } elseif (empty($u4)) {
                                $month = "{$u1}-{$u2}";
                                if (!empty($u3)) {
                                    $month .= "-{$u3}";
                                }
                                if (preg_match('/\\d+-\\d+(?:-\\d+)?/', $month)) {
                                    $out['month'] = $month;
                                    $out['s'] = 'default';
                                } else {
                                    $is_404 = 1;
                                }
                            } else {
                                $when = "{$u1}-{$u2}-{$u3}";
                                $rs = lookupByDateTitle($when, $u4);
                                $out['id'] = !empty($rs['ID']) ? $rs['ID'] : '';
                                $out['s'] = !empty($rs['Section']) ? $rs['Section'] : '';
                                $is_404 = (empty($out['s']) or empty($out['id']));
                            }
                            break;
                        case 'section_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
                                $is_404 = empty($out['s']);
                            } else {
                                $rs = lookupByTitleSection($u2, $u1);
                                $out['id'] = @$rs['ID'];
                                $out['s'] = @$rs['Section'];
                                $is_404 = (empty($out['s']) or empty($out['id']));
                            }
                            break;
                        case 'title_only':
                            $rs = lookupByTitle($u1);
                            $out['id'] = @$rs['ID'];
                            $out['s'] = empty($rs['Section']) ? ckEx('section', $u1) : $rs['Section'];
                            $is_404 = empty($out['s']);
                            break;
                        case 'id_title':
                            if (is_numeric($u1) && ckExID($u1)) {
                                $rs = lookupByID($u1);
                                $out['id'] = !empty($rs['ID']) ? $rs['ID'] : '';
                                $out['s'] = !empty($rs['Section']) ? $rs['Section'] : '';
                                $is_404 = (empty($out['s']) or empty($out['id']));
                            } else {
                                # We don't want to miss the /section/ pages
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
                                $is_404 = empty($out['s']);
                            }
                            break;
                    }
            }
        } else {
            $out['s'] = 'default';
        }
    } else {
        // Messy mode, but prevent to get the id for file_downloads
        if ($out['id'] && !$out['s']) {
            $rs = lookupByID($out['id']);
            $out['id'] = !empty($rs['ID']) ? $rs['ID'] : '';
            $out['s'] = !empty($rs['Section']) ? $rs['Section'] : '';
            $is_404 = (empty($out['s']) or empty($out['id']));
        }
    }
    // Resolve AuthorID from Authorname
    if ($out['author']) {
        $name = urldecode(strtolower(urlencode($out['author'])));
        $name = safe_field('name', 'txp_users', "RealName like '" . doSlash($out['author']) . "'");
        if ($name) {
            $out['author'] = $name;
        } else {
            $out['author'] = '';
            $is_404 = true;
        }
    }
    // Stats: found or not
    $out['status'] = $is_404 ? '404' : '200';
    $out['pg'] = is_numeric($out['pg']) ? intval($out['pg']) : '';
    $out['id'] = is_numeric($out['id']) ? intval($out['id']) : '';
    if ($out['s'] == 'file_download') {
        // get id of potential filename
        if (!is_numeric($out['id'])) {
            $rs = safe_row("*", "txp_file", "filename='" . doSlash($out['id']) . "' and status = 4");
        } else {
            $rs = safe_row("*", "txp_file", 'id=' . intval($out['id']) . ' and status = 4');
        }
        $out = $rs ? array_merge($out, $rs) : array('s' => 'file_download', 'file_error' => 404);
        return $out;
    }
    if (!$is_404) {
        $out['s'] = empty($out['s']) ? 'default' : $out['s'];
    }
    $s = $out['s'];
    $id = $out['id'];
    // hackish
    global $is_article_list;
    if (empty($id)) {
        $is_article_list = true;
    }
    // by this point we should know the section, so grab its page and css
    $rs = safe_row("*", "txp_section", "name = '" . doSlash($s) . "' limit 1");
    $out['page'] = @$rs['page'];
    if (is_numeric($id)) {
        $a = safe_row('*, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires', 'textpattern', 'ID=' . intval($id) . ' and Status in (4,5)');
        if ($a) {
            $Posted = $a['Posted'];
            $out['id_keywords'] = $a['Keywords'];
            // TODO: remove, since this is already in $thisarticle?
            $out['id_author'] = $a['AuthorID'];
            // TODO: remove, since this is already in $thisarticle?
            populateArticleData($a);
            $uExpires = $a['uExpires'];
            if ($uExpires != NULLDATETIME and time() > $uExpires and !$publish_expired_articles) {
                $out['status'] = '410';
            }
            if ($np = getNextPrev($id, $Posted, $s)) {
                $out = array_merge($out, $np);
            }
        }
    }
    $out['path_to_site'] = $path_to_site;
    $out['permlink_mode'] = $permlink_mode;
    $out['sitename'] = $sitename;
    return $out;
}
Example #5
0
        case 'clear':
            comment_delete($to);
            break;
        case 'post':
            post_add($at);
            break;
        case 'board':
            board_view($at);
            break;
        case 'join':
            member_join();
            break;
        case 'modify':
            member_modify();
            break;
        case 'member':
            member_view($to);
            break;
        case 'feed':
            feed();
            break;
        case 'action':
            require './core/action.php';
            break;
        default:
            include load_page($_GET['do']);
    }
} else {
    include load_page('index');
}
mysql_close($connect);
Example #6
0
 protected function make()
 {
     return feed();
 }
Example #7
0
 function pmaRSSFeed($cachefilename)
 {
     feed($this, $cachefilename);
 }