Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)

Reply
 
Thread Tools Display Modes
  #1  
Old 08-15-2012, 11:43 AM
agtsai agtsai is offline
 
Join Date: Aug 2012
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 404 header on empty threads

When no thread exists, the error page that's says "No Thread specified. If you followed a valid link, please notify the administrator." actually returns a 200 OK header rather than a 404.

Does anyone know how I can modify vbulletin to ensure error pages return a hard 404. Thanks!
Reply With Quote
  #2  
Old 08-16-2012, 01:16 AM
Eosian Eosian is offline
 
Join Date: Feb 2009
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can do it, but you have add some redundant code to make it happen.

The verify_id() function is what generates that error, so if you want to preempt it you have to throw in a check before it gets called and override what it would've done.

Add a plugin that is triggered by showthread_start

Code:
if (!$check = $vbulletin->db->query_first('SELECT threadid FROM ' . TABLE_PREFIX . 'thread WHERE threadid = ' . $vbulletin->db->escape_string(  $vbulletin->GPC['threadid']) ))
{
// If using fastcgi this is the 404 header
//	header("Status: 404 Not Found");
// otherwise this is the standard 404
	header("HTTP/1.0 404 Not Found");
}
If you don't add an exit after the header you'll throw the 404 instead of the 200, but still show the normal page.

If you want to actually pass the handling to your webserver's error handling document you'd need to either include the error document after it and exit, or similar.
Reply With Quote
  #3  
Old 03-04-2013, 09:43 AM
Expert1 Expert1 is offline
 
Join Date: Mar 2011
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks alot Eosian, I am looking for this solution for a long. Your solution have worked perfectly for me. But I am getting one more soft error http://www.techhotfix.com/forum/sear...155&pp=&page=3 in search.php. Please help me this type of broken links returning 200 response code or soft 404 instead of 404 error page not found. Please help
Reply With Quote
  #4  
Old 03-04-2013, 11:34 AM
Eosian Eosian is offline
 
Join Date: Feb 2009
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Should be approximately the same but you use search_intro as your hook and the test for whether or not an error has occurred would be to check either empty($errors) or !$show['errors'] (either of those checks, both shouldn't be necessary because the show is set earlier by the $errors variable).

You could probably also use search_complete as the hook, but any other hooks on search_intro could potentially change the results before search_complete is called.
Reply With Quote
  #5  
Old 03-04-2013, 12:20 PM
Expert1 Expert1 is offline
 
Join Date: Mar 2011
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

My brother, actually I have very little knowledge of programming. So please gimme code which have you given in post number 2. Thank You.
Reply With Quote
  #6  
Old 03-04-2013, 12:38 PM
Eosian Eosian is offline
 
Join Date: Feb 2009
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Add a plugin that is triggered by search_intro

Code:
if ( !empty($errors) )
{
// If using fastcgi this is the 404 header
//	header("Status: 404 Not Found");
// otherwise this is the standard 404
	header("HTTP/1.0 404 Not Found");
}
Reply With Quote
  #7  
Old 03-05-2013, 05:24 AM
Expert1 Expert1 is offline
 
Join Date: Mar 2011
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi, above solution is not working brother.
Please check out this link http://www.techhotfix.com/forum/sear...505&pp=&page=2 and i want 404 error but it showing 200 response code. Try to give me some other solution. Thank You.
Reply With Quote
  #8  
Old 03-06-2013, 05:47 AM
Expert1 Expert1 is offline
 
Join Date: Mar 2011
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Please help me brother.
Reply With Quote
  #9  
Old 03-13-2013, 01:02 PM
Expert1 Expert1 is offline
 
Join Date: Mar 2011
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anybody here to help me....

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

Quote:
Originally Posted by Eosian View Post
Add a plugin that is triggered by search_intro

Code:
if ( !empty($errors) )
{
// If using fastcgi this is the 404 header
//	header("Status: 404 Not Found");
// otherwise this is the standard 404
	header("HTTP/1.0 404 Not Found");
}
This is not working....
Reply With Quote
  #10  
Old 04-11-2013, 11:45 PM
vbresults vbresults is offline
 
Join Date: Apr 2009
Posts: 687
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Create a plugin hook on the `init_startup` hook, place the following code in, and save.
PHP Code:
if (THIS_SCRIPT == 'showthread' && !verify_id('threadid'$_GET['t'], false)) {
    
header('HTTP/1.0 404 Not Found');
    
header('Status: 404 Not Found');

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 01:26 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04297 seconds
  • Memory Usage 2,252KB
  • 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_code
  • (1)bbcode_php
  • (1)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
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete