Modular System: Any good?

Discussion in 'PHP' started by liam_d, Oct 18, 2005.

  1. #1
    Hi everyone, this is a sorta modular system i made i need some feedback if it is any good?

    
    // Modules
    $modules = array(
    'forum' => 'forum',
    'viewforum' => 'viewforum',
    'viewtopic' => 'viewtopic',
    'register' => 'register',
    'login' => 'login',
    'usercp' => 'usercp',
    'newtopic' => 'newtopic',
    'newreply' => 'newreply',
    'newpoll' => 'newpoll',
    'editpost' => 'editpost',
    'member' => 'member',
    'members' => 'members'
    );
    
    if (!isset($_GET['act']))
    {
    	$act = 'forum';
    }
    
    else
    {
    	$act = $_GET['act'];
    }
    
    // Include the current module
    if (in_array($act, $modules))
    {
    	include('modules/' . $act . '.php');
    }
    
    else
    {
    	die;
    }
    
    
    PHP:

     
    liam_d, Oct 18, 2005 IP
  2. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Looks good.. A more elegant death with error message output would be nice though. Also, Google does not care for pages that are formed like

    index.php?page=calendar

    Better to rewrite your URLs if you plan to run your site from just one page.
     
    TheHoff, Oct 18, 2005 IP
  3. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Where does it say so? I have never heard of this. What makes it alergic to google? cud u please explain?
     
    king_cobra, Oct 18, 2005 IP
  4. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Their webmaster specs indicate the bot will not even crawl pages that have the "id=" in the query string. Personal experience with many clients running vBulletin portals has shown that the pages formed with

    index.php?page=modulename

    do not get crawled nearly as often as the more static-looking pages even if those modules are linked from every page on the site. Google knows it is a dynamically generated page and may be falling into a spam trap. Better to feed it static-looking URLs.
     
    TheHoff, Oct 18, 2005 IP
  5. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    they say that their bots crawl dynamic urls (with parameters in them), but recommend to keep the number of parameters to a low. however, they say that googlebot wont crawl a parameter named id. this is specific to the 'id' and not to any other url parameters. u can make the id to i or even d or anything other than 'id' and it will get crawled.

    the problem with dynamic scripts is that most of them use session ids, and since the bot visits a page multiple times, what it see is multiple pages with same content and it raises a flag.

    there is no problem in using module=calender or something as parameters. if u use SEF URLs with .htm extension, the bot wont go much in to analysing the page it normally does for dynamic URLs like trying to get rid of sessions (just a try, i havent seen any of the session ids remved from indexing) or cookies or many things like that which it normally does before indexing a dynamic page, and it just index the page as it were a static html page. that is an advantage, faster indexing.
     
    king_cobra, Oct 18, 2005 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,840
    Likes Received:
    4,542
    Best Answers:
    123
    Trophy Points:
    665
    #6
    I'd tend to write the bottom part of the script like this

    $act = ( isset($_GET['act']))?$_GET['act']:'forum';
    if ( !in_array($act, $modules)) $act = 'forum';
    
    include('modules/' . $act . '.php');
    PHP:
    but I also have a function called getGetVar, most systems have one and the bare bones of mine is
    function getGetVar($name, $default='')
    {
      global $_GET;
      $output= ( isset($_GET[$name]))?$_GET[$name]:$default;
      // check for sql hacks
      $output = replace_str( '/*','',$output);
      return $output;
    }
    PHP:
    and this would transform my example to

    $act = getGetVar('act','forum');
    if ( !in_array($act, $modules)) $act = 'forum';
    
    include('modules/' . $act . '.php');
    PHP:
    and the user would never "die", they'd always go through to the forum if they chose something invalid.
     
    sarahk, Oct 18, 2005 IP
    TheHoff likes this.
  7. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I agree with you in theory. There is no theoretical problem with using page= in the URL string. All I can tell you is that, from personal experience, those pages are not crawled as frequently as they should be. My latest example is a client in the financial sector with a strong PR4 and top-10 rankings for his phrases. He has an economic calendar that is linked as the second menu item from every page on his site and updated multiple times per day. It took two weeks for Google to re-cache his calendar after I changed the page title and the calendar (and other page= dynamic pages) have NEVER inherited pagerank from the rest of his site. I've seen this more than a few times with sites running the various free vBulletin portals that use poorly formed URLs. I can PM the site if you'd like.

    I would simply avoid the problem and make friendly URLs. It takes 2 minutes with mod_rewrite, right?
     
    TheHoff, Oct 19, 2005 IP
  8. kalius

    kalius Peon

    Messages:
    599
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #8
    If you are coding your own just make the url's look static, and redirect everything to the main page, there you get the variables and stuff, no need to mod_rewrite.
     
    kalius, Oct 19, 2005 IP
  9. liam_d

    liam_d Active Member

    Messages:
    306
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    80
    #9
    What do you mean by that kalius, good you give me an example?
     
    liam_d, Oct 22, 2005 IP