vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Help with plugin array and option settings (https://vborg.vbsupport.ru/showthread.php?t=264820)

kh99 06-08-2011 02:27 PM

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");
}


Simon Lloyd 06-08-2011 03:26 PM

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.


kh99 06-08-2011 03:33 PM

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.

Simon Lloyd 06-08-2011 03:48 PM

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"); 


BirdOPrey5 06-08-2011 08:51 PM

Quote:

Originally Posted by Simon Lloyd (Post 2205107)
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");

Simon Lloyd 06-09-2011 04:45 AM

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.

BirdOPrey5 06-09-2011 11:32 AM

Quote:

Originally Posted by Simon Lloyd (Post 2205361)
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.

Simon Lloyd 06-09-2011 02:41 PM

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?


All times are GMT. The time now is 03:16 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.01192 seconds
  • Memory Usage 1,751KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete