251

(4 replies, posted in Programming)

1) You calling this a subselect EXISTS (SELECT blah)? sqlite3 supports it, dono about sqlite; but I figured if I could do it in sqlite3, I could do it anywhere... I'd have to do it as a few lines of php if that wasn't there... (trust me, I've tried) which meens slowing it down hmm

2) lol, yah, I was to busy trying to get it to work, to think of the simple stuff ~.~ lol, almost always the case, for everyone big_smile

252

(4 replies, posted in Programming)

I'm working on a really "new posts" thing, instead of the "since last visit" stuff.

Anyways... Here's the line, and it works... but I'm wondering if there's a better way of making it (read: optimize for speed and memory usage). It's from search.php below "if ($action == 'show_new')"

$result = $db->query('SELECT t.id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_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) AND NOT EXISTS (SELECT pr.tid FROM posts_read AS pr WHERE pr.tid=t.id AND pr.uid='.$pun_user['id'].')') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

The only thing I've done is add a table, "posts_read (uid INTEGER, tid INTEGER)" uid is the user id of someone who has read the tid, and the tid is you guessed it, the topic id. What happends (or will happen, soon as I finish up) is as viewtopic.php is run, a (uid, tid) pair is added to the table (if it doesn't already exist). As new topics are created nothing need be done. When search.php?action=show_new is run, only the topic id's that the user is allowed to see are returned, and only if the (uid tid) pair for that topic doesn't already exist.

I'm also thinking of inverting it, so that as new messages are created every user get's a (uid, tid) pair added to the posts_read table (or posts_unread, in that case). In the inverted sence, finding new posts would be relatively fast ("SELECT t.* FROM topics AS t INNER JOIN posts_unread AS p LEFT JOIN (permission stuffs) WHERE (more permission stuff) p.uid=CUR_USER_ID p.tid=t.id") and removing the "new post" status would be fast too "DELETE FROM posts_unread WHERE uid=CUR_UID and tid=CUR_TID". There are two downsides to this, the obvious one, new topic meens NUM_OF_REGISTERED_USERS entries created in the database, new posts, same thing, edits, same thing. Then the less obvious... as the number of inactive members grows, the size of the database starts to grow.

Another way would be to have a (uid, tid, timelastviewed); but you wouldn't be able to read the first 3 posts and leave the forth and fifth unread...

253

(114 replies, posted in Programming)

hehe, Nice pic big_smile

