function quick_tag_page_html($html) { global $CONFIG; $num_keywords = 10; $keywords_array = array(); $keyword_count = array(); $result = cpg_db_query("SELECT keywords FROM {$CONFIG['TABLE_PICTURES']} WHERE keywords <> ''"); if (mysql_num_rows($result)) { while (list($keywords) = mysql_fetch_row($result)) { $array = explode($CONFIG['keyword_separator'], html_entity_decode($keywords)); foreach ($array as $word) { if (!trim($word)) { continue; } if (!in_array($word = utf_strtolower($word), $keywords_array)) { $keywords_array[] = $word; $keyword_count[$word] = 1; } else { $keyword_count[$word]++; } } } arsort($keyword_count); } $i = 0; $buttons = ''; foreach ($keyword_count as $keyword => $count) { if ($i++ >= $num_keywords) { break; } $buttons .= "<span class=\"admin_menu\" style=\"white-space: nowrap;\" onclick=\"jQuery('#keywords\\1').focus(); jQuery('#keywords\\1').val(jQuery('#keywords\\1').val() + '{$CONFIG['keyword_separator']}{$keyword}{$CONFIG['keyword_separator']}');\">{$keyword}</span> "; } $html = preg_replace('/<input type="text" style="width: 100%" name="keywords([0-9]+)?".* \\/>/U', "\\0<p></p>" . $buttons, $html); return $html; }
function collect_groups() { $sql = "SELECT * FROM {$this->groupstable} WHERE group_single_user = 0"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(102 => 'Administrators', 2 => 'Registered', 3 => 'Guests'); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']] + 100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } return $udb_groups; }
function collect_groups() { $sql = "SELECT * FROM {$this->groupstable}"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(1 => 'Guests'); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']] + 100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } return $udb_groups; }
function auto_tag_after_edit_file($pid) { global $CONFIG; static $keywords_array = null; if ($keywords_array === null) { $keywords_array = array(); $result = cpg_db_query("SELECT keywords FROM {$CONFIG['TABLE_PICTURES']} WHERE keywords <> ''"); if (mysql_num_rows($result)) { while (list($keywords) = mysql_fetch_row($result)) { $array = explode($CONFIG['keyword_separator'], html_entity_decode($keywords)); foreach ($array as $word) { if (!in_array($word = utf_strtolower($word), $keywords_array) && trim($word)) { $keywords_array[] = $word; } } } } } if (!count($keywords_array)) { return; } $result = cpg_db_query("SELECT title, caption, keywords FROM {$CONFIG['TABLE_PICTURES']} WHERE pid = {$pid} LIMIT 1"); if (!mysql_num_rows($result)) { return; } $picture = mysql_fetch_assoc($result); if (!$picture['title'] && !$picture['caption']) { return; } preg_match_all('/[\\w]+/', $picture['title'], $matches_title); preg_match_all('/[\\w]+/', $picture['caption'], $matches_caption); $word_array = array_merge($matches_title[0], $matches_caption[0]); if ($picture['keywords']) { $keyword_array = array(); $keyword_array_lowercase = array(); $array = explode($CONFIG['keyword_separator'], html_entity_decode($picture['keywords'])); foreach ($array as $word) { if (!in_array(utf_strtolower($word), $keyword_array_lowercase) && trim($word)) { $keyword_array[] = $word; $keyword_array_lowercase[] = utf_strtolower($word); } } } $new_keyword = false; foreach ($word_array as $word) { if (!in_array(utf_strtolower($word), $keyword_array_lowercase) && in_array(utf_strtolower($word), $keywords_array)) { $new_keyword = true; $keyword_array[] = $word; $keyword_array_lowercase[] = utf_strtolower($word); } } if ($new_keyword) { cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET keywords = '" . implode($CONFIG['keyword_separator'], $keyword_array) . "' WHERE pid = {$pid} LIMIT 1"); } }
function collect_groups() { $sql = "SELECT * FROM {$this->groupstable}"; $result = $this->query($sql); // XMB has no guest group in groups table, so adding one here $udb_groups = array(3 => 'Guests'); while ($row = cpg_db_fetch_assoc($result)) { $udb_groups[$row['id'] + 100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } $result->free(); return $udb_groups; }
function search_text_in_db($searchstr, $base_sql, $where_search, $add_where = array(), $strict = false) { global $db, $config; //$stopword_array = @file($root_path . 'languages/lang_' . $config['default_lang'] . '/search_stopwords.txt'); //$synonym_array = @file($root_path . 'languages/lang_' . $config['default_lang'] . '/search_synonyms.txt'); $match_types = array('or', 'not', 'and'); $add_where = sizeof($add_where) ? ' AND ' . implode(' AND ', $add_where) : ''; $cleansearchstr = searchfield($searchstr); $lower_searchstr = utf_strtolower($searchstr); if ($strict) { $split_search = array($lower_searchstr); } else { $split_search = split_words($cleansearchstr); if ($lower_searchstr != $searchstr) { $search_full_string = true; foreach ($match_types as $_null => $match_type) { if (strpos($lower_searchstr, $match_type) !== false) { $search_full_string = false; } } if ($search_full_string) { $split_search[] = $lower_searchstr; } } } $word_count = 0; $current_match_type = 'and'; $word_match = array(); $result_list = array(); for ($i = 0; $i < sizeof($split_search); $i++) { if (utf_strlen(str_replace(array('*', '%'), '', trim($split_search[$i]))) < $config['search_min_chars'] && !in_array($split_search[$i], $match_types)) { $split_search[$i] = ''; continue; } switch ($split_search[$i]) { case 'and': $current_match_type = 'and'; break; case 'or': $current_match_type = 'or'; break; case 'not': $current_match_type = 'not'; break; default: if (!empty($search_terms)) { $current_match_type = 'and'; } if ($strict) { $search = $where_search . ' = \'' . sqlesc($split_search[$i]) . '\'' . $add_where; } else { $match_word = str_replace('*', '%', $split_search[$i]); $search = $where_search . ' LIKE \'%' . sqlesc($match_word) . '%\'' . $add_where; //$search = $where_search . ' REGEXP \'[[:<:]]' . $db->sql_escape($match_word) . '[[:>:]]\'' . $add_where; } $sql = $base_sql . ' WHERE ' . $search; $result = sql_query($sql); $row = array(); while ($temp_row = mysqli_fetch_row($result)) { $row[$temp_row['id']] = 1; if (!$word_count) { $result_list[$temp_row['id']] = 1; } else { if ($current_match_type == 'or') { $result_list[$temp_row['id']] = 1; } else { if ($current_match_type == 'not') { $result_list[$temp_row['id']] = 0; } } } } if ($current_match_type == 'and' && $word_count) { @reset($result_list); foreach ($result_list as $id => $match_count) { if (!isset($row[$id]) || !$row[$id]) { //$result_list[$id] = 0; @($result_list[$id] -= 1); } else { @($result_list[$id] += 1); } } } $word_count++; mysqli_fetch_assoc($result); } } @reset($result_list); $search_ids = array(); foreach ($result_list as $id => $matches) { if ($matches > 0) { //if ( $matches ) { $search_ids[] = $id; } } unset($result_list); return $search_ids; }
$nb = 0; } } endtable(); //end of displaying keyword list //begin display pic title $keyword = $_GET['keyword']; if ($keyword != "") { starttable('100%', $lang_plugin_keyword_list['pic_list'] . "<b>" . $keyword . "</b><i>" . $lang_plugin_keyword_list['click_image'] . "</i>", $pic_rownumber); $nb = 0; $pics = cpg_db_query("SELECT a.pid, a.aid, a.title, a.caption, a.keywords, a.filepath, a.filename, b.title atitle from {$CONFIG['TABLE_PICTURES']} a, {$CONFIG['TABLE_ALBUMS']} b where a.aid = b.aid {$album_filter} order by a.aid, a.pid desc"); while ($row = mysql_fetch_array($pics)) { $keywords_array = array(); $array = explode(" ", $row['keywords']); foreach ($array as $word) { if (!in_array($word = utf_strtolower($word), $keywords_array)) { $keywords_array[] = $word; } } sort($keywords_array); $count = count($keywords_array); for ($i = 0; $i < $count; $i++) { if ($keywords_array[$i] == $keyword) { if ($nb == 0) { echo "<tr>"; echo "<td><a href=\"displayimage.php?pos=-{$row['pid']}\" title=\"{$row['title']}\"class=\"summary\">{$row['title']}"; //display file title //css popup contain echo "<span><img border=\"1\" src=\"albums/{$row['filepath']}thumb_{$row['filename']}\" alt=\"{$row['title']}\" title=\"{$row['title']}{$lang_plugin_keyword_list['click_view']}\" />"; echo "<br /><b>{$lang_plugin_keyword_list[pic_caption]}</b>: {$row[caption]}<br />"; echo "<b>{$lang_plugin_keyword_list[keywords]}</b>: {$row[keywords]}</span></a></td>";
function collect_groups() { // Use this version to exclude true post based groups //$sql ="SELECT * FROM {$this->groupstable} WHERE minposts=-1"; // Use this version to include all SMF groups $sql = "SELECT * FROM {$this->groupstable}"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(1 => 'Guests', 2 => 'Registered'); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']] + 100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } return $udb_groups; }
function synchronize_groups() { global $CONFIG; if ($this->use_post_based_groups) { if ($this->group_overrride) { $udb_groups = $this->collect_groups(); } else { $sql = "SELECT * FROM {$this->groupstable} WHERE {$this->field['grouptbl_group_name']} <> ''"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']] + 100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } } } else { $udb_groups = array(1 => 'Administrators', 2 => 'Registered', 3 => 'Guests'); } $result = cpg_db_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE 1"); while ($row = mysql_fetch_array($result)) { $cpg_groups[$row['group_id']] = $row['group_name']; } mysql_free_result($result); /* Must be removed to allow new groups to be created in an unbridged install. // Scan Coppermine groups that need to be deleted foreach($cpg_groups as $c_group_id => $c_group_name) { if ((!isset($udb_groups[$c_group_id]))) { cpg_db_query("DELETE FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = '" . $c_group_id . "' LIMIT 1"); unset($cpg_groups[$c_group_id]); } } */ // Scan udb groups that need to be created inside Coppermine table foreach ($udb_groups as $i_group_id => $i_group_name) { if (!isset($cpg_groups[$i_group_id])) { // add admin info $admin_access = in_array($i_group_id - 100, $this->admingroups) ? '1' : '0'; cpg_db_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']} (group_id, group_name, has_admin_access) VALUES ('{$i_group_id}', '" . addslashes($i_group_name) . "', '{$admin_access}')"); $cpg_groups[$i_group_id] = $i_group_name; } } // Update Group names foreach ($udb_groups as $i_group_id => $i_group_name) { if ($cpg_groups[$i_group_id] != $i_group_name) { cpg_db_query("UPDATE {$CONFIG['TABLE_USERGROUPS']} SET group_name = '" . addslashes($i_group_name) . "' WHERE group_id = '{$i_group_id}' LIMIT 1"); } } // fix admin grp if (!$this->use_post_based_groups) { cpg_db_query("UPDATE {$CONFIG['TABLE_USERGROUPS']} SET has_admin_access = '1' WHERE group_id = '1' LIMIT 1"); } }
if (!checkFormToken()) { cpg_die(ERROR, $lang_errors['invalid_form_token'], __FILE__, __LINE__); } if ($superCage->get->keyExists('remove')) { $remove = $superCage->get->getEscaped('remove'); } elseif ($superCage->post->keyExists('remove')) { $remove = $superCage->post->getEscaped('remove'); } $query = "SELECT pid, keywords FROM {$CONFIG['TABLE_PICTURES']} WHERE CONCAT('{$keysep}', keywords, '{$keysep}') LIKE '%{$keysep}{$remove}{$keysep}%'"; $result = cpg_db_query($query); while (list($id, $keywords) = mysql_fetch_row($result)) { $array_new = array(); $array_old = explode($keysep, trim(html_entity_decode($keywords))); foreach ($array_old as $word) { // convert old to new if it's the same word if (utf_strtolower(Inspekt::getEscaped($word)) == utf_strtolower($remove)) { $word = ''; } // rebuild array to reprocess it $array_new[] = Inspekt::getEscaped(trim($word)); } $keywords = implode($keysep, $array_new); $newquerys[] = "UPDATE {$CONFIG['TABLE_PICTURES']} SET keywords = '{$keywords}' WHERE pid = {$id}"; } $newquerys[] = "UPDATE {$CONFIG['TABLE_PICTURES']} SET keywords = TRIM(REPLACE(keywords, '{$keysep}{$keysep}', '{$keysep}'))"; $newquerys[] = "UPDATE {$CONFIG['TABLE_PICTURES']} SET keywords = '' WHERE keywords = '{$keysep}'"; foreach ($newquerys as $query) { $result = cpg_db_query($query); } header("Location: keywordmgr.php?page=display"); break;
$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; }
header("Location: keywordmgr.php?page=display"); break; case 'delete': if ($superCage->get->keyExists('remov')) { $remov = $superCage->get->getEscaped('remov'); } elseif ($superCage->post->keyExists('remov')) { $remov = $superCage->post->getEscaped('remov'); } $query = "SELECT `pid`,`keywords` FROM {$CONFIG['TABLE_PICTURES']} WHERE CONCAT(' ',`keywords`,' ') LIKE '% {$remov} %'"; $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) == $remov) { $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; }
// Sort selected keywords sort($keywords_array); $count = count($keywords_array); $n = 0; for ($i = 0; $i < $count; $i++) { if (substr($keywords_array[$i], 0, 1) == $initial) { echo "<tr><td class=\"tableh2\" colspan={$pic_rownumber}><b>{$keywords_array[$i]}</b><i>{$lang_plugin_keyword_list['click_image']}</i></td></tr>"; $n++; //display pic title $nb = 0; $pics = cpg_db_query("SELECT a.pid, a.aid, a.title, a.caption, a.keywords, a.filepath, a.filename, b.title atitle from {$CONFIG['TABLE_PICTURES']} a, {$CONFIG['TABLE_ALBUMS']} b where a.aid = b.aid {$album_filter} order by a.pid desc"); while ($row = mysql_fetch_array($pics)) { $keysearch_array = array(); $searcharray = explode(" ", $row['keywords']); foreach ($searcharray as $word) { if (!in_array($word = utf_strtolower($word), $keysearch_array)) { $keysearch_array[] = $word; } } //end foreach($searcharray as $word) sort($keysearch_array); $searchcount = count($keysearch_array); for ($j = 0; $j < $searchcount; $j++) { if ($keysearch_array[$j] == $keywords_array[$i]) { if ($nb == 0) { echo "<tr>"; echo "<td><a href=\"displayimage.php?pos=-{$row['pid']}\" title=\"{$row['title']}\"class=\"summary\">{$row['title']}"; //display file title //css popup contain echo "<span><img border=\"1\" src=\"albums/{$row['filepath']}thumb_{$row['filename']}\" alt=\"{$row['title']}\" title=\"{$row['title']}{$lang_plugin_keyword_list['click_view']}\" />"; echo "<br /><b>{$lang_plugin_keyword_list[pic_caption]}</b>: {$row[caption]}<br />";
function collect_groups() { $sql = "SELECT * FROM {$this->groupstable}"; $result = $this->query($sql); $udb_groups = array(1 => 'Administrators', 2 => 'Registered', 3 => 'Guests'); while ($row = cpg_db_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']] + 100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } $result->free(); return $udb_groups; }