forked from coppermine-gallery/cpg1.6.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyword_create_dict.php
66 lines (55 loc) · 2 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
63
64
65
66
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2016 Coppermine Dev Team
v1.0 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.6.01
$HeadURL$
$Revision$
**********************************************/
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'], $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");
}
?>