1

(8 replies, posted in Programming)

Rickard wrote:

dchan: You should be a columnist or something. You make me laugh smile

Science Officer:"Captain, we've just taken a hyperbole torpedo to the starboard deflector grid!"
Captain [yelling over the RED-ALERT siren]: "What's our status!?"
Science Officer: "I've initiated the self-deprecators but we're losing containment! I'm afraid this may just go to his head."
...
smile

Now up to vers. 1.0.3 after finding a reflective, insidious logic error I made in profile.php, where I was holding up a timezone mirror to myself. That's all better now, easy oversight fix.

3

(8 replies, posted in Programming)

With debian it's all about the shades of gray...there's probably a fresh postgresql 7.4.6 or something in the untrusted, unstable, unwashed, boogie-oogie-oogie-unblessed repositories.  I've come to regard Debian linux like she's some subtly attractive woman until I realize that spending the night with her requires such a brutal level of attention to detail that only the most ardent enthusiast/fanboy/rabid-fanatic would be able to service her correctly.  That said, when I'm being brutally punished in an RPM dependency dungeon (crack that whip!) I think of her fondly, but then it passes and I forget about her for months, even years at a time.  :-)
I've heard she's wearing attractive installation lingere, I might have to date her again sometime.

4

(8 replies, posted in Programming)

Just for grins I thought I'd take a stab at installing pgadminIII on a fresh Fedora 3 install.

PAIN, SUFFERING, and HUMILIATIONS GALORE!

You're going to find yourself installing from source, which means installing the wxWindows gui toolkit from source.
The wxWindows toolkit chaps like to joke about how long it takes to compile that puppy.

Suprise! FC3 doesn't have the X11 development libs on hand (up2date anyone?) or many of the other libs.
(I'm not a FC3 guru but their python admin toolkit doesn't say anything about X11 or GTK+ lib packages in the install listings -- I've been spoiled to death by Mandrake Linux)

For FC3 installs, you're much better off with something like phpPgAdmin.

5

(8 replies, posted in Programming)

Rickard wrote:

I use pgAdmin III, but only because it's the only one I've ever tested smile

Despite the marketeer feeling a thread like this carries...

A needed pgAdmin III link.

I've used phpPgAdmin but usually I'm up to absolutely no good at the prompt.

On a personal note, I really dislike/distrust gui database tools on production servers. Not only can they serve as a root-kit vector, but sometimes it's hard to understand all the nuances that go with the tools. To have something nice on a development server to help speed up things and then using these toolkits to easily package changes, queries, and scripts for upload and deployment on a production system makes life good. These amenities become liabilities when a developer/admin cannot keep up with the security changes and then someone develops an exploit against their database admin toolkit and they don't hear about it until some guy in charge of the network starts noticing massive amounts of activity.

Frank H wrote:

thanks smile

does the vacuum clean up 'old internal caches' and stuff?

de re postgresql vacuum

I've been using PostgreSQL since 1997, when I wrote a support ticket web app using Perl and Postgresql.  I remember having to use gcc to compile the interface module to use PostgreSQL for CGI.  Once the Perl libs showed up I never looked at c-based CGI ever again.

If you're installing the current version PostgreSQL don't bother tinkering under the hood too much. It's easy to give PostgeSQL too much power, its setup to handle about anything you want to do with it unless you're working on something that wickedly parallel (clustered/sync'd/and nested joining up the wazoo).

Anyone using PostgreSQL should only have to do the two following tasks daily:

1)setup an scheduled backup

2)setup a scheduled vacuum

Here's some crontab examples:

30 4 * * * /home/db_su_name/scripts/dbroller 2>&1
* 3 * * * /usr/bin/vacuumdb -q -d punbb 2>&1

Here's the code I use for a database backup. Basically you add the name of any of the databases you want to keep a backup of into the array. Converting this to run with the database name passed as an argument is a trivial exercise.

#!/usr/bin/perl

$dbFileFilter="%s.%s";

my @dbName=("punbb","template1");

foreach $db(@dbName){

        $dbFile  = sprintf "$dbFileFilter",$db,"sql";
        $rslt=`pg_dump $db > ~db_su_name/pgData/$dbFile`;
}

I also use the logrotate daemon to do my bidding...basically keeping me from having a buttload of database files hanging around. If you are running a "snapshot" service, then this isn't for you.  The benefits of this are a limited number of database files are kept and you can set how much backstepping you want to do.

In the /etc/logrotate.d/ folder I create a file called "pg-bak"

