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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
<?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/keywordmgr.php $ $Revision: 4392 $ $Author: gaugau $ $Date: 2008-04-16 09:25:35 +0200 (Mi, 16 Apr 2008) $ **********************************************/
define('IN_COPPERMINE', true); define('KEYWORDMGR_PHP', true); define('SEARCH_PHP', true); require('include/init.inc.php'); //Die if not admin_mode if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
pageheader($lang_keywordmgr_php['title']);
starttable("100%", $lang_keywordmgr_php['title'], 3); echo <<<EOT <tr> <td class="tablef"><b>{$lang_keywordmgr_php['edit']}</b></td> <td class="tablef"><b>{$lang_keywordmgr_php['delete']}</b></td> <td class="tablef"><b>{$lang_keywordmgr_php['search']}</b></td> </tr>
EOT;
switch($_REQUEST['page']) {
default : case 'display':
$result = cpg_db_query("select keywords from {$CONFIG['TABLE_PICTURES']}"); if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap']); // Find unique keywords $total_array = array();
while (list($keywords) = mysql_fetch_row($result)) { $array = explode(' ',$keywords);
foreach($array as $word) { if ($word == '.' || $word == '' || $word == ' ' ) continue; $orig_word = $word; $single_word = addslashes($word); $lowercase_word = utf_strtolower($single_word); $lowercase_word = addslashes($lowercase_word); $word = <<<EOT <td class="tableb"> <input type="radio" class="radio" name="keywordEdit" value="$lowercase_word" onClick="document.keywordForm.newword.value='$single_word'" id="$lowercase_word" /> <label for="$lowercase_word" class="clickable_option"> <img src="images/edit.gif" width="16" height="16" border="0" alt="" title="{$lang_keywordmgr_php['edit']} "$orig_word"" /> "<i>$orig_word</i>" </label> </td> EOT; $word .= '<td class="tableb"><a href="keywordmgr.php?page=delete&remov='.$single_word.'" onclick="return confirm(\''.sprintf($lang_keywordmgr_php['confirm_delete'], '"'.$single_word.'"').'\')">'; $word .= '<img src="images/delete.gif" width="16" height="16" border="0" alt="" title="'.sprintf($lang_keywordmgr_php['keyword_del'],'"'.$orig_word.'"').'" /> '.$orig_word; $word .= <<<EOT </a></td> <td class="tableb"><a href="thumbnails.php?album=search&search=$orig_word" target="_blank"> EOT;
$word .= sprintf($lang_keywordmgr_php['keyword_test_search'], '"<i>'.$orig_word.'</i>"'); $word .= '</a></td>';
if (!in_array($word,$total_array)) $total_array[] = $word; } }
sort($total_array);
$output = implode("</tr>\n<tr>", $total_array);
echo <<<EOT <form name="keywordForm" action="keywordmgr.php?page=changeword" method="post"> $output <tr><td colspan="5" class="tablef" align="center"> <input type="text" name="newword" /> <input type="submit" value="{$lang_keywordmgr_php['change_keyword']}" /> </td></tr> </form> EOT;
break;
case 'changeword':
if ($_REQUEST['keywordEdit'] && $_REQUEST['newword']) { $keywordEdit = addslashes($_REQUEST['keywordEdit']);
$query = "SELECT `pid`,`keywords` FROM {$CONFIG['TABLE_PICTURES']} WHERE CONCAT(' ',`keywords`,' ') LIKE '% {$keywordEdit} %'"; $result = cpg_db_query($query) or die(mysql_error());
while (list($id,$keywords) = mysql_fetch_row($result)) { $array_new = array(); $array_old = explode(" ", addslashes(trim($keywords)));
foreach($array_old as $word) { // convert old to new if its the same word if (utf_strtolower($word) == $keywordEdit) $word = addslashes($_REQUEST['newword']);
// rebuild array to reprocess it $array_new[] = $word; }
$keywords = implode(" ", $array_new); $newquerys[] = "UPDATE {$CONFIG['TABLE_PICTURES']} SET `keywords` = '$keywords' WHERE `pid` = '$id'"; } } $newquerys[] = "UPDATE {$CONFIG['TABLE_PICTURES']} SET `keywords` = TRIM(REPLACE(`keywords`,' ',' '))";
foreach ($newquerys as $query) { $result = cpg_db_query($query) or die($query."<br />".mysql_error()); }
header("Location: keywordmgr.php?page=display");
break;
case 'delete':
$keywordEdit = addslashes($_REQUEST['remov']);
$query = "SELECT `pid`,`keywords` FROM {$CONFIG['TABLE_PICTURES']} WHERE CONCAT(' ',`keywords`,' ') LIKE '% {$keywordEdit} %'"; $result = cpg_db_query($query) or die(mysql_error());
while (list($id,$keywords) = mysql_fetch_row($result)) { $array_new = array(); $array_old = explode(" ", addslashes(trim($keywords)));
foreach($array_old as $word) { // convert old to new if its the same word if (utf_strtolower($word) == $keywordEdit) $word = '';
// rebuild array to reprocess it $array_new[] = $word; }
$keywords = implode(" ", $array_new); $newquerys[] = "UPDATE {$CONFIG['TABLE_PICTURES']} SET `keywords` = '$keywords' WHERE `pid` = '$id'"; }
$newquerys[] = "UPDATE {$CONFIG['TABLE_PICTURES']} SET `keywords` = TRIM(REPLACE(`keywords`,' ',' '))";
foreach ($newquerys as $query) { $result = cpg_db_query($query) or die($query."<br />".mysql_error()); }
header("Location: ?page=display");
break;
} endtable(); if ($CONFIG['clickable_keyword_search'] != 0) { include('include/keyword.inc.php'); } pagefooter(); ob_end_flush(); ?>
|