I still can't side with you though, because your compairing VS to vi... My point about vi being a terribly useful tool is that it is not the development environment, it's just the text editor of the development environment. Plug in a script (with cron? your bash login script? the list goes on) to check the cvs/svn repository every X minutes, and read alloud through one of the text2speech apps, when new junks arrived. Have it open a window on your desktop instead, with say, Quanta, or have a perl script parse the code and just spit out all the public functions in an html file? The important point here is that 1) this stuff isn't being done by vi, 2) you choose who says what to who now. Having vi as your editor, really meens you have bash as your ide. Depending on the project, you can alter the very nature of the development environment. With VS it's all or nothing... total lack of freedom (Other windows apps often follow this approach; interestingly enough that's what emacs ~sortof~ did). That being said, I am a hobbist; and I probably won't every work for oddles of other peoples money (at least not for programming/scripting). Should that time come we'd have to time me on vi, and then on VS... I'm about 100% sure that vi would be faster though, cause I'd get 'unknown statement ":.,+100s/a/iMyValue/g"' errors all the time, ohh, and alt+f4 isn't a good thing to press on windows...

It really comes down to what your confortable with, like I know football (soccer in north america) is the best sport in the world, but if your not comfortable saying it, I understand tongue big_smile

254

(7 replies, posted in General discussion)

Yah, i was sort of ranting, aimlessly, sorry grudon...
Anyways, if you havn't hurd of linux, red hat, debian, ubuntu... Mac OSX? ... then you shouldn't bother ;p

Follow Mark's suggestion, it's the fastest easiest way to get it done big_smile

find this around line 246 in viewtopic.php

        if ($pun_user['g_id'] < PUN_GUEST)
        {
            $user_info[] = '<dd>IP: <a href="moderate.php?get_host='.$cur_post['id'].'">'.$cur_post['poster_ip'].'</a>';

            if ($cur_post['admin_note'] != '')
                $user_info[] = '<dd>'.$lang_topic['Note'].': <strong>'.pun_htmlspecialchars($cur_post['admin_note']).'</strong>';
        }
    }
    // If the poster is a guest (or a user that has been deleted)
    else
    {
        $username = pun_htmlspecialchars($cur_post['username']);
        $user_title = get_title($cur_post);

        if ($pun_user['g_id'] < PUN_GUEST)
            $user_info[] = '<dd>IP: <a href="moderate.php?get_host='.$cur_post['id'].'">'.$cur_post['poster_ip'].'</a>';

chang to this:

        if ($pun_user['g_id'] < PUN_GUEST)
        {
            if ($pun_user['g_id'] == PUN_ADMIN)
                $user_info[] = '<dd>IP: <a href="moderate.php?get_host='.$cur_post['id'].'">'.$cur_post['poster_ip'].'</a>';

            if ($cur_post['admin_note'] != '')
                $user_info[] = '<dd>'.$lang_topic['Note'].': <strong>'.pun_htmlspecialchars($cur_post['admin_note']).'</strong>';
        }
    }
    // If the poster is a guest (or a user that has been deleted)
    else
    {
        $username = pun_htmlspecialchars($cur_post['username']);
        $user_title = get_title($cur_post);

        if ($pun_user['g_id'] == PUN_ADMIN)
            $user_info[] = '<dd>IP: <a href="moderate.php?get_host='.$cur_post['id'].'">'.$cur_post['poster_ip'].'</a>';

Then to profile.php, line 1192 or there about you see this:

                <div class="inform">
                    <fieldset>
                        <legend><?php echo $lang_profile['User activity'] ?></legend>
                        <div class="infldset">
                            <p><?php echo $lang_common['Registered'] ?>: <?php echo format_time($user['registered'], true); if ($pun_user['g_id'] < PUN_GUEST) echo ' (<a href="moderate.php?get_host='.pun_htmlspecialchars($user['registration_ip']).'">'.pun_htmlspecialchars($user['registration_ip']).'</a>)'; ?></p>

change it to this:

                <div class="inform">
                    <fieldset>
                        <legend><?php echo $lang_profile['User activity'] ?></legend>
                        <div class="infldset">
                            <p><?php echo $lang_common['Registered'] ?>: <?php echo format_time($user['registered'], true); if ($pun_user['g_id'] == PUN_ADMIN) echo ' (<a href="moderate.php?get_host='.pun_htmlspecialchars($user['registration_ip']).'">'.pun_htmlspecialchars($user['registration_ip']).'</a>)'; ?></p>

256

(7 replies, posted in General discussion)

To run your own free punbb powered forum host

1) Install linux big_smile
2) Get a chrooted httpd that isn't apache
3) Install php into the chroot
4) Have funs big_smile

257

(114 replies, posted in Programming)

So you would like bloated software? I like 5 commands to filter out all the junk of that 12Gig into 5Gig, and then 10 to split that 5 Gigs up in X Mb files, and open each with less, all from a one line bash script ;p

  VS (and microsoft prodocts, or even windows; adobe, corel, etc... are all doing the same) is all calling in the army, to respond to a broken fingernail. Why waste all that CPU on things your not going to use in that session, when your computer could be doing other, more important things; like archiving porn off the web automagically, and rotating each of your 10 virtual desktops to display the images, while hosting a website, calculating the rating to give to you music collection based on your interactions with your music player, reading you an e-book, botting 10 games, building a C++ app, and calculating the relative position of the moon to the sun in 2 billion years, all whilest your writing your latest addition to your php script on less then 1Gig of ram, and not even using 50% of your 3Gig CPU... ;p

Just as a funny aside... Many pda programs already have that inverted buffering of files... ;p You could open that 12 Gig file on my either of my palm pilots (33Mhz, 64Kb RAM; and 300Mhz, 512Kb RAM), assuming... it had some way to get to the data, lol ;p I remeber having to write a image loader that keeped the image in a run line encoded compressed chunk of memory, and I had to decode and recode each edit in BYTE chunks. Hehe, if the image had to much "noise" then the app would run out of memory and crash! Fun stuff ~.~

258

(114 replies, posted in Programming)

@Frank+elekko Meh, don't need auto-complete, just use bash. And sure in SSH, but it really shines as an add-on to all the other fancy tools. WMaker, vi, 10+vdesktops, grep, find, sed, indent... I'm forgetting alot... but you know it's there big_smile

If I had a few more monitors, and some extra sets of arms, I could code Windows XP in a day (home version though, Pro would take a day and a bit...) tongue

