Пример #1
0
/**
 * Delete a download.
 *
 * @param  AUTO_LINK		The ID of the download to delete
 * @param  boolean		Whether to leave the actual file behind
 */
function delete_download($id, $leave = false)
{
    $myrows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('name', 'description', 'comments'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $myrows)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $myrow = $myrows[0];
    log_it('DELETE_DOWNLOAD', strval($id), get_translated_text($myrow['name']));
    delete_lang($myrow['name']);
    delete_lang($myrow['description']);
    delete_lang($myrow['comments']);
    require_code('seo2');
    seo_meta_erase_storage('downloads_download', strval($id));
    if (!$leave) {
        require_code('files2');
        delete_upload('uploads/downloads', 'download_downloads', 'url', 'id', $id);
    }
    // Delete from database
    $GLOBALS['SITE_DB']->query_delete('download_downloads', array('id' => $id), '', 1);
    $GLOBALS['SITE_DB']->query_delete('download_logging', array('id' => $id));
    $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'downloads', 'rating_for_id' => $id));
    $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'downloads', 'trackback_for_id' => $id));
    $GLOBALS['SITE_DB']->query_update('download_downloads', array('out_mode_id' => NULL), array('out_mode_id' => $id), '', 1);
    if (addon_installed('galleries')) {
        // Delete gallery
        $name = 'download_' . strval($id);
        require_code('galleries2');
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'parent_id', array('name' => 'download_' . strval($id)));
        if (!is_null($test)) {
            delete_gallery($name);
        }
    }
    decache('main_recent_downloads');
    decache('main_top_downloads');
    decache('main_download_category');
    decache('main_download_tease');
}
Пример #2
0
/**
 * Delete a specified gallery.
 *
 * @param  ID_TEXT		The gallery codename
 */
function delete_gallery($name)
{
    if ($name == '') {
        warn_exit(do_lang_tempcode('NO_DELETE_ROOT'));
    }
    $rows = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('name' => $name), '', 1);
    if (!array_key_exists(0, $rows)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    require_code('files2');
    delete_upload('uploads/grepimages', 'galleries', 'rep_image', 'name', $name);
    delete_upload('uploads/watermarks', 'galleries', 'watermark_top_left', 'name', $name);
    delete_upload('uploads/watermarks', 'galleries', 'watermark_top_right', 'name', $name);
    delete_upload('uploads/watermarks', 'galleries', 'watermark_bottom_left', 'name', $name);
    delete_upload('uploads/watermarks', 'galleries', 'watermark_bottom_right', 'name', $name);
    log_it('DELETE_GALLERY', $name, get_translated_text($rows[0]['fullname']));
    delete_lang($rows[0]['fullname']);
    delete_lang($rows[0]['description']);
    delete_lang($rows[0]['teaser']);
    // Images and videos are deleted, because we are deleting the _gallery_, not just a category (nobody is going to be deleting galleries with the expectation of moving the image to a different one in bulk - unlike download categories, for example).
    if (function_exists('set_time_limit')) {
        @set_time_limit(0);
    }
    do {
        $images = $GLOBALS['SITE_DB']->query_select('images', array('id'), array('cat' => $name), '', 200);
        foreach ($images as $image) {
            delete_image($image['id'], false);
        }
    } while ($images != array());
    do {
        $videos = $GLOBALS['SITE_DB']->query_select('videos', array('id'), array('cat' => $name), '', 200);
        foreach ($videos as $video) {
            delete_video($video['id'], false);
        }
    } while ($images != array());
    //... but the subgalleries remain
    $GLOBALS['SITE_DB']->query_update('galleries', array('parent_id' => $rows[0]['parent_id']), array('parent_id' => $name));
    $GLOBALS['SITE_DB']->query_delete('galleries', array('name' => $name), '', 1);
    $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'images', 'rating_for_id' => $name));
    $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'videos', 'rating_for_id' => $name));
    require_code('seo2');
    seo_meta_erase_storage('gallery', $name);
    $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'galleries', 'category_name' => $name));
    $GLOBALS['SITE_DB']->query_delete('gsp', array('module_the_name' => 'galleries', 'category_name' => $name));
    decache('main_top_galleries');
    decache('main_recent_galleries');
    decache('main_root_galleries');
    decache('side_root_galleries');
}
Пример #3
0
/**
 * Delete a news entry.
 *
 * @param  AUTO_LINK		The ID of the news to edit
 */
