Ejemplo n.º 1
0
     $query = "SELECT COUNT(*) FROM {$note_table} WHERE post_id='{$id}' AND id='{$note_id}'";
     $result = $db->query($query);
     $row = $result->fetch_assoc();
     if ($row['COUNT(*)'] == 1) {
         $result->free_result();
         $query = "DELETE FROM {$note_table} WHERE post_id='{$id}' AND id='{$note_id}'";
         $db->query($query);
         $query = "DELETE FROM {$note_history_table} WHERE post_id='{$id}' AND id='{$note_id}'";
         $db->query($query);
         $cache->destroy("cache/" . $id . "/post.cache");
         print $note_id;
     }
 } else {
     if (isset($_GET['removepost']) && $_GET['removepost'] == 1) {
         $image = new image();
         if ($image->removeimage($id) == true) {
             $cache->destroy_page_cache("cache/" . $id);
             $query = "SELECT id FROM {$post_table} WHERE id < {$id} ORDER BY id DESC LIMIT 1";
             $result = $db->query($query);
             $row = $result->fetch_assoc();
             $prev_id = $row['id'];
             $result->free_result();
             $query = "SELECT id FROM {$post_table} WHERE id > {$id} ORDER BY id ASC LIMIT 1";
             $result = $db->query($query);
             $row = $result->fetch_assoc();
             $next_id = $row['id'];
             $date = date("Ymd");
             if (is_dir("{$main_cache_dir}" . "" . "cache/" . $prev_id) && "{$main_cache_dir}" . "" . "cache/" . $prev_id != "{$main_cache_dir}" . "" . "cache/") {
                 $cache->destroy_page_cache("cache/" . $prev_id);
             }
             if (is_dir("{$main_cache_dir}" . "" . "cache/" . $next_id) && "{$main_cache_dir}" . "" . "cache/" . $next_id != "{$main_cache_dir}" . "" . "cache/") {
$sql_query = "SELECT id,tags,title from {$post_table} WHERE {$where_clause};";
if ($debug) {
    echo "<strong>SQL query:</strong><br/>{$sql_query}<br/><br/>";
}
if ($results = $db->query($sql_query)) {
    $tag_obj = new tag();
    $user = new user();
    $cache = new cache();
    $image = new image();
    echo "Query returned " . $results->num_rows . " rows<br/>";
    $post = $results->fetch_assoc();
    while (!is_null($post)) {
        if ($debug || isset($_GET['display_ids'])) {
            echo "ID: '" . $post['id'] . "' Title: '" . $post['title'] . "'<br/>&nbsp;&nbsp;&nbsp;&nbsp;Tags: " . $post['tags'] . "<br/><br/>";
        } else {
            if ($image->removeimage($post['id']) == true) {
                $delete_count++;
                echo "<span style=\"color: rgb(0, 255, 0);\">Image " . $post['id'] . " successfully deleted!</span><br/>";
                //copied the rest from remove.php
                $cache->destroy_page_cache("cache/" . $post['id']);
                $query = "SELECT id FROM {$post_table} WHERE id < " . $post['id'] . " ORDER BY id DESC LIMIT 1";
                if ($result = $db->query($query)) {
                    $row = $result->fetch_assoc();
                    $prev_id = $row['id'];
                    $result->free_result();
                } else {
                    echo "<strong>No previous ID, Cannot remove image from cache!</strong><br/>\r\n\t\t\t\t\t\tHere's the query: {$query}<br/>\r\n\t\t\t\t\t\tand here's the error(" . $db->errno . "): " . $db->error . "<br/><br/>";
                    $post = $results->fetch_assoc();
                    continue;
                }
                $query = "SELECT id FROM {$post_table} WHERE id > " . $post['id'] . " ORDER BY id ASC LIMIT 1";