Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 04-16-2011, 06:18 PM
Tasking Mickey's Avatar
Tasking Mickey Tasking Mickey is offline
 
Join Date: Jun 2010
Location: United States
Posts: 148
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Reset Notices

Does anyone know of a php file, that when you go to it, any notices that you dismissed reappears, then drops you back at the forum index.

I have the file from another site,

PHP Code:
<?php
if ($_COOKIE['bbuserid']==|| $_COOKIE['bbuserid']==null)
{ die(
'You must be logged in to reset dismissed notices.'); }
include(
'includes/config.php');
$con mysql_connect("localhost",$config['MasterServer']['username'],$config['MasterServer']['password']);
mysql_select_db($config['Database']['dbname'], $con);
mysql_query("DELETE FROM tta_noticedismissed WHERE userid=" $_COOKIE['bbuserid']);
mysql_close($con);
echo 
'<script type="text/javascript">
<!--
window.location = "http://toontowners.com/forums/"
//-->
</script>'
;

?>
But dont know how to re-put it, so it can work on my forum.

Any help?
Reply With Quote
  #2  
Old 04-16-2011, 07:59 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It looks like you might be able to put that code in it's own php file, like maybe reset_notices.php, then enter the url (or make a link somewhere) that goes to http://toontowners.com/forums/reset_notices.php.

However...I'm not a security expert or anything, but I think the way $_COOKIE['bbuserid'] is used directly in the SQL is a security risk, so you probably don't want to do that unless you add some other access control for that file. (Or add code to make sure $_COOKIE['bbuserid'] contains only digits).
Reply With Quote
  #3  
Old 04-16-2011, 08:09 PM
Tasking Mickey's Avatar
Tasking Mickey Tasking Mickey is offline
 
Join Date: Jun 2010
Location: United States
Posts: 148
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, but how do I change that code, so when users on my site go to the link, http://mysite.com/forums/resetnotices.php, it would re-put the dismissed notices, then drop the users back at the forum index?
Reply With Quote
  #4  
Old 04-16-2011, 08:22 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh..well, if your database server is not 'localhost' then I think you'd want to use the server and port from the config file in place of "localhost", like:

Code:
$servername = $config['MasterServer']['servername'];
$port = $config['MasterServer']['port'] ? $config['MasterServer']['port'] : 3306;
$con = mysql_connect("$servername:$port",$config['MasterServer']['username'],$config['MasterServer']['password']);
Then change "http://toontowners.com/forums/" if that's not your forum.


ETA: and while we're at it, change the query line like this:
Code:
mysql_query("DELETE FROM tta_noticedismissed WHERE userid=" . intval($_COOKIE['bbuserid']));
to hopefully take care of that security issue.


Hope that helps.
Reply With Quote
  #5  
Old 04-16-2011, 08:30 PM
Tasking Mickey's Avatar
Tasking Mickey Tasking Mickey is offline
 
Join Date: Jun 2010
Location: United States
Posts: 148
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So, I put that, in the place of
PHP Code:
$con mysql_connect("localhost",$config['MasterServer']['username'],$config['MasterServer']['password']); 
?
Reply With Quote
  #6  
Old 04-16-2011, 08:31 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes.

I haven't tried any of it, so there may be a typo I missed.
Reply With Quote
  #7  
Old 04-16-2011, 08:42 PM
Tasking Mickey's Avatar
Tasking Mickey Tasking Mickey is offline
 
Join Date: Jun 2010
Location: United States
Posts: 148
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is my resetdismiss.php file so far

PHP Code:
<?php
if ($_COOKIE['bbuserid']==|| $_COOKIE['bbuserid']==null)
{ die(
'You must be logged in to reset dismissed notices.'); }
include(
'includes/config.php');
$servername $config['MasterServer']['servername'];
$port $config['MasterServer']['port'] ? $config['MasterServer']['port'] : 3306;
$con mysql_connect("$servername:$port",$config['MasterServer']['username'],$config['MasterServer']['password']);
mysql_select_db($config['Database']['dbname'], $con);
mysql_query("DELETE FROM tta_noticedismissed WHERE userid=" intval($_COOKIE['bbuserid']));
mysql_close($con);
echo 
'<script type="text/javascript">
<!--
window.location = "http://toontownacres.com/forums/"
//-->
</script>'
;

?>
I uploaded that to my forums. then went to my http://mysite.com/forums/resetdismss.php, it redirected me back to my forums, but my dismissed notice didn't pop back up again.

Did I code something wrong?
Reply With Quote
  #8  
Old 04-16-2011, 08:48 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I actually don't know if that's the right code to un-dismiss notices. But there is one more thing I missed - that query has a table prefix (tta_) hard-coded and I guess that's not yours. So one more change:

PHP Code:
mysql_query("DELETE FROM " $config['Database']['tableprefix'] . "noticedismissed WHERE userid=" intval($_COOKIE['bbuserid'])); 
Reply With Quote
  #9  
Old 04-16-2011, 08:50 PM
Tasking Mickey's Avatar
Tasking Mickey Tasking Mickey is offline
 
Join Date: Jun 2010
Location: United States
Posts: 148
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

YES! Thank you! Yes!

It worked! thank you so much!
Reply With Quote
  #10  
Old 07-11-2017, 01:13 PM
cmmguy cmmguy is offline
 
Join Date: Oct 2007
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for this little script. I know this is old but others may find it useful.

One note- if you changed the cookie prefix then that has to be added to the cookie name. In the example above, the prefix is "bb" added to 'userid' and yours may be different. Otherwise, it works well.
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 12: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.05016 seconds
  • Memory Usage 2,264KB
  • 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
  • (2)bbcode_code
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete