tips for phpbb3 modders

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
asinshesq
Registered User
Posts: 156
Joined: Fri May 14, 2004 10:32 pm
Location: NYC

Re: tips for phpbb3 modders

Post by asinshesq »

jojobarjo32 wrote: IMO, the sql_escape method should be call only IN sql queries.

Thanks, that's the right advice. That way, in every single sql, you can check to see if there is any variable that is a string inputted from outside and if there is you can make sure that you use either sql_build_array or sql_escape.
Alan

asinshesq
Registered User
Posts: 156
Joined: Fri May 14, 2004 10:32 pm
Location: NYC

Re: tips for phpbb3 modders

Post by asinshesq »

jojobarjo32, I just edited my point (9) in the first post of this topic to pick up your advice. Thanks again.
Alan

User avatar
jojobarjo32
Registered User
Posts: 164
Joined: Wed Jun 22, 2005 7:38 pm
Location: France

Re: tips for phpbb3 modders

Post by jojobarjo32 »

Besides, this is how developpers are doing :)

2 little notes :
  • There is a "new" user variable in phpBB3 : username_clean. If you simply want to display an username, then use $user->data['username']. But if you want to check if a given username exists, you must do as this :

    Code: Select all

    $sql = 'SELECT user_id
    		FROM ' . USERS_TABLE . '
    		WHERE username_clean = "' . $db->sql_escape(utf8_clean_string(request_var('username', '', true))) . '"';
    $db->sql_query($sql);
  • Maybe this is already said (I've not read all posts :oops:), but it is important ! When you use request_var, you must think about the content you want in the variable (I mainly talk about strings here, for integers or whatever else, there is no such a problem). If the string doesn't need to contain UTF8 data, so simply use request_var('foo', ''). If you don't specify the third argument, all non-ASCII characters from the string will be removed. Else, if this is a text which must contain unicode characters (topic subject, post message, username, password...), then set the third argument to true. This will simply ALLOW unicode chars (and check if they're well-formed) but not check if this is a "valid" utf8 string (I don't know very much about utf8 so I can't tell more :P). If this is a string which doesn't need to be displayed (like passwords) or who are validated by other means (like usernames), this is all you have to worry about. Else, use the utf8_normalize_nfc function on the string (this is the only time you have to use this function as far as I know).
In any cases, read attentively the coding guidelines and ALL the code documentation (directly from the code or here) before modifying anything :)

User avatar
rxu
Registered User
Posts: 171
Joined: Tue Apr 04, 2006 4:28 pm
Contact:

Re: tips for phpbb3 modders

Post by rxu »

So, how do I add a custom localized image now, when imegeset localization nave been changed?
I upload an image to imageset/en, add image info to phpbb_styles_imageset_data table and imageset/en/imageset.cfg, add appropriate styles to button.css and colours.css and variables to language files, then refresh the imageset. Then I try to put an image to template like this

Code: Select all

<div class="buttons">
     <div class="custom_image"><span>{L_CUSTOM_IMAGE}</span></div>
</div>
Nothing happens.

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: tips for phpbb3 modders

Post by igorw »

EXreaction wrote: It probably is just easier to do this in the php files to call the image:

Code: Select all

<img src="' . $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/imageset/' . $user->data['user_lang'] . '/button_blog_new.gif">
replace button_blog_new.gif with the name of your image.

use the $user->img() function.

User avatar
poyntesm
Registered User
Posts: 176
Joined: Fri May 13, 2005 4:08 pm
Location: Dublin, Ireland
Contact:

Re: tips for phpbb3 modders

Post by poyntesm »

But mixing php & html should be a no no.

Do the images show up in the imageset in the ACP? If my memory is correct and do not shoot me if I am wrong you also need to edit the following .. includes/acp/acp_styles.php, language/en/acp/styles.php

Use a tool like web developer bar to make sure the CSS values for height & width and source are getting correctly passed to the CSS side.

User avatar
rxu
Registered User
Posts: 171
Joined: Tue Apr 04, 2006 4:28 pm
Contact:

Re: tips for phpbb3 modders

Post by rxu »

eviL3 wrote: use the $user->img() function.

Off/on-state image switching doesn't work in this case.

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: tips for phpbb3 modders

Post by EXreaction »

eviL3 wrote:
EXreaction wrote: It probably is just easier to do this in the php files to call the image:

Code: Select all

<img src="' . $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/imageset/' . $user->data['user_lang'] . '/button_blog_new.gif">
replace button_blog_new.gif with the name of your image.

use the $user->img() function.


Then you need to add the code to the imageset, and reset the imageset before you can use it. ;)

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: tips for phpbb3 modders

Post by igorw »

poyntesm, yes there are a few files that need to be modified.

rxu, what do you mean by on/off switching?

User avatar
rxu
Registered User
Posts: 171
Joined: Tue Apr 04, 2006 4:28 pm
Contact:

Re: tips for phpbb3 modders

Post by rxu »

eviL3, I mean Prosilver "2-layered" buttons.

Post Reply