forum.coppermine-gallery.net
Support => Older/other versions => cpg1.3.x Support => Topic started 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?
-
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.
-
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();
?>
-
gives a database error after clearing favs!
"There was an error while processing a database query"
-
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
-
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>
-
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??
-
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
-
:-[ 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
-
I followed the instructions by Kper, but I am unsure as to where to put this line "<a href="dellfav.php">Delete favorites </a>"
-
I thought you were running 1.4?