/home/pg_su_name/pgData/*.sql
{
    rotate 7
    daily
    missingok
    compress
}

This means I keep 7 days of compressed backups.

Combine this with rsync to an offsite server and your bases are covered.

I cannot overstate the performance gains you will get from performing a vacuum on the punbb database once a day. PostgreSQL was loading the server pretty high until I started doing a daily vacuum.

Just updated the timezone_mod for PunBB.

Had some real fun modifying a production forum with it and included some very useful notes in the readme.txt on how to implement the mod.

Now up to vers.
timezone_mod v. 1.0.2
And now with even more forehead slapping goodness.

How to modify PunBB v. 1.2.5 to use plaintext zoneinfo locality strings vs. GMT relative
integer values.

This modification changes the timezone selection from a pure-math fixed-form system
to one based on strings and the system zoneinfo libraries. The associations between the
timezone strings and any PHP date/time functions is made by the OS system library calls.

It can be downloaded from here.

For example:
GMT -7 == US/Arizona

There are hundreds of these locality strings and they are much more descriptive than
GMT-relative values.

Note: This mod could cause privacy problems for those who would rather not disclose their locality.
A warning to the effect that would protect those who have issues with revealing such info and
they can always change their locality to be a little off but still be accurate.

10

(7 replies, posted in Programming)

Just probably bungled my way through the punres project deployment shuffle.
Still scratching my head over the "release" setup and category selections. hmm

Hopefully I haven't left too many oversights.

timezone_mod

11

(7 replies, posted in Programming)

Rickard wrote:

Ah, OK. 500 tuples? I didn't think there existed that many timezones.

I would be careful about placing stuff in the cache folder unless you have code to automatically regenerate the cache in case it is missing. What is in the cache folder is considered volatile. For example, the upgrade scripts usually delete all .php scripts in the cache folder.

Please check out the drop-down list in the timelab link I posted. I'm pretty sure there are 500 entries.

I did a tree of the zoneinfo folder and used a bit of perl to create a flatfile I could push at postgresql to fill a table. I'm going to pare it down a little but that's how many references there are.

When I was mentioning semaphores I was trying to say that I am using the existing code and definitions for regenerating cache files as an example. So I have setup the same mechanisms which exist for files PunBB is caching. I try to learn from examples.

As usual life is performing some blocking interrupts on my completing things.
I'm learning all about PHP's array fetishes and how to properly play with multi-dimensional associative arrays.

12

(7 replies, posted in Programming)

Rickard wrote:

Nice work. Looking forward to seeing this in action.

What do you mean by "reduces the static page sizes by several kb"?

Thank you for taking an interest.

I have created two files in the cache/ folder.
One is a simple array containing integer/timezone string tuples.
The other is the guts of the form used to select timezone in the profile.php, admin_options.php, etc...
Doing this saves having to make a 500 tuple query each time profile.php or any other template calling the timezone info.

Here's how I reduced the static page size in the profile.php and other timezone modifying templates:

<select name="form[timezone]">
<option value="<? echo $pun_user['timezone']; ?>" selected><? echo $pun_tzones[$pun_user['timezone']]; ?></option>
<? require "cache/pun_time_zone_options.php"; ?>
</select>

Over the course of several templates this reduces the static page size by about 4kb a form and eliminates what would be a 499 conditional if block when using the zoneinfo for each timezone selection form.

Nothing too dramatic.  :-)  I think the templates are pretty lean already.
I've had fun working with PunBB.

I'm almost done writing up the documentation where I'm using

"diff mytree/filename.php  sourcetree/filename.php"

to note the changes. The timezone mod works and I'm testing it against an event system which enticed me to write the timezone mod to begin with. I finished the initial testing on that last night but I'm still tormenting it to see what breaks.

13

(7 replies, posted in Programming)

I've rolled a database mod, and modifications to several templates which comprise a complete change-over from using the numeric locality system to using the zoneinfo libs through php. I'm going to try to test this over the weekend with an event facility/plugin I wrote and if it works I'll post it all on punres.

In writing this mod I have learned about the caching/semaphores punbb uses, and reduced the static page sizes by several kb.

The flipside of this mod would probably be a localization layer. For English and some European forums it wouldn't be an issue, beyond that I imagine spelling "Asia/Pyongyang" would look much different.

The nice thing about using the zoneinfo calls is that instead of just relying on relative GMT the user can actually select a written locality. I also modified the header.php to display their timezone next to the Last Visit, so it looks like:

Last visit: 2005-05-09 15:16:34 (US/Arizona)

Hope everyone has a nice weekend.

14

(7 replies, posted in Programming)

Has anyone here had to deal with mission-critical timezone resolution issues using PHP?

The timezone range provided by punbb is adequate for messages posted in the forum, however, in the work I've done bringing seamless event calendaring to the forum I'm starting to consider a modification or bolt-on which would give the users the choice of using the environment timezones (/usr/share/zoneinfo).  Here's a link to a lab I've setup to explore this.

If anyone has had to explore this kind of endeavor I would really enjoy hearing from you.