function delete_news($id)
{
    $rows = $GLOBALS['SITE_DB']->query_select('news', array('title', 'news', 'news_article'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $rows)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $title = $rows[0]['title'];
    $news = $rows[0]['news'];
    $news_article = $rows[0]['news_article'];
    $_title = get_translated_text($title);
    log_it('DELETE_NEWS', strval($id), $_title);
    require_code('files2');
    delete_upload('uploads/grepimages', 'news', 'news_image', 'id', $id);
    $GLOBALS['SITE_DB']->query_delete('news', array('id' => $id), '', 1);
    $GLOBALS['SITE_DB']->query_delete('news_category_entries', array('news_entry' => $id));
    $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'news', 'rating_for_id' => $id));
    $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'news', 'trackback_for_id' => $id));
    delete_lang($title);
    delete_lang($news);
    require_code('attachments2');
    require_code('attachments3');
    if (!is_null($news_article)) {
        delete_lang_comcode_attachments($news_article, 'news', strval($id));
    }
    require_code('seo2');
    seo_meta_erase_storage('news', strval($id));
    decache('main_news');
    decache('side_news');
    decache('side_news_archive');
    decache('bottom_news');
}
Пример #4
0
 /**
  * The actualiser to delete a page.
  *
  * @return tempcode		The UI
  */
 function __delete()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/deletepage';
     $zone = post_param('zone', NULL);
     $afm_needed = false;
     $pages = find_all_pages_wrap($zone);
     foreach ($pages as $page => $type) {
         if (is_integer($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             if (get_file_base() != get_custom_file_base() && strpos($type, 'comcode_custom') !== false) {
                 warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
             }
             if ($type != 'comcode_custom') {
                 $afm_needed = true;
             }
         }
     }
     if ($afm_needed) {
         require_code('abstract_file_manager');
         force_have_afm_details();
     }
     foreach ($pages as $page => $type) {
         if (is_integer($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             if (substr($type, 0, 7) == 'modules') {
                 $_page = $page . '.php';
             } elseif (substr($type, 0, 7) == 'comcode') {
                 $_page = $page . '.txt';
             } elseif (substr($type, 0, 4) == 'html') {
                 $_page = $page . '.htm';
             }
             $GLOBALS['SITE_DB']->query_delete('menu_items', array('i_url' => $zone . ':' . $page));
             if (substr($type, 0, 7) == 'comcode' || substr($type, 0, 4) == 'html') {
                 $type_shortened = preg_replace('#/.+#', '', $type);
                 if (substr($type, 0, 7) == 'comcode' && get_option('store_revisions') == '1') {
                     $time = time();
                     $fullpath = zone_black_magic_filterer((strpos($type, 'comcode/') !== false ? get_file_base() : get_custom_file_base()) . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page);
                     $bs_path = zone_black_magic_filterer(str_replace('/comcode/', '/comcode_custom/', $fullpath) . '.' . strval($time));
                     @copy($fullpath, $bs_path) or intelligent_write_error($fullpath);
                     sync_file($bs_path);
                     fix_permissions($bs_path);
                 }
                 $langs = find_all_langs(true);
                 foreach (array_keys($langs) as $lang) {
                     $_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type_shortened) . '/' . $lang . '/' . $_page, true);
                     $path = (strpos($type, 'comcode/') !== false ? get_file_base() : get_custom_file_base()) . '/' . $_path;
                     if (file_exists($path)) {
                         if ($afm_needed) {
                             afm_delete_file($_path);
                         } else {
                             unlink(get_custom_file_base() . '/' . $_path);
                         }
                     }
                 }
                 if (substr($type, 0, 7) == 'comcode') {
                     require_code('attachments2');
                     require_code('attachments3');
                     delete_comcode_attachments('comcode_page', $zone . ':' . $page);
                     $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $page, 'the_zone' => $zone));
                     $GLOBALS['SITE_DB']->query_delete('comcode_pages', array('the_page' => $page, 'the_zone' => $zone));
                     persistant_cache_empty();
                     decache('main_comcode_page_children');
                     require_code('seo2');
                     seo_meta_erase_storage('comcode_page', $zone . ':' . $page);
                 }
             } else {
                 $_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true);
                 $path = (strpos($type, '_custom') === false ? get_file_base() : get_custom_file_base()) . '/' . $_path;
                 if (file_exists($path)) {
                     if ($afm_needed) {
                         afm_delete_file($_path);
                     } else {
                         unlink(get_custom_file_base() . '/' . $_path);
                     }
                 }
             }
             $GLOBALS['SITE_DB']->query_delete('https_pages', array('https_page_name' => $page), '', 1);
             log_it('DELETE_PAGES', $page);
         }
     }
     persistant_cache_empty();
     decache('main_sitemap');
     $title = get_page_title('DELETE_PAGES');
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PAGES')), array('_SELF:_SELF:delete', do_lang_tempcode('DELETE_PAGES'))));
     return $this->do_next_manager($title, NULL, $zone, new ocp_tempcode());
 }
Пример #5
0
/**
 * Delete a calendar event.
 *
 * @param  AUTO_LINK		The ID of the event
 */
function delete_calendar_event($id)
{
    $myrows = $GLOBALS['SITE_DB']->query_select('calendar_events', array('e_title', 'e_content'), array('id' => $id), '', 1);
    $myrow = $myrows[0];
    $e_title = get_translated_text($myrow['e_title']);
    $GLOBALS['SITE_DB']->query_delete('calendar_events', array('id' => $id), '', 1);
    $GLOBALS['SITE_DB']->query_delete('calendar_jobs', array('j_event_id' => $id));
    $GLOBALS['SITE_DB']->query_delete('calendar_reminders', array('e_id' => $id));
    require_code('seo2');
    seo_meta_erase_storage('event', strval($id));
    $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'events', 'rating_for_id' => $id));
    $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'events', 'trackback_for_id' => $id));
    delete_lang($myrow['e_title']);
    require_code('attachments2');
    require_code('attachments3');
    if (!is_null($myrow['e_content'])) {
        delete_lang_comcode_attachments($myrow['e_content'], 'e_content', strval($id));
    }
    decache('side_calendar');
    log_it('DELETE_CALENDAR_EVENT', strval($id), $e_title);
}
Пример #6
0
/**
 * Delete a quiz.
 *
 * @param  AUTO_LINK		The ID
 */
function delete_quiz($id)
{
    $rows = $GLOBALS['SITE_DB']->query_select('quizzes', array('*'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $rows)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $_name = $rows[0]['q_name'];
    $_start_text = $rows[0]['q_start_text'];
    $_end_text = $rows[0]['q_end_text'];
    $_end_text_fail = $rows[0]['q_end_text_fail'];
    $name = get_translated_text($_name);
    delete_lang($_name);
    delete_lang($_start_text);
    delete_lang($_end_text);
    delete_lang($_end_text_fail);
    require_code('seo2');
    seo_meta_erase_storage('quiz', strval($id));
    $GLOBALS['SITE_DB']->query_delete('quizzes', array('id' => $id), '', 1);
    $GLOBALS['SITE_DB']->query_delete('quiz_winner', array('q_quiz' => $id));
    $questions = $GLOBALS['SITE_DB']->query_select('quiz_questions', array('*'), array('q_quiz' => $id));
    foreach ($questions as $question) {
        delete_lang($question['q_question_text']);
        $answers = $GLOBALS['SITE_DB']->query_select('quiz_question_answers', array('*'), array('q_question' => $question['id']));
        foreach ($answers as $answer) {
            delete_lang($answer['q_answer_text']);
            delete_lang($answer['q_explanation']);
        }
        $GLOBALS['SITE_DB']->query_delete('quiz_entry_answer', array('q_question' => $question['id']));
        $GLOBALS['SITE_DB']->query_delete('quiz_question_answers', array('q_question' => $question['id']));
    }
    $GLOBALS['SITE_DB']->query_delete('quiz_questions', array('q_quiz' => $id));
    $GLOBALS['SITE_DB']->query_delete('quiz_entries', array('q_quiz' => $id));
    log_it('DELETE_QUIZ', strval($id), $name);
}
Пример #7
0
/**
 * Delete a catalogue entry.
 *
 * @param  AUTO_LINK		The ID of the entry to delete
 */
function actual_delete_catalogue_entry($id)
{
    $old_category_id = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'cc_id', array('id' => $id));
    $catalogue_name = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'c_name', array('id' => $id));
    require_code('fields');
    require_code('catalogues');
    $fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $catalogue_name));
    $title = NULL;
    foreach ($fields as $field) {
        $object = get_fields_hook($field['cf_type']);
        list(, , $storage_type) = $object->get_field_value_row_bits($field);
        $value = _get_catalogue_entry_field($field['id'], $id, $storage_type);
        if (method_exists($object, 'cleanup')) {
            $object->cleanup($value);
        }
        if (is_null($title)) {
            if ($storage_type == 'long_trans' || $storage_type == 'short_trans') {
                $title = get_translated_text(intval($value));
            } else {
                $title = $value;
            }
        }
    }
    $lang1 = $GLOBALS['SITE_DB']->query_select('catalogue_efv_long_trans', array('cv_value'), array('ce_id' => $id));
    $lang2 = $GLOBALS['SITE_DB']->query_select('catalogue_efv_short_trans', array('cv_value'), array('ce_id' => $id));
    $lang = array_merge($lang1, $lang2);
    foreach ($lang as $lang_to_delete) {
        if (true) {
            require_code('attachments2');
            require_code('attachments3');
            delete_lang_comcode_attachments($lang_to_delete['cv_value'], 'catalogue_entry', strval($id));
        } else {
            delete_lang($lang_to_delete['cv_value']);
        }
    }
    $GLOBALS['SITE_DB']->query_delete('catalogue_efv_long_trans', array('ce_id' => $id));
    $GLOBALS['SITE_DB']->query_delete('catalogue_efv_short_trans', array('ce_id' => $id));
    $GLOBALS['SITE_DB']->query_delete('catalogue_efv_long', array('ce_id' => $id));
    $GLOBALS['SITE_DB']->query_delete('catalogue_efv_short', array('ce_id' => $id));
    $GLOBALS['SITE_DB']->query_delete('catalogue_efv_float', array('ce_id' => $id));
    $GLOBALS['SITE_DB']->query_delete('catalogue_efv_integer', array('ce_id' => $id));
    $GLOBALS['SITE_DB']->query_delete('catalogue_entries', array('id' => $id), '', 1);
    $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'catalogues', 'trackback_for_id' => $id));
    $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'catalogues', 'rating_for_id' => $id));
    require_code('seo2');
    seo_meta_erase_storage('catalogue_entry', strval($id));
    calculate_category_child_count_cache($old_category_id);
    decache('main_recent_cc_entries');
    decache('main_cc_embed');
    if ($catalogue_name[0] != '_') {
        log_it('DELETE_CATALOGUE_ENTRY', strval($id), $title);
    }
}