The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Few general vb coding queries
I have a custom vb page.php that has many subpages like do=this and do=that and accesses database in every sub-page. Now my queries in relation to page.php are:-
1. I use $db->free_result($query); every time I use SELECT query to fetch multiple rows. But when, where and why is $db->close(); used ? 2. I want to add one setting to ENABLE/DISABLE access to page.php, how do I do that? I know how to add settings, but what next ? I want to display an error message on page.php when set to DISABLED, but let admins view it. (almost similar to the forums turn off or arcade.php turn off feature) 3. This is a simple INSERT query:- PHP Code:
4. What is the difference between `" . TABLE_PREFIX . "mytable` and " . TABLE_PREFIX . "mytable (notice the ` symbol) 5. To display a standard redirect, we use this:- PHP Code:
6. Why is it considered a good practise to use vbphrases in templates and not direct text. Say, in the template for my page.php there is just one phrase that won't be repeated like "Welcome to our Page", can I just write it directly in the template without creating a vbphrase ? 7. I am inserting current TIMESTAMP into mytable from page.php, how do I make it show in the vbstyle? I mean, how to automatically correct it according to per user timezone setting? and leave it default for guests. I hope someone takes out time to answer these, it will help many others I think. Thank You |
#2
|
|||
|
|||
1. Not sure, personally I have never used it.
2. Add a vBulletin option setting then use PHP like: PHP Code:
4. There isn't much, some people prefer to enclose column/table names in backticks. Sometimes useful if you use a reserved MySQL word for a name (though you shouldn't really do this). 5. Just remove it from the $vbulletin->url variable... PHP Code:
7. When converting from TIMESTAMP to a "text date" e.g. "3rd Aug", the vbdate() function should automatically factor in timezones. |
#3
|
||||
|
||||
1. Okay (but still need to know coz I have seen it at few places)
2. This means my whole code in page.php would be wrapped with this ?? like below:- PHP Code:
3. Okay, I'll check it out 4. So, is it okay to NOT to use backticks ? 5. Ah.. why I didn't thought of that .. thanks 6. So, if I'm not using any other language, is it okay to NOT to use phrases at all for simple text ? 7. See, I am inserting current time in this format $TIMESTAMP=date('jS \of F, Y h:i:s A'); , and simply retrieving it. It shows time in GMT to all. Can you please give an example of this on how to use vbdate(). Thank You so much |
#4
|
|||
|
|||
1. Check the articles section for the thread about using the vBulletin Database Class
2. No give them a no permission error. or some message: PHP Code:
6. If it is just for your own board then its up to you. Personally I keep it in a phrase so I can edit it easier, instead of editing a template I just edit a phrase. If you are release the product as a modification you should use phrases. 7. A timestamp is a number (google: "Unix Timestamp" for info about it). What you wrote there is a date/time not a timestamp. Use the TIMENOW constant to fetch the timestamp when a script is executing, insert that into your database not the date() thing. When you fetch the timestamp from the database then you use vbdate/date function. PHP Code:
|
#5
|
||||
|
||||
1. okay, got this in articles:-
Quote:
And thank you so much for the rest !! Will come up with more queries later . Thanks |
#6
|
||||
|
||||
Thanks for answering all my above 7 queries. I have understood each one of them.
Few more things:- 8. Whenever we create a setting for our product, it is available globally at $vbulletin->options['var-name']; and we can use this option anywhere as it would be available throughout our site i.e. in all pages. Am I correct? If yes, then I wanted to know, if suppose we are having 100 products installed with 10 settings each, will there be 1000 unnecessary variables lying in the memory? How can I restrict a setting to be available only to a specific page.php and must not be available on any other vbpage. 9. Also, in relation to above, how do I use the setting variable in the associated template? Say I want to display a link from the template if the option is enabled in the product otherwise not. 10. I have read about vbulletin input cleaner. But can someone please explain me, when to use TYPE_STR and when TYPE_NOHTML coz I am able to achieve what i want from both and both allow $db->escape_string 11. vB uses this code to redirect to any location (in our case page.php), how do I redirect to previous page that user accessed? PHP Code:
Thank You |
#7
|
||||
|
||||
waiting for reply plz..
|
#8
|
|||
|
|||
8. Yes (but use "_" (underscore) instead of "-" (hyphen)). No you can't restrict to single page.
9. Just use <if> conditions.... 10. TYPE_STR allows HTML, TYPE_NOHTML does not allow HTML (it uses htmlspecialchars() basically). $db->escape_string is not related to input, you use it escape strings that you insert into the database. It will change " to \" e.t.c. |
#9
|
||||
|
||||
thank you for so much help uptill now..
Few more things please:- 12. vB has a system of putting things in moderation queue and then wait for moderator's approval to show them publicly. It would be pretty easy to do so by taking input from user and inserting the records in a temporary table and then after reviewing let mods move them to the main table. But, is this the same way vB does this? How do I create a notification sort of for achieving that thing ? 13. Also, how does vB sends emails to users? Is it the same old php mail() function? Can I use the same in my page.php? or there is a better way to do it off vB? |
#10
|
|||
|
|||
12. It is done by a status column in the post table (visible).
13. Yes the old mail() function with a small wrapper around it: vbmail(). |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|