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

Reply
 
Thread Tools Display Modes
  #21  
Old 06-08-2011, 02:27 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's actually what I'd expect to see if the stristr() was never matching anything. Maybe try this:

Code:
...
$fp = fopen("output.txt", "w"); 
fwrite($fp, "User Agent: '" . $user_agent . "'\n"); 
for ($i=0;$i<$n;$i++) {
fwrite($fp, "bots[$i]: '" . $bots[$i] . "'\n"); 
if (strstr($user_agent,$bots[$i])) 
{
    fwrite($fp, "Matched.\n"); 
    banned_redirect('www.google.com.cn/search?hl=zh-CN&q=crystal+light+centrum&meta=');
}
} 
    fwrite($fp, "\nNothing matched.\n"); 
}
Reply With Quote
  #22  
Old 06-08-2011, 03:26 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

KH99, thanks for that, could you amend the code so that it keeps appending, right now it just gives one set of results which i assume are the last set to be written.
Quote:
User Agent: 'MOZILLA/5.0 (COMPATIBLE; GOOGLEBOT/2.1; +HTTP://WWW.GOOGLE.COM/BOT.HTML)'
bots[0]: 'MOZILLA/5.0 (COMPATIBLE; YANDEXBOT/3.0; +HTTP://YANDEX.COM/BOTS)'
bots[1]: 'MOZILLA/5.0 (COMPATIBLE; BAIDUSPIDER/2.0; +HTTP://WWW.BAIDU.COM/SEARCH/SPIDER.HTML)'

Nothing matched.
Reply With Quote
  #23  
Old 06-08-2011, 03:33 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, just change the "w" to "a" in the fopen line, like:

$fp = fopen("output.txt", "a");

and maybe add an extra \n to the "Nothing Matched" message so that there'll be some separation between runs.
Reply With Quote
  #24  
Old 06-08-2011, 03:48 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well it does seem to be working as intended
Quote:
User Agent: 'MOZILLA/5.0 (COMPATIBLE; YANDEXBOT/3.0; +HTTP://YANDEX.COM/BOTS)'
bots[0]: 'MOZILLA/5.0 (COMPATIBLE; YANDEXBOT/3.0; +HTTP://YANDEX.COM/BOTS)'
Matched.
So why isn't it redirecting them?, if i use the useragent at www.botsvsbrowsers.com the UA can still access the site!?

--------------- Added [DATE]1307551911[/DATE] at [TIME]1307551911[/TIME] ---------------

I guess that somehow this particular plugin has to be initiated at first call of the forum so it's in the header as im assuming the page is already loading before this gets executed so no redirect takes place???

What do you think?

--------------- Added [DATE]1307555486[/DATE] at [TIME]1307555486[/TIME] ---------------

I changed the fwrite line and removed the others to only show matched, and sure enough they still do, i've tried different hooks but no redirect?
Quote:
Matched bots[1]: . MOZILLA/5.0 (COMPATIBLE; BAIDUSPIDER/2.0; +HTTP://WWW.BAIDU.COM/SEARCH/SPIDER.HTML) .
With User Agent: . MOZILLA/5.0 (COMPATIBLE; BAIDUSPIDER/2.0; +HTTP://WWW.BAIDU.COM/SEARCH/SPIDER.HTML)
--------------- Added [DATE]1307557610[/DATE] at [TIME]1307557610[/TIME] ---------------

Maybe it is working, ran it for around 15 minutes and BAIDU disappeared!, juts doing some more tests over 30 minutes and will report back

--------------- Added [DATE]1307558959[/DATE] at [TIME]1307558959[/TIME] ---------------

Yep, found a hook....etc that works, thanks for all your diagnostic help getting the output for each of the actions, thats something i'll always use now

--------------- Added [DATE]1307565957[/DATE] at [TIME]1307565957[/TIME] ---------------

One more question (honest!) how would i date and time stamp this entry
PHP Code:
fwrite($fp"Matched bots[$i]: . $bots[$i] . \nWith User Agent:  . $user_agent . \n\n"); 
Reply With Quote
  #25  
Old 06-08-2011, 08:51 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Simon Lloyd View Post
One more question (honest!) how would i date and time stamp this entry
1st... Please use the [CODE] [/CODE] bb code for code and not [QUOTE] [/QUOTE] in the future as it's easier to read and the code will remain when someone quotes your post.

To date it use the php date() function.

I would try this:

Code:
fwrite($fp, "Matched bots[$i]: . $bots[$i] . \nWith User Agent: . $user_agent . " . date('m-d-Y H:i:s') . " \n\n");
Reply With Quote
  #26  
Old 06-09-2011, 04:45 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code changed as requested , ialready tried a version of the date function
PHP Code:
$DateOfRequest date("Y-m-d H:i:s"mktime($_REQUEST["Hour"],$_REQUEST["Min"],$_REQUEST
 
["Sec"],$_REQUEST["Month"],$_REQUEST["Day"],$_REQUEST["Year"])); 
But it produces a 1900 date with 00:00 time, i'll cut it down to just the date function and see what results i get, thanks.
Reply With Quote
  #27  
Old 06-09-2011, 11:32 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Simon Lloyd View Post
Code changed as requested , ialready tried a version of the date function
PHP Code:
$DateOfRequest date("Y-m-d H:i:s"mktime($_REQUEST["Hour"],$_REQUEST["Min"],$_REQUEST
 
["Sec"],$_REQUEST["Month"],$_REQUEST["Day"],$_REQUEST["Year"])); 
But it produces a 1900 date with 00:00 time, i'll cut it down to just the date function and see what results i get, thanks.
Don't give it a time, it will auto use the current time.
Reply With Quote
  #28  
Old 06-09-2011, 02:41 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Boofo but i'm not sure what you're referring to , as for the date/time stamp BoP5's suggestion of cutting down my original stamp works, i can't understand why mine gave just 1900 and time 00:00?
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 10:42 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.05325 seconds
  • Memory Usage 2,254KB
  • Queries Executed 11 (?)
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
  • (2)bbcode_code
  • (3)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete