forum.coppermine-gallery.net

Support => Older/other versions => cpg1.3.x Support => Topic started by: Pedros on July 06, 2004, 05:02:16 pm

Title: [Solved]: How to delete all favorites
Post by: Pedros on July 06, 2004, 05:02:16 pm
Is there a way i can delete all favorites by pressing one button??
I know it's a clientsite cookie...
Any code available?
Title: Re: How to delete all favorites
Post by: Casper on July 06, 2004, 06:27:28 pm
Just change the name of the cookie, in config.  it will mean all client saved data is cleared.
You will also find yourself logged out.  Just log back in.
Title: Re: How to delete all favorites
Post by: Pedros on July 07, 2004, 12:35:00 pm
sorry your answer was no help
I did it myself!! actualy very simpel

<?php
define('IN_COPPERMINE', true);
define('INDEX_PHP', true);
require('include/init.inc.php');

setcookie($CONFIG['cookie_name'] . '_fav', "", time() + 86400 * 30, $CONFIG['cookie_path']);

$location = "index.php";
$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
header($header_location . $location);
pageheader($lang_info, "<META http-equiv=\"refresh\" content=\"1;url=$location\">");
msg_box($lang_info, "Het zipbestand werd verwijderd", $lang_continue, $location);
pagefooter();
ob_end_flush();
?>
Title: Re: [Solved]: How to delete all favorites
Post by: bit bit spears on July 10, 2004, 09:35:29 am
gives a database error after clearing favs!

"There was an error while processing a database query"
Title: Re: [Solved]: How to delete all favorites
Post by: Joachim Müller on July 10, 2004, 04:26:56 pm
you've been told before: if there's a database error, enable debug_mode in config and post what query actually failed. When will you learn to properly ask questions on this board?

GauGau
Title: Re: [Solved]: How to delete all favorites
Post by: Pedros on July 16, 2004, 10:31:15 am
gives a database error after clearing favs!

"There was an error while processing a database query"
The code dont need access to the database!
Just put this code in a new file : dellfav.php (example)
Make a new  button and link it
<a href="dellfav.php">Delete favorites </a>
Title: Re: [Solved]: How to delete all favorites
Post by: littletomfool on November 11, 2004, 04:37:34 am
Hi~~~ I'm new here, and I don't know PHP very much, can you please teach me what code should I add to let user automaticaly Delete Favorites after download the ZIP file??
Title: Re: [Solved]: How to delete all favorites
Post by: kper on May 07, 2005, 05:48:17 pm
Pedros' code does not quite work from a UI point of view because the page is refreshed before the message box can be output.

It also summarily returns you to the index page, whether you came from there or not.

The following should do the job if you paste it into an empty delfav.php file (which you need to create yourself in Coppermine's root directory).

The
Code: [Select]
define('INDEX_PHP', true); line is not needed because you aren't using any special language variables which pertain only to index.php pages.

Code: [Select]
<?php
/*************************
  Coppermine Photo Gallery
  ************************
  
  Code to clear all files from the user's favorites (lightbox).
  
  It does this simply by clearing the data in the appropriate cookie.
  
  To use it, add a button link to this file in your template theme.php file,
  eg. <a href="delfav.php">Clear Lightbox</a>
  
**********************************************/

define('IN_COPPERMINE'true);
require(
'include/init.inc.php');

setcookie($CONFIG['cookie_name'] . '_fav'""time() + 86400 30$CONFIG['cookie_path']); //The "" bit is what resets the cookie data to nothing

$referer $HTTP_GET_VARS['referer'] ? $HTTP_GET_VARS['referer'] : 'index.php'//Sets the index page as your previous location if it can't determine where you came from by reading the referer from the browser

pageheader($lang_info"<META http-equiv=\"refresh\" content=\"3;url=$referer\">"); //Sends you back to the page you came from (or index.php) after 3 secs if you don't click the continue button
msg_box($lang_info"Your lightbox has been cleared"$lang_continue$referer);
pagefooter();
ob_end_flush(); //Sends all this to the browser and flushes the php output buffer
?>


Hope that helps. Please do correct me if I've got anything wrong.

Craig
Title: Re: [Solved]: How to delete all favorites
Post by: kper on May 10, 2005, 11:14:55 am
 :-[  Sorry: my last post contains an error. Replace the obvious line with the following. It will then work. Ooops.
Code: [Select]
$referer = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : 'index.php'; //Sets the index page as your previous location if it can't determine where you came from by reading the referer from the browser
Craig
Title: Re: [Solved]: How to delete all favorites
Post by: digitalravi on August 23, 2006, 06:07:08 pm
I followed the instructions by Kper, but I am unsure as to where to put this line "<a href="dellfav.php">Delete favorites </a>"
Title: Re: [Solved]: How to delete all favorites
Post by: Nibbler on August 23, 2006, 06:11:00 pm
I thought you were running 1.4?