[Solved]: How to delete all favorites [Solved]: How to delete all favorites
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[Solved]: How to delete all favorites

Started by Pedros, July 06, 2004, 05:02:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Pedros

Is there a way i can delete all favorites by pressing one button??
I know it's a clientsite cookie...
Any code available?

Casper

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.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

Pedros

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();
?>

bit bit spears

gives a database error after clearing favs!

"There was an error while processing a database query"

Joachim Müller

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

Pedros

Quote from: tangibleBRIT.com on July 10, 2004, 09:35:29 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>

littletomfool

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??

kper

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 define('INDEX_PHP', true); line is not needed because you aren't using any special language variables which pertain only to index.php pages.


<?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

kper

 :-[  Sorry: my last post contains an error. Replace the obvious line with the following. It will then work. Ooops.
$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

digitalravi

I followed the instructions by Kper, but I am unsure as to where to put this line "<a href="dellfav.php">Delete favorites </a>"

Nibbler