-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathkeyword_create_dict.php
62 lines (53 loc) · 1.79 KB
/
keyword_create_dict.php
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
<?php
/**
* Coppermine Photo Gallery
*
* v1.0 originally written by Gregory Demar
*
* @copyright Copyright (c) 2003-2021 Coppermine Dev Team
* @license GNU General Public License version 3 or later; see LICENSE
*
* keyword_create_dict.php
* @since 1.6.10
*/
define('IN_COPPERMINE', true);
define('EDITPICS_PHP', true);
require 'include/init.inc.php';
if (!GALLERY_ADMIN_MODE) {
cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
}
$output = ($CPG_REFERER != 'keyword_select.php');
if ($output) { pageheader_mini($lang_gallery_admin_menu['key_lnk']); }
$query = "SELECT keywords FROM {$CONFIG['TABLE_PICTURES']} WHERE keywords <> ''";
$result = cpg_db_query($query);
$i = 0;
if ($result->numRows()) {
if ($output) { starttable('100%', $lang_gallery_admin_menu['key_lnk']); }
cpg_db_query("TRUNCATE TABLE {$CONFIG['TABLE_DICT']}");
while ($row = $result->fetchAssoc()) {
$keyArr = explode($CONFIG['keyword_separator'], html_entity_decode($row['keywords']));
foreach ($keyArr as $keyword) {
$keyword = trim($keyword);
if (empty($keyword)) {
continue;
}
$query = "SELECT null FROM {$CONFIG['TABLE_DICT']} WHERE keyword = '$keyword'";
$result2 = cpg_db_query($query);
if (!$result2->numRows(true)) {
$query = "INSERT INTO {$CONFIG['TABLE_DICT']} (keyword) VALUES ('$keyword')";
cpg_db_query($query);
if ($output) { echo '<tr><td class="tableh2">' . $keyword . '</td></tr>'; }
$i++ ;
}
}
}
if ($output) { endtable(); }
}
$result->free();
if ($output) {
echo "<p>{$lang_editpics_php['new_keywords']}: $i</p>";
pagefooter_mini();
} else {
header("Location: $CPG_REFERER");
}
//EOF