@MadHatter VS takes ~way~ to long to parse lines of code, or load header (for it's auto-completion), and has serious issues with updating/timestamping resources durring a build (I think I had v2004 or something though). Plus the overhead of 3 blue screen a week... and windows... My brain hurts just writing about it tongue My computer uses less memory then a clean install of windows (ME/2K/XP) when it's bzip2-tar-balling 300MB of data from a cgi script and buffering up all the data ~before~ sending it out to the web. Wern't you the guy who's grandpa invented computers? I thought you liked unixtabs? tongue

259

(11 replies, posted in PunBB 1.2 troubleshooting)

Type this (with the url bbcode) on a forum

http://www............/video150.html

Press "preview"

Right click the link and select "save target as..." or the likes

Upload videoXXX.html to you webserver, or review the jscript and figure out how to do it with less work next time tongue

260

(114 replies, posted in Programming)

Gawd, what's wrong with yous... at bloatedest, I use (g?)vi(m?); If I have to use windows ~.~ Notepad, unless enough posix is installed to run vi big_smile

With (g?)vi(m?), I could load up 10,000+ lines (in x files), and perform a regex substitutions on all 10, 000 of them lines without losing a tick tongue

Ohh, and the overhead of starting it up is mostly in the OS, like adding the title bar, or grabbing a handle to the window.

261

(6 replies, posted in Programming)

http://sqlite.org/

Click on the "syntax" link at the top right. It's sqlite command syntax, but I use it all the time.

Plus, with sqlite you can run it locally (on your home computer) for testing, and not get complaints from your host if you bugger something up (or lose your real databse).

262

(114 replies, posted in Programming)

Yah, well I have a 2x86 laptop that's bigger then my microwave, and has a screen about the size of my palm pilot! and it still works tongue

Heck... if war-dialing was still popular I'd be sitting beside a pay-phone with the thing pluged into the light socket for power big_smile

(Read: I want a univac computers that filled enormous rooms with the big desk sized terminal)

lol, until then I just hardcoded the default timezone in registrations, and switch my server timezone to -1... it does the job big_smile

264

(16 replies, posted in PunBB 1.2 discussion)

Wholy good god, you with deamhost?
What's the catch with them?...

265

(10 replies, posted in PunBB 1.2 show off)

The first PunBB powered forum to feature SQLite3 database support! big_smile

It's a forum for my makeshift band big_smile

http://robshouse.no-ip.info/

EDIT --

Seems like my ISP is having trouble... the site may be slow hmm

My post are always one hour early, and I can't really figure out why...

Either my computer forgot to alter the time (I don't think so though, it's set-up as GMT and converts to EST), or punbb doesn't have support for daylight savings...

ATM in -5 GMT (EST) it's really -4 GMT... I think... it only happend twice a year, so I don't know the details... tongue

267

(114 replies, posted in Programming)

indent + emacs? dono if there's an indent that does php, but the good old one should at least not bugger up the html/php...

Course if your me, it's vim big_smile I get caught adding ":wq" to my e-mails sometimes, lol

268

(6 replies, posted in Feature requests)

I found a bug, didn't update the files in the archive though, so you have to do it yourself.

Just open up ./include/dblayer/pdosqlite3.php and  ./include/dblayer/pdosqlite2.php and replace the escape function with this one

    function escape($str)
    {
        // php really isn't perl, is it? PDO::quote anyone? ;.;
        $retVal = false;
        if ($this->link_id) {
            $retVal = $this->link_id->quote($str);
            $retVal = substr($retVal, 1, strlen($retVal)-2);
        }
        return $retVal;
    }

problem is with this line:
substr($this->link_id->quote($str), 1, strlen($str))

strlen of $str may be, let's say 5, but the quoted $this->link_id->quote($str) is actually longer!

269

(16 replies, posted in PunBB 1.2 discussion)

Neat stuff smartys big_smile

Just curious though... how do you intend to make a profit from it? (profit could be defined as, you know, stuff to put on a resume, so I get that $100K per year job). I meen it must cost money to host, and forums are know to be CPU/bandwidth hogs.

Here's the command to delete EVERY subscription you (or anyone else) has:

DROP TABLE subscriptions;

Now the next part is VERY IMPORTANT TO GET RIGHT!!!!
Click on Administration and find out what type of databse you have. It should be at the very bottom, something like this:

Database            PDO_SQLite 3.2.8

if you use mysql, or msqli, to restore the table do this:

CREATE TABLE subscriptions (
                    user_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
                    topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
                    PRIMARY KEY (user_id, topic_id)
                    ) TYPE=MyISAM;

if you use pgsql, to restore the table do this:

CREATE TABLE subscriptions (
                    user_id INT NOT NULL DEFAULT 0,
                    topic_id INT NOT NULL DEFAULT 0,
                    PRIMARY KEY (user_id, topic_id)
                    );

if you use sqlite, to restore the table do this:

CREATE TABLE subscriptions (
                    user_id INTEGER NOT NULL DEFAULT 0,
                    topic_id INTEGER NOT NULL DEFAULT 0,
                    PRIMARY KEY (user_id, topic_id)
                    );

I suggest you backup your database before doing this.

To confirm that the table has been removed and recreated, dump the table.
In sqlite the command is

.dump subscriptions

I'm not sure about mysql or pgsql though.
Then make a new subscription and dump the table again, you should see something like this:

CREATE TABLE subscriptions (
                    user_id INTEGER NOT NULL DEFAULT 0,
                    topic_id INTEGER NOT NULL DEFAULT 0,
                    PRIMARY KEY (user_id, topic_id)
                    );
INSERT INTO "subscriptions" VALUES(3, 1);

PS: I take no responsibility if your forum blows up and causes you mother's, friend's, pet's, imaginary bird to poop out walnuts.

271

(10 replies, posted in Feature requests)

I suppose the added overhead of a db abstrction layer would be a bad thing... but adding in a litle spot to say what databases the mods been tested with is necessary for my brain to stop hurting tongue

Did you configure your smtp options in the admin section of the forum?
Do you recieve e-mail for alternative sources?

Try this:
1) Log-on as yourself
2) Click "Profile"
3) Click "Privacy"
4) Select "Hide your e-mail address but allow form e-mail."
5) Click Submit

