1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<?php /************************* Coppermine Photo Gallery ************************ Copyright (c) 2003-2008 Dev Team v1.1 originally written by Gregory DEMAR
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.
******************************************** Coppermine version: 1.4.19 $HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.4.x/addfav.php $ $Revision: 4392 $ $Author: gaugau $ $Date: 2008-04-16 09:25:35 +0200 (Mi, 16 Apr 2008) $ **********************************************/
/** * Coppermine Photo Gallery addfav.php * * This file does the needful when add to fav links are clicked, if the user is logged in then * the favs are stored in the database else the favs are stored in a local cookie, the favs in * database take precedence over the cookie favs * * @copyright 2002-2007 Gregory DEMAR, Coppermine Dev Team * @license http://www.gnu.org/licenses/gpl.html GNU General Public License V3 * @package Coppermine * @version $Id: addfav.php 4392 2008-04-16 07:25:35Z gaugau $ */
/** * @ignore */ define('IN_COPPERMINE', true); /** * @ignore */ define('RATEPIC_PHP', true);
require('include/init.inc.php'); // Check if required parameters are present if (!isset($_GET['pid'])) cpg_die(CRITICAL_ERROR, $lang_errors['param_missing'], __FILE__, __LINE__);
$pic = (int)$_GET['pid'];
$ref = $CONFIG['site_url'] . (isset($_GET['ref']) ? $_GET['ref'] : "displayimage.php?pos=-$pic"); $ref = str_replace('&', '&', $ref);
// If user does not accept script's cookies, we don't accept the vote if (!isset($_COOKIE[$CONFIG['cookie_name'] . '_data'])) { header("Location: $ref"); exit; } // See if this picture is already present in the array if (!in_array($pic, $FAVPICS)) { $FAVPICS[] = $pic; } else { $key = array_search($pic, $FAVPICS); unset ($FAVPICS[$key]); }
$data = base64_encode(serialize($FAVPICS)); setcookie($CONFIG['cookie_name'] . '_fav', $data, time() + 86400 * 30, $CONFIG['cookie_path']); // If the user is logged in then put it in the DB if (USER_ID > 0) { $sql = "UPDATE {$CONFIG['TABLE_FAVPICS']} SET user_favpics = '$data' WHERE user_id = " . USER_ID; cpg_db_query($sql); // User never stored a fav... so insert new row if (!mysql_affected_rows($CONFIG['LINK_ID'])) { $sql = "INSERT INTO {$CONFIG['TABLE_FAVPICS']} ( user_id, user_favpics) VALUES (" . USER_ID . ", '$data')"; cpg_db_query($sql); } }
$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: '; header($header_location . $ref); pageheader($lang_info, "<meta http-equiv=\"refresh\" content=\"1;url=$ref\">"); msg_box($lang_info, $lang_rate_pic_php['rate_ok'], $lang_continue, $ref); pagefooter(); ob_end_flush();
?>
|