smile

2

(10 replies, posted in PunBB 1.2 troubleshooting)

oh, weird. didn't understand that, i guess. i'll have to read the punbb code again.

thanks

3

(10 replies, posted in PunBB 1.2 troubleshooting)

Smartys wrote:

PunBB 1.2's read/unread tracking actually marks simply that a topic has been posted in since your last visit. PunBB 1.3 (the version currently under development) will have full read/unread tracking (which is the behavior you're used to). There is at least one mod which will add full read/unread tracking, you can find it over at PunRes

how come i'll post in a thread then it'll be marked as new?

4

(0 replies, posted in Programming)

no comment

5

(1 replies, posted in Programming)

you need to get the forum ids for each subcategory

then for each q/a, you need to do something like:
insert into topic {corresponding forum id, title, ...}
insert into post {resultant topic id, question text, ...}
insert into post {resultant topic id, answer text, ...}
then you need to increment values as necessary

i don't know anything about punbb except for its table format. hopefully this helps. read the code!

6

(11 replies, posted in PunBB 1.2 discussion)

Smartys wrote:

I hate timezones with a passion tongue
Sorry for the confusion smile

the only thing i hate worse than timezones is DST. i'll make some fun threads about that later..

7

(11 replies, posted in PunBB 1.2 discussion)

i get it now. thanks a lot! big_smile

8

(11 replies, posted in PunBB 1.2 discussion)

man, i don't like this.

mysql says the time is: 1176666741

php says the time is: 1176666741

php says the server tz is: MDT

is the output from:

<?php

$dbms_host = "localhost";
$dbms_user = "root";
$dbms_pass = "";
$dbms_db   = "wlw";

$dbms_cnx = mysql_connect($dbms_host, $dbms_user, $dbms_pass);
mysql_select_db($dbms_db);
$result = mysql_query("SELECT UNIX_TIMESTAMP()");
list($mysql_time) = mysql_fetch_row($result);
$php_time = time();
$php_tz = date("T");

echo "mysql says the time is: ".$mysql_time."<br /><br />\n";
echo "php says the time is: ".$php_time."<br /><br />\n";
echo "php says the server tz is: ".$php_tz."<br /><br />\n";

mysql_close();

?>

and if i load that page at the same time as http://www.unixtimestamp.com/, i get the exact same number of seconds. and http://www.unixtimestamp.com/ claims to be running EDT, i'm running MDT!

9

(11 replies, posted in PunBB 1.2 discussion)

but mysql's UNIX_TIMESTAMP() doesn't depend on the server locale?

10

(11 replies, posted in PunBB 1.2 discussion)

so you're saying that if my server is configured for GMT-5, then on Jan 1 1970 00:00:00, time()==(-5*60*60) ?

11

(11 replies, posted in PunBB 1.2 discussion)

    $now = time();

    // Did everything go according to plan?
    if (empty($errors) && !isset($_POST['preview']))
    {
        // If it's a reply
        if ($tid)
        {
            if (!$pun_user['is_guest'])
            {
                // Insert the new post
                $db->query('INSERT INTO '.$db->prefix.'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id) VALUES(\''.$db->escape($username).'\', '.$pun_user['id'].', \''.get_remote_address().'\', \''.$db->escape($message).'\', \''.$hide_smilies.'\', '.$now.', '.$tid.')') or error('Unable to create post', __FILE__, __LINE__, $db->error());

so it is! but php.net says:

Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

it says GMT and not the local server time. so is the manual wrong?

12

(11 replies, posted in PunBB 1.2 discussion)

according to the documentation, times are stored in tables such as `posts` as a UNIX timestamp in an INT field.

as far as i know, the UNIX timestamp returned by mysql is seconds since the epoch in UTC.

this begs the question: if the times stored in the database are in UTC, why do you adjust for it in your format_date() function?

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;
}

you apply the user's timezone and the server's timezone as $diff to $timestamp. but _why_ would you diff the server's timezone if the UNIX timestamp is in UTC anyway?