function prev_next($output, $hook)
{
    global $all_active_news, $active_news, $news_arr, $category, $ucat, $aj_plugins, $archive;
    $PN = new PluginSettings('Previous-Next');
    $catrestrict = $PN->settings['prevnext'];
    if (empty($catrestrict)) {
        $catrestrict = STAY_IN_CATEGORIES;
    }
    $prevnum = 1;
    $nextnum = 1;
    $thisnews = explode("|", $active_news);
    $thiscat = $thisnews[6];
    $all_active_news = array_reverse($all_active_news);
    $index = array_search($active_news, $all_active_news);
    if ($catrestrict == 'true') {
        do {
            $prev = explode("|", $all_active_news[$index - $prevnum]);
            if (empty($prev[6])) {
                break;
            }
            $prevnum++;
        } while ($thiscat != $prev[6]);
        do {
            $next = explode("|", $all_active_news[$index + $nextnum]);
            if (empty($next[6])) {
                break;
            }
            $nextnum++;
        } while ($thiscat != $next[6]);
    } else {
        $next = explode("|", $all_active_news[$index + 1]);
        $prev = explode("|", $all_active_news[$index - 1]);
    }
    # humanfriendly stuff
    if (!$ucat && $category) {
        $ucat = $category;
    }
    $nid = aj_prepareTitle($next[2]);
    if ($nid == "") {
        $nid = $next[0];
    }
    $pid = aj_prepareTitle($prev[2]);
    if ($pid == "") {
        $pid = $prev[0];
    }
    // Friendly urls w/ archive recognition
    if (isset($GLOBALS['aj_plugins']['friendlyurls'])) {
        $kat = aj_getCat($ucat);
        if (!$archive) {
            $next_link = "<a href=\"" . date("Y/m/d/", $next[0]) . "{$kat}/{$nid}.html\">{$next['2']}</a>";
            $prev_link = "<a href=\"" . date("Y/m/d/", $prev[0]) . "{$kat}/{$pid}.html\">{$prev['2']}</a>";
        } else {
            $furls = new PluginSettings('Userfriendly_URLs');
            $linkdata = $furls->settings['text']['0'];
            $next_link = "<a href=\"{$linkdata['AR']}/{$archive}/" . date("Y/m/d/", $next[0]) . "{$kat}/{$nid}.html\">{$next['2']}</a>";
            $prev_link = "<a href=\"{$linkdata['AR']}/{$archive}/" . date("Y/m/d/", $prev[0]) . "{$kat}/{$pid}.html\">{$prev['2']}</a>";
        }
    } else {
        $next_link = "<a href='{$PHP_SELF}?aj_go=more&amp;id={$next['0']}&amp;archive={$archive}&amp;start_from={$start_from}&amp;ucat={$ucat}&amp;{$user_query}'>{$next['2']}</a>";
        $prev_link = "<a href='{$PHP_SELF}?aj_go=more&amp;id={$prev['0']}&amp;archive={$archive}&amp;start_from={$start_from}&amp;ucat={$ucat}&amp;{$user_query}'>{$prev['2']}</a>";
    }
    if (!empty($next[0])) {
        $output = str_replace("{nextlink}", $next_link, $output);
    } else {
        $output = str_replace("{nextlink}", "", $output);
    }
    if (!empty($prev[0])) {
        $output = str_replace("{prevlink}", $prev_link, $output);
    } else {
        $output = str_replace("{prevlink}", "", $output);
    }
    return $output;
}
function furls_monthlyarchive($output, $hook)
{
    global $cutepath, $date, $info, $lang_article_linktext;
    $furls = new PluginSettings('Userfriendly_URLs');
    $linkdata = $furls->settings['text']['0'];
    $title = aj_prepareTitle($info[title]);
    $category = aj_getCat($info[category]);
    $output = "<a title=\"{$info['title']}\"href=\"{$linkdata['AR']}/{$info['home']}/" . date("Y/m/d", $date) . "/{$category}/{$title}.html\">{$info['title']}</a>";
    return $output;
}