SitePoint Sponsor

User Tag List

Page 8 of 10 FirstFirst ... 45678910 LastLast
Results 176 to 200 of 230
  1. #176
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Silverhawk
    If i understand OOP correctly, objects are considered unique so if a function needs to operate on an object it should be operating on that object. So naturally passing by reference makes sense and cloning does not. Am i getting this right?
    Absolutely. This is also how every other OO language besides PHP4 works(including PHP5). The reason why PHP4 is odd is purely technical. Objects in PHP4 are implemented as hacked arrays "behind the scenes".

    Quote Originally Posted by Silverhawk
    However i can't seem to figure out why a temp variable will be required when returning an object. If an object is already passed into the function by reference there is no need to return the object.
    I probably didn't express myself too clear. This wouldn't work in PHP4.4 :
    PHP Code:
    class Foo {}

    function & 
    bar() {
        return new 
    Foo();

    You'd have to do it like this :
    PHP Code:
    class Foo {}

    function & 
    bar() {
        
    $tmp =& new Foo();
        return 
    $tmp;


  2. #177
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nacho
    Fair enough ... I don't do TDD ... Still it sounds to me kind of strange that because of testing a design pattern becomes somehow invalid ... it doesn't fit the bill, as far as I'm concern, but that would get us to yet a whole different discussion. I'll let it rest ... Enough OT
    By "design pattern" you mean the Singleton pattern? All design patterns have their pros and cons, and much recent thinking about the singleton pattern considers it to have a number of problems, testing issues only being one of them. Do a google search on "Singleton antipattern" if you'd like more information.

  3. #178
    SitePoint Enthusiast Silverhawk's Avatar
    Join Date
    Sep 2003
    Location
    Malaysia
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    I probably didn't express myself too clear. This wouldn't work in PHP4.4 :
    Ahh that makes it clear. Thanks a lot

  4. #179
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    By "design pattern" you mean the Singleton pattern? All design patterns have their pros and cons, and much recent thinking about the singleton pattern considers it to have a number of problems, testing issues only being one of them. Do a google search on "Singleton antipattern" if you'd like more information.
    I knew the arguments against the use of the Singleton, but I went looking anyway, as you suggested. The thing is I can only find arguments against it from the point of view of testing, which I can't buy because I don't do TDD myself. The rest are just complaints about how the pattern is being misused and abused, which obviously does nothing to do with the Singleton pattern itself but with the attitude of the developer towards that pattern.

    Anyway, I really think we are getting heavily OT, so I'll leave it here. Maybe some other time I'll start a thread to discuss this issue.

    My apollogies to the OP.
    There’s more than one way to skin a cat.

  5. #180
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's an article by Marcus with an example of a test safe singleton Registry.

  6. #181
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm ... interesting discussion. I'm using phpBB in two forums, www.EnglishParis.com and www.Sharpdebate.com, and the only problem I found with them is to manage the sid (session_ids) in case of adding complex self-made add-ons. Otherwise they work fine, and it's very easy to change looks. ex. in both the above sites, I'm using the standard subSilver template, but could change the look quite a lot.

    I think another advantage with phpBB is its sheer popularity and price. Combining both together, in case you want to sell it off oneday, you will find a purchaser for a phpBB much easily compared to any other forum. Also, popularity means support as well. Have you ever looked at the phpBB community and the add-on section?

  7. #182
    SitePoint Wizard mcsolas's Avatar
    Join Date
    Jul 2004
    Location
    Hermosa Costa Rica
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    At least php HAS forum solutions.

    Im a coldfusion coder. At least you guys have options to consider when choosing a forum. You should see the garbage that CF offers, they make phpbb look state of the art.

    PHP has plenty of functional free forums backed up with good pay choices.

    I did a lot of research on the UI design of the forums. While I cant speak for server side PHP code, I was paying attention to the rendered output. PunBB - MyBB - minibb do a pretty good job. Pun gets props for the xhtml compliant code it renders, although there is no shortage of div tags / css declarations.

    If you dont like the current solutions, join a project or create your own.

    I saw the huge gap in CF forum software, so I volunteered to create a mockup for a coldfusion forum project. Designing a forums UI is no small undertaking. Countless hours spent assembling a collection of the best output code I can find and further cleaning it from there. Forums are advanced communication tools, with options in every direction you look. A very demanding design environment to create an intuitive user oriented app.

    Cant wait until this is done, when I can watch other coders complain about the code I wrote in a forum I designed. What fun
    Last edited by mcsolas; May 12, 2006 at 20:28.

  8. #183
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Interesting thread.

    I used to use vBulletin, but whilst flexible, it has so many features my users don't need. Not to mention £48-odd every time you want to launch a site. MyBB is excellent too - and I've just installed Vanilla to try out, but I'm waiting on 1.0 before getting too excited.

    One of the things that doesn't seem to come as standard with most is running a forum with one user base, different domains and forums. Say I had cats.com and dogs.org - I'd want the same user base, same software, different boards.

    Like MCsolas says - if you don't like it, join a project or build your own. I'm getting ready to re-read the PHP/MySQL book and do just that.

  9. #184
    SitePoint Wizard mcsolas's Avatar
    Join Date
    Jul 2004
    Location
    Hermosa Costa Rica
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JamesDB
    Like MCsolas says - if you don't like it, join a project or build your own. I'm getting ready to re-read the PHP/MySQL book and do just that.
    There was definitely a formidable amount of code in all forum apps I unzipped ( php or cfm ). I spent a lot of time considering what is the essential objects required to create a forum app.

    Came up with 5: Categories, Forums, Threads, Users, Subscriptions

    Then I created a functional discussion board (with a subscription system) using just those 5 tables. Fitting the simple definition of the roles forums play.

    You might find this interesting reading material - Anatomy of a Forum: Part 1 - Part 2
    Last edited by mcsolas; May 13, 2006 at 09:19.

  10. #185
    SitePoint Member
    Join Date
    May 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MCsolas
    There was definitely a formidable amount in all forum apps I unzipped ( php or cfm ). I spent a lot of time considering what is the essential objects required to create a forum app. I came up with 5:
    Categories, Forums, Threads, Users, Subscriptions

    I created a functional discussion board (with a subscription system) using just those 5 tables. Fitting the simple definition of the roles forums play.

    You might find this interesting reading material - Anatomy of a Forum: Part 1 - Part 2

    yah nice

  11. #186
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MCsolas
    There was definitely a formidable amount of code in all forum apps I unzipped ( php or cfm ). I spent a lot of time considering what is the essential objects required to create a forum app.

    Came up with 5: Categories, Forums, Threads, Users, Subscriptions

    Then I created a functional discussion board (with a subscription system) using just those 5 tables. Fitting the simple definition of the roles forums play.
    That sounds excellent - and you're totally right.

    Just checked an old vB test database - 100 tables, including two add ons. That really can't all be necessary, in my opinion - for the sort of discussions many sites have anyway. Again, like you say, you only really need 5 tables.

    You might find this interesting reading material - Anatomy of a Forum: Part 1 - Part 2
    Thanks very much for posting those links - part 3 is great too. Amazing resource!

    James is spot on in my mind about many of the points, and the designs he's done there to go with the theory are very close to what I've been thinking of.

    I go to so many sites where the signatures are huge, the avatars are huge and pointless (there's only so many times you can see Homer Simpson doing a dance), the user title serves little purpose etc. All of the features vB comes with, as great as they are, just make things a little more confusing in my opinion - for new users anyway. I love the idea of a very clean, fast and easy to work with system. I've had more vB plugins and hacks than you can shake a stick at, and nearly none of them actually added anything of real value to the discussions.

    SitePoint seems to have it pretty good - the signatures are useful and often contain good links, or details about the poster - such as that they're a logo designer, and this is where you can find me.

    However - whilst I agree about location (I'd lean towards a predefined option - Europe, Asia, North America, South America etc or a tiny monochrome flag) and the public post count. The only thing is a user title / some way of clearly defining writers, editors, bloggers, members, etc.

    I think the lighter forums and home brews are going to be used a little more as developers go for that "Web 2.0" feel - loads of big writing and space. Some sites (like devshed, moneysavingexpert etc) use vB, but the amount of links, images and junk on every page makes it a real unpleasant experience - but the information is usually great.

    Not to mention being able to use the same template as the rest of your site and easily include it in your structure, seamless integration across forum/blogs/articles, and a fairly straight forward way of setting up multiple boards, using the same user table.

    Better dig that book out - should be able to have it done by 2023.

  12. #187
    SitePoint Wizard mcsolas's Avatar
    Join Date
    Jul 2004
    Location
    Hermosa Costa Rica
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JamesDB
    a.
    Thanks very much for posting those links - part 3 is great too. Amazing resource!
    ...
    I think the lighter forums and home brews are going to be used a little more as developers go for that "Web 2.0" feel - loads of big writing and space. Some sites (like devshed, moneysavingexpert etc) use vB, but the amount of links, images and junk on every page makes it a real unpleasant experience - but the information is usually great.
    Part 3 sweeet I had forgotten to go back and check.

    Edit: Read pt 3. I think 1 & 2 went to his head. He's right on a few points but its a bit of a rant. Whats good is that he is focusing on the discussion itself and narrowing down the forum around that.

    As for the web 2.0 feel.. check out the mockup ui design I am doing for my project. Just added the spanky corners and it really gave it a nice look.
    Last edited by mcsolas; May 13, 2006 at 22:42.

  13. #188
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Location
    wholesale cellular phone accessory
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    very good topic & posts, I have always felt forums are so bulky and bloated & wish there was a clean, w3 valid, css based alternative. I did find a .Net forum software once which was doing this but I can't find the link now...

  14. #189
    SitePoint Zealot agoossens's Avatar
    Join Date
    Mar 2004
    Location
    Adelaide, Australia
    Posts
    124
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MCsolas
    As for the web 2.0 feel.. check out the mockup ui design I am doing for my project. Just added the spanky corners and it really gave it a nice look.
    That's a nice looking mockup there - good work. I really like the "Web 2.0" look, even though I loathe the name with a burning passion.
    This space for rent.

  15. #190
    SitePoint Wizard mcsolas's Avatar
    Join Date
    Jul 2004
    Location
    Hermosa Costa Rica
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by agoossens
    I really like the "Web 2.0" look, even though I loathe the name with a burning passion.
    Yeah, thats probably the first time I ever used it to describe what I had done... its really not what I was going after, as spanky added that look, it wasnt my fault

  16. #191
    SitePoint Member JFS's Avatar
    Join Date
    Jul 2005
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think you should explain to ppl why some code is bad.
    i'm a programer myself althoug i code vb more and i don't understand some things you said about the code. thanks

  17. #192
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Speaking as a person who needs to employ PHP coders since I personally don't know how to code.

    How can we tell if code is good, bad or not without having a full understanding about it?

    The entire community doesn't have standards, right down to the beginning which is acquisition of a programmer. I mean I get quotes ranging from $500 to $5000 for the same project, and unfortunately credentials are pretty similar as well - it usually boils down to who I've had past experience with, but that's personality over talent and skill.

  18. #193
    SitePoint Enthusiast didimo's Avatar
    Join Date
    Jan 2006
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think you should explain to ppl why some code is bad.
    read thru the WHOLE thread theres some very good points and explanations


    basicaly if the code looks convoluted and is hard/impossible to follow its bad,

    a good programmer should comment, not over use globals, have some grasp of OO theory, know bout design patterns, and most importantly code things that the user/client needs not what the programmer wants

    some of the code in phpbb and mambo etc is complete rubbish (dont belive me open up any of the files and thry to make sense of whats going on)


    alot of people coming into php dont have soft engineering or programing backgrounds they think that by making the code convoluted it makes them pros. WRONG!

    before people say "if your so great why wouldnt u write a forum.."
    i did!

  19. #194
    SitePoint Enthusiast didimo's Avatar
    Join Date
    Jan 2006
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can we tell if code is good, bad or not without having a full understanding about it?
    below are 2 code samples

    first is from my cms's index.php
    and second is phpBB's index.php



    you dont have to be a programmer to tell which one makes more sense



    PHP Code:

    <?php


    //include base class
    require_once('PHPB_Framework.class.php');



    //load the framework stats class
    PHPB_Framework::loadClass('FrameworkStats');



    //start execution time timer
    PHPB_FrameworkStats::startTimer();



    //loads settings, languages and skin arrays
    PHPB_Framework::loadConfiguration('../configuration.php');



    //set the module from the url
    PHPB_Framework::setModule$_GET['module'] );



    //set the language from the language cookie
    PHPB_Framework::setLanguage$_COOKIE['language'] );



    //set the skin from the skin cookie
    PHPB_Framework::setSkin$_COOKIE['skin'] );



    //try to connect to database using PDO
    try {
        
        
        
    //create new database object
        
    $DB = new PDO(    PHPB_Framework::$settings['db1_dsn'], 
                        
    PHPB_Framework::$settings['db1_user'], 
                        
    PHPB_Framework::$settings['db1_pass'] );

        
        
    //make the database layer throw exceptions on error
        
    $DB->setAttributePDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION );
        
        
        
    //create new statement object
        
    $STMT = new PDOStatement();

    catch (
    PDOException $e) {
        
        
        
    //deal with the exception
        
    PHPB_Framework::handleException($e);
    }



    //load the user class
    PHPB_Framework::loadClass('FrameworkUser');



    //authorise current user
    PHPB_FrameworkUser::authorise(    $DB,
                                    
    $_COOKIE['auth'],
                                    
    PHPB_Framework::$settings['cookieDomain'] );

                                    
                                    
    //check user has access to this module
    PHPB_Framework::checkModuleAccessPermissionPHPB_FrameworkUser::get('user_level') );    



    //pass control to the module
    include_once( PHPB_Framework::makeModuleFilename() );
    ?>

    and phpbbs

    PHP Code:
    <?php
    /***************************************************************************
     *                                index.php
     *                            -------------------
     *   begin                : Saturday, Feb 13, 2001
     *   copyright            : (C) 2001 The phpBB Group
     *   email                : support@phpbb.com
     *
     *   $Id: index.php,v 1.99.2.7 2006/01/28 11:13:39 acydburn Exp $
     *
     *
     ***************************************************************************/

    /***************************************************************************
     *
     *   This program is free software; you can redistribute it and/or modify
     *   it under the terms of the GNU General Public License as published by
     *   the Free Software Foundation; either version 2 of the License, or
     *   (at your option) any later version.
     *
     ***************************************************************************/

    define('IN_PHPBB'true);
    $phpbb_root_path './';
    include(
    $phpbb_root_path 'extension.inc');
    include(
    $phpbb_root_path 'common.'.$phpEx);

    //
    // Start session management
    //
    $userdata session_pagestart($user_ipPAGE_INDEX);
    init_userprefs($userdata);
    //
    // End session management
    //

    $viewcat = ( !empty($HTTP_GET_VARS[POST_CAT_URL]) ) ? $HTTP_GET_VARS[POST_CAT_URL] : -1;

    if( isset(
    $HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) )
    {
        
    $mark_read = ( isset($HTTP_POST_VARS['mark']) ) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
    }
    else
    {
        
    $mark_read '';
    }

    //
    // Handle marking posts
    //
    if( $mark_read == 'forums' )
    {
        if( 
    $userdata['session_logged_in'] )
        {
            
    setcookie($board_config['cookie_name'] . '_f_all'time(), 0$board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
        }

        
    $template->assign_vars(array(
            
    "META" => '<meta http-equiv="refresh" content="3;url='  .append_sid("index.$phpEx") . '">')
        );

        
    $message $lang['Forums_marked_read'] . '<br /><br />' sprintf($lang['Click_return_index'], '<a href="' append_sid("index.$phpEx") . '">''</a> ');

        
    message_die(GENERAL_MESSAGE$message);
    }
    //
    // End handle marking posts
    //

    $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
    $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();

    //
    // If you don't use these stats on your index you may want to consider
    // removing them
    //
    $total_posts get_db_stat('postcount');
    $total_users get_db_stat('usercount');
    $newest_userdata get_db_stat('newestuser');
    $newest_user $newest_userdata['username'];
    $newest_uid $newest_userdata['user_id'];

    if( 
    $total_posts == )
    {
        
    $l_total_post_s $lang['Posted_articles_zero_total'];
    }
    else if( 
    $total_posts == )
    {
        
    $l_total_post_s $lang['Posted_article_total'];
    }
    else
    {
        
    $l_total_post_s $lang['Posted_articles_total'];
    }

    if( 
    $total_users == )
    {
        
    $l_total_user_s $lang['Registered_users_zero_total'];
    }
    else if( 
    $total_users == )
    {
        
    $l_total_user_s $lang['Registered_user_total'];
    }
    else
    {
        
    $l_total_user_s $lang['Registered_users_total'];
    }


    //
    // Start page proper
    //
    $sql "SELECT c.cat_id, c.cat_title, c.cat_order
        FROM " 
    CATEGORIES_TABLE " c 
        ORDER BY c.cat_order"
    ;
    if( !(
    $result $db->sql_query($sql)) )
    {
        
    message_die(GENERAL_ERROR'Could not query categories list'''__LINE____FILE__$sql);
    }

    $category_rows = array();
    while (
    $row $db->sql_fetchrow($result))
    {
        
    $category_rows[] = $row;
    }
    $db->sql_freeresult($result);

    if( ( 
    $total_categories count($category_rows) ) )
    {
        
    //
        // Define appropriate SQL
        //
        
    switch(SQL_LAYER)
        {
            case 
    'postgresql':
                
    $sql "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id 
                    FROM " 
    FORUMS_TABLE " f, " POSTS_TABLE " p, " USERS_TABLE " u
                    WHERE p.post_id = f.forum_last_post_id 
                        AND u.user_id = p.poster_id  
                        UNION (
                            SELECT f.*, NULL, NULL, NULL, NULL
                            FROM " 
    FORUMS_TABLE " f
                            WHERE NOT EXISTS (
                                SELECT p.post_time
                                FROM " 
    POSTS_TABLE " p
                                WHERE p.post_id = f.forum_last_post_id  
                            )
                        )
                        ORDER BY cat_id, forum_order"
    ;
                break;

            case 
    'oracle':
                
    $sql "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id 
                    FROM " 
    FORUMS_TABLE " f, " POSTS_TABLE " p, " USERS_TABLE " u
                    WHERE p.post_id = f.forum_last_post_id(+)
                        AND u.user_id = p.poster_id(+)
                    ORDER BY f.cat_id, f.forum_order"
    ;
                break;

            default:
                
    $sql "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
                    FROM (( " 
    FORUMS_TABLE " f
                    LEFT JOIN " 
    POSTS_TABLE " p ON p.post_id = f.forum_last_post_id )
                    LEFT JOIN " 
    USERS_TABLE " u ON u.user_id = p.poster_id )
                    ORDER BY f.cat_id, f.forum_order"
    ;
                break;
        }
        if ( !(
    $result $db->sql_query($sql)) )
        {
            
    message_die(GENERAL_ERROR'Could not query forums information'''__LINE____FILE__$sql);
        }

        
    $forum_data = array();
        while( 
    $row $db->sql_fetchrow($result) )
        {
            
    $forum_data[] = $row;
        }
        
    $db->sql_freeresult($result);

        if ( !(
    $total_forums count($forum_data)) )
        {
            
    message_die(GENERAL_MESSAGE$lang['No_forums']);
        }

        
    //
        // Obtain a list of topic ids which contain
        // posts made since user last visited
        //
        
    if ($userdata['session_logged_in'])
        {
            
    // 60 days limit
            
    if ($userdata['user_lastvisit'] < (time() - 5184000))
            {
                
    $userdata['user_lastvisit'] = time() - 5184000;
            }

            
    $sql "SELECT t.forum_id, t.topic_id, p.post_time 
                FROM " 
    TOPICS_TABLE " t, " POSTS_TABLE " p 
                WHERE p.post_id = t.topic_last_post_id 
                    AND p.post_time > " 
    $userdata['user_lastvisit'] . 
                    AND t.topic_moved_id = 0"

            if ( !(
    $result $db->sql_query($sql)) )
            {
                
    message_die(GENERAL_ERROR'Could not query new topic information'''__LINE____FILE__$sql);
            }

            
    $new_topic_data = array();
            while( 
    $topic_data $db->sql_fetchrow($result) )
            {
                
    $new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
            }
            
    $db->sql_freeresult($result);
        }

        
    //
        // Obtain list of moderators of each forum
        // First users, then groups ... broken into two queries
        //
        
    $sql "SELECT aa.forum_id, u.user_id, u.username 
            FROM " 
    AUTH_ACCESS_TABLE " aa, " USER_GROUP_TABLE " ug, " GROUPS_TABLE " g, " USERS_TABLE " u
            WHERE aa.auth_mod = " 
    TRUE 
                AND g.group_single_user = 1 
                AND ug.group_id = aa.group_id 
                AND g.group_id = aa.group_id 
                AND u.user_id = ug.user_id 
            GROUP BY u.user_id, u.username, aa.forum_id 
            ORDER BY aa.forum_id, u.user_id"
    ;
        if ( !(
    $result $db->sql_query($sql)) )
        {
            
    message_die(GENERAL_ERROR'Could not query forum moderator information'''__LINE____FILE__$sql);
        }

        
    $forum_moderators = array();
        while( 
    $row $db->sql_fetchrow($result) )
        {
            
    $forum_moderators[$row['forum_id']][] = '<a href="' append_sid("profile.$phpEx?mode=viewprofile&amp;" POST_USERS_URL "=" $row['user_id']) . '">' $row['username'] . '</a>';
        }
        
    $db->sql_freeresult($result);

        
    $sql "SELECT aa.forum_id, g.group_id, g.group_name 
            FROM " 
    AUTH_ACCESS_TABLE " aa, " USER_GROUP_TABLE " ug, " GROUPS_TABLE " g 
            WHERE aa.auth_mod = " 
    TRUE 
                AND g.group_single_user = 0 
                AND g.group_type <> " 
    GROUP_HIDDEN "
                AND ug.group_id = aa.group_id 
                AND g.group_id = aa.group_id 
            GROUP BY g.group_id, g.group_name, aa.forum_id 
            ORDER BY aa.forum_id, g.group_id"
    ;
        if ( !(
    $result $db->sql_query($sql)) )
        {
            
    message_die(GENERAL_ERROR'Could not query forum moderator information'''__LINE____FILE__$sql);
        }

        while( 
    $row $db->sql_fetchrow($result) )
        {
            
    $forum_moderators[$row['forum_id']][] = '<a href="' append_sid("groupcp.$phpEx?" POST_GROUPS_URL "=" $row['group_id']) . '">' $row['group_name'] . '</a>';
        }
        
    $db->sql_freeresult($result);

        
    //
        // Find which forums are visible for this user
        //
        
    $is_auth_ary = array();
        
    $is_auth_ary auth(AUTH_VIEWAUTH_LIST_ALL$userdata$forum_data);

        
    //
        // Start output of page
        //
        
    define('SHOW_ONLINE'true);
        
    $page_title $lang['Index'];
        include(
    $phpbb_root_path 'includes/page_header.'.$phpEx);

        
    $template->set_filenames(array(
            
    'body' => 'index_body.tpl')
        );

        
    $template->assign_vars(array(
            
    'TOTAL_POSTS' => sprintf($l_total_post_s$total_posts),
            
    'TOTAL_USERS' => sprintf($l_total_user_s$total_users),
            
    'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' append_sid("profile.$phpEx?mode=viewprofile&amp;" POST_USERS_URL "=$newest_uid") . '">'$newest_user'</a>'), 

            
    'FORUM_IMG' => $images['forum'],
            
    'FORUM_NEW_IMG' => $images['forum_new'],
            
    'FORUM_LOCKED_IMG' => $images['forum_locked'],

            
    'L_FORUM' => $lang['Forum'],
            
    'L_TOPICS' => $lang['Topics'],
            
    'L_REPLIES' => $lang['Replies'],
            
    'L_VIEWS' => $lang['Views'],
            
    'L_POSTS' => $lang['Posts'],
            
    'L_LASTPOST' => $lang['Last_Post'], 
            
    'L_NO_NEW_POSTS' => $lang['No_new_posts'],
            
    'L_NEW_POSTS' => $lang['New_posts'],
            
    'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'], 
            
    'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'], 
            
    'L_ONLINE_EXPLAIN' => $lang['Online_explain'], 

            
    'L_MODERATOR' => $lang['Moderators'], 
            
    'L_FORUM_LOCKED' => $lang['Forum_is_locked'],
            
    'L_MARK_FORUMS_READ' => $lang['Mark_all_forums'], 

            
    'U_MARK_READ' => append_sid("index.$phpEx?mark=forums"))
        );

        
    //
        // Let's decide which categories we should display
        //
        
    $display_categories = array();

        for (
    $i 0$i $total_forums$i++ )
        {
            if (
    $is_auth_ary[$forum_data[$i]['forum_id']]['auth_view'])
            {
                
    $display_categories[$forum_data[$i]['cat_id']] = true;
            }
        }

        
    //
        // Okay, let's build the index
        //
        
    for($i 0$i $total_categories$i++)
        {
            
    $cat_id $category_rows[$i]['cat_id'];

            
    //
            // Yes, we should, so first dump out the category
            // title, then, if appropriate the forum list
            //
            
    if (isset($display_categories[$cat_id]) && $display_categories[$cat_id])
            {
                
    $template->assign_block_vars('catrow', array(
                    
    'CAT_ID' => $cat_id,
                    
    'CAT_DESC' => $category_rows[$i]['cat_title'],
                    
    'U_VIEWCAT' => append_sid("index.$phpEx?" POST_CAT_URL "=$cat_id"))
                );

                if ( 
    $viewcat == $cat_id || $viewcat == -)
                {
                    for(
    $j 0$j $total_forums$j++)
                    {
                        if ( 
    $forum_data[$j]['cat_id'] == $cat_id )
                        {
                            
    $forum_id $forum_data[$j]['forum_id'];

                            if ( 
    $is_auth_ary[$forum_id]['auth_view'] )
                            {
                                if ( 
    $forum_data[$j]['forum_status'] == FORUM_LOCKED )
                                {
                                    
    $folder_image $images['forum_locked']; 
                                    
    $folder_alt $lang['Forum_locked'];
                                }
                                else
                                {
                                    
    $unread_topics false;
                                    if ( 
    $userdata['session_logged_in'] )
                                    {
                                        if ( !empty(
    $new_topic_data[$forum_id]) )
                                        {
                                            
    $forum_last_post_time 0;

                                            while( list(
    $check_topic_id$check_post_time) = @each($new_topic_data[$forum_id]) )
                                            {
                                                if ( empty(
    $tracking_topics[$check_topic_id]) )
                                                {
                                                    
    $unread_topics true;
                                                    
    $forum_last_post_time max($check_post_time$forum_last_post_time);

                                                }
                                                else
                                                {
                                                    if ( 
    $tracking_topics[$check_topic_id] < $check_post_time )
                                                    {
                                                        
    $unread_topics true;
                                                        
    $forum_last_post_time max($check_post_time$forum_last_post_time);
                                                    }
                                                }
                                            }

                                            if ( !empty(
    $tracking_forums[$forum_id]) )
                                            {
                                                if ( 
    $tracking_forums[$forum_id] > $forum_last_post_time )
                                                {
                                                    
    $unread_topics false;
                                                }
                                            }

                                            if ( isset(
    $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
                                            {
                                                if ( 
    $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
                                                {
                                                    
    $unread_topics false;
                                                }
                                            }

                                        }
                                    }

                                    
    $folder_image = ( $unread_topics ) ? $images['forum_new'] : $images['forum']; 
                                    
    $folder_alt = ( $unread_topics ) ? $lang['New_posts'] : $lang['No_new_posts']; 
                                }

                                
    $posts $forum_data[$j]['forum_posts'];
                                
    $topics $forum_data[$j]['forum_topics'];

                                if ( 
    $forum_data[$j]['forum_last_post_id'] )
                                {
                                    
    $last_post_time create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']);

                                    
    $last_post $last_post_time '<br />';

                                    
    $last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' $lang['Guest'] . ' ' ) : '<a href="' append_sid("profile.$phpEx?mode=viewprofile&amp;" POST_USERS_URL '='  $forum_data[$j]['user_id']) . '">' $forum_data[$j]['username'] . '</a> ';
                                    
                                    
    $last_post .= '<a href="' append_sid("viewtopic.$phpEx?"  POST_POST_URL '=' $forum_data[$j]['forum_last_post_id']) . '#' $forum_data[$j]['forum_last_post_id'] . '"><img src="' $images['icon_latest_reply'] . '" border="0" alt="' $lang['View_latest_post'] . '" title="' $lang['View_latest_post'] . '" /></a>';
                                }
                                else
                                {
                                    
    $last_post $lang['No_Posts'];
                                }

                                if ( 
    count($forum_moderators[$forum_id]) > )
                                {
                                    
    $l_moderators = ( count($forum_moderators[$forum_id]) == ) ? $lang['Moderator'] : $lang['Moderators'];
                                    
    $moderator_list implode(', '$forum_moderators[$forum_id]);
                                }
                                else
                                {
                                    
    $l_moderators '&nbsp;';
                                    
    $moderator_list '&nbsp;';
                                }

                                
    $row_color = ( !($i 2) ) ? $theme['td_color1'] : $theme['td_color2'];
                                
    $row_class = ( !($i 2) ) ? $theme['td_class1'] : $theme['td_class2'];

                                
    $template->assign_block_vars('catrow.forumrow',    array(
                                    
    'ROW_COLOR' => '#' $row_color,
                                    
    'ROW_CLASS' => $row_class,
                                    
    'FORUM_FOLDER_IMG' => $folder_image
                                    
    'FORUM_NAME' => $forum_data[$j]['forum_name'],
                                    
    'FORUM_DESC' => $forum_data[$j]['forum_desc'],
                                    
    'POSTS' => $forum_data[$j]['forum_posts'],
                                    
    'TOPICS' => $forum_data[$j]['forum_topics'],
                                    
    'LAST_POST' => $last_post,
                                    
    'MODERATORS' => $moderator_list,

                                    
    'L_MODERATOR' => $l_moderators
                                    
    'L_FORUM_FOLDER_ALT' => $folder_alt

                                    
    'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" POST_FORUM_URL "=$forum_id"))
                                );
                            }
                        }
                    }
                }
            }
        } 
    // for ... categories

    }// if ... total_categories
    else
    {
        
    message_die(GENERAL_MESSAGE$lang['No_forums']);
    }

    //
    // Generate the page
    //
    $template->pparse('body');

    include(
    $phpbb_root_path 'includes/page_tail.'.$phpEx);

    ?>

  20. #195
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well just from glancing at them with my "newb" eyes lol, this is what I can kinda say...

    The first is a lot lighter, almost all of it is FrameWork::something, whatever that means - a class or something?

    The PHPBB one includes templates and html within the php, is bulkier and less commented

    But I also mean like security, MySQL injects, things like that

  21. #196
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kiren
    Speaking as a person who needs to employ PHP coders since I personally don't know how to code. How can we tell if code is good, bad or not without having a full understanding about it?
    Ask if they view unit testing as an essential programming practice. If not don't employ them. That will rule out the majority of php programmers. The one's who are left should know what they're doing although they might not be cheap. If you can find them.

  22. #197
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by McGruff
    Ask if they view unit testing as an essential programming practice. If not don't employ them. That will rule out the majority of php programmers. The one's who are left should know what they're doing although they might not be cheap. If you can find them.
    Oh, come on man, I truly think you're going way too far implying testing is an essential requirement for good programming.

    If it really worked that way you would have not had a job yourself until some months ago

    Too bad I don't have the time to get into some challenge, but I surely would like to see us both coding the same application in order to probe what you're saying
    There’s more than one way to skin a cat.

  23. #198
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Melbourne
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd say that it's essential for good development practice; I wouldn't not hire someone if they don't do it themselves, but if they can recognise the value, and are willing to do it in an environment that is already set up to help them use TDD (existing testing suite etc), then that's good enough. However, if someone was to say to me "testing is for suckers" then I'd put a massive red cross through their application.

  24. #199
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Lithuania, Europe
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    didimo: Why do you append PHPB_Framework:: everywhere? It looks kinda silly. The fact that you put your functions in a class and then call them statically doesn't make your app object oriented - it's still procedural. And since it is, you should use procedural syntax.

  25. #200
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL....now my head is going to explode

    In the end though, if it works and it's secure - and the person coding it knows what's going on, isn't that all that matters? I guess "cleaner" code will run faster, but...you can take the money you saved on getting a coder who isn't a perfectionist and put it in to the server fees :P


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •