Пример #1
0
                            <p class="meta">securityfocus.com</p>

    <?php 
rss('http://www.securityfocus.com/rss/vulnerabilities.xml');
?>

                        </div>
                    </div>
                    
                        <div class="post">
                        <h2 class="title"><a name="cxsecurity" href="#top" >cxsecurity</a></h2>
                        <div class="entry">
                            <p class="meta">cxsecurity.com</p>

    <?php 
rss('http://cxsecurity.com/cverss/fullmap/');
?>

                        </div>
                    </div>
                    <div style="clear: both;">&nbsp;</div>
                </div>
                <div id="sidebar">
                    <ul>
                        <li>
                            <h2>Home</h2>
                            <ul>
                                <li><a href="index.php">Index</a></li>
                                <li><a href="settings.php">Settings</a></li>
                                <li><a href="rss.php"><b>RSS</b></a></li>
                            </ul>
Пример #2
0
// Check first for genconfig before we try to parseConfig
if ($argv[1] == 'genconfig') {
    genConfig();
    exit;
}
// Parse the user's config
$config = parseConfig($config['configfile'], $config);
// Main Controler
if ($_REQUEST['rss'] !== NULL or $argv[1] == 'rss') {
    // Run rss()
    // Create instance of cache class.
    $cache = new cache('rss.xml', $config);
    // Start the caching engine
    $cache->start();
    // Do the actuall rss function
    rss();
    // End the rss engine
    $cache->end();
} else {
    if ($argv[1] == 'setstatus') {
        genStatusUpdate();
    } else {
        if ($argv[1] == '-h' || $argv[1] == '--help') {
            echo <<<EOT
{$config['version']} Help
\trss - Output RSS
\tsetstatus - netstat.txt generation helper
\tgenconfig - generate sample netstat.conf.php
\t
EOT;
        } else {
Пример #3
0
function preText($s, $prefs)
{
    extract($prefs);
    callback_event('pretext');
    if (gps('rss')) {
        include txpath . '/publish/rss.php';
        exit(rss());
    }
    if (gps('atom')) {
        include txpath . '/publish/atom.php';
        exit(atom());
    }
    // 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/atom.php';
                    exit(atom());
                case 'rss':
                    include txpath . '/publish/rss.php';
                    exit(rss());
                    // 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;
        }
    }
    // allow article preview
    if (gps('txpreview') and is_logged_in()) {
        global $nolog;
        $nolog = true;
        $rs = safe_row("ID as id,Section as s", 'textpattern', 'ID = ' . intval(gps('txpreview')) . ' limit 1');
        if ($rs and $is_404) {
            $is_404 = false;
            $out = array_merge($out, $rs);
        }
    }
    // 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("page, css", "txp_section", "name = '" . doSlash($s) . "' limit 1");
    $out['page'] = @$rs['page'];
    $out['css'] = @$rs['css'];
    if (is_numeric($id) and !$is_404) {
        $a = safe_row('*, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod', 'textpattern', 'ID=' . intval($id) . (gps('txpreview') ? '' : ' and Status in (4,5)'));
        if ($a) {
            $Posted = $a['Posted'];
            $out['id_keywords'] = $a['Keywords'];
            $out['id_author'] = $a['AuthorID'];
            populateArticleData($a);
            $uExpires = $a['uExpires'];
            if ($uExpires and time() > $uExpires and !$publish_expired_articles) {
                $out['status'] = '410';
            }
            if ($np = getNextPrev($id, $Posted, $s)) {
                $out = array_merge($out, $np);
            }
        }
    }
    $out['path_from_root'] = rhu;
    // these are deprecated as of 1.0
    $out['pfr'] = rhu;
    // leaving them here for plugin compat
    $out['path_to_site'] = $path_to_site;
    $out['permlink_mode'] = $permlink_mode;
    $out['sitename'] = $sitename;
    return $out;
}
Пример #4
0
function preText($s, $prefs)
{
    extract($prefs);
    if (gps('rss')) {
        include txpath . '/publish/rss.php';
        exit(rss());
    }
    if (gps('atom')) {
        include txpath . '/publish/atom.php';
        exit(atom());
    }
    // set messy variables
    $out = makeOut('id', 's', 'c', 'q', 'pg', 'p', 'month');
    // if messy vars exist, bypass url parsing
    if (!$out['id'] && !$out['s']) {
        // define the useable url, minus any subdirectories.
        // this is pretty fugly, if anyone wants to have a go at it - dean
        $subpath = preg_quote(preg_replace("/http:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/");
        $req = preg_replace("/^{$subpath}/i", "/", serverSet('REQUEST_URI'));
        extract(chopUrl($req));
        //first we sniff out some of the preset url schemes
        if (!empty($u1)) {
            switch ($u1) {
                case 'atom':
                    include txpath . '/publish/atom.php';
                    exit(atom());
                case 'rss':
                    include txpath . '/publish/rss.php';
                    exit(rss());
                case strtolower(gTxt('section')):
                    $out['s'] = ckEx('section', $u2) ? $u2 : 'default';
                    break;
                case strtolower(gTxt('category')):
                    $out['c'] = ckEx('category', $u2) ? $u2 : '';
                    break;
                case urlencode(strtolower(gTxt('author'))):
                    $author_name = !empty($u2) ? urldecode($u2) : '';
                    $out['author'] = safe_field('name', 'txp_users', "RealName like '{$author_name}'");
                    break;
                case strtolower(gTxt('file_download')):
                    $out['s'] = 'file_download';
                    $out['id'] = !empty($u2) ? $u2 : '';
                    break;
                case 'p':
                    $out['p'] = is_numeric($u2) ? $u2 : '';
                    break;
                default:
                    // then see if the prefs-defined permlink scheme is usable
                    switch ($permlink_mode) {
                        case 'section_id_title':
                            $out['s'] = ckEx('section', $u1) ? $u1 : 'default';
                            $out['id'] = is_numeric($u2) && ckExID($u2) ? $u2 : '';
                            break;
                        case 'year_month_day_title':
                            if (empty($u4)) {
                                $out['month'] = "{$u1}-{$u2}";
                                if (!empty($u3)) {
                                    $out['month'] .= "-{$u3}";
                                }
                                $out['s'] = 'default';
                            } else {
                                $when = date("Y-m-d", strtotime("{$u1}-{$u2}-{$u3}") + $timeoffset);
                                $rs = lookupByDateTitle($when, $u4);
                                $out['id'] = !empty($rs['ID']) ? $rs['ID'] : '';
                                $out['s'] = !empty($rs['Section']) ? $rs['Section'] : '';
                            }
                            break;
                        case 'section_title':
                            $rs = lookupByTitleSection($u2, $u1);
                            $out['id'] = !empty($rs['ID']) ? $rs['ID'] : '';
                            $out['s'] = ckEx('section', $u1) ? $u1 : 'default';
                            break;
                        case 'title_only':
                            $rs = lookupByTitle($u1);
                            $out['id'] = !empty($rs['ID']) ? $rs['ID'] : '';
                            $out['s'] = !empty($rs['Section']) ? $rs['Section'] : ckEx('section', $u1) ? $u1 : 'default';
                            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'] : 'default';
                            } else {
                                # We don't want to miss the /section/ pages
                                $out['s'] = ckEx('section', $u1) ? $u1 : 'default';
                            }
                            break;
                    }
            }
        } else {
            $out['s'] = 'default';
        }
    } else {
        // Messy mode, but prevent to get the id for file_downloads
        if ($out['id'] && !$out['s']) {
            $out['s'] = safe_field('section', 'textpattern', "ID='" . doSlash($out['id']) . "'");
        }
    }
    if ($out['s'] == 'file_download') {
        // get id of potential filename
        if (!is_numeric($out['id'])) {
            $rs = safe_row("*", "txp_file", "filename='" . $out['id'] . "'");
        } else {
            $rs = safe_row("*", "txp_file", "id='" . $out['id'] . "'");
        }
        $out = $rs ? array_merge($out, $rs) : array('s' => 'file_download', 'file_error' => 404);
        return $out;
    }
    $out['s'] = empty($out['s']) ? 'default' : $out['s'];
    $s = $out['s'];
    $id = $out['id'];
    // hackish
    if (empty($id)) {
        $GLOBALS['is_article_list'] = true;
    }
    // by this point we should know the section, so grab its page and css
    $rs = safe_row("*", "txp_section", "name = '{$s}' limit 1");
    $out['page'] = @$rs['page'];
    $out['css'] = @$rs['css'];
    if (is_numeric($id)) {
        $idrs = safe_row("Posted, AuthorID, Keywords", "textpattern", "ID={$id}");
        extract($idrs);
        if ($np = getNextPrev($id, $Posted, $s)) {
            $out = array_merge($out, $np);
        }
        $out['id_keywords'] = $Keywords;
        $out['id_author'] = get_author_name($AuthorID);
    }
    $out['path_from_root'] = $path_from_root;
    // these are deprecated as of 1.0
    $out['pfr'] = $path_from_root;
    // leaving them here for plugin compat
    $out['path_to_site'] = $path_to_site;
    $out['permlink_mode'] = $permlink_mode;
    $out['sitename'] = htmlspecialchars($sitename);
    return $out;
}
Пример #5
0
function preText($s, $prefs)
{
    extract($prefs);
    callback_event('pretext');
    if (gps('rss')) {
        include txpath . '/publish/rss.php';
        exit(rss());
    }
    if (gps('atom')) {
        include txpath . '/publish/atom.php';
        exit(atom());
    }
    // set messy variables
    $out = makeOut('id', 's', 'c', 'q', 'pg', 'p', 'month', 'author');
    // some useful vars for taghandlers, plugins
    $out['request_uri'] = serverSet('REQUEST_URI');
    $out['qs'] = serverSet('QUERY_STRING');
    // IIS - can someone confirm whether or not this works?
    if (!$out['request_uri'] and $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("/http:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/");
    $out['req'] = $req = preg_replace("/^{$subpath}/i", "/", serverSet('REQUEST_URI'));
    $is_404 = 0;
    // if messy vars exist, bypass url parsing
    if (!$out['id'] && !$out['s']) {
        extract(chopUrl($req));
        //first we sniff out some of the preset url schemes
        if (!empty($u1)) {
            switch ($u1) {
                case 'atom':
                    include txpath . '/publish/atom.php';
                    exit(atom());
                case 'rss':
                    include txpath . '/publish/rss.php';
                    exit(rss());
                    // 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 : '';
                    break;
                case urldecode(strtolower(urlencode(gTxt('category')))):
                    $out['c'] = ckEx('category', $u2) ? $u2 : '';
                    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;
                case 'p':
                    $out['p'] = is_numeric($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 = ckExID($u2);
                                $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']) {
            $out['s'] = safe_field('section', 'textpattern', "ID='" . doSlash($out['id']) . "'");
        }
    }
    // Resolve AuthorID from Authorname
    if ($out['author']) {
        $out['author'] = safe_field('name', 'txp_users', "RealName like '" . doSlash($out['author']) . "'");
    }
    // Stats: found or not
    $out['status'] = $is_404 ? '404' : '200';
    if ($out['s'] == 'file_download') {
        // get id of potential filename
        if (!is_numeric($out['id'])) {
            $rs = safe_row("*", "txp_file", "filename='" . doSlash($out['id']) . "'");
        } else {
            $rs = safe_row("*", "txp_file", "id='" . intval($out['id']) . "'");
        }
        $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
    if (empty($id)) {
        $GLOBALS['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'];
    // Remove the below line if nothing breaks
    // 		$out['css']  = @$rs['css'];
    if (is_numeric($id)) {
        $idrs = safe_row("Posted, AuthorID, Keywords", "textpattern", "ID=" . doSlash($id));
        extract($idrs);
        if ($np = getNextPrev($id, $Posted, $s)) {
            $out = array_merge($out, $np);
        }
        $out['id_keywords'] = $Keywords;
        $out['id_author'] = get_author_name($AuthorID);
    }
    $out['path_from_root'] = $path_from_root;
    // these are deprecated as of 1.0
    $out['pfr'] = $path_from_root;
    // leaving them here for plugin compat
    $out['path_to_site'] = $path_to_site;
    $out['permlink_mode'] = $permlink_mode;
    $out['sitename'] = htmlspecialchars($sitename);
    return $out;
}
Пример #6
0
function randEngine()
{
    global $keywords, $rss_arr;
    for ($i = 0; $i < 4; $i++) {
        array_pop($keywords);
    }
    $a = count($keywords);
    $b = count($rss_arr);
    if (rand(1, $a + $b) <= $b) {
        $key = array_rand($rss_arr, 1);
        $data = rss($key);
        array_unshift($data, $rss_arr[$key]);
    } else {
        $data = $keywords[array_rand($keywords, 1)];
    }
    return $data;
}
Пример #7
0
 case "print":
     printlink($link_id, $option);
     break;
     /* RSS feed */
 /* RSS feed */
 case 'rss':
     $type = JRequest::getCmd('type', 'new');
     $token = JRequest::getCmd('token', '');
     $rss_secret_token = $mtconf->get('rss_secret_token');
     if ($type == 'new' && $mtconf->get('show_listnewrss') == 0 || $type == 'type' && $mtconf->get('show_listupdatedrss') == 0) {
         echo JText::_("ALERTNOTAUTH");
     } elseif (!empty($rss_secret_token) && $token != $rss_secret_token) {
         echo JText::_("ALERTNOTAUTH");
     } else {
         require_once JPATH_SITE . DS . 'components' . DS . 'com_mtree' . DS . 'rss.php';
         rss($option, $type, $cat_id);
     }
     break;
     /* Visit a URL */
 /* Visit a URL */
 case "visit":
     visit($link_id, $cf_id);
     break;
     /* Reviews */
 /* Reviews */
 case "writereview":
     writereview($link_id, $option);
     break;
 case "addreview":
     addreview($link_id, $option);
     break;
Пример #8
0
 * @author Carlo Joerges <*****@*****.**>
 *
 * @copyright Copyright 2008 Peter Gassner
 * @license http://www.opensource.org/licenses/gpl-3.0.html GPLv3
 */
require_once './system/spyc.php';
require_once './system/pclzip.php';
require_once './system/image.php';
require_once './system/system.php';
require_once './system/application.php';
require_once './system/helpers.php';
/* Define Filesystem Anchors
------------------------------------------------ */
define('WEB_ROOT', dirname($_SERVER['PHP_SELF'])) . '/';
define('ALBUMS_ROOT', dirname(__FILE__) . '/albums/');
/* Load Configuration
------------------------------------------------ */
$params = Spyc::YAMLLoad('albums/config.yml');
define('USE_MOD_REWRITE', $params['nice_urls']);
/* Start Application
------------------------------------------------ */
if (array_key_exists('q', $_GET)) {
    $args = split('/', $_GET['q']);
    switch ($args[0]) {
        case 'album':
            return isset($args[1]) ? album($args[1]) : index();
        case 'rss':
            return isset($args[1]) ? rss($args[1]) : rss();
    }
}
return index();
 function _textpattern()
 {
     global $plugins_ver, $pretext, $prefs, $plugin_callback;
     $this->debug('Plugin: ' . $this->plugin_name . ' - ' . $plugins_ver[$this->plugin_name]);
     $this->debug('Function: ' . __FUNCTION__ . '()');
     // URI
     $req = $pretext['req'];
     $req = preg_replace('%\\?[^\\/]+$%', '', $req);
     $this->debug('Request URI: ' . $req);
     $uri = explode('/', trim($req, '/'));
     // The number of components comes in useful when determining the best partial match.
     $uri_component_count = count($uri);
     // Permanent links
     $permlinks = $this->get_all_permlinks(1);
     // Force Textpattern and tags to use messy URLs - these are easier to
     // find in regex
     $this->set_permlink_mode();
     if (count($permlinks)) {
         // We also want to match the front page of the site (for page numbers / feeds etc..).
         // Add a permlinks rule which will do that.
         $permlinks['default'] = array('components' => array(), 'settings' => array('pl_name' => 'gbp_permanent_links_default', 'pl_precedence' => '', 'pl_preview' => '/', 'con_section' => '', 'con_category' => '', 'des_section' => '', 'des_category' => '', 'des_permlink' => '', 'des_feed' => '', 'des_location' => '', 'des_page' => ''));
         // Extend the pretext_replacement scope outside the foreach permlink loop
         $pretext_replacement = NULL;
         foreach ($permlinks as $id => $pl) {
             // Extract the permlink settings
             $pl_settings = $pl['settings'];
             extract($pl_settings);
             $this->debug('Permlink name: ' . $pl_name);
             $this->debug('Permlink id: ' . $id);
             $this->debug('Preview: ' . $pl_preview);
             $pl_components = $pl['components'];
             // URI components
             $uri_components = $uri;
             $this->debug('PL component count: ' . count($pl_components));
             $this->debug('URL component count: ' . count($uri_components));
             $date = false;
             $title_page_feed = false;
             foreach ($pl_components as $pl_c) {
                 // Are we expecting a date component? If so the number of pl and uri components won't match
                 if ($pl_c['type'] == 'date') {
                     $date = true;
                 } else {
                     if (in_array($pl_c['type'], array('title', 'page', 'feed'))) {
                         $title_page_feed = true;
                     }
                 }
             }
             if (!$title_page_feed) {
                 // If there isn't a title, page or feed component then append a special type for cleaver partial matching
                 $pl_components[] = array('type' => 'title_page_feed', 'prefix' => '', 'suffix' => '', 'regex' => '', 'text' => '');
             }
             // Exit early if there are more URL components than PL components,
             // taking into account whether there is a data component
             if (!$uri_components[0] || count($uri_components) > count($pl_components) + ($date ? 2 : 0)) {
                 $this->debug('More URL components than PL components');
                 continue;
             }
             // Reset pretext_replacement as we are about to start another comparison
             $pretext_replacement = array('permlink_id' => $id);
             // Reset the article context string
             $context = array();
             unset($context_str);
             if (!empty($des_section)) {
                 $context[] = "`Section` = '{$des_section}'";
             }
             if (!empty($des_category)) {
                 $context[] = "(`Category1` = '{$des_category}' OR `Category2` = '{$des_category}')";
             }
             $context_str = count($context) > 0 ? 'and ' . join(' and ', $context) : '';
             // Assume there is no match
             $partial_match = false;
             $cleaver_partial_match = false;
             // Loop through the permlink components
             foreach ($pl_components as $pl_c_index => $pl_c) {
                 // Assume there is no match
                 $match = false;
                 // Check to see if there are still URI components to be checked.
                 if (count($uri_components)) {
                     // Get the next component.
                     $uri_c = array_shift($uri_components);
                 } else {
                     if (!$title_page_feed && count($pl_components) - 1 == $uri_component_count) {
                         // If we appended a title_page_feed component earlier and permlink and URI components
                         // counts are equal, we must of finished checking this permlink, and it matches so break.
                         $match = true;
                         break;
                     } else {
                         // If there are no more URI components then we have a partial match.
                         // Store the partial match data unless there has been a preceding permlink with the
                         // same number of components, as permlink have already been sorted by precedence.
                         if (!array_key_exists($uri_component_count, $this->partial_matches)) {
                             $this->partial_matches[$uri_component_count] = $pretext_replacement;
                         }
                         // Unset pretext_replacement as changes could of been made in a preceding component
                         unset($pretext_replacement);
                         // Break early form the foreach permlink components loop.
                         $partial_match = true;
                         break;
                     }
                 }
                 // Extract the permlink components.
                 extract($pl_c);
                 // If it's a date, grab and combine the next two URI components.
                 if ($type == 'date') {
                     $uri_c .= '/' . array_shift($uri_components) . '/' . array_shift($uri_components);
                 }
                 // Decode the URL
                 $uri_c = urldecode($uri_c);
                 // Always check the type unless the prefix or suffix aren't there
                 $check_type = true;
                 // Check prefix
                 if ($prefix && $this->pref('show_prefix')) {
                     $sanitized_prefix = urldecode($this->encode_url($prefix));
                     if (($pos = strpos($uri_c, $sanitized_prefix)) === false || $pos != 0) {
                         $check_type = false;
                         $this->debug('Can\'t find prefix: ' . $prefix);
                     } else {
                         // Check passed, remove prefix ready for the next check
                         $uri_c = substr_replace($uri_c, '', 0, strlen($sanitized_prefix));
                     }
                 }
                 // Check suffix
                 if ($check_type && $suffix && $this->pref('show_suffix')) {
                     $sanitized_suffix = urldecode($this->encode_url($suffix));
                     if (($pos = strrpos($uri_c, $sanitized_suffix)) === false) {
                         $check_type = false;
                         $this->debug('Can\'t find suffix: ' . $suffix);
                     } else {
                         // Check passed, remove suffix ready for the next check
                         $uri_c = substr_replace($uri_c, '', $pos, strlen($sanitized_suffix));
                     }
                 }
                 // Both the prefix and suffix settings have passed
                 if ($check_type) {
                     $this->debug('Checking if "' . $uri_c . '" is of type "' . $type . '"');
                     $uri_c = doSlash($uri_c);
                     //
                     if ($prefs['permalink_title_format']) {
                         $mt_search = array('/_/', '/\\.html$/');
                         $mt_replace = array('-', '');
                     } else {
                         $mt_search = array('/(?:^|_)(.)/e', '/\\.html$/');
                         $mt_replace = array("strtoupper('\\1')", '');
                     }
                     $mt_uri_c = $this->pref('redirect_mt_style_links') ? preg_replace($mt_search, $mt_replace, $uri_c) : '';
                     // Compare based on type
                     switch ($type) {
                         case 'section':
                             if ($rs = safe_row('name', 'txp_section', "(`name` like '{$uri_c}' or `name` like '{$mt_uri_c}') limit 1")) {
                                 $this->debug('Section name: ' . $rs['name']);
                                 $pretext_replacement['s'] = $rs['name'];
                                 $context[] = "`Section` = '{$rs['name']}'";
                                 $match = true;
                             }
                             break;
                         case 'category':
                             if ($rs = safe_row('name', 'txp_category', "(`name` like '{$uri_c}' or `name` like '{$mt_uri_c}') and `type` = 'article' limit 1")) {
                                 $this->debug('Category name: ' . $rs['name']);
                                 $pretext_replacement['c'] = $rs['name'];
                                 $context[] = "(`Category1` = '{$rs['name']}' OR `Category2` = '{$uri_c}')";
                                 $match = true;
                             }
                             break;
                         case 'title':
                             if ($rs = safe_row('url_title', 'textpattern', "(`url_title` like '{$uri_c}' or `url_title` like '{$mt_uri_c}') {$context_str} and `Status` >= 4 limit 1")) {
                                 $this->debug('URL Title: ' . $rs['url_title']);
                                 $mt_redirect = $uri_c != $mt_uri_c;
                                 $pretext_replacement['url_title'] = $rs['url_title'];
                                 $match = true;
                             }
                             break;
                         case 'id':
                             if ($rs = safe_row('ID, Posted', 'textpattern', "`ID` = '{$uri_c}' {$context_str} and `Status` >= 4 limit 1")) {
                                 $pretext_replacement['id'] = $rs['ID'];
                                 $pretext_replacement['Posted'] = $rs['Posted'];
                                 $pretext['numPages'] = 1;
                                 $pretext['is_article_list'] = false;
                                 $match = true;
                             }
                             break;
                         case 'author':
                             if ($author = safe_field('name', 'txp_users', "RealName like '{$uri_c}' limit 1")) {
                                 $pretext_replacement['author'] = $author;
                                 $context[] = "`AuthorID` = '{$author}'";
                                 $match = true;
                             }
                             break;
                         case 'login':
                             if ($author = safe_field('name', 'txp_users', "name like '{$uri_c}' limit 1")) {
                                 $pretext_replacement['author'] = $author;
                                 $context[] = "`AuthorID` = '{$author}'";
                                 $match = true;
                             }
                             break;
                         case 'custom':
                             $custom_options = array_values(array_map(array($this, "encode_url"), safe_column("custom_{$custom}", 'textpattern', "custom_{$custom} != ''")));
                             if ($this->pref('force_lowercase_urls')) {
                                 $custom_options = array_map("strtolower", $custom_options);
                             }
                             if (in_array($uri_c, $custom_options)) {
                                 $match = true;
                             }
                             break;
                         case 'date':
                             if (preg_match('/^\\d{4}\\/\\d{2}\\/\\d{2}$/', $uri_c)) {
                                 $pretext_replacement['date'] = str_replace('/', '-', $uri_c);
                                 $match = true;
                             }
                             break;
                         case 'year':
                             if (preg_match('/^\\d{4}$/', $uri_c)) {
                                 $pretext_replacement['year'] = $uri_c;
                                 $match = true;
                             }
                             break;
                         case 'month':
                         case 'day':
                             if (preg_match('/^\\d{2}$/', $uri_c)) {
                                 $pretext_replacement[$type] = $uri_c;
                                 $match = true;
                             }
                             break;
                         case 'page':
                             if (is_numeric($uri_c)) {
                                 $pretext_replacement['pg'] = $uri_c;
                                 $match = true;
                             }
                             break;
                         case 'feed':
                             if (in_array($uri_c, array('rss', 'atom'))) {
                                 $pretext_replacement[$uri_c] = 1;
                                 $match = true;
                             }
                             break;
                         case 'search':
                             $pretext_replacement['q'] = $uri_c;
                             $match = true;
                             break;
                         case 'text':
                             if ($this->encode_url($text) == $uri_c) {
                                 $match = true;
                                 $pretext_replacement["permlink_text_{$name}"] = $uri_c;
                             }
                             break;
                         case 'regex':
                             // Check to see if regex is valid without outputting error messages.
                             ob_start();
                             preg_match($regex, $uri_c, $regex_matches);
                             $is_valid_regex = !ob_get_clean();
                             if ($is_valid_regex && @$regex_matches[0]) {
                                 $match = true;
                                 $pretext_replacement["permlink_regex_{$name}"] = $regex_matches[0];
                             }
                             break;
                     }
                     // switch type end
                     // Update the article context string
                     $context_str = count($context) > 0 ? 'and ' . join(' and ', $context) : '';
                     $this->debug($match == true ? 'YES' : 'NO');
                     if (!$match && !$cleaver_partial_match && $this->pref('use_cleaver_partial_matches')) {
                         // There hasn't been a match or a complete cleaver partial match. Lets try to be cleaver and
                         // check to see if this component is either a title, page or a feed. This makes it more probable
                         // a successful match for a given permlink rule occurs.
                         $this->debug('Checking if "' . $uri_c . '" is of type "title_page_feed"');
                         if ($type != 'title' && ($url_title = safe_field('url_title', 'textpattern', "`url_title` like '{$uri_c}' {$context_str} and `Status` >= 4 limit 1"))) {
                             $pretext_replacement['url_title'] = $url_title;
                             $pretext['numPages'] = 1;
                             $pretext['is_article_list'] = false;
                             $cleaver_partial_match = true;
                         } else {
                             if ($this->pref('clean_page_archive_links') && $type != 'page' && is_numeric($uri_c)) {
                                 $pretext_replacement['pg'] = $uri_c;
                                 $cleaver_partial_match = true;
                             } else {
                                 if ($type != 'feed' && in_array($uri_c, array('rss', 'atom'))) {
                                     $pretext_replacement[$uri_c] = 1;
                                     $cleaver_partial_match = true;
                                 }
                             }
                         }
                         $this->debug($cleaver_partial_match == true ? 'YES' : 'NO');
                         if ($cleaver_partial_match) {
                             $this->cleaver_partial_match = $pretext_replacement;
                             // Unset pretext_replacement as changes could of been made in a preceding component
                             unset($pretext_replacement);
                             $cleaver_partial_match = true;
                             continue 2;
                         }
                     }
                 }
                 // check type end
                 // Break early if the component doesn't match, as there is no point continuing
                 if ($match == false) {
                     // Unset pretext_replacement as changes could of been made in a preceding component
                     unset($pretext_replacement);
                     break;
                 }
             }
             // foreach permlink component end
             if (!isset($pretext_replacement['id'])) {
                 if (isset($pretext_replacement['url_title'])) {
                     if (isset($pretext_replacement['date'])) {
                         $date_val = $pretext_replacement['date'];
                     } else {
                         if (isset($pretext_replacement['year'])) {
                             $date_val = $pretext_replacement['year'];
                             if (isset($pretext_replacement['month'])) {
                                 $date_val .= '-' . $pretext_replacement['month'];
                                 if (isset($pretext_replacement['day'])) {
                                     $date_val .= '-' . $pretext_replacement['day'];
                                 }
                             }
                         }
                     }
                     if (isset($date_val)) {
                         $context_str .= " and `Posted` like '{$date_val}%'";
                     }
                     if ($rs = safe_row('ID, Posted', 'textpattern', "`url_title` like '{$pretext_replacement['url_title']}' {$context_str} and `Status` >= 4 order by `Posted` desc limit 1")) {
                         if (isset($date_val)) {
                             $this->debug('Found date and title-based match.');
                         } else {
                             $this->debug('Found title-based match.');
                         }
                         $pretext_replacement['id'] = $rs['ID'];
                         $pretext_replacement['Posted'] = $rs['Posted'];
                         $pretext['numPages'] = 1;
                         $pretext['is_article_list'] = false;
                     } else {
                         $match = false;
                         unset($pretext_replacement);
                     }
                 }
             }
             if ($match || $partial_match || $cleaver_partial_match) {
                 // Extract the settings for this permlink
                 @extract($permlinks[$pretext_replacement['permlink_id']]['settings']);
                 // Check the permlink section and category conditions
                 if (!empty($con_section) && $con_section != @$pretext_replacement['s'] || !empty($con_category) && $con_category != @$pretext_replacement['c']) {
                     $this->debug('Permlink conditions failed');
                     if (@$con_section) {
                         $this->debug('con_section = ' . $con_section);
                     }
                     if (@$con_category) {
                         $this->debug('con_category = ' . $con_category);
                     }
                     unset($pretext_replacement);
                 } else {
                     if ($match && isset($pretext_replacement)) {
                         $this->debug('We have a match!');
                     } else {
                         if ($partial_match && count($this->partial_matches)) {
                             $this->debug('We have a \'partial match\'');
                         } else {
                             if ($cleaver_partial_match && isset($cleaver_partial_match)) {
                                 $this->debug('We have a \'cleaver partial match\'');
                             } else {
                                 $this->debug('Error: Can\'t determine the correct type match');
                                 // This permlink has failed, continue execution of the foreach permlinks loop
                                 unset($pretext_replacement);
                             }
                         }
                     }
                 }
             }
             // We have a match
             if (@$pretext_replacement) {
                 break;
             }
         }
         // foreach permlinks end
         // If there is no match restore the most likely partial match. Sorted by number of components and then precedence
         if (!@$pretext_replacement && count($this->partial_matches)) {
             $pt_slice = array_slice($this->partial_matches, -1);
             $pretext_replacement = array_shift($pt_slice);
         }
         unset($this->partial_matches);
         // Restore the cleaver_partial_match if there is no other matches
         if (!@$pretext_replacement && $this->cleaver_partial_match) {
             $pretext_replacement = $this->cleaver_partial_match;
         }
         unset($this->cleaver_partial_match);
         // Extract the settings for this permlink
         @extract($permlinks[$pretext_replacement['permlink_id']]['settings']);
         // If pretext_replacement is still set here then we have a match
         if (@$pretext_replacement) {
             $this->debug('Pretext Replacement ' . print_r($pretext_replacement, 1));
             if (!empty($des_section)) {
                 $pretext_replacement['s'] = $des_section;
             }
             if (!empty($des_category)) {
                 $pretext_replacement['c'] = $des_category;
             }
             if (!empty($des_feed)) {
                 $pretext_replacement[$des_feed] = 1;
             }
             if (@$pretext_replacement['id'] && @$pretext_replacement['Posted']) {
                 if ($np = getNextPrev($pretext_replacement['id'], $pretext_replacement['Posted'], @$pretext_replacement['s'])) {
                     $pretext_replacement = array_merge($pretext_replacement, $np);
                 }
             }
             unset($pretext_replacement['Posted']);
             // If there is a match then we most set the http status correctly as txp's pretext might set it to 404
             $pretext_replacement['status'] = '200';
             // Store the orginial HTTP status code
             // We might need to log the page hit if it equals 404
             $orginial_status = $pretext['status'];
             // Txp only looks at the month, but due to how we phase the month we can manipulate the sql to our needs
             if (array_key_exists('date', $pretext_replacement)) {
                 $pretext_replacement['month'] = $pretext_replacement['date'];
                 unset($pretext_replacement['date']);
             } else {
                 if (array_key_exists('year', $pretext_replacement) || array_key_exists('month', $pretext_replacement) || array_key_exists('day', $pretext_replacement)) {
                     $month = '';
                     $month .= array_key_exists('year', $pretext_replacement) ? $pretext_replacement['year'] . '-' : '____-';
                     $month .= array_key_exists('month', $pretext_replacement) ? $pretext_replacement['month'] . '-' : '__-';
                     $month .= array_key_exists('day', $pretext_replacement) ? $pretext_replacement['day'] . ' ' : '__ ';
                     $pretext_replacement['month'] = $month;
                     unset($pretext_replacement['year']);
                     unset($pretext_replacement['day']);
                 }
             }
             // Section needs to be defined so we can always get a page template.
             if (!array_key_exists('s', $pretext_replacement)) {
                 if (!@$pretext_replacement['id']) {
                     $pretext_replacement['s'] = 'default';
                 } else {
                     $pretext_replacement['s'] = safe_field('Section', 'textpattern', 'ID = ' . $pretext_replacement['id']);
                 }
             }
             // Set the css and page template, otherwise we get an unknown section
             $section_settings = safe_row('css, page', 'txp_section', "name = '{$pretext_replacement['s']}' limit 1");
             $pretext_replacement['page'] = @$des_page ? $des_page : $section_settings['page'];
             $pretext_replacement['css'] = $section_settings['css'];
             $this->matched_permlink = $pretext_replacement;
             global $permlink_mode;
             if (in_array($prefs['permlink_mode'], array('id_title', 'section_id_title')) && @$pretext_replacement['pg'] && !@$pretext_replacement['id']) {
                 $pretext_replacement['id'] = '';
                 $pretext_replacement['is_article_list'] = true;
             }
             // Merge pretext_replacement with pretext
             $pretext = array_merge($pretext, $pretext_replacement);
             if (is_numeric(@$pretext['id'])) {
                 $a = safe_row('*, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod', 'textpattern', 'ID=' . intval($pretext['id']) . ' and Status >= 4');
                 populateArticleData($a);
             }
             // Export required values to the global namespace
             foreach (array('id', 's', 'c', 'pg', 'is_article_list', 'prev_id', 'prev_title', 'next_id', 'next_title', 'css') as $key) {
                 if (array_key_exists($key, $pretext)) {
                     $GLOBALS[$key] = $pretext[$key];
                 }
             }
             if (count($this->matched_permlink) || @$mt_redirect) {
                 $pl_index = $pretext['permlink_id'];
                 if (!@$mt_redirect || !$this->pref('redirect_mt_style_links')) {
                     $pl = $this->get_permlink($pretext['permlink_id']);
                     $pl_index = @$pl['settings']['des_permlink'];
                 }
                 if (@$pretext['id'] && $pl_index) {
                     if (count($this->get_permlink($pl_index)) > 0) {
                         ob_clean();
                         global $siteurl;
                         $rs = safe_row('*, ID as thisid, unix_timestamp(Posted) as posted', 'textpattern', "ID = '{$pretext['id']}'");
                         $host = rtrim(str_replace(rtrim(doStrip($pretext['subpath']), '/'), '', hu), '/');
                         $this->redirect($host . $this->_permlinkurl($rs, PERMLINKURL, $pl_index), $this->pref('permlink_redirect_http_status'));
                     }
                 } else {
                     if ($url = @$pl['settings']['des_location']) {
                         ob_clean();
                         $this->redirect($url, $this->pref('url_redirect_http_status'));
                     }
                 }
             }
             if (@$pretext['rss']) {
                 if (@$pretext['s']) {
                     $_POST['section'] = $pretext['s'];
                 }
                 if (@$pretext['c']) {
                     $_POST['category'] = $pretext['c'];
                 }
                 ob_clean();
                 include txpath . '/publish/rss.php';
                 exit(rss());
             }
             if (@$pretext['atom']) {
                 if (@$pretext['s']) {
                     $_POST['section'] = $pretext['s'];
                 }
                 if (@$pretext['c']) {
                     $_POST['category'] = $pretext['c'];
                 }
                 ob_clean();
                 include txpath . '/publish/atom.php';
                 exit(atom());
             }
             $this->debug('Pretext ' . print_r($pretext, 1));
         } else {
             $this->debug('NO CHANGES MADE');
         }
         // Log this page hit
         if (@$orginial_status == 404) {
             log_hit($pretext['status']);
         }
         // Start output buffering and pseudo callback to textpattern_end
         ob_start(array(&$this, '_textpattern_end_callback'));
         // TxP 4.0.5 (r2436) introduced the textpattern_end callback making the following redundant
         $version = array_sum(array_map(create_function('$line', 'if (preg_match(\'/^\\$' . 'LastChangedRevision: (\\w+) \\$/\', $line, $match)) return $match[1];'), @file(txpath . '/publish.php')));
         if ($version >= '2436') {
             return;
         }
         // Remove the plugin callbacks which have already been called
         function filter_callbacks($c)
         {
             if ($c['event'] != 'textpattern') {
                 return true;
             }
             if (@$c['function'][0]->plugin_name == 'gbp_permanent_links' && @$c['function'][1] == '_textpattern') {
                 $GLOBALS['gbp_found_self'] = true;
                 return false;
             }
             return @$GLOBALS['gbp_found_self'];
         }
         $plugin_callback = array_filter($plugin_callback, 'filter_callbacks');
         unset($GLOBALS['gbp_found_self']);
         // Re-call textpattern
         textpattern();
         // Call custom textpattern_end callback
         $this->_textpattern_end();
         // textpattern() has run, kill the connection
         die;
     }
 }
Пример #10
0
function preText($s, $prefs)
{
    extract($prefs);
    if (gps('rss')) {
        include txpath . '/publish/rss.php';
        exit(rss());
    }
    if (gps('atom')) {
        include txpath . '/publish/atom.php';
        exit(atom());
    }
    if (!$s) {
        $s = gps('s');
    }
    $id = gps('id');
    $id = !$id && $url_mode ? frompath() : $id;
    // hackish
    if (empty($id)) {
        $GLOBALS['is_article_list'] = true;
    }
    $out['id'] = $id;
    // what section are we in?
    if ($s) {
        $out['s'] = $s;
    } elseif ($id) {
        $out['s'] = fetch('Section', 'textpattern', 'ID', $id);
    } else {
        $out['s'] = "default";
    }
    $s = $out['s'];
    $rs = safe_row("*", "txp_section", "name = '{$s}' limit 1");
    if ($rs) {
        // useful stuff from the database
        extract($rs);
        $out['page'] = $page;
        $out['css'] = $css;
    }
    $out['c'] = gps('c');
    // category?
    $out['q'] = gps('q');
    // search query?
    $out['count'] = gps('count');
    // pageby count? *deprecated*
    $out['pg'] = gps('pg');
    // paging?
    $out['p'] = gps('p');
    // image?
    if ($id) {
        // check for next or previous article in the same section
        $Posted = fetch('Posted', 'textpattern', 'ID', $id);
        $thenext = getNeighbour($Posted, $s, '>');
        $out['next_id'] = $thenext ? $thenext['ID'] : '';
        $out['next_title'] = $thenext ? $thenext['Title'] : '';
        $out['next_utitle'] = $thenext ? $thenext['url_title'] : '';
        $theprev = getNeighbour($Posted, $s, '<');
        $out['prev_id'] = $theprev ? $theprev['ID'] : '';
        $out['prev_title'] = $theprev ? $theprev['Title'] : '';
        $out['prev_utitle'] = $theprev ? $theprev['url_title'] : '';
    }
    $out['path_from_root'] = $path_from_root;
    $out['pfr'] = $path_from_root;
    $out['url_mode'] = $url_mode;
    $out['sitename'] = $sitename;
    return $out;
}
Пример #11
0
/* Let the magic begin */
pixie();
/* Referral */
referral();
/* Get the language file */
include_once "admin/lang/{$language}.php";
/* Load the current themes settings */
include_once "admin/themes/{$site_theme}/settings.php";
if (isset($s) && $s == 404) {
    /* Send correct header for 404 pages */
    header('HTTP/1.0 404 Not Found');
}
if ($m == 'rss') {
    if (isset($s)) {
        /* RSS */
        rss($s, $page_display_name, $page_id);
    }
} else {
    if (isset($s)) {
        /* Load this page's description */
        $page_description = safe_field('page_description', 'pixie_core', "page_name='{$s}'");
    }
    if ($page_type == 'module') {
        if (isset($s)) {
            if (file_exists("admin/modules/{$s}_functions.php")) {
                include "admin/modules/{$s}_functions.php";
            }
            /* Load the module in pre mode */
            $do = 'pre';
            include "admin/modules/{$s}.php";
        }
Пример #12
0
function center($article_limit)
{
    if (isset($_GET['category'])) {
        $id = $_GET['category'];
    }
    if (isset($_GET['articleid'])) {
        $articleid = $_GET['articleid'];
    }
    if (isset($_POST['submit_text'])) {
        processing();
        $processed = True;
    }
    if (isset($_POST['contactform'])) {
        contact();
        $processed = True;
    }
    if (isset($_GET['category'])) {
        $action = $_GET['category'];
    } else {
        if (isset($_GET['action'])) {
            $action = $_GET['action'];
        }
    }
    if (isset($processed) and $processed == True) {
        unset($action);
    }
    switch ($action) {
        case "archives":
            archives();
            break;
        case "contact":
            contact();
            break;
        case "rss":
            rss();
            break;
        case "login":
            login();
            break;
        case "categories":
            if (isset($_SESSION['Logged_In'])) {
                view_categories();
            }
            break;
        case "editcategory":
            if (isset($_SESSION['Logged_In'])) {
                edit_category();
            }
            break;
        case "new":
            if (isset($_SESSION['Logged_In'])) {
                new_article();
            }
            break;
        case "unpublished":
            if (isset($_SESSION['Logged_In'])) {
                unpublished_articles();
            }
            break;
        case "simpleedit":
            if (isset($_SESSION['Logged_In'])) {
                edit_article(simple);
            }
            break;
        case "advancededit":
            if (isset($_SESSION['Logged_In'])) {
                edit_article(advanced);
            }
            break;
        case "editcomment":
            if (isset($_SESSION['Logged_In'])) {
                edit_comment();
            }
            break;
        case "images":
            if (isset($_SESSION['Logged_In'])) {
                images();
            }
            break;
        case "process":
            if (isset($_SESSION['Logged_In']) and $display_further != "NO") {
                processing();
            }
            break;
        case "logout":
            session_start();
            $_SESSION = array();
            session_destroy();
            echo "<META HTTP-EQUIV='refresh' content='1; URL=" . $_SERVER['PHP_SELF'] . "'>";
            echo "<h2>" . l('log_out') . "</h2>";
            break;
        default:
            if (isset($_POST['search'])) {
                search();
            } else {
                if (isset($_POST['comment'])) {
                    comment("comment_posted");
                } else {
                    if ($processed == False) {
                        $article = get_id('article');
                        $category = get_id('category');
                        if ($article != "") {
                            $query = "SELECT * FROM " . s('prefix') . "articles WHERE seftitle = '{$article}'";
                            $shorten = 99990000;
                        } else {
                            if (isset($category)) {
                                $query_catname = "SELECT * FROM " . s('prefix') . "categories";
                                $result_catname = mysql_query($query_catname);
                                while ($r_catname = mysql_fetch_array($result_catname)) {
                                    if (isset($num_cat)) {
                                        $num_cat++;
                                    }
                                    if ($r_catname['seftitle'] == $category) {
                                        $use_cat_id = $r_catname['id'];
                                    }
                                }
                                if ($category == "") {
                                    $use_cat_id = 0;
                                    $category = 0;
                                }
                                if (s('display_new_on_home') == True) {
                                    if ($use_cat_id != 0) {
                                        $query = "SELECT * FROM " . s('prefix') . "articles WHERE position = 1 AND published = 1 AND category = {$use_cat_id} ORDER BY date DESC LIMIT {$article_limit}";
                                    } else {
                                        $query = "SELECT * FROM " . s('prefix') . "articles WHERE position = 1 AND published = 1 ORDER BY date DESC LIMIT {$article_limit}";
                                    }
                                } else {
                                    $query = "SELECT * FROM " . s('prefix') . "articles WHERE position = 1 AND published = 1 AND category = {$use_cat_id} ORDER BY date DESC LIMIT {$article_limit}";
                                }
                                if (isset($r['textlimit'])) {
                                    $shorten = $r['textlimit'];
                                }
                                if (isset($shorten) == 0) {
                                    $shorten = 9999000;
                                }
                            }
                        }
                        $result = mysql_query($query);
                        while ($r = mysql_fetch_array($result)) {
                            if ($article == "") {
                                $shorten = $r['textlimit'];
                                if ($shorten == 0) {
                                    $shorten = 99990000;
                                }
                            }
                            $comments_num = 0;
                            $comment_query = "SELECT * FROM " . s('prefix') . "comments WHERE articleid = {$r['id']}";
                            $comment_result = mysql_query($comment_query);
                            while ($comment_r = mysql_fetch_array($comment_result)) {
                                $comments_num++;
                            }
                            $date = date(s('date_format'), strtotime($r['date']));
                            $fp_date_format = date(s('fp_date_format'), strtotime($r['date']));
                            $position = $r['position'];
                            if ($category == "0") {
                                $category = s('home');
                            }
                            if ($r['displaytitle'] == "YES" and $article == "") {
                                echo "<h2><a href='" . s('website') . find_cat_sef($r['category']) . "/" . $r['seftitle'] . "/'>" . $r['title'] . "</a></h2>";
                            } else {
                                if ($r['displaytitle'] == "YES") {
                                    echo "<h2>" . $r['title'] . "</h2>";
                                }
                            }
                            if ($r['image'] != "") {
                                ?>
				<div class="image">
					<img src="<?php 
                                echo s('website') . s('image_folder');
                                ?>
/<?php 
                                echo $r['image'];
                                ?>
" alt="<?php 
                                echo $r['title'];
                                ?>
" />
				</div><?php 
                            }
                            // PHP files inclusion routine
                            $fulltext = $r['text'];
                            $findme = "[include]";
                            $pos = strpos($fulltext, $findme);
                            $findme = "[/include]";
                            $pos2 = strpos($fulltext, $findme);
                            $file = substr($fulltext, $pos + 9, $pos2 - 9);
                            if ($pos2 > 0) {
                                $text = str_replace("[include]", "|&|", $fulltext);
                                $text = str_replace("[/include]", "|&|", $text);
                                $text = explode("|&|", $text);
                                $num = count($text);
                                for ($i = 0;; $i++) {
                                    if ($i == $num) {
                                        break;
                                    }
                                    if (strpos($text[$i], '.php') === false and strpos($text[$i], '.txt') === false and strpos($text[$i], '.inc') === false) {
                                        echo substr(stripslashes($text[$i]), 0, $shorten);
                                    } else {
                                        include $text[$i];
                                    }
                                }
                            } else {
                                echo substr(stripslashes($fulltext), 0, $shorten);
                            }
                            if (isset($numrows)) {
                                $numrows++;
                            }
                            if ($article == "" and strlen($r['text']) > $shorten) {
                                echo "...</p>";
                            }
                            $commentable = $r['commentable'];
                            if ($r['position'] != 3 and $r['position'] != 4 or isset($_SESSION['Username'])) {
                                if ($article == "") {
                                    if ($r['displayinfo'] == "YES") {
                                        echo "<p class='" . s('date_class') . "'>";
                                        if (strlen($r['text']) > $shorten) {
                                            echo "<img src='" . s('website') . "images/more.gif' alt='' /> <a href='" . s('website') . $category . "/" . $r['seftitle'] . "/'>" . l('read_more') . "</a> ";
                                        }
                                        if ($commentable == "YES" or $commentable == "FREEZ") {
                                            echo "<img src='" . s('website') . "images/comment.gif' alt='' /> <a href='" . s('website') . $category . "/" . $r['seftitle'] . "/'>" . l('comments') . "(" . $comments_num . ")</a> ";
                                        }
                                        echo "<img src='" . s('website') . "images/timeicon.gif' alt='' /> " . $fp_date_format . "</p>";
                                    }
                                } else {
                                    echo "<p class='" . s('date_class') . "'>";
                                    if (isset($_SESSION['Logged_In'])) {
                                        echo l('edit_article') . " [ <a href='" . s('website') . "index.php?action=simpleedit&id={$r['id']}'>" . l('simple') . "</a> <img src='" . s('website') . "images/arrow.gif' alt='|' /> <a href='" . s('website') . "index.php?action=advancededit&id={$r['id']}'>" . l('advanced') . " </a> ] <img src='" . s('website') . "images/arrow.gif' alt='|' /> <a href='" . s('website') . "index.php?action=process&task=delete&id={$r['id']}'" . if_javascript_on(" onclick='return confirm(\"" . l('warning_delete') . "\");'", 'return') . ">" . l('delete_article') . "</a> <img src='" . s('website') . "images/arrow.gif' alt='|' /> ";
                                        if ($r['commentable'] == "FREEZ") {
                                            echo "<a href='" . s('website') . "index.php?action=process&task=unfreezecomments&id={$r['id']}'>" . l('unfreeze_comments') . "</a> <img src='" . s('website') . "images/arrow.gif' alt='|' /> ";
                                        } else {
                                            if ($r['commentable'] != "NO") {
                                                echo "<a href='" . s('website') . "index.php?action=process&task=freezecomments&id={$r['id']}'>" . l('freeze_comments') . "</a> <img src='" . s('website') . "images/arrow.gif' alt='|' /> ";
                                            }
                                        }
                                    }
                                    if ($category != s('home')) {
                                        $category = $category . "/";
                                    }
                                    echo "<a href='" . s('website');
                                    if ($category != s('home')) {
                                        echo $category . "'>";
                                    } else {
                                        echo "'>";
                                    }
                                    echo l('back') . "</a> <img src='" . s('website') . "images/timeicon.gif' alt='' /> " . $date . "</p>";
                                }
                            }
                        }
                    }
                }
            }
            if ($article != "" and $commentable == "YES") {
                comment("unfreezed");
            } else {
                if ($article != "" and $commentable == "FREEZ") {
                    comment("freezed");
                }
            }
    }
}
function cnk_pretext()
{
    global $prefs;
    // only takeover url algorithm when in section_title mode
    if (CNK_FRIENDLY_URLS && $prefs['permlink_mode'] == 'section_title') {
        extract($prefs);
        $out = array();
        // 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);
        }
        $subpath = preg_quote(preg_replace("/https?:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/");
        $req = preg_replace("/^{$subpath}/i", "/", $out['request_uri']);
        $url_chunks = explode('/', trim($req, '/'));
        $req = '/' . implode('/', array_slice($url_chunks, -2));
        //echo $req;
        extract(chopUrl($req));
        //first we sniff out some of the preset url schemes
        if (strlen($u1)) {
            switch ($u1) {
                case 'atom':
                    include txpath . '/publish/atom.php';
                    exit(atom());
                case 'rss':
                    include txpath . '/publish/rss.php';
                    exit(rss());
                    // 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 : '';
                    break;
                case urldecode(strtolower(urlencode(gTxt('category')))):
                    $out['c'] = ckEx('category', $u2) ? $u2 : '';
                    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 : '';
                        		}
                        		else 
                        		{
                        				$rs = lookupByIDSection($u2, $u1);
                        				$out['s'] = @$rs['Section'];
                        				$out['id'] = @$rs['ID'];
                        		}
                        break;
                        
                        case 'year_month_day_title':
                        		if (empty($u2)) 
                        		{
                        				$out['s'] = (ckEx('section',$u1)) ? $u1 : '';
                        		}
                        		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
                        		{
                        				$when = "$u1-$u2-$u3";
                        				$rs = lookupByDateTitle($when,$u4);
                        				$out['id'] = (!empty($rs['ID'])) ? $rs['ID'] : '';
                        				$out['s'] = (!empty($rs['Section'])) ? $rs['Section'] : '';
                        		}
                        break;
                        */
                        case 'section_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
                            } else {
                                // match section/title
                                $rs = lookupByTitleSection($u2, $u1);
                                if (count($rs)) {
                                    $out['id'] = @$rs['ID'];
                                    $out['s'] = @$rs['Section'];
                                } else {
                                    // match parentsection/section
                                    $rs = safe_row("name, lft", 'txp_section', "lower(name) like '" . doSlash($u2) . "' AND lower(parent)='" . doSlash($u1) . "' limit 1");
                                    if (count($rs)) {
                                        // check path TODO: move to function
                                        $rs_path = safe_rows("name", "txp_section", "lft <= " . $rs['lft'] . " and ((rgt-lft) > 1 OR lft = " . $rs['lft'] . ") and name != 'default' order by lft");
                                        $path = '/';
                                        for ($i = 0; $i < count($rs_path); $i++) {
                                            $path .= $rs_path[$i]['name'] . '/';
                                        }
                                        if ($path == '/' . implode('/', $url_chunks) . '/') {
                                            $out['s'] = @$rs['name'];
                                        }
                                    }
                                }
                            }
                            break;
                            /*
                            								case 'title_only':
                            										$rs = lookupByTitle($u1);
                            										$out['id'] = @$rs['ID'];
                            										$out['s'] = (empty($rs['Section']) ? ckEx('section', $u1) : $rs['Section']);
                            								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'] : '';
                            										}
                            										else
                            										{
                            												# We don't want to miss the /section/ pages
                            												$out['s']= ckEx('section',$u1)? $u1 : '';
                            										}
                            								break; */
                    }
            }
        } else {
            $out['s'] = 'default';
        }
        //print_r($out);
        if (isset($out['id'])) {
            $_GET['id'] = $out['id'];
        }
        if (isset($out['s'])) {
            $_GET['s'] = $out['s'];
        }
    }
}
Пример #14
0
function specials($string,$list) {
	return rss($list[2],$list[1]); 
}