Now log-off and create a new user. Log on as that new user, and click the user list. Find your name and click it. In the "Personal" section there will be a "Send e-mail" button. Try to send yourself an e-mail through the form.

If it fails, then you havn't configured you smtp options properly.

You could always make another Invision 1.2 board on a private site, make like 5 users, and 10 posts (a couple sticky, a few with bb code, etc). Then run the conversion on the smaller board. It would make finding the parts that are broken much easier.

274

(10 replies, posted in Feature requests)

I suggest expanding the db abstraction layer. Many mods, atm, only support a few of the database types that punbb does support. With extra php and/or less sql, Any mod could support any database type that punbb support, without modification to the mod big_smile

ie: mod wants to create a table, so do something like this:

$db->create_table(
  array(
    array('id', 'DBLayer::INT', array('DBLayer::PRIMARY', 'DBLayer::UNIQUE', 'DBLayer::SIZE', '10')),
    array('username', 'DBLayer::VCHAR', array('DBLayer::SIZE', '255')),
    array('pid', 'DBLayer::INT')
  )
);

Much more compatible, eh? EH? EH?

In the meentime you could make up some "general rules" like for one ALL them dam mods should update thier headers

// ... snip
##   Works on PunBB:  1.2.x
##   Works with: mysql, mysqli, pgsql
// .. snip

Seriously! I meen walk through 200 lines of changes just to find out that the dam mod doesn't support sqlite ~.~

275

(6 replies, posted in Feature requests)

Ummm, I request my PDO_SQLite dblayer be a feature big_smile

What's wrong with the current SQLite dblayer? It can only support SQLite v2 databases.
What's new with the PDO_SQLite dblayer? It can support SQLite v3 databases (and v2 databases, if compiled with all the right options).

What's to change? Well gimme a few, and I'll letcha know... have to find a clear copy of punbb 1.2.12...

(PS: I've only tested it lightly, but it should work just fine with a SQLite3 database. Never tried the SQLite v2 database yet; but then again my PDO install doesn't support it)

EDIT --

http://robshouse.no-ip.info/music/forum/index.php

Username: test
Password: guest

Just incase you want to try it out. I've managed to test most options and such out, all successfully. If you want to post, just toss something in the Off-Topic tongue

I'mah have a cigarette before I pull out the diff (should be just install.php, include/common.php, include/dblayer/common_db.php that are affected, and then the two new dblayer files.)

EDIT --

Hokais, got the diff, some install directions and the 2 new dblayer files big_smile

http://robshouse.no-ip.info/pdosqlite.tar.bz2

PS: My server is dirty farking slow atm (~Special~ thanks to my ISP), so if your downloading at 10KBytes/s well... your on turbo speed ;p

The only problem I can see right now is that install.php's CREATE TABLE commands should be different for pdosqlite3, so if anyone wants to optimize them for SQLite3, be my guest big_smile (the pdosqlite2 and sqlite commands should remain the exact same though!). Also, I've only tested PDO_SQLite's SQLite3 database support, SQLite2 database support remains untested.

The pdosqlite3.php file should be able to server as a template to start supporting other database formats that PDO can make use of.