$query = "UPDATE {$alias_table} SET status='accepted' WHERE tag='{$tag}' AND alias='{$alias}'"; $db->query($query); //Convert all current posts from the AKA to the tag. $query = "SELECT * FROM {$post_table} WHERE tags LIKE '% " . str_replace('%', '\\%', str_replace('_', '\\_', $alias)) . " %'"; $result = $db->query($query) or die($db->error); while ($row = $result->fetch_assoc()) { $tags = explode(" ", $row['tags']); foreach ($tags as $current) { $tagc->deleteindextag($current); } $tmp = str_replace(' ' . $alias . ' ', ' ' . $tag . ' ', $row['tags']); $tags = implode(" ", $tagc->filter_tags($tmp, $tag, explode(" ", $tmp))); $tags = mb_trim(str_replace(" ", "", $tags)); $tags2 = explode(" ", $tags); foreach ($tags2 as $current) { $tagc->addindextag($current); } $tags = " {$tags} "; $query = "UPDATE {$post_table} SET tags='{$tags}' WHERE id='" . $row['id'] . "'"; $db->query($query); } } else { if ($_POST['accept'] == 2) { $query = "UPDATE {$alias_table} SET status='rejected' WHERE tag='{$tag}' AND alias='{$alias}'"; $db->query($query); } } print '<meta http-equiv="refresh" content="2;url=' . $site_url . 'admin/?page=alias">'; exit; } echo '<form method="post" action=""><table><tr><td>
$tags = implode(" ", $ttags); foreach ($ttags as $current) { if ($current != "" && $current != " ") { $ttags = $tclass->filter_tags($tags, $current, $ttags); if (is_dir("{$main_cache_dir}" . "" . "search_cache/" . $misc->windows_filename_fix($current) . "/")) { $cache->destroy_page_cache("search_cache/" . $misc->windows_filename_fix($current) . "/"); } else { if (is_dir("{$main_cache_dir}" . "" . "search_cache/{$current}/")) { $cache->destroy_page_cache("search_cache/{$current}/"); } } } } asort($ttags); foreach ($ttags as $current) { $tclass->addindextag($current); } $tags = implode(" ", $ttags); if (substr($tags, 0, 1) != " ") { $tags = " {$tags}"; } if (substr($tags, -1, 1) != " ") { $tags = "{$tags} "; } $date = date("Y-m-d H:i:s"); $new_tags = str_replace($row['tags'], "", $tags); $ret = "SELECT tags_version FROM {$post_table} WHERE id='{$id}'"; $set = $db->query($ret); $retme = $set->fetch_assoc(); $version = $retme['tags_version']; $version = $version + 1;
} $result->free_result(); foreach ($tmp_arr as $r) { //Replace all occurances of the old tag with the new one $newtag = substr($r, $l); //Don't touch posts that contain the new tag already $query = "UPDATE {$post_table} SET tags = REPLACE(tags, ' {$r} ', ' {$newtag} ') WHERE tags LIKE '% {$r} %' AND tags NOT LIKE '% {$newtag} %'"; //Include posts that already have the new tag //$query = "UPDATE $post_table SET tags = REPLACE(tags, ' $r ', ' $newtag ') WHERE tags LIKE '% $r %' AND tags NOT LIKE '% $newtag %'"; echo "{$r} ==> {$newtag}<br/>{$query}<br/>"; $db->query($query) or die($db->error); $qt = $db->affected_rows; echo "Affected rows: {$qt}<br/>"; if ($qt > 0) { $tclass->deleteindextag($r, $qt); $tclass->addindextag($newtag, $qt); $query = "UPDATE {$tag_index_table} SET category = '{$t}' WHERE tag = '{$newtag}' AND category != '{$t}'"; echo "Setting category to '{$t}' for new tag '{$newtag}'<br/><br/>"; $db->query($query) or die($db->error); if ($db->affected_rows > 0) { $query = "UPDATE {$tag_category_table} SET tag_count = tag_count + 1 WHERE category_name='{$t}'"; $db->query($query) or die($db->error); $query = "UPDATE {$tag_category_table} SET tag_count = tag_count - 1 WHERE category_name='generic'"; $db->query($query) or die($db->error); } //delete the old tag from any post that still has it $without = substr($r, $l); $query = "UPDATE {$post_table} SET tags = REPLACE(tags, ' {$r} ', ' ') WHERE tags LIKE '% {$r} %' AND tags LIKE '% {$without} %'"; $db->query($query) or die($db->error); $tclass->deleteindextag($r, $db->affected_rows); }
foreach ($image_set as $cur_id) { if ($cur_id === end($image_set)) { $query .= "id = {$cur_id});"; } else { $query .= "id = {$cur_id} OR "; } } } //Execute Query (if we're not in debug mode) if ($debug) { echo "<strong>Update Query:</strong>{$query}<br/><br/>"; } else { $db->query($query); $qt = $db->affected_rows; print "\"{$cur_tag}\" tag added to " . $qt . " posts<br/><a href=\"index.php?page=tag_ops\">Go Back</a>"; $tclass->addindextag($cur_tag, $qt); } } } else { if ($_GET['action'] == "remove") { $losetags = explode(" ", $db->real_escape_string($_GET['remove_tags'])); if ($debug) { echo "<h4>Removing the following tags</h4>"; print_r($losetags); echo "<br/><br/>"; } foreach ($losetags as $cur_tag) { //Build update query $query = "UPDATE {$post_table} SET tags = REPLACE(tags, '{$cur_tag} ', '') WHERE tags LIKE '% {$cur_tag} %'"; if ($all_posts) { $query .= ";";