Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 10-07-2006, 10:14 PM
Quarterbore Quarterbore is offline
 
Join Date: Mar 2005
Location: Valley Forge PA
Posts: 538
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Want to take info from location and use it to query database

I have a pet project to log all activity of a couple IP Hosts because of some issues I have been having... I have tools like the AEMultiple account detector and Multiple account registration detector in place and they have enabled me to handle new accounts but these trolls have resorted to browsing my site as guests and then e-mailing their nonsense.

So, I have been on a mission to identify these trolls and now it has just become kind of a fun technical challange to tighten up my website security and I want to release what I have done as a hack but I want to get one more thing added....

The following is done ONLY to visitors to my site that meet specific requirements (IE Usergroup = "0" AND Host = "AOL") but I can change those settings on the fly as necessary...
-----------------------------------------------------------------

Here is my question, my logging program determines the location of the person on my site and outputs the location like this:

/forums/showthread.php?t=19670
/forums/showthread.php?t=9356&page=2
/forums/search.php?searchid=35344
/forums/showpost.php?p=71629
/forums/showpost.php?p=71629&postcount=3
/forums/forumdisplay.php?f=49
/forums/member.php?u=3

What I need help understanding, even at a basic level (and I know this is not basic) is how can I create a series of conditionals to determine if the page is one of the following:

PART 1
showthread.php?t=
search.php?searchid=
forumdisplay.php?f=
/forums/member.php?u=

And then get the numeric ID

PART 2
19670
35344
49
3

...so that I can then query the database based on that numeric ID to get the corresponding information as the functions_online.php file does using the function convert_ids_to_titles()

STEP 3
Thread Title
Search Term
Forum Name
Member Profile Looked at

This will make reviewing my logs to find a troll with rather unusual interests to be quickly identified and with their IP and host being logged with this information is allows for corrective measures to be out into place.

I know how to use the pregmatch to get the info from STEP 1 but I do not know how I can get the numeric value from STEP 2 and put that into a variable. I do know how to do STEP 3 however!

So, can someone direct me to an online tutorial or just work up ONE example to get me started and I can then use my logs to work out how to do the rest...

So, can someone help me do JUST This one?

PHP Code:
// In the real world the following will be generated by server - defined as an example
$URL_logged '/forums/showthread.php?t=9356&page=2'

if (
preg_match ("/showthread.php/i"$URL_logged))  

// Define the location 
$page 'Viewing Thread'
// in here I need to get the numeric value following the showthread.php?t= string above
// ----------------------------------------------
// --------- THIS IS WHERE I NEED HELP!!! ------
// ----------------------------------------------
$threadid '9356'

//Then I can get the Name of the thread 

$results $db->query_read("
    SELECT title, threadid, forumid, postusername
     FROM " 
TABLE_PREFIX "thread
     WHERE threadid = 
$threadid
     LIMIT 1"
); 
while (
$threadinfo $db->fetch_array($results))
   {
    echo 
$page ': ';
    echo 
$threadinfo[title] . '<br />';
    echo 
$URL_logged '<br />';
    echo 
'Forum: ' $threadinfo[forumid] . '<br />';
    echo 
' Posted By: ' $threadinfo[postusername] . '<br />';

    } 


Reply With Quote
  #2  
Old 10-08-2006, 05:54 PM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:

$URL_logged 
'/forums/showthread.php?t=9356&page=2';  


if (
preg_match ("/showthread.php\?(t|p)=([0-9]{1,10})/i"$URL_logged$threadinfo))  

// Define the location 
$page 'Viewing Thread'
// in here I need to get the numeric value following the showthread.php?t= string above
// ----------------------------------------------
// --------- THIS IS WHERE I NEED HELP!!! ------
// ----------------------------------------------
$threadid $threadinfo[2];

echo 
$threadid
Reply With Quote
  #3  
Old 10-09-2006, 04:52 AM
Quarterbore Quarterbore is offline
 
Join Date: Mar 2005
Location: Valley Forge PA
Posts: 538
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you SO VERY MUCH again for solving one of these preg_match questions for me!

Can you, or anyone else, confirm my "guess" that the (t|p) part of that code means that this is a variable with a value that follows it? I am also confident that the "t|p" serves as an "OR".

Regardless, I have been able to work out the rest of the versions of this code that I need and I am able to continue working on my hack. It is amaing how much information we can get if you start parcing these various page and variables for a potential problem user

Poor trolls will need to find a new hobby soon as I will be able to identify them before they even post at this rate....
Reply With Quote
  #4  
Old 10-09-2006, 11:40 AM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, it would match either t or p. Note that you have to select from different tables, depending on the first match. Something like this

PHP Code:

if ($threadinfo[1] == 'p')
{
    
$query "
        SELECT * FROM "
TABLE_PREFIX "post
        WHERE postid = "
$threadinfo[2];
}
else
{
    
$query "
        SELECT * FROM "
TABLE_PREFIX ."thread
        WHERE threadid = "
$threadinfo[2];

Reply With Quote
Reply

Thread Tools
Display Modes

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 07:44 PM.


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.03314 seconds
  • Memory Usage 2,196KB
  • 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
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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_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