Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Shortcuts to topic areas

Options
  • 27-08-2003 11:08pm
    #1
    Registered Users Posts: 762 ✭✭✭


    Not sure if this has been suggested before but how about some shortcuts to the topic areas, e.g., the following urls could redirect to their respective forum category :

    www.boards.ie/sci (redirects to sci-fi and fantasy)
    www.boards.ie/web (redirects to webmaster)
    Post edited by Shield on


Comments

  • Subscribers Posts: 9,716 ✭✭✭CuLT


    Its useful for IOFFL , ( www.boards.ie/irelandoffline ) and Know Your Nerds ( www.boards.ie/nerds ) , but i think putting it on all forums would be time consuming and ultimately, not worth the effort.

    Thats what the Subbed forum list is for :) .


  • Registered Users Posts: 2,648 ✭✭✭smiles


    www.boards.ie/ctyi goes to ctyi and always has.

    << Fio >>


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    (The original code would have thrown an error because vBulletin munged the escapes in the preg_ functions. I've replaced the delimiters with pipes.)

    [PHP]<?php

    /**
    * vBulletin Shortcut Handler
    *
    * Copyright (C) 2003 Adam Beecher <beecher.net>.
    * You can do anything bar remove the copyright.
    *
    * The script can be called by an Apache ErrorDocument handler or a
    * RewriteRule. Regi or ecksor will know how to do this. The input
    * is simply the forum name with all non-alphanumeric chars removed.
    *
    * Originally developed for Foot.ie <foot.ie/inc/php/shortcuts.php>.
    *
    */

    // Change to the vBulletin base directory.
    chdir('/home/sites/foot.ie/web/forums');

    // You could use the vBulletin DB class, I just think it's ****. PEAR rocks.
    require_once 'DB.php';
    require_once 'admin/config.php';

    // DB connection stuff.
    $db = DB::connect("mysql://$dbusername:$dbpassword@$servername/$dbname");
    $db->setFetchMode(DB_FETCHMODE_ASSOC);
    if (DB::isError($db)) exit($db->getMessage());

    // Get a list of the forums. Exclude inactive forums. There
    // should probably be more in the WHERE clause but **** it.
    $forums = $db->getAll('SELECT displayorder,forumid,title,parentid FROM forum WHERE active=1');

    // The URI here is the path from docroot of this script. If this doesn't match the
    // REQUEST_URI, the request must have come via the ErrorDocument or RewriteRule.
    if ( ($uri = getenv('REQUEST_URI')) != '/inc/php/shortcuts.php') {
    // This matches on a URI like /f/SHORTCUT, i.e. request via RewriteRule.
    if (preg_match('|^/f/(.*)$|', $uri, $matches)) {
    $shortcut = $matches[1];
    } else {
    // This matches on /SHORTCUT, i.e. request via ErrorDocument.
    $shortcut = preg_replace('|^/([^/]+).*$|', "$1", $uri);
    }
    // Loop throught the luvverly forums.
    for($h=0; $h<count($forums); $h++) {
    // Default location.
    $location = '/forums/';
    // If we get a match, tack on the forumdisplay part and forumid.
    if ($shortcut == preg_replace('|[^0-9a-z-]|', '', strtolower($forums[$h]))) {
    $location .= 'forumdisplay.php?forumid=' . $forums[$h];
    break;
    }
    }
    // Day Day!
    header("Location: $location");
    // Just in case.
    exit();

    // If the REQUEST_URI DOES match the script path (from docroot), generate a listing...
    } else {
    // Do stuff with the parents. Can't remember what. <grin>
    for($i=0; $i<count($forums); $i++) {
    if ($forums[$i] == -1) {
    $parents[] = $forums[$i];
    }
    }
    sort($parents);
    // Generate the list. Nicely indented, amn't I pretty! One problem though,
    // it doesn't recurse properly. One day I'll add that in.
    $output = "<ul>\n";
    for($j=0; $j<count($parents); $j++) {
    $title = $parents[$j];
    $url = 'http://foot.ie/' . preg_replace('|[^0-9a-z-]|', '', strtolower($title));
    $output .= " <li><a href=\"$url\"><b>$title</b></a>: <small>$url</small></li>\n";
    $output .= " <ul>\n";
    for($k=0; $k<count($forums); $k++) {
    if ($forums[$k] == $parents[$j]) {
    $children[] = $forums[$k];
    }
    }
    sort($children);
    for($l=0; $l<count($children); $l++) {
    $title = $children[$l];
    $url = 'http://foot.ie/' . preg_replace('|[^0-9a-z-]|', '', strtolower($title));
    $output .= " <li><a href=\"$url\"><b>$title</b></a>: <small>$url</small></li>\n";
    }
    $output .= " </ul>\n";
    unset($children);
    }
    $output .= "</ul>\n";
    }

    // Day Day Database!
    $db->disconnect();

    // My script wraps this up in a static embedded template,
    // I'm just printing it so you can see the result.
    echo $content;

    ?>[/PHP]http://foot.ie/corkcity
    http://foot.ie/premierdivision
    http://foot.ie/forfans


  • Registered Users Posts: 762 ✭✭✭Terminator


    Originally posted by CuLT


    Thats what the Subbed forum list is for :) .

    Yes but what if you're not on the site and want to skip the home page altogether - a shortcut would be handy.


Advertisement