using fetch method to get rank title in phpBB

I was coding my phpbb mod and I had troubled with getting the rank title from the database. I went to Star TrekGuide for help, and it turned out to be a great idea.
get rank title

According to what Erik suggested, the way it works is to fetch it out once we get the correct and value from the table.
The problem I had was didn't get any value in return, so my codes failed to get either the correct row, or didn't get anything out from the table.

The correct way is to do something like as the following

1
2
3
$sql = 'SELECT *
   FROM '
. RANKS_TABLE . '
   WHERE rank_id = '
. $user->data['user_rank'];

So I got the concept and went ahead coded the rest on my code.
The resulting code is this:

1
2
3
4
5
6
7
8
$sql = 'SELECT rank_title
   FROM '
. RANKS_TABLE . '
   WHERE rank_id = '
. $user->data['user_rank'];
$result = $db->sql_query($sql);
$rank_title = $db->sql_fetchfield('rank_title');
$db->sql_freeresult($result);

'RANK_TITLE'  =>  $rank_title;

Another fact I learned is the problem with free the sql result, or close down the query.
I was tricked by the fact that, in phpBB, the developers do not immediately close down the request all the time. Sometime $db->sql_freeresult($result); is used right after the $sql selection request, but in most cases, in the page footer, one single $db->sql_freeresult($result); will be enough to close all the requests.

Of course, it will still be good to close it right after each $sql. But for a larger application like phpBB as a whole, it is very reasonable to close them down all at once (not always all, most of the time, yes).

Reference from Erik

The $db->sql_freeresult($result); is used always. I think that you are tricked by the fact that it isn't always called right after the query, sometimes this isn't possible as you might want to re-use the result later on or just don't want to worry about it.
Due to the way phpBB is setup you can (but shouldn't) leave the call out at all as long you call the garbage_collection() function somewhere (this is done in page_footer()) as this function calls the $db->sql_close() method. This method will run $db->sql_freeresult($result) on all open queries before it closes the database connection.
Good coding practices however makes you to call it yourself.

Working on phpBB mod again

Yes, I am working on some phpBB mod again. I haven't update any of my small mod for really a long time: just a year :)
Well, I did like 20% of the work today, re-coding my avatar mod into a real welcome panel modification which I planned a year ago.

This is not just a new feature but to enhance the forum system in a way.
The design was still very ugly, I'd rather to have jquery accordion to do the job, but I withdrew the plan because I just couldn't find a dream one: speed, light-weight, and feature-useful.

Many of the jquery acordion I found are very heavy and slow. If I have to include php, loading data, it will cause a big trouble on the users.

Here is the screenshot on what I did today, very messy, very bad, if you look at all those php and html files I opened, you probably will get a heart attack because they were so messy... new codes were all over the place...

#

Advanced Points System for phpBB3 (clean up for v0.8.2) - Part 1

Since I am working on a mod-packed phpBB, so I came across with this modification developed by Adrian.
The modification homepage is here:
http://phpbbgods.org/index.php

I am not the author of this mod. Adrian is the author.

So, this is a great mod but there are so many things that the author needs to clean up before moving to the next version.
There are three major problems:

[1] The subsilver2 template, many minor changes, or outdated advanced points system add-on.
[2] The language files which will also link to the issue with the outdated subsilver2
[3] The transfer system in version 0.8.2 should upgrade

Let me get this started.
The major problem with the subsilver2 template is that, adrian, probably too busy with fixing the php content of the code (the core), didn't remember to re-code the subsilver2.

Some of the add-on template conde in subsilver2 are outdated. For example:

Open Points\root\styles\subsilver2\template\points_bank.html

1
 Options

(more...)

another fun c++ program

It's just for fun, i will integrate a similar one into my hello world program :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Let me trying to run another calculation program
// no more salary now
// let gets this people vs bandwidth

#include <iostream>
using namespace std;

// let us do a gloabl variables

   int visitorNumber, visitBotNumber, bandwidth, dataSize, transferTime;
   signed int dataBWR = 4;

// let us begin the main body of this program

int main()
    {
          // asks some questions
          int x;
          cout << "How many visitors so far?\n"<< endl;
          cin >> x;
          cin.get();

          int y;
          cout << "How many bot visitors?\n"<< endl;
          cin >> y;
          cin.get();

          int z;
          cout << "What is the total amount of data size being uploaded?\n"<< endl;
          cin >> z;
          if (z >10000)
             bandwidth = (x + y) + (dataBWR * z);
          else
              bandwidth = (x + y) * (dataBWR);
          cin.get();
          cout << bandwidth;
          cin.get();
          return 0;
    }

starting a mod-packed phpbb3

I remembered there are similar packages released by other organizations in the 2.0 series. One is phpbbchina lead by IOSetting.
Well, some of you may start wondering, why? I mean, hey, if I do this, it will not only insecure phpBB3, but may also endanger the reputation of phpBB3. Since I am going to incorporated the stock phpBB3 with some plugins and add-ons, and release such a package to the community, especially those who just want to use it....

Another blame is that the majority of the phpBB users describe phpBB3 as one of the best and the master forum system in the open source community: you really need some basic coding skills, as simple as html and css, to make your phpBB site to fit and to reach your goals...

there are many modifications and themes release by the community already. But the problem is that people wants more and more features, so they start requesting new modifications. But only a number of users can actually code and release a safe phpBB3 modification, or theme. So IOSetting once said, "phpBB3 is more for advance users...".

Let's take a look at the chinese forum product, Discuz!. Discuz is now the #1 forum software use by the Chinese community. There are hundreds of modifications and thousands of themes. The Discuz, from version to version, increase its size, components and features, try to make everyone able to run a good forum site with just efforts on learning how to use the Discuz.
(more...)