Aha! Yes that's it. Changed my date/time format in Admin and all is well again.

Many thanks!

Not sure if this is really the problem. I just switched back to my 1.2.10 version of the forum and the dates are working as expected.

I haven't changed the formatting of the date between versions.

I might try upgrading again tonight....

<?php
/***********************************************************************

  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)

  This file is part of PunBB.

  PunBB 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.

  PunBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/

// slimstats
     @include_once( $_SERVER["DOCUMENT_ROOT"]."/slimstat/inc.stats.php" );

define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';


if ($pun_user['g_read_board'] == '0')
    message($lang_common['No view']);


// Load the index.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';

$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';

// allan added
if ($pun_user['is_guest'])
require PUN_ROOT.'login_index.php';
else
{
     echo '<h2>Forum Index</h2>';
    echo '<p>'.$lang_common['Logged in as'].' <em>'.pun_htmlspecialchars($pun_user['username']).'</em></p>';
    
        // Display the "Jump to" drop list
    if ($pun_config['o_quickjump'] == '1')
    {
        // Load cached quickjump
        @include PUN_ROOT.'cache/cache_quickjump_'.$pun_user['g_id'].'.php';
        if (!defined('PUN_QJ_LOADED'))
        {
            require_once PUN_ROOT.'include/cache.php';
            generate_quickjump_cache($pun_user['g_id']);
            require PUN_ROOT.'cache/cache_quickjump_'.$pun_user['g_id'].'.php';
        }
    }

//end jump menu

    if ($pun_user['g_id'] < PUN_GUEST)
    {
        $result_header = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'reports WHERE zapped IS NULL') or error('Unable to fetch reports info', __FILE__, __LINE__, $db->error());

        if ($db->result($result_header))
            $tpl_temp .= "\n\t\t\t\t".'<li class="reportlink"><strong><a href="admin_reports.php">There are new reports</a></strong></li>';

        if ($pun_config['o_maintenance'] == '1')
            $tpl_temp .= "\n\t\t\t\t".'<li class="maintenancelink"><strong><a href="admin_options.php#maintenance">Maintenance mode is enabled!</a></strong></li>';
    }

    if (in_array(basename($_SERVER['PHP_SELF']), array('index.php', 'search.php')))
        $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<ul class="conr">'."\n\t\t\t\t".'<li><a href="search.php?action=show_new">'.$lang_common['Show new posts'].'</a></li>'."\n\t\t\t\t".'<li><a href="misc.php?action=markread">'.$lang_common['Mark all as read'].'</a></li>'."\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
    else
        $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
}
// end allan added
?>




<?php
// Print the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

$cur_category = 0;
$cat_count = 0;
while ($cur_forum = $db->fetch_assoc($result))
{
    $moderators = '';

    if ($cur_forum['cid'] != $cur_category)    // A new category since last iteration?
    {
        if ($cur_category != 0)
            echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".''."\n\t".''."\n".''."\n\n";

        ++$cat_count;

?>

            <table cellspacing="0">
            <thead>
                <tr>
                    <th class="tcl" scope="col"><?php echo $lang_common['Forum'] ?></th>
                    <th class="tc2" scope="col"><?php echo $lang_index['Topics'] ?></th>
                    <th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>
                    <th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
                </tr>
            </thead>
            <tbody>
<?php

        $cur_category = $cur_forum['cid'];
    }

    $item_status = '';
    $icon_text = $lang_common['Normal icon'];
    $icon_type = 'icon';

    // Are there new posts?
    if (!$pun_user['is_guest'] && $cur_forum['last_post'] > $pun_user['last_visit'])
    {
        $item_status = 'inew';
        $icon_text = $lang_common['New icon'];
        $icon_type = 'icon inew';
    }

    // Is this a redirect forum?
    if ($cur_forum['redirect_url'] != '')
    {
        $forum_field = '<h3><a href="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" title="'.$lang_index['Link to'].' '.pun_htmlspecialchars($cur_forum['redirect_url']).'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
        $num_topics = $num_posts = ' ';
        $item_status = 'iredirect';
        $icon_text = $lang_common['Redirect icon'];
        $icon_type = 'icon';
    }
    else
    {
        $forum_field = '<h3><a href="viewforum.php?id='.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
        $num_topics = $cur_forum['num_topics'];
        $num_posts = $cur_forum['num_posts'];
    }

    if ($cur_forum['forum_desc'] != '')
        $forum_field .= "\n\t\t\t\t\t\t\t\t<p>".$cur_forum['forum_desc'].'</p>';


    // If there is a last_post/last_poster.
    if ($cur_forum['last_post'] != '')
        $last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';
    else
        $last_post = ' ';

    if ($cur_forum['moderators'] != '')
    {
        $mods_array = unserialize($cur_forum['moderators']);
        $moderators = array();

        while (list($mod_username, $mod_id) = @each($mods_array))
            $moderators[] = '<a href="profile.php?id='.$mod_id.'">'.pun_htmlspecialchars($mod_username).'</a>';

        $moderators = "\t\t\t\t\t\t\t\t".'<p><em>('.$lang_common['Moderated by'].'</em> '.implode(', ', $moderators).')</p>'."\n";
    }

?>
                 <tr<?php if ($item_status != '') echo ' class="'.$item_status.'"'; ?>>
                    <td class="tcl">
                                <?php echo $forum_field."\n".$moderators ?>
                    </td>
                    
                    
                    
                    <td class="tc2"><?php echo $num_topics ?></td>
                    <td class="tc3"><?php echo $num_posts ?></td>
                    <td class="tcr"><?php echo $last_post ?></td>
                </tr><!-- STILL IN INDEX.PHP -->
<?php

}

// Did we output any categories and forums?
if ($cur_category > 0)
    echo "\t\t\t".'</tbody><!-- ALSO FROM INDEX.PHP -->'."\n\t\t\t".'</table>'."\n\t\t".''."\n\t".''."\n".''."\n\n";
else
    echo '<p>'.$lang_index['Empty board'].'</p>';



?>
    <!--<h2><span><?php echo $lang_index['Board info'] ?></span></h2>
    
            <dl class="conr">
                <dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt>
                <dd><?php echo $lang_index['No of users'].': <strong>'. $stats['total_users'] ?></strong></dd>
                <dd><?php echo $lang_index['No of topics'].': <strong>'.$stats['total_topics'] ?></strong></dd>
                <dd><?php echo $lang_index['No of posts'].': <strong>'.$stats['total_posts'] ?></strong></dd>
            </dl>
-->
<?php

$footer_style = 'index';
require PUN_ROOT.'footer.php';

index, viewforum and viewtopic

When I do a new topic, the post time is correct, but always remains as "Today"

function format_time($timestamp, $date_only = false)
{
    global $pun_config, $lang_common, $pun_user;

    if ($timestamp == '')
        return $lang_common['Never'];

    $diff = ($pun_user['timezone'] - $pun_config['o_server_timezone']) * 3600;
    $timestamp += $diff;
    $now = time();

    $date = date($pun_config['o_date_format'], $timestamp);
    $today = date($pun_config['o_date_format'], $now+$diff);
    $yesterday = date($pun_config['o_date_format'], $now+$diff-86400);

    if ($date == $today)
        $date = $lang_common['Today'];
    else if ($date == $yesterday)
        $date = $lang_common['Yesterday'];

    if (!$date_only)
        return $date.' '.date($pun_config['o_time_format'], $timestamp);
    else
        return $date;
}

I just upgraded from 1.2.10 to 1.2.14, doing it the hdiff way as I've made quite a few changes to the code. So, I realise I may have given myself this problem but before I go back and start upgrading aagin, I thought I'd see if anyone would know what was going on. So:

A topic that was posted before I upgraded changed date to "Today". Three days after the upgrade, it's still at "Today".

I posted a new test  topic after the upgrade and today, 2 days later, it still shows as "Today".

Not got a clue why this might be happening, but it sure is a long day!

Any ideas please?

7

(3 replies, posted in General discussion)

Cake is one; I believe there are a few others too...

So, to continue this conversation with myself - I have now cracked it!

If the user is logged in, then the url will contain the post id, so this is cross referenced in the database to get the topic id (this query was copied from viewtopic.php, with just a minor change to get the post id from the url).

Here's the code I've ended up with in header.php:

if ($_GET["pid"])
{
    $result = $db->query('SELECT topic_id FROM '.$db->prefix.'posts WHERE id='.$_GET["pid"]) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        message($lang_common['Bad request']);

    $aid = $db->result($result);
}

else
    
{
    $aid = $_GET["id"];
}

echo '<style type="text/css"> ';

echo 'ul li.pun_'.$aid.' a:link,';
echo 'ul li.pun_'.$aid.' a:hover,';
echo 'ul li.pun_'.$aid.' a:active,';
echo 'ul li.pun_'.$aid.' a:visited';

echo '{color: #ccc; text-decoration: none;} ';
echo '</style>';

Hurrah!

A follow up to my previous post - I've got the styling working for logged-out users by using $_GET["id"] as shown in the code below:

echo '<style type="text/css"> ';

echo 'ul li.pun_'.$_GET["id"].' a:link,';
echo 'ul li.pun_'.$_GET["id"].' a:hover,';
echo 'ul li.pun_'.$_GET["id"].' a:active,';
echo 'ul li.pun_'.$_GET["id"].' a:visited';

echo '{color: #ccc; text-decoration: none;} ';
echo '</style>';

However, I'm still stuck with what to do when the id changes to the post id rather than the topic id for logged-in users.

Hmmm, I've just realised that there's more to this than I first thought.

In my example above, different id's were present in extern.php to the url that was displayed by the post. However, I just realised that this is only the case when logged in to the forum. When logged out, the id's are the same.

As an example, here are two url's that are from the same page, one while logged in and the other while logged out:

http://swindonharriers.com/forum/viewto … action=new  (logged out)
http://swindonharriers.com/forum/viewto … d=182#p182  (logged in)

As I want to use the class name (the topic id) from extern.php in the CSS within header.php, header.php needs to get that id somehow. Can it still do that if the user is logged in? I guess I need some SQL query cleverness here that I just don't have....

So, the problem is now a little more complicated. If (in header.php) I get the topic id from the url, it will only work when the user is logged out. If the user is logged in, I will need to find the topic id based on the post id (I think).

Does this make sense? And if it does, any ideas how to do it? This'll make me a very happy chap if I can get it to work smile

Well I thought about that, but do you know how I can append that to the <li> tag in extern.php?

I need to use the same id in the CSS as in the <li> within extern.php.  Extern.php seems to use the topic id, while the id variable in the page that extern.php links to is the post id (I think).

Just to clarify here's an example from my forum:

In extern.php, $cur_topic['id'] == 148
But the id in url of the page that extern.php points to is 182. (I guess this is the post id?)

So can I get extern.php to use the post id instead?

On my site, I have a two column layout with recent topics displayed in a sidebar using extern.php.  I'd like to use CSS to change the colour of the sidebar link if that topic is being displayed.

I've managed to get a class into the list output from extern.php by changing:

echo '<li><a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.$subject_truncated.'</a></li>'."\n";

to:

echo '<li class="pun_'.$cur_topic['id'].'"><a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.$subject_truncated.'</a></li>'."\n";

(note I've added the following inside the <li> tag:

class="pun_'.$cur_topic['id'].'"

I've now tried adding the following CSS to the <head> of header.php:

<?php
echo '<style type="text/css"> ';

echo 'ul li. pun_'.$cur_topic['id'].' a:link,';
echo 'ul li. pun_'.$cur_topic['id'].' a:hover,';
echo 'ul li. pun_'.$cur_topic['id'].' a:active,';
echo 'ul li. pun_'.$cur_topic['id'].' a:visited,';

echo '{color: #ccc; text-decoration: none;} ';
echo '</style>';
?>

But I don't get a value for $cur_topic[id]. I think that I need to get the topic id into header.php but I don't know how.

I'm pretty sure it should be easy to give $cur_topic[id] the id of the current topic but I'm at the limit of my (very limited) php/sql knowledge here.

Can anyone help me out please?

I want the users of my forum to be able to post new topics from the front page of the forum (index.php).

My aim is to have a "post new topic" link which will take the user to a post creation form where they can select (by a dropdown list) which forum the message should be added to. This is the same (or similar) behaviour to Vanilla.

I've already hacked around a little in punbb but I'm no programmer and I'm not really sure where to start with this one. Could anyone give me some help here to get me started?

Cheers,

marv

that was quick smile

Excellent, just what I was looking for, and so simple I wish I had tried to do it myself smile

Isn't it only a case of saying: "if permission level = [can't post] then show link a, else show link b" ?  I'm probably missing something here...

I agree that we should not clutter the screen with extra links - that's why I'm suggesting the links could be conditional.

It's not a huge requirement of mine but would be nice to have.

Thanks Rickard. If this found it's way into 1.3 I would be a very happy camper smile

Well yes that would do (and I have done this on my forum) but it needs to be at the top of the page (like where the "Post new topic" option is) so that it can't be missed.

Ideally I would like it to be a link in the same place as the "Post new topic" or "Reply" option, with the text "Login to post new topic" or "Login to reply" - the link would take the user to the login / register page.

When users are not logged in to my forum, they can't post new topics or reply to existing ones. However, if they want to do so, it would be helpful if the "Post new topic" and "Reply" options were visible but not active, with perhaps a title attribute telling the user that they must login to use those options. Currently these two options are not visible, so it is difficult for the inexperienced user to see why they can't use the forum.

I'm guessing that this would be fairly easy to implement; what do you think?

20

(5 replies, posted in Feature requests)

hurrah!

21

(5 replies, posted in Feature requests)

Just wondering if this is a likely 1.3 feature or a mod - is anyone working on it?

22

(4 replies, posted in PunBB 1.2 show off)

Thanks for those positive comments...

I've now redesigned the site, and wanted to integrate punbb much more closely into the design. I also wanted to simplify things for users (my users are very simple...)  so I have hacked around rather a lot. In fact, there's hardly any resemblance to the original punbb - and I guess that's one measure of good software - how flexible it is. Having said that, there is an awful lot of html living within many different php files - it was a bit of a challenge to find everything that I wanted to modify.

I wonder if there are any plans to separate the structure of the html from the functionality that's in the php? It would be great to have punbb tags that could be placed in your own custom design, be it a table, a div, a list or whatever. I've just gotten used to using textpattern, and it occurred to me that punbb tags, like txp tags, would make custom designs a lot easier to implement.

Anyway, thanks again for punbb.

23

(18 replies, posted in Feature requests)

Anyone care to share their experience of google ads? Can they cover your hosting costs?  I realise this will depend on your traffic and type of site but I'd just be interested to see if people think they are worth having. Personally, I always ignore them...

24

(1 replies, posted in PunBB 1.2 discussion)

Many of the forum users that i have are very, very non-techie. So, I'm thinking of writing a user guide, explaining things like: the registration process, how to create and edit a post, how to change some siplay setings, upload an avatar, how to subscribe to posts and why you'd want to, what RSS is and how to use it...... I could go on, but you get the idea.

I just wondered if anyone else had done this? If so can I have a look?

If no-one has, I will post here when mine is complete.

Cheers,

Marv

Well, I've fixed it.  I had to delve into the SQL text file, which is a first for me, so I'm pretty pleased with myself smile

The problem lay with the last line of this bit of code:

DROP TABLE IF EXISTS posts;
CREATE TABLE posts(
    id int(10) unsigned NOT NULL auto_increment,
    poster varchar(200) NOT NULL,
    poster_id int(10) unsigned DEFAULT '1' NOT NULL,
    poster_ip varchar(15),
    poster_email varchar(50),
    message text NOT NULL,
    hide_smilies tinyint(1) NOT NULL,
    posted int(10) unsigned NOT NULL,
    edited int(10) unsigned,
    edited_by varchar(200),
    topic_id int(10) unsigned NOT NULL, 
    PRIMARY KEY (id), 
    KEY posts_topic_id_idx (topic_id), 
    KEY posts_multi_idx (poster_id, topic_id), 
    KEY message (message)
);

I deleted the last line, and the "posts" table was then created, albeit with it's "message" row missing. I added this using phpmyadmin, and was then able to import all the post data - basically by copying the relevant section from the SQL file into phpmyadmin.

And it all worked. wow smile  I might just have a go at getting my hands dirty with some more SQL now, I've been meaning to use it for ages.....


Marv