vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Reset Notices (https://vborg.vbsupport.ru/showthread.php?t=262108)

Tasking Mickey 04-16-2011 06:18 PM

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?

kh99 04-16-2011 07:59 PM

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).

Tasking Mickey 04-16-2011 08:09 PM

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?

kh99 04-16-2011 08:22 PM

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.

Tasking Mickey 04-16-2011 08:30 PM

So, I put that, in the place of
PHP Code:

$con mysql_connect("localhost",$config['MasterServer']['username'],$config['MasterServer']['password']); 

?

kh99 04-16-2011 08:31 PM

Yes.

I haven't tried any of it, so there may be a typo I missed.

Tasking Mickey 04-16-2011 08:42 PM

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?

kh99 04-16-2011 08:48 PM

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'])); 


Tasking Mickey 04-16-2011 08:50 PM

YES! Thank you! Yes!

It worked! thank you so much! :)

cmmguy 07-11-2017 01:13 PM

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.


All times are GMT. The time now is 05:27 AM.

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.01582 seconds
  • Memory Usage 1,749KB
  • 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
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete