1 (edited by zipoking 2007-08-25 06:53)

Topic: forum.linux.pl - Polish Linux Site

http://forum.linux.pl
Features added in our version of PunBB:
- category groups - this forum is available from many addresses (newbie.linux.pl/forum - subsite for new Linux-users, gry.linux.pl/forum - games in Linux, biznes.linux.pl/forum - Linux in bussiness) and every subsite has it's own forum; on forum.linux.pl all these forums are available together;
- category view - it is possible to see only one category; in our forum 2 categories have special meaning - we maintain 2 big projects: "We're giving Linux" (everybody, who wants share Linux-disks with the others, can announce it here) and "Hardware compability with Linux" (people can share their experiencies about this subject) - in this category topics are sorted alphabetically;
- extended RSS output
- "/dev/null" - forum with automated removing capability;
- latest topics list, which is based on the cached files;
- fully integrated with the rest of linux.pl code.

(P.S.: Sorry for my English ;-))

Re: forum.linux.pl - Polish Linux Site

Very well put together. Wow, lots of members too.

The  "/dev/null" forum - how did you set that up to auto-remove posts?

Re: forum.linux.pl - Polish Linux Site

sirena wrote:

Very well put together. Wow, lots of members too.

Thx ;-)

sirena wrote:

The  "/dev/null" forum - how did you set that up to auto-remove posts?

There is function which do this :-) (putted in functions.php, invoked from header.php)

// Delete topics from '/dev/null'
function forum_clean_devnull()
{
    global $db, $db_type, $pun_config, $pun_user;
    
    if($pun_user['g_id'] > PUN_MOD)
        return;
        
    require_once PUN_ROOT.'include/search_idx.php';
    
    //For each forum, which name is '/dev/null'
    $fresult = $db->query('SELECT id FROM '.$db->prefix.'forums WHERE forum_name=\'/dev/null\'') or error('Unable to get forum list', __FILE__, __LINE__, $db->error());
    while(list($fid) = $db->fetch_row($fresult)){
        
        // Find topics, where last_post is time() - 1 day
        $long_ago = time() - 60 * 60 * 24;
        $topics_were_deleted = 0;
        
        $tresult = $db->query('SELECT id FROM '.$db->prefix.'topics WHERE last_post<'.$long_ago.' AND forum_id='.$fid) or error('Unable to get topic list', __FILE__, __LINE__, $db->error());
        while(list($topic) = $db->fetch_row($tresult)){

            // Delete the topics and any redirect topics
            $db->query('DELETE FROM '.$db->prefix.'topics WHERE id='.$topic.' OR moved_to='.$topic) or error('Unable to delete topic', __FILE__, __LINE__, $db->error());
            $topics_were_deleted = 1;

            // Delete any subscriptions
            $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE topic_id='.$topic) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());

            // Create a list of the post ID's in this topic and then strip the search index
            $result = $db->query('SELECT id, poster_id FROM '.$db->prefix.'posts WHERE topic_id='.$topic) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());

            $post_ids = '';
            while (list($post_id, $user_id) = $db->fetch_row($result)){
                $post_ids .= ($post_ids != '') ? ','.$post_id : $post_id;
                $db->query('UPDATE user SET forum_posty=forum_posty-1 WHERE id='.$user_id) or error('Unable to update user data', __FILE__, __LINE__, $db->error());
            }

            // We have to check that we actually have a list of post ID's since we could be deleting just a redirect topic
            if ($post_ids != '')
                strip_search_index($post_ids);

            // Delete posts
            $db->query('DELETE FROM '.$db->prefix.'posts WHERE topic_id='.$topic) or error('Unable to delete posts', __FILE__, __LINE__, $db->error());
        }

        if($topics_were_deleted == 1){
            update_forum($fid);
    
            @include PUN_ROOT.'include/cache.php';
            generate_latest_topics_cache();
        }
    }
}

Some code was cp'ed from delete.php (AFAIR). There is reference to table user in the database - this table is a part of linux.pl, not PunBB. At the end there is reference to generate_latest_topics_cache() - this function generates file in cache with list of the newest posted topics.