vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Custom name check in register.php / log IP of each visit? (https://vborg.vbsupport.ru/showthread.php?t=156332)

Wastl 08-26-2007 09:15 PM

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 :)

Kirk Y 08-26-2007 09:58 PM

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

Wastl 08-27-2007 07:08 PM

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 :(.

Kirk Y 08-27-2007 09:31 PM

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..

Wastl 08-27-2007 09:59 PM

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 :eek:. But anyway thanks for your concern :).

Kirk Y 08-27-2007 10:02 PM

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.

Dismounted 08-28-2007 06:56 AM

Hmmm, Kirk, if you insist on following vBulletin coding standards ;).
PHP Code:

if (!$db->num_rows($exist))
{
    
$userdata->error('namenotexistant');




All times are GMT. The time now is 03:00 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.01170 seconds
  • Memory Usage 1,735KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete