Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2007, 09:15 PM
Wastl Wastl is offline
 
Join Date: Mar 2005
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom name check in register.php / log IP of each visit?

Hello,

I have two questions about custom functions in vBulletin.
  1. I have a custom check function in register.php that checks if the name with which the user registers already exists in a database table. Currently I added code to the "start add member" section of register.php:
    PHP Code:
    $exist    MYSQL_QUERY(some SQL query);
    if(!
    MYSQL_NUM_ROWS($exist)){
        eval(
    standard_error(fetch_error('namenotexistant')));
        exit;

    Each time I update the forum, I have to add this code again. Is this something I could do with some kind of plugin that stays unaffected by updates? At least the phrase "namenotexistant" stays active for minor upgrages.
  2. Can I activate somehow logging the IP address each time a user enters the forum with user name and password and not only on registration and for each post? I am having problems with hacked forum accounts and people do only read but not post and looking up IPs in the apache log files is very time consuming and I always need time and URL of the activity.

Thanks a lot for any hint
Reply With Quote
  #2  
Old 08-26-2007, 09:58 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Look for a hook near that section; you can then add a plugin using that hook location.
You should also use vBulletin's DB class if you're executing queries.

eg: $db->query_write(); or $db->query_read();
see: https://vborg.vbsupport.ru/showthread.php?t=119350
Reply With Quote
  #3  
Old 08-27-2007, 07:08 PM
Wastl Wastl is offline
 
Join Date: Mar 2005
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your comment, the use of the $db class was no problem, I was already thinking of doing that. More useful was this article:

https://vborg.vbsupport.ru/showthread.php?t=82625

which I found thanks to you mentioning the word hook, I have read it before in the code but couldn't think of what was used for.

What about the IP loggin on each login? Is there a function in vBulletin or an existing plugin or would I have to write my own hook for that?

Hm somehow I can't get the hook to work. I inserted it at 'register_addmember_process' but now the step "Complete Registration" just takes forever and does not show the next page. My hook code is:
PHP Code:
$exist $db->query_read("SELECT name FROM table WHERE name = '".$vbulletin->GPC['username']."'");
if(!
$db->num_rows($exist))
    
$userdata->error('namenotexistant'); 
I already removed the "exit;" I had at the end and also replaced the eval - standard_error - fetch_error by $userdata->error, but nothing works .
Reply With Quote
  #4  
Old 08-27-2007, 09:31 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've never seen an IF statement like this:
PHP Code:
if(!$db->num_rows($exist))
    
$userdata->error('namenotexistant'); 
Try:
PHP Code:
if(!$db->num_rows($exist)){
    
$userdata->error('namenotexistant');} 
Unless they both work the same and I've just never seen one written like that..
Reply With Quote
  #5  
Old 08-27-2007, 09:59 PM
Wastl Wastl is offline
 
Join Date: Mar 2005
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Both work the same, you can omit the {} if there is only one statement following the IF condition, you just need it to mark a whole block of statements to be executed when the condition is met. I tried it with {} in case vBulletin interprets the code different to PHP, it took also ages for the page to load but finally my error was displayed. Then I removed the {} again, reloaded the page and it responded quickly with the error message. Very strange . But anyway thanks for your concern .
Reply With Quote
  #6  
Old 08-27-2007, 10:02 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, either way - if you want to code according to vBulletin's standards you should always use braces in conditionals, unless you're using the ternary operator.
Reply With Quote
  #7  
Old 08-28-2007, 06:56 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmmm, Kirk, if you insist on following vBulletin coding standards .
PHP Code:
if (!$db->num_rows($exist))
{
    
$userdata->error('namenotexistant');

Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:35 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04011 seconds
  • Memory Usage 2,233KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete