Пример #1
0
if (isset($_GET['tag']) && $_GET['tag'] != "" && isset($_GET['alias']) && $_GET['alias'] != "") {
    if (isset($_POST['accept']) && is_numeric($_POST['accept'])) {
        $tag = $db->real_escape_string($_GET['tag']);
        $alias = $db->real_escape_string($_GET['alias']);
        if ($_POST['accept'] == 1) {
            $tagc = new tag();
            //tag boot, alias boots singular is better.
            $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}'";
Пример #2
0
     $tmp_arr[] = $row['tag'];
 }
 $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);
Пример #3
0
}
if (substr($tags, -1, 1) != " ") {
    $tags = "{$tags} ";
}
$parent = '';
$query = "SELECT tags FROM {$post_table} WHERE id='{$id}'";
$result = $db->query($query);
$row = $result->fetch_assoc();
if ($tags != $row['tags']) {
    $cache = new cache();
    $tclass = new tag();
    $mtags = explode(" ", $row['tags']);
    $misc = new misc();
    foreach ($mtags as $current) {
        if ($current != "") {
            $tclass->deleteindextag($current);
            if (is_dir("{$main_cache_dir}" . "" . "search_cache/" . $current . "/")) {
                $cache->destroy_page_cache("search_cache/" . $current . "/");
            } else {
                if (is_dir("{$main_cache_dir}" . "" . "search_cache/" . $misc->windows_filename_fix($current) . "/")) {
                    $cache->destroy_page_cache("search_cache/" . $misc->windows_filename_fix($current) . "/");
                }
            }
        }
    }
    foreach ($ttags as $current) {
        if ($misc->is_html(html_entity_decode($current, ENT_QUOTES, 'UTF-8'))) {
            header('Location: ../index.php');
            exit;
        }
        if (strpos($current, 'parent:') !== false) {
Пример #4
0
 function removeimage($id)
 {
     global $db, $post_table, $note_table, $note_history_table, $user_table, $group_table, $favorites_table, $favorites_count_table, $comment_table, $comment_vote_table, $deleted_image_table;
     $can_delete = false;
     $id = $db->real_escape_string($id);
     $query = "SELECT directory, image, owner, tags, hash FROM {$post_table} WHERE id='{$id}'";
     $result = $db->query($query);
     $row = $result->fetch_assoc();
     $image = $row['image'];
     $dir = $row['directory'];
     $owner = $row['owner'];
     $tags = $row['tags'];
     $hash = $row['hash'];
     if (isset($_COOKIE['user_id']) && is_numeric($_COOKIE['user_id']) && isset($_COOKIE['pass_hash'])) {
         $user_id = $db->real_escape_string($_COOKIE['user_id']);
         $pass_hash = $db->real_escape_string($_COOKIE['pass_hash']);
         $query = "SELECT user FROM {$user_table} WHERE id='{$user_id}' AND pass='******'";
         $result = $db->query($query);
         $row = $result->fetch_assoc();
         $user = $row['user'];
         $query = "SELECT t2.delete_posts FROM {$user_table} AS t1 JOIN {$group_table} AS t2 ON t2.id=t1.ugroup WHERE t1.id='{$user_id}' AND t1.pass='******'";
         $result = $db->query($query);
         $row = $result->fetch_assoc();
         if (strtolower($user) == strtolower($owner) && $user != "Anonymous" || $row['delete_posts'] == true) {
             $can_delete = true;
         }
     }
     if ($can_delete == true) {
         $cache = new cache();
         $query = "SELECT parent FROM {$post_table} WHERE id='{$id}'";
         $result = $db->query($query);
         $row = $result->fetch_assoc();
         if ($row['parent'] != "" && $row['parent'] != 0) {
             $cache->destroy("../cache/" . $row['parent'] . "/post.cache");
         }
         $query = "DELETE FROM {$post_table} WHERE id='{$id}'";
         $db->query($query);
         $query = "DELETE FROM {$note_table} WHERE post_id='{$id}'";
         $db->query($query);
         $query = "DELETE FROM {$note_history_table} WHERE post_id='{$id}'";
         $db->query($query);
         $query = "DELETE FROM {$comment_table} WHERE post_id='{$id}'";
         $db->query($query);
         $query = "DELETE FROM {$comment_vote_table} WHERE post_id='{$id}'";
         $db->query($query);
         $query = "SELECT user_id FROM {$favorites_table} WHERE favorite='{$id}' ORDER BY user_id";
         $result = $db->query($query);
         while ($row = $result->fetch_assoc()) {
             $ret = "UPDATE {$favorites_count_table} SET fcount=fcount-1 WHERE user_id='" . $row['user_id'] . "'";
             $db->query($ret);
         }
         $query = "DELETE FROM {$favorites_table} WHERE favorite='{$id}'";
         $db->query($query);
         $query = "DELETE FROM {$parent_child_table} WHERE parent='{$id}'";
         $db->query($query);
         $query = "SELECT id FROM {$post_table} WHERE parent='{$id}'";
         $result = $db->query($query);
         while ($row = $result->fetch_assoc()) {
             $cache->destroy("../cache/" . $id . "/post.cache");
         }
         $query = "UPDATE {$post_table} SET parent='' WHERE parent='{$id}'";
         $db->query($query);
         unlink("../images/" . $dir . "/" . $image);
         $thumb = explode($image);
         array_pop($thumb);
         $thumb = implode($thumb) . ".jpg";
         unlink("../thumbnails/" . $dir . "/thumbnail_" . $thumb);
         $this->folder_index_decrement($dir);
         $itag = new tag();
         $tags = explode(" ", $tags);
         $misc = new misc();
         foreach ($tags as $tag) {
             if ($tag != "") {
                 $itag->deleteindextag($tag);
                 if (is_dir("../search_cache/" . $misc->windows_filename_fix($tag) . "/")) {
                     $cache->destroy_page_cache("../search_cache/" . $misc->windows_filename_fix($tag) . "/");
                 }
             }
         }
         $query = "UPDATE {$post_count_table} SET last_update='20060101' WHERE access_key='posts'";
         $db->query($query);
         $query = "INSERT INTO {$deleted_image_table}(hash) VALUES('{$hash}')";
         $db->query($query);
         return true;
     }
     return false;
 }
Пример #5
0
             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 removed from " . $qt . " posts<br/><a href=\"index.php?page=tag_ops\">Go Back</a>";
             $tclass->deleteindextag($cur_tag, $qt);
         }
     }
 } else {
     if ($_GET['action'] == "replace") {
         $losetag = $db->real_escape_string(htmlentities($_GET['replace_tags'], ENT_QUOTES, 'UTF-8'));
         $newtag = $db->real_escape_string(htmlentities($_GET['new_tags'], ENT_QUOTES, 'UTF-8'));
         if (strstr($losetag, " ") != FALSE || strstr($newtag, " ") != FALSE) {
             echo "<strong>When replacing one tag with another, neither of the input fields can contain a space</strong><br/>";
             exit;
         }
         if ($debug) {
             echo "<strong>Replacing:</strong><br/>";
             print_r($losetag);
             echo "<br/><strong>With:</strong><br/>";
             print_r($newtag);