示例#1
0
/**
 * Edit a gallery.
 *
 * @param  ID_TEXT		The old gallery codename (in case we are renaming)
 * @param  ID_TEXT		The gallery codename (maybe the same as the old one)
 * @param  SHORT_TEXT	The full human-readeable name of the gallery
 * @param  LONG_TEXT		The description of the gallery
 * @param  SHORT_TEXT	Teaser text for the gallery
 * @param  LONG_TEXT		Hidden notes associated with the gallery
 * @param  ?ID_TEXT		The parent gallery (NULL: no parent)
 * @param  BINARY			Whether images may be put in this gallery
 * @param  BINARY			Whether videos may be put in this gallery
 * @param  BINARY			Whether the gallery serves as a container for automatically created member galleries
 * @param  BINARY			Whether the gallery uses the flow mode interface
 * @param  URLPATH		The representative image of the gallery (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  ?SHORT_TEXT	Meta keywords for this resource (NULL: do not edit)
 * @param  ?LONG_TEXT	Meta description for this resource (NULL: do not edit)
 * @param  BINARY			Whether rating are allowed
 * @param  BINARY			Whether comments are allowed
 * @param  ?MEMBER		The gallery owner (NULL: nobody)
 */
function edit_gallery($old_name, $name, $fullname, $description, $teaser, $notes, $parent_id = NULL, $accept_images = 1, $accept_videos = 1, $is_member_synched = 0, $flow_mode_interface = 0, $rep_image = '', $watermark_top_left = '', $watermark_top_right = '', $watermark_bottom_left = '', $watermark_bottom_right = '', $meta_keywords = NULL, $meta_description = NULL, $allow_rating = 1, $allow_comments = 1, $g_owner = NULL)
{
    require_code('urls2');
    suggest_new_idmoniker_for('galleries', 'misc', $name, $fullname);
    $under_category_id = $parent_id;
    while ($under_category_id != '' && $under_category_id != STRING_MAGIC_NULL) {
        if ($name == $under_category_id) {
            warn_exit(do_lang_tempcode('OWN_PARENT_ERROR'));
        }
        $under_category_id = $GLOBALS['SITE_DB']->query_value('galleries', 'parent_id', array('name' => $under_category_id));
    }
    if (is_null($parent_id)) {
        $parent_id = '';
    }
    require_code('seo2');
    if ($old_name != $name) {
        require_code('type_validation');
        if (!is_alphanumeric($name, true)) {
            warn_exit(do_lang_tempcode('BAD_CODENAME'));
        }
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $name));
        if (!is_null($test)) {
            warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($name)));
        }
        seo_meta_erase_storage('gallery', $old_name);
        $GLOBALS['SITE_DB']->query_update('images', array('cat' => $name), array('cat' => $old_name));
        $GLOBALS['SITE_DB']->query_update('videos', array('cat' => $name), array('cat' => $old_name));
        $GLOBALS['SITE_DB']->query_update('galleries', array('parent_id' => $name), array('parent_id' => $old_name));
        if (addon_installed('awards')) {
            $types = $GLOBALS['SITE_DB']->query_select('award_types', array('id'), array('a_content_type' => 'gallery'));
            foreach ($types as $type) {
                $GLOBALS['SITE_DB']->query_update('award_archive', array('content_id' => $name), array('content_id' => $old_name, 'a_type_id' => $type['id']));
            }
        }
    }
    if (!is_null($meta_keywords)) {
        seo_meta_set_for_explicit('gallery', $name, $meta_keywords, $meta_description);
    }
    $myrows = $GLOBALS['SITE_DB']->query_select('galleries', array('fullname', 'description', 'teaser'), array('name' => $old_name), '', 1);
    if (!array_key_exists(0, $myrows)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $myrow = $myrows[0];
    $map = array('name' => $name, 'notes' => $notes, 'fullname' => lang_remap($myrow['fullname'], $fullname), 'description' => lang_remap_comcode($myrow['description'], $description), 'teaser' => lang_remap_comcode($myrow['teaser'], $teaser), 'parent_id' => $parent_id, 'accept_images' => $accept_images, 'accept_videos' => $accept_videos, 'is_member_synched' => $is_member_synched, 'flow_mode_interface' => $flow_mode_interface, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'g_owner' => $g_owner);
    require_code('files2');
    if (!is_null($rep_image)) {
        $map['rep_image'] = $rep_image;
        delete_upload('uploads/grepimages', 'galleries', 'rep_image', 'name', $old_name, $rep_image);
    }
    if (!is_null($watermark_top_left)) {
        $map['watermark_top_left'] = $watermark_top_left;
        delete_upload('uploads/watermarks', 'galleries', 'watermark_top_left', 'name', $old_name, $watermark_top_left);
    }
    if (!is_null($watermark_top_right)) {
        $map['watermark_top_right'] = $watermark_top_right;
        delete_upload('uploads/watermarks', 'galleries', 'watermark_top_right', 'name', $old_name, $watermark_top_right);
    }
    if (!is_null($watermark_bottom_left)) {
        $map['watermark_bottom_left'] = $watermark_bottom_left;
        delete_upload('uploads/watermarks', 'galleries', 'watermark_bottom_left', 'name', $old_name, $watermark_bottom_left);
    }
    if (!is_null($watermark_bottom_right)) {
        $map['watermark_bottom_right'] = $watermark_bottom_right;
        delete_upload('uploads/watermarks', 'galleries', 'watermark_bottom_right', 'name', $old_name, $watermark_bottom_right);
    }
    $GLOBALS['SITE_DB']->query_update('galleries', $map, array('name' => $old_name), '', 1);
    log_it('EDIT_GALLERY', $name, $fullname);
    $GLOBALS['SITE_DB']->query_update('group_category_access', array('category_name' => $name), array('module_the_name' => 'galleries', 'category_name' => $old_name));
    decache('main_top_galleries');
    decache('main_recent_galleries');
    decache('main_root_galleries');
    decache('side_root_galleries');
    require_code('feedback');
    update_spacer_post($allow_comments != 0, 'galleries', $name, build_url(array('page' => 'galleries', 'type' => 'misc', 'id' => $name), get_module_zone('galleries'), NULL, false, false, true), $fullname, get_value('comment_forum__galleries'));
}
示例#2
0
/**
 * Edit a CEDI page
 *
 * @param  AUTO_LINK		The page ID
 * @param  SHORT_TEXT	The page title
 * @param  LONG_TEXT		The page description
 * @param  LONG_TEXT		Hidden notes pertaining to the page
 * @param  BINARY			Whether to hide the posts on the page by default
 * @param  SHORT_TEXT	Meta keywords
 * @param  LONG_TEXT		Meta description
 * @param  ?MEMBER		The member doing the action (NULL: current member)
 */
function cedi_edit_page($id, $title, $description, $notes, $hide_posts, $meta_keywords, $meta_description, $member = NULL)
{
    if (is_null($member)) {
        $member = get_member();
    }
    $pages = $GLOBALS['SITE_DB']->query_select('seedy_pages', array('*'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $pages)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $page = $pages[0];
    $_description = $page['description'];
    $_title = $page['title'];
    $GLOBALS['SITE_DB']->query_update('seedy_children', array('title' => $title), array('title' => get_translated_text($_title), 'child_id' => $id));
    require_code('attachments2');
    require_code('attachments3');
    $GLOBALS['SITE_DB']->query_update('seedy_pages', array('hide_posts' => $hide_posts, 'description' => update_lang_comcode_attachments($_description, $description, 'cedi_page', strval($id), NULL, true), 'notes' => $notes, 'title' => lang_remap($_title, $title)), array('id' => $id), '', 1);
    $GLOBALS['SITE_DB']->query_insert('seedy_changes', array('the_action' => 'CEDI_EDIT_PAGE', 'the_page' => $id, 'date_and_time' => time(), 'ip' => get_ip_address(), 'the_user' => $member));
    require_code('seo2');
    seo_meta_set_for_explicit('seedy_page', strval($id), $meta_keywords, $meta_description);
    dispatch_cedi_page_notification($id, 'EDIT');
}
示例#3
0
/**
 * Edit a download.
 *
 * @param  AUTO_LINK			The ID of the download to edit
 * @param  AUTO_LINK			The ID of the category the download is to be in
 * @param  SHORT_TEXT		The name of the download
 * @param  URLPATH			The URL to the download
 * @param  LONG_TEXT			The description of the download
 * @param  ID_TEXT			The author of the download (not necessarily same as the submitter)
 * @param  LONG_TEXT			The comments for the download
 * @param  AUTO_LINK			The out-mode-id (the ID of a download that this download is an old version of). Often people wonder why this is specified with the old version, and not the opposite with the new version - it is because statistically, we perceive more chance of downloads merging than splitting
 * @param  integer			The ordered number of the gallery image to use as the download representative image
 * @param  BINARY				Whether the download has been validated
 * @param  BINARY				Whether the download may be rated
 * @param  SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style)
 * @param  BINARY				Whether the download may be trackbacked
 * @param  LONG_TEXT			Hidden notes pertaining to the download
 * @param  SHORT_TEXT		The downloads original filename (the URL may be obfuscated)
 * @param  integer			The file size of the download (we can't really detect this in real-time for remote URLs)
 * @param  integer			The cost of the download that members will have to pay to get it
 * @param  BINARY				Whether the submitter gets the points for the download (they are selling it) (otherwise they are just thrown out, which is an alternative model - one of enforcing community point building)
 * @param  ?AUTO_LINK		The licence to use (NULL: none)
 * @param  SHORT_TEXT		Meta keywords
 * @param  LONG_TEXT			Meta description
 */
function edit_download($id, $category_id, $name, $url, $description, $author, $comments, $out_mode_id, $default_pic, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $original_filename, $file_size, $cost, $submitter_gets_points, $licence, $meta_keywords, $meta_description)
{
    require_code('urls2');
    suggest_new_idmoniker_for('downloads', 'view', strval($id), $name);
    if ($file_size == 0 || url_is_local($url)) {
        if (url_is_local($url)) {
            $file_size = filesize(get_custom_file_base() . '/' . rawurldecode($url));
        } else {
            $file_size = @filesize($url) or $file_size = NULL;
        }
    }
    $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];
    require_code('seo2');
    seo_meta_set_for_explicit('downloads_download', strval($id), $meta_keywords, $meta_description);
    require_code('files2');
    delete_upload('uploads/downloads', 'download_downloads', 'url', 'id', $id, $url);
    $met = @ini_get('max_execution_time');
    $data_mash = create_data_mash($url, NULL, get_file_extension($original_filename));
    if (function_exists('set_time_limit')) {
        @set_time_limit($met);
    }
    if (!addon_installed('unvalidated')) {
        $validated = 1;
    }
    require_code('submit');
    $just_validated = !content_validated('download', strval($id)) && $validated == 1;
    if ($just_validated) {
        send_content_validated_notification('download', strval($id));
    }
    $map = array('download_data_mash' => $data_mash, 'download_licence' => $licence, 'original_filename' => $original_filename, 'download_submitter_gets_points' => $submitter_gets_points, 'download_cost' => $cost, 'edit_date' => time(), 'file_size' => $file_size, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'name' => lang_remap($myrow['name'], $name), 'description' => lang_remap_comcode($myrow['description'], $description), 'comments' => lang_remap_comcode($myrow['comments'], $comments), 'validated' => $validated, 'category_id' => $category_id, 'url' => $url, 'author' => $author, 'default_pic' => $default_pic, 'out_mode_id' => $out_mode_id);
    $GLOBALS['SITE_DB']->query_update('download_downloads', $map, array('id' => $id), '', 1);
    $self_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $id), get_module_zone('downloads'), NULL, false, false, true);
    if ($just_validated) {
        require_lang('downloads');
        require_code('notifications');
        $subject = do_lang('DOWNLOAD_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $name);
        $mail = do_lang('DOWNLOAD_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($name), array(comcode_escape($self_url->evaluate())));
        dispatch_notification('download', strval($category_id), $subject, $mail);
    }
    log_it('EDIT_DOWNLOAD', strval($id), get_translated_text($myrow['name']));
    if (addon_installed('galleries')) {
        // Change its gallery
        require_code('galleries2');
        $download_gallery_root = get_option('download_gallery_root');
        if (is_null($download_gallery_root)) {
            $download_gallery_root = 'root';
        }
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'parent_id', array('name' => 'download_' . strval($id)));
        if (!is_null($test)) {
            edit_gallery('download_' . strval($id), 'download_' . strval($id), do_lang('GALLERY_FOR_DOWNLOAD', $name), '', '', '', $download_gallery_root);
        }
    }
    decache('main_recent_downloads');
    decache('main_top_downloads');
    decache('main_download_category');
    decache('main_download_tease');
    require_code('feedback');
    update_spacer_post($allow_comments != 0, 'downloads', strval($id), $self_url, $name, get_value('comment_forum__downloads'));
}
示例#4
0
/**
 * Import wordpress db
 */
function import_wordpress_db()
{
    disable_php_memory_limit();
    $data = get_wordpress_data();
    $is_validated = post_param_integer('wp_auto_validate', 0);
    $to_own_account = post_param_integer('wp_add_to_own', 0);
    // Create members
    require_code('ocf_members_action');
    require_code('ocf_groups');
    $def_grp_id = get_first_default_group();
    $cat_id = array();
    $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
    $NEWS_CATS = list_to_map('id', $NEWS_CATS);
    foreach ($data as $values) {
        if (get_forum_type() == 'ocf') {
            $member_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'id', array('m_username' => $values['user_login']));
            if (is_null($member_id)) {
                if (post_param_integer('wp_import_wordpress_users', 0) == 1) {
                    $member_id = ocf_make_member($values['user_login'], $values['user_pass'], '', NULL, NULL, NULL, NULL, array(), NULL, $def_grp_id, 1, time(), time(), '', NULL, '', 0, 0, 1, '', '', '', 1, 0, '', 1, 1, '', NULL, '', false, 'wordpress');
                } else {
                    $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username('admin');
                    // Set admin as owner
                    if (is_null($member_id)) {
                        $member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id() + 1;
                    }
                }
            }
        } else {
            $member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id();
        }
        // Guest user
        // If post should go to own account
        if ($to_own_account == 1) {
            $member_id = get_member();
        }
        if (array_key_exists('POSTS', $values)) {
            // Create posts in blog
            foreach ($values['POSTS'] as $post_id => $post) {
                if (array_key_exists('category', $post)) {
                    $cat_id = array();
                    foreach ($post['category'] as $cat_code => $category) {
                        $cat_code = NULL;
                        if ($category == 'Uncategorized') {
                            continue;
                        }
                        // Skip blank category creation
                        foreach ($NEWS_CATS as $id => $existing_cat) {
                            if (get_translated_text($existing_cat['nc_title']) == $category) {
                                $cat_code = $id;
                            }
                        }
                        if (is_null($cat_code)) {
                            $cat_code = add_news_category($category, 'newscats/community', $category);
                            $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'));
                            $NEWS_CATS = list_to_map('id', $NEWS_CATS);
                        }
                        $cat_id = array_merge($cat_id, array($cat_code));
                    }
                }
                $owner_category_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $member_id));
                if ($post['post_type'] == 'post') {
                    $id = add_news($post['post_title'], html_to_comcode($post['post_content']), NULL, $is_validated, 1, $post['comment_status'] == 'closed' ? 0 : 1, 1, '', html_to_comcode($post['post_content']), $owner_category_id, $cat_id, NULL, $member_id, 0, time(), NULL, '');
                } elseif ($post['post_type'] == 'page') {
                    // If dont have permission to write comcode page, skip the post
                    if (!has_submit_permission('high', get_member(), get_ip_address(), NULL, NULL)) {
                        continue;
                    }
                    require_code('comcode');
                    // Save articles as new comcode pages
                    $zone = filter_naughty(post_param('zone', 'site'));
                    $lang = filter_naughty(post_param('lang', 'EN'));
                    $file = preg_replace('/[^A-Za-z0-9]/', '_', $post['post_title']);
                    // Filter non alphanumeric charactors
                    $parent_page = post_param('parent_page', '');
                    $fullpath = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang . '/' . $file . '.txt');
                    // Check existancy of new page
                    $submiter = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file));
                    if (!is_null($submiter)) {
                        continue;
                    }
                    // Skip existing titled articles	- may need change
                    require_code('submit');
                    give_submit_points('COMCODE_PAGE_ADD');
                    if (!addon_installed('unvalidated')) {
                        $is_validated = 1;
                    }
                    $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => $zone, 'the_page' => $file, 'p_parent_page' => $parent_page, 'p_validated' => $is_validated, 'p_edit_date' => NULL, 'p_add_date' => strtotime($post['post_date']), 'p_submitter' => $member_id, 'p_show_as_edit' => 0));
                    if (!file_exists($fullpath)) {
                        $_content = html_to_comcode($post['post_content']);
                        $myfile = @fopen($fullpath, 'wt');
                        if ($myfile === false) {
                            intelligent_write_error($fullpath);
                        }
                        if (fwrite($myfile, $_content) < strlen($_content)) {
                            warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                        }
                        fclose($myfile);
                        sync_file($fullpath);
                    }
                    require_code('seo2');
                    seo_meta_set_for_explicit('comcode_page', $zone . ':' . $file, post_param('meta_keywords', ''), post_param('meta_description', ''));
                    require_code('permissions2');
                    set_page_permissions_from_environment($zone, $file);
                }
                $content_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $id), get_module_zone('news'), NULL, false, false, true);
                $content_title = $post['post_title'];
                // Add comments
                if (post_param_integer('wp_import_blog_comments', 0) == 1) {
                    if (array_key_exists('COMMENTS', $post)) {
                        $submitter = NULL;
                        foreach ($post['COMMENTS'] as $comment) {
                            $submitter = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'id', array('m_username' => $comment['comment_author']));
                            if (is_null($submitter)) {
                                $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                            }
                            // If comment is made by a non-member, assign comment to guest account
                            $forum = is_null(get_value('comment_forum__news')) ? get_option('comments_forum_name') : get_value('comment_forum__news');
                            $result = $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum, 'news_' . strval($id), $submitter, $post['post_title'], $comment['comment_content'], $content_title, do_lang('COMMENT'), $content_url, NULL, NULL, 1, 1, false);
                        }
                    }
                }
            }
        }
    }
}
示例#5
0
/**
 * Edit a news entry.
 *
 * @param  AUTO_LINK			The ID of the news to edit
 * @param  SHORT_TEXT		The news title
 * @param  LONG_TEXT			The news summary (or if not an article, the full news)
 * @param  ID_TEXT			The news author (possibly, a link to an existing author in the system, but does not need to be)
 * @param  BINARY				Whether the news has been validated
 * @param  BINARY				Whether the news may be rated
 * @param  SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style)
 * @param  BINARY				Whether the news may have trackbacks
 * @param  LONG_TEXT			Notes for the news
 * @param  LONG_TEXT			The news entry (blank means no entry)
 * @param  AUTO_LINK			The primary news category (NULL: personal)
 * @param  ?array				The IDs of the news categories that this is in (NULL: do not change)
 * @param  SHORT_TEXT		Meta keywords
 * @param  LONG_TEXT			Meta description
 * @param  ?URLPATH			URL to the image for the news entry (blank: use cat image) (NULL: don't delete existing)
 * @param  ?TIME				Recorded add time (NULL: leave alone)
 */
function edit_news($id, $title, $news, $author, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $news_article, $main_news_category, $news_category, $meta_keywords, $meta_description, $image, $time = NULL)
{
    $rows = $GLOBALS['SITE_DB']->query_select('news', array('title', 'news', 'news_article', 'submitter'), array('id' => $id), '', 1);
    $_title = $rows[0]['title'];
    $_news = $rows[0]['news'];
    $_news_article = $rows[0]['news_article'];
    require_code('urls2');
    suggest_new_idmoniker_for('news', 'view', strval($id), $title);
    require_code('attachments2');
    require_code('attachments3');
    if (!addon_installed('unvalidated')) {
        $validated = 1;
    }
    require_code('submit');
    $just_validated = !content_validated('news', strval($id)) && $validated == 1;
    if ($just_validated) {
        send_content_validated_notification('news', strval($id));
    }
    $map = array('news_category' => $main_news_category, 'news_article' => update_lang_comcode_attachments($_news_article, $news_article, 'news', strval($id), NULL, false, $rows[0]['submitter']), 'edit_date' => time(), 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'validated' => $validated, 'title' => lang_remap_comcode($_title, $title), 'news' => lang_remap_comcode($_news, $news), 'author' => $author);
    if (!is_null($time)) {
        $map['date_and_time'] = $time;
    }
    if (!is_null($image)) {
        $map['news_image'] = $image;
        require_code('files2');
        delete_upload('uploads/grepimages', 'news', 'news_image', 'id', $id, $image);
    }
    /*$news_categories=$news_category[0];
    	foreach ($news_category as $key=>$value)
    	{
    		if($key>0) $news_categories.=','.$value;
    	}*/
    if (!is_null($news_category)) {
        $GLOBALS['SITE_DB']->query_delete('news_category_entries', array('news_entry' => $id));
        foreach ($news_category as $value) {
            $GLOBALS['SITE_DB']->query_insert('news_category_entries', array('news_entry' => $id, 'news_entry_category' => $value));
        }
    }
    log_it('EDIT_NEWS', strval($id), $title);
    $GLOBALS['SITE_DB']->query_update('news', $map, array('id' => $id), '', 1);
    $self_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $id), get_module_zone('news'), NULL, false, false, true);
    if ($just_validated) {
        dispatch_news_notification($id, $title, $main_news_category);
    }
    require_code('seo2');
    seo_meta_set_for_explicit('news', strval($id), $meta_keywords, $meta_description);
    decache('main_news');
    decache('side_news');
    decache('side_news_archive');
    decache('bottom_news');
    if ($validated == 1 && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'news', strval($main_news_category))) {
        $_ping_url = str_replace('{url}', urlencode(get_base_url()), str_replace('{rss}', urlencode(find_script('backend')), str_replace('{title}', urlencode(get_site_name()), get_option('ping_url'))));
        $ping_urls = explode(',', $_ping_url);
        foreach ($ping_urls as $ping_url) {
            $ping_url = trim($ping_url);
            if ($ping_url != '') {
                http_download_file($ping_url, NULL, false);
            }
        }
    }
    require_code('feedback');
    update_spacer_post($allow_comments != 0, 'news', strval($id), $self_url, $title, get_value('comment_forum__news'));
}
示例#6
0
    /**
     * Standard import function.
     *
     * @param  object			The DB connection to import from
     * @param  string			The table prefix the target prefix is using
     * @param  PATH			The base directory we are importing from
     */
    function import_pages($db, $table_prefix, $file_base)
    {
        unset($db);
        unset($table_prefix);
        require_code('files2');
        $files = @get_directory_contents($file_base);
        $theme = either_param('theme');
        $convert_to_comcode = either_param_integer('convert_to_comcode', 0);
        $fix_html = either_param_integer('fix_html', 0);
        $base_url = either_param('base_url');
        if (substr($base_url, -1) == '/') {
            $base_url = substr($base_url, 0, strlen($base_url) - 1);
        }
        // Find all htm/html/php files
        $content_files = array();
        foreach ($files as $i => $file) {
            if (substr(strtolower($file), -4) == '.htm' || substr(strtolower($file), -5) == '.html' || substr(strtolower($file), -4) == '.php') {
                $content_files[] = $file;
                unset($files[$i]);
            }
        }
        if (count($content_files) == 0) {
            warn_exit(do_lang_tempcode('NO_PAGES_FOUND'));
        }
        // Discern new zones needed
        //  Note: files in directories in a deep path will be considered in a zone name changed so underscores replace slashes
        $new_zones = array();
        $current_zones = find_all_zones();
        foreach ($content_files as $file) {
            $zone = str_replace('/', '_', dirname($file));
            if ($zone == '.') {
                $zone = '';
            }
            if (!in_array($zone, $current_zones)) {
                $new_zones[] = $zone;
            }
        }
        $new_zones = array_unique($new_zones);
        // (Maybe AFM needed here - if zones have to be created, and possibly .htaccess changed to incorporate zone names in the redirects)
        if (count($new_zones) != 0) {
            require_code('abstract_file_manager');
            force_have_afm_details();
            $change_htaccess = get_option('htm_short_urls') == '1';
            $htaccess_path = get_file_base() . '/.htaccess';
            if ($change_htaccess && file_exists($htaccess_path) && is_writable_wrap($htaccess_path)) {
                $htaccess = file_get_contents($htaccess_path);
                $htaccess = preg_replace('#\\(site\\|forum\\|adminzone\\|cms\\|collaboration[^\\)]*#', '${0}|' . implode('|', $new_zones), $htaccess);
                $myfile = fopen($htaccess_path, 'wt');
                fwrite($myfile, $htaccess);
                fclose($myfile);
                fix_permissions($htaccess_path);
                sync_file($htaccess_path);
            }
            // Create new zones as needed (and set them to our chosen theme too)
            require_code('zones2');
            foreach ($new_zones as $zone) {
                actual_add_zone($zone, ucwords(str_replace('_', ' ', $zone)), 'start', '', $theme, 0, 0);
            }
        }
        // Discern cruft in htm/html via looking for best levenshtein to length ratio over a few pages; scan by tag, not by byte
        $compare_file_contents = array();
        shuffle($content_files);
        for ($i = 0; $i < min(2, count($content_files)); $i++) {
            $file_contents = file_get_contents($file_base . '/' . $content_files[$i]);
            $compare_file_contents[$content_files[$i]] = $this->_html_filter($file_contents, $fix_html, $base_url, $files, $file_base);
        }
        $cruft = array();
        if (count($compare_file_contents) > 1) {
            $to_find = array();
            if (file_exists($file_base . '/header.txt')) {
                $cruft['HEADER'] = $this->_html_filter(file_get_contents($file_base . '/header.txt'), $fix_html, $base_url, $files, $file_base);
            } else {
                $to_find[] = 'HEADER';
            }
            if (file_exists($file_base . '/footer.txt')) {
                $cruft['FOOTER'] = $this->_html_filter(file_get_contents($file_base . '/footer.txt'), $fix_html, $base_url, $files, $file_base);
            } else {
                $to_find[] = 'FOOTER';
            }
            foreach ($to_find as $template_wanted) {
                $best_ratios = array();
                foreach ($compare_file_contents as $i => $reference_file) {
                    if ($template_wanted == 'HEADER') {
                        $last_pos = strpos($reference_file, '<body');
                        if ($last_pos === false) {
                            $last_pos = 0;
                        } else {
                            $last_pos += 5;
                        }
                    } else {
                        $last_pos = strlen($reference_file) - 1;
                    }
                    $best_av_ratios = mixed();
                    $ratios = array();
                    while ($last_pos !== false) {
                        //@print('!'.(strlen($reference_file)-$last_pos).' '.$lv.' '.$ratio.'<br />'.chr(10));flush();if (@$dd++==180) @exit('fini'); // Useful for debugging
                        if ($template_wanted == 'HEADER') {
                            $next_pos = strpos($reference_file, '<', $last_pos);
                        } else {
                            $next_pos = strrpos(substr($reference_file, 0, $last_pos), '<');
                        }
                        if ($next_pos !== false) {
                            if ($template_wanted == 'HEADER') {
                                $up_to = substr($reference_file, 0, $next_pos);
                            } else {
                                $up_to = substr($reference_file, $next_pos);
                            }
                            $all_ratios_for_pos = array();
                            foreach ($compare_file_contents as $j => $other_file) {
                                if ($i != $j) {
                                    if ($template_wanted == 'HEADER') {
                                        $up_to_other_file = substr($other_file, 0, $next_pos);
                                    } else {
                                        $up_to_other_file = substr($other_file, $next_pos - (strlen($reference_file) - strlen($other_file)));
                                    }
                                    $lv = fake_levenshtein($up_to, $up_to_other_file);
                                    if ($template_wanted == 'HEADER') {
                                        $ratio = floatval($lv) * 3 - floatval($next_pos + 1);
                                        // We want this number to be as small as possible. We have multiplied the levenshtein distance because we care about that more than length (this number reached by experimentation); HTML has a low entropy which this number is fighting against.
                                    } else {
                                        $ratio = floatval($lv) * 3 - floatval(strlen($reference_file) - $next_pos);
                                        // We want this number to be as small as possible. We have multiplied the levenshtein distance because we care about that more than length (this number reached by experimentation); HTML has a low entropy which this number is fighting against.
                                    }
                                    $all_ratios_for_pos[] = $ratio;
                                }
                            }
                            $av_ratios = array_sum($all_ratios_for_pos) / floatval(count($all_ratios_for_pos));
                            if (is_null($best_av_ratios) || $av_ratios < $best_av_ratios) {
                                $best_av_ratios = $av_ratios;
                            } elseif ($av_ratios > $best_av_ratios + 300) {
                                break;
                            }
                            $ratios[$next_pos] = $av_ratios;
                            if ($template_wanted == 'HEADER') {
                                $next_pos++;
                            } else {
                                $next_pos--;
                            }
                        }
                        $last_pos = $next_pos;
                    }
                    asort($ratios);
                    $best_by_pos = array_keys($ratios);
                    $best_ratios[] = array($best_by_pos[0], $ratios[$best_by_pos[0]], $reference_file);
                }
                $best = mixed();
                $best_pos = NULL;
                $best_reference_file = NULL;
                foreach ($best_ratios as $bits) {
                    list($pos, $ratio, $reference_file) = $bits;
                    if (is_null($best) || $ratio < $best) {
                        $best = $ratio;
                        $best_pos = $pos;
                        $best_reference_file = $reference_file;
                    }
                }
                if ($template_wanted == 'HEADER') {
                    $cruft[$template_wanted] = substr($best_reference_file, 0, $best_pos);
                } else {
                    $cruft[$template_wanted] = substr($best_reference_file, $best_pos);
                }
            }
        } else {
            // We can't find any common consistency when we only have one, so we mark all cruft and then later we will actually assume GLOBAL.tpl does not change and the only header/footer bit is the logical one
            $cruft['HEADER'] = array_key_exists(0, $compare_file_contents) ? $compare_file_contents[0] : '';
            $cruft['FOOTER'] = array_key_exists(1, $compare_file_contents) ? $compare_file_contents[0] : '';
        }
        // Extract header from cruft (<body> and before); SAVE
        $header = $cruft['HEADER'];
        // special cases of something with ID or class of header/top going through too
        $header_cases = array('<div id="header"', '<div id="page_header"', '<div class="header"', '<div class="page_header"');
        foreach ($header_cases as $header_case) {
            $header_start_pos = strpos($header, $header_case);
            if ($header_start_pos !== false) {
                $header_start_pos = strpos($header, '>', $header_start_pos) + 1;
                break;
            }
        }
        if ($header_start_pos !== false) {
            $div_count = 1;
            do {
                $next_start = strpos($header, '<div ', $header_start_pos);
                $next_end = strpos($header, '</div>', $header_start_pos);
                $header_start_pos = $next_start !== false && $next_start < $next_end ? $next_start : $next_end;
                if ($header_start_pos !== false) {
                    $header_start_pos = strpos($header, '>', $header_start_pos) + 1;
                }
                $div_count += $next_start !== false && $next_start < $next_end ? 1 : -1;
            } while ($div_count > 0 && $header_start_pos !== false);
        }
        $body_start_pos = strpos($header, '<body');
        $head_end_pos = strpos($header, '<link');
        if ($head_end_pos === false) {
            $head_end_pos = strpos($header, '</head');
        }
        if ($header_start_pos === false) {
            $header_start_pos = strpos($header, '>', $body_start_pos) + 1;
        }
        if ($header_start_pos !== false) {
            $header = substr($header, 0, $header_start_pos);
        }
        $path = get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/templates_custom/HEADER.tpl';
        $myfile = fopen($path, 'wt');
        $header_to_write = substr($header, 0, $head_end_pos) . '	<script type="text/javascript">// <![CDATA[
		{+START,IF,{$AND,{$EQ,,{$_GET,keep_has_js}},{$NOT,{$JS_ON}}}}
		if ((window.location.href.indexOf(\'upgrader.php\')==-1) && (window.location.search.indexOf(\'keep_has_js\')==-1)) {$,Redirect with JS on, and then hopefully we can remove keep_has_js after one click. This code only happens if JS is marked off, no infinite loops can happen.}
			window.location=window.location.href+((window.location.search==\'\')?(((window.location.href.indexOf(\'.htm\')==-1)&&(window.location.href.indexOf(\'.php\')==-1))?(((window.location.href.substr(window.location.href.length-1)!=\'/\')?\'/\':\'\')+\'index.php?\'):\'?\'):\'&\')+\'keep_has_js=1{+START,IF,{$DEV_MODE}}&keep_devtest=1{+END}\';
		{+END}
		{+START,IF,{$NOT,{$BROWSER_MATCHES,ie}}}{+START,IF,{$HAS_SPECIFIC_PERMISSION,sees_javascript_error_alerts}}window.take_errors=true;{+END}{+END}
		var {+START,IF,{$CONFIG_OPTION,is_on_timezone_detection}}server_timestamp={$FROM_TIMESTAMP%},{+END}ocp_lang=\'{$LANG;}\',ocp_theme=\'{$THEME;}\';
	//]]></script>

	<meta name="description" content="{+START,IF,{$NEQ,{DESCRIPTION},{!NA}}}{DESCRIPTION*}{+END}" />
	<meta name="keywords" content="{KEYWORDS*}" />

	{$CSS_TEMPCODE}

	{+START,IF_PASSED,EXTRA_HEAD}
		{EXTRA_HEAD}
	{+END}

	{$JS_TEMPCODE,header}

	{REFRESH}' . substr($header, $head_end_pos);
        $header_to_write = preg_replace('#<title>[^<>]*</title>#', '<title>{+START,IF_NON_EMPTY,{HEADER_TEXT}}{HEADER_TEXT*} - {+END}{$SITE_NAME*}</title>', $header_to_write);
        $header_to_write = preg_replace('#<meta name="keywords" content="([^"]*)"[^>]*>#', '', $header_to_write);
        $header_to_write = preg_replace('#<meta name="description" content="([^"]*)"[^>]*>#', '', $header_to_write);
        fwrite($myfile, $header_to_write);
        fclose($myfile);
        fix_permissions($path);
        sync_file($path);
        // Extract footer from cruft (</body> and below); SAVE
        $footer = $cruft['FOOTER'];
        // special cases of something with ID or class of footer/bottom going through too
        $footer_cases = array('<div id="footer"', '<div id="page_footer"', '<div class="footer"', '<div class="page_footer"');
        foreach ($footer_cases as $footer_case) {
            $footer_start_pos = strpos($footer, $footer_case);
            if ($footer_start_pos !== false) {
                break;
            }
        }
        if ($footer_start_pos === false) {
            $footer_start_pos = strpos($footer, '</body');
        }
        if ($footer_start_pos !== false) {
            $footer = substr($footer, $footer_start_pos);
        }
        $path = get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/templates_custom/FOOTER.tpl';
        $myfile = fopen($path, 'wt');
        $footer_to_write = $footer;
        fwrite($myfile, $footer_to_write);
        fclose($myfile);
        fix_permissions($path);
        sync_file($path);
        // What remains is saved to GLOBAL (note that we don't try and be clever about panels - this is up to the user, and they don't really need them anyway)
        if (count($compare_file_contents) > 1) {
            $global_to_write = substr($cruft['HEADER'], strlen($header)) . "\n{MIDDLE}\n" . substr($cruft['FOOTER'], 0, strlen($cruft['FOOTER']) - strlen($footer));
        } else {
            $cruft['HEADER'] = $header_to_write;
            $cruft['FOOTER'] = $footer_to_write;
            $global_to_write = '{MIDDLE}';
        }
        $path = get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/templates_custom/GLOBAL.tpl';
        $myfile = fopen($path, 'wt');
        fwrite($myfile, $global_to_write);
        fclose($myfile);
        fix_permissions($path);
        sync_file($path);
        // Extract site name from <title> tag, based on common consistency (largest common substring)
        $site_name = get_site_name();
        if (count($compare_file_contents) > 1) {
            $titles_in_reference_files = array();
            foreach ($compare_file_contents as $reference_file) {
                $matches = array();
                if (preg_match('#<title>(.*)</title>#', $reference_file, $matches) != 0) {
                    $titles_in_reference_files[] = $matches[1];
                }
            }
            // Find largest common substring
            $lcs = '';
            foreach ($titles_in_reference_files as $title_a) {
                for ($start = 0; $start < strlen($title_a); $start++) {
                    for ($end = $start + 1; $end < strlen($title_a); $end++) {
                        $current = substr($title_a, $start, $end - $start + 1);
                        foreach ($titles_in_reference_files as $title_b) {
                            if ($title_a != $title_b) {
                                if (strpos(strtolower($title_b), strtolower($current)) === false) {
                                    continue 2;
                                }
                            }
                        }
                        if (strpos(strtolower($title_b), strtolower($current)) !== false) {
                            if (strlen($current) > strlen($lcs)) {
                                $lcs = $current;
                            }
                        }
                    }
                }
            }
            // Strip bits
            $site_name = trim(preg_replace('#^[\\|\\-�,]#', '', preg_replace('#[\\|\\-�,]$#', '', trim($lcs))));
            // Save as site name
            set_option('site_name', $site_name);
        }
        // Go and save our pages
        disable_php_memory_limit();
        foreach ($content_files as $content_file) {
            $file_contents = file_get_contents($file_base . '/' . $content_file);
            // Find page-link for page
            $slash_count = substr_count($content_file, '/');
            if ($slash_count == 0) {
                $content_file = '/' . $content_file;
            } elseif ($slash_count > 1) {
                $last_slash_pos = strrpos($content_file, '/');
                $content_file = str_replace('/', '_', substr($content_file, 0, $last_slash_pos)) . substr($content_file, 0, $last_slash_pos);
            }
            list($zone, $page) = explode('/', preg_replace('#\\..*$#', '', $content_file), 2);
            if ($page == 'index') {
                $page = 'start';
            }
            if (substr($content_file, -4) == '.php') {
                $file_path = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/minimodules_custom/' . $page . '.php');
                $myfile = fopen($file_path, 'wt');
                fwrite($myfile, $file_contents);
                fclose($myfile);
                fix_permissions($file_path);
                sync_file($file_path);
            } else {
                $filtered = $this->_html_filter($file_contents, $fix_html, $base_url, $files, $file_base);
                // Try and work out page title from <title> tag
                $matches = array();
                $page_title = NULL;
                if (preg_match('#<title>(.*)</title>#', $filtered, $matches) != 0) {
                    $page_title = preg_replace('#( [\\|\\-�] )?' . preg_quote($site_name) . '( [\\|\\-�] )?#', '', $matches[1]);
                }
                $page_keywords = NULL;
                if (preg_match('#<meta name="keywords" content="([^"]*)"#', $filtered, $matches) != 0) {
                    $page_keywords = $matches[1];
                }
                $page_description = NULL;
                if (preg_match('#<meta name="description" content="([^"]*)"#', $filtered, $matches) != 0) {
                    $page_description = $matches[1];
                }
                require_code('seo2');
                seo_meta_set_for_explicit('comcode_page', $zone . ':' . $page, $page_keywords, $page_description);
                // Strip cruft off for htm/html files
                $i = strpos($filtered, '</head>');
                if ($i === false) {
                    $i = 0;
                } else {
                    $i += 7;
                }
                $filtered = $this->levenshtein_strip_search($cruft['HEADER'], $filtered, false, $i);
                $filtered = $this->levenshtein_strip_search($cruft['FOOTER'], $filtered, true, 0);
                // Copy htm/html/php files to correct zone page directories (html_custom/<lang>, or minimodules_custom)
                if ($convert_to_comcode == 0) {
                    // Insert an <h1> if the h1 is not there
                    if (strpos($filtered, '<h1') === false && !is_null($page_title)) {
                        $filtered = "<h1>" . $page_title . "</h1>\n\n" . $filtered;
                    }
                    $file_path = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/' . $page . '.txt');
                    $myfile = fopen($file_path, 'wt');
                    fwrite($myfile, '[semihtml]' . $filtered . '[/semihtml]');
                    fclose($myfile);
                    fix_permissions($file_path);
                    sync_file($file_path);
                } else {
                    // Insert an <h1> if the h1 is not there
                    if (strpos($filtered, '[title') === false && !is_null($page_title)) {
                        $filtered = "[title]" . $page_title . "[/title]\n\n" . $filtered;
                    }
                    require_code('comcode_from_html');
                    $comcode = semihtml_to_comcode($filtered);
                    $file_path = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/' . $page . '.txt');
                    $myfile = fopen($file_path, 'wt');
                    fwrite($myfile, $comcode);
                    fclose($myfile);
                    fix_permissions($file_path);
                    sync_file($file_path);
                }
            }
        }
        // Copy all remaining files to under uploads/website_specific
        foreach ($files as $file) {
            if (!file_exists($file_base . '/' . $file)) {
                continue;
            }
            $path = get_custom_file_base() . '/uploads/website_specific/' . $file;
            $create_path = $path;
            do {
                @mkdir(dirname($create_path), 0777);
                $create_path = dirname($create_path);
            } while (strlen($create_path) > 1);
            copy($file_base . '/' . $file, $path);
            fix_permissions($path);
            sync_file($path);
        }
        // Set the panels to be blank
        foreach (array('site/', '') as $zone) {
            $panels = array('panel_left', 'panel_right');
            foreach ($panels as $panel) {
                $path = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . 'pages/comcode_custom/' . filter_naughty(fallback_lang()) . '/' . filter_naughty($panel) . '.txt');
                $myfile = fopen($path, 'wt');
                fclose($myfile);
                fix_permissions($path);
                sync_file($path);
            }
        }
    }
示例#7
0
/**
 * Edit a calendar event.
 *
 * @param  AUTO_LINK			The ID of the event
 * @param  ?AUTO_LINK		The event type (NULL: default)
 * @param  SHORT_TEXT		The recurrence code
 * @param  ?integer			The number of recurrences (NULL: none/infinite)
 * @param  BINARY				Whether to segregate the comment-topics/rating/trackbacks per-recurrence
 * @param  SHORT_TEXT		The title of the event
 * @param  LONG_TEXT			The full text describing the event
 * @param  integer			The priority
 * @range  1 5
 * @param  BINARY				Whether it is a public event
 * @param  ?integer			The year the event starts at (NULL: default)
 * @param  ?integer			The month the event starts at (NULL: default)
 * @param  ?integer			The day the event starts at (NULL: default)
 * @param  ?integer			The hour the event starts at (NULL: default)
 * @param  ?integer			The minute the event starts at (NULL: default)
 * @param  ?integer			The year the event ends at (NULL: not a multi day event)
 * @param  ?integer			The month the event ends at (NULL: not a multi day event)
 * @param  ?integer			The day the event ends at (NULL: not a multi day event)
 * @param  ?integer			The hour the event ends at (NULL: not a multi day event)
 * @param  ?integer			The minute the event ends at (NULL: not a multi day event)
 * @param  ?ID_TEXT			The timezone for the event (NULL: current user's timezone)
 * @param  BINARY				Whether the time should be presented in the viewer's own timezone
 * @param  SHORT_TEXT		Meta keywords
 * @param  LONG_TEXT			Meta description
 * @param  BINARY				Whether the download has been validated
 * @param  BINARY				Whether the download may be rated
 * @param  SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style)
 * @param  BINARY				Whether the download may be trackbacked
 * @param  LONG_TEXT			Hidden notes pertaining to the download
 */
function edit_calendar_event($id, $type, $recurrence, $recurrences, $seg_recurrences, $title, $content, $priority, $is_public, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, $timezone, $do_timezone_conv, $meta_keywords, $meta_description, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes)
{
    $myrows = $GLOBALS['SITE_DB']->query_select('calendar_events', array('e_title', 'e_content', 'e_submitter'), array('id' => $id), '', 1);
    $myrow = $myrows[0];
    require_code('urls2');
    suggest_new_idmoniker_for('calendar', 'view', strval($id), $title);
    require_code('seo2');
    seo_meta_set_for_explicit('event', strval($id), $meta_keywords, $meta_description);
    require_code('attachments2');
    require_code('attachments3');
    if (!addon_installed('unvalidated')) {
        $validated = 1;
    }
    require_code('submit');
    $just_validated = !content_validated('event', strval($id)) && $validated == 1;
    if ($just_validated) {
        send_content_validated_notification('event', strval($id));
    }
    $GLOBALS['SITE_DB']->query_update('calendar_events', array('e_title' => lang_remap($myrow['e_title'], $title), 'e_content' => update_lang_comcode_attachments($myrow['e_content'], $content, 'calendar', strval($id), NULL, false, $myrow['e_submitter']), 'e_edit_date' => time(), 'e_recurrence' => $recurrence, 'e_recurrences' => $recurrences, 'e_seg_recurrences' => $seg_recurrences, 'e_start_year' => $start_year, 'e_start_month' => $start_month, 'e_start_day' => $start_day, 'e_start_hour' => $start_hour, 'e_start_minute' => $start_minute, 'e_end_year' => $end_year, 'e_end_month' => $end_month, 'e_end_day' => $end_day, 'e_end_hour' => $end_hour, 'e_end_minute' => $end_minute, 'e_timezone' => $timezone, 'e_do_timezone_conv' => $do_timezone_conv, 'e_is_public' => $is_public, 'e_priority' => $priority, 'e_type' => $type, 'validated' => $validated, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes), array('id' => $id), '', 1);
    $self_url = build_url(array('page' => 'calendar', 'type' => 'view', 'id' => $id), get_module_zone('calendar'), NULL, false, false, true);
    if ($just_validated) {
        require_lang('calendar');
        require_code('notifications');
        $subject = do_lang('CALENDAR_EVENT_NOTIFICATION_MAIL_SUBJECT', get_site_name(), strip_comcode($title));
        $mail = do_lang('CALENDAR_EVENT_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($title), array($self_url->evaluate()));
        dispatch_notification('calendar_event', strval($type), $subject, $mail);
    }
    decache('side_calendar');
    require_code('feedback');
    update_spacer_post($allow_comments != 0, 'events', strval($id), $self_url, $title, get_value('comment_forum__calendar'));
    log_it('EDIT_CALENDAR_EVENT', strval($id), $title);
}
示例#8
0
 /**
  * The actualiser to edit a comcode page.
  *
  * @return tempcode		The UI
  */
 function __ed()
 {
     $simple_add = get_param_integer('simple_add', 0) == 1;
     $title = get_page_title($simple_add ? 'COMCODE_PAGE_ADD' : 'COMCODE_PAGE_EDIT');
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/comcode_page_edit';
     $file = filter_naughty(post_param('file'));
     $lang = filter_naughty(post_param('lang'));
     $zone = filter_naughty(post_param('zone'));
     if (addon_installed('page_management')) {
         $new_file = filter_naughty(has_actual_page_access(get_member(), 'admin_sitetree') ? post_param('title', $file) : $file);
     } else {
         $new_file = filter_naughty($file);
     }
     if ($file == '') {
         $file = $new_file;
     }
     require_code('type_validation');
     if (!is_alphanumeric($file, true)) {
         warn_exit(do_lang_tempcode('BAD_CODENAME'));
     }
     $fullpath = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang . '/' . $file . '.txt');
     $renaming_page = $new_file != $file;
     if ($renaming_page) {
         if (!is_alphanumeric($new_file, true)) {
             warn_exit(do_lang_tempcode('BAD_CODENAME'));
         }
         $langs = find_all_langs(true);
         $rename_map = array();
         $afm_needed = false;
         // Actually will stay false as we don't allow renaming original-pages at the moment
         foreach (array_keys($langs) as $lang) {
             $path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt', true);
             if (is_file(get_file_base() . '/' . $path)) {
                 $new_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $new_file . '.txt', true);
                 if (is_file($new_path)) {
                     warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($zone . ':' . $new_file)));
                 }
                 $rename_map[$path] = $new_path;
             }
             if (is_file(get_file_base() . '/' . str_replace('/comcode_custom/', '/comcode/', $path))) {
                 $completion_text = do_lang_tempcode('ORIGINAL_PAGE_NO_RENAME');
             }
         }
         if ($afm_needed) {
             require_code('abstract_file_manager');
             force_have_afm_details();
         }
     }
     $validated = post_param_integer('validated', 0);
     if (!has_specific_permission(get_member(), 'bypass_validation_highrange_content')) {
         $validated = 0;
     }
     $parent_page = post_param('parent_page', '');
     $show_as_edit = post_param_integer('show_as_edit', 0);
     $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file));
     check_edit_permission('high', $resource_owner);
     if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
         $_owner = post_param('owner', $GLOBALS['FORUM_DRIVER']->get_username(get_member()));
         $owner = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_owner);
         if (is_null($owner)) {
             $owner = get_member();
         }
     } else {
         $owner = get_member();
     }
     if (is_null($resource_owner)) {
         check_submit_permission('high');
         require_code('submit');
         give_submit_points('COMCODE_PAGE_ADD');
         if (!addon_installed('unvalidated')) {
             $validated = 1;
         }
         $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => $zone, 'the_page' => $file, 'p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => NULL, 'p_add_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => 0));
     } else {
         if (!has_actual_page_access(get_member(), $file, $zone)) {
             access_denied('PAGE_ACCESS');
         }
         require_code('submit');
         $just_validated = !content_validated('comcode_page', $zone . ':' . $file) && $validated == 1;
         if ($just_validated) {
             send_content_validated_notification('comcode_page', $zone . ':' . $file);
         }
         if (!addon_installed('unvalidated')) {
             $validated = 1;
         }
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => $show_as_edit), array('the_zone' => $zone, 'the_page' => $file), '', 1);
     }
     if ($validated == 0) {
         require_code('submit');
         $edit_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $new_file), '_SELF', NULL, false, false, true);
         if (addon_installed('unvalidated')) {
             send_validation_request('COMCODE_PAGE_EDIT', 'comcode_pages', true, $zone . ':' . $new_file, $edit_url);
         }
     }
     $new = post_param('post');
     require_code('attachments2');
     $_new = do_comcode_attachments($new, 'comcode_page', $zone . ':' . $file);
     $new = $_new['comcode'];
     if (!file_exists($fullpath) || $new != file_get_contents($fullpath, FILE_TEXT)) {
         $myfile = @fopen($fullpath, 'wt');
         if ($myfile === false) {
             intelligent_write_error($fullpath);
         }
         final_attachments_from_preview($zone . ':' . $file);
         if (fwrite($myfile, $new) < strlen($new)) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fclose($myfile);
         sync_file($fullpath);
         $file_changed = true;
     } else {
         $file_changed = false;
     }
     require_code('seo2');
     $new_keywords = post_param('meta_keywords', '');
     $new_description = post_param('meta_description', '');
     if ($new_keywords == '' && $new_description == '') {
         seo_meta_set_for_implicit('comcode_page', $zone . ':' . $file, array($new), $new);
     } else {
         seo_meta_set_for_explicit('comcode_page', $zone . ':' . $file, $new_keywords, $new_description);
     }
     $completion_text = $validated == 0 ? do_lang_tempcode('SUBMIT_UNVALIDATED') : do_lang_tempcode('SUCCESS');
     // Update cache  NO WE CAN'T - THEY'RE MULTI-THEME NOW
     /*	$string_index=$GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages','string_index',array('the_zone'=>$zone,'the_page'=>$file));
     		if (!is_null($string_index))
     		{
     			lang_remap_comcode($string_index,$new);
     		} else
     		{
     			$string_index=insert_lang_comcode($new,1,NULL,false,NULL,NULL,false,NULL,NULL,60,true,true);
     			$GLOBALS['SITE_DB']->query_insert('cached_comcode_pages',array('the_zone'=>$zone,'the_page'=>$file,'string_index'=>$string_index));
     		}*/
     require_code('permissions2');
     set_page_permissions_from_environment($zone, $file);
     $caches = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index'), array('the_zone' => $zone, 'the_page' => $file));
     $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $file));
     foreach ($caches as $cache) {
         delete_lang($cache['string_index']);
     }
     persistant_cache_empty();
     persistant_cache_delete(array('PAGE_INFO'));
     decache('main_comcode_page_children');
     fix_permissions($fullpath);
     if (is_file($fullpath) && get_option('store_revisions') == '1' && $file_changed) {
         $time = time();
         @copy($fullpath, $fullpath . '.' . strval($time)) or intelligent_write_error($fullpath . '.' . strval($time));
         fix_permissions($fullpath . '.' . strval($time));
         sync_file($fullpath . '.' . strval($time));
     }
     log_it('COMCODE_PAGE_EDIT', $file, $zone);
     require_code('autosave');
     clear_ocp_autosave();
     if ($renaming_page) {
         $GLOBALS['SITE_DB']->query_delete('comcode_pages', array('the_zone' => $zone, 'the_page' => $new_file), '', 1);
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('the_page' => $new_file), array('the_zone' => $zone, 'the_page' => $file), '', 1);
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $new_file), array('the_zone' => $zone, 'p_parent_page' => $file));
         foreach ($rename_map as $path => $new_path) {
             if ($afm_needed) {
                 afm_move($path, $new_path);
             } else {
                 rename(get_custom_file_base() . '/' . $path, get_custom_file_base() . '/' . $new_path);
             }
         }
         if (addon_installed('awards')) {
             $types = $GLOBALS['SITE_DB']->query_select('award_types', array('id'), array('a_content_type' => 'comcode_page'));
             foreach ($types as $type) {
                 $GLOBALS['SITE_DB']->query_update('award_archive', array('content_id' => $new_file), array('content_id' => $file, 'a_type_id' => $type['id']));
             }
         }
         $file = $new_file;
     }
     if (post_param_integer('delete', 0) == 1) {
         unlink(get_custom_file_base() . '/' . $path);
     }
     if (addon_installed('awards')) {
         require_code('awards');
         handle_award_setting('comcode_page', $zone . ':' . $file);
     }
     decache('main_sitemap');
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     // Look for bad title semantics
     $_new['html'] = $_new['tempcode']->evaluate();
     if (substr($file, 0, 1) != '_' && substr($file, 0, 6) != 'panel_' && trim($_new['html']) != '') {
         if (strpos($_new['html'], '<h1') === false && strpos($_new['comcode'], '[title]') === false && strpos($_new['comcode'], '[title="1"]') === false) {
             attach_message(do_lang_tempcode('NO_LEVEL_1_HEADERS'), 'notice');
         }
         $matches = array();
         if (strpos($_new['html'], '<h2') === false && preg_match_all('#\\n\\[(b|font|size)\\][^\\.]+\\[/(b|font|size)\\]\\n#', $_new['comcode'], $matches) >= 2) {
             attach_message(do_lang_tempcode('NO_LEVEL_2_HEADERS'), 'inform');
         }
     }
     // Show it worked / Refresh
     $url = post_param('redirect', '');
     if ($url != '') {
         return redirect_screen($title, $url, $completion_text);
     }
     return $this->do_next_manager($title, $file, $zone, $completion_text);
 }
示例#9
0
/**
 * Sets the meta information for the specified resource, by auto-summarisation from the given parameters.
 *
 * @param  ID_TEXT		The type of resource (e.g. download)
 * @param  ID_TEXT		The ID of the resource
 * @param  array			Array of content strings to summarise from
 * @param  SHORT_TEXT	The description to use
 * @return SHORT_TEXT	Keyword string generated (it's also saved in the DB, so usually you won't want to collect this)
 */
function seo_meta_set_for_implicit($type, $id, $keyword_sources, $description)
{
    if (!is_null(post_param('meta_keywords', NULL)) && (post_param('meta_keywords') != '' || post_param('meta_description') != '')) {
        seo_meta_set_for_explicit($type, $id, post_param('meta_keywords'), post_param('meta_description'));
        return '';
    }
    if (get_value('no_auto_meta') === '1') {
        return '';
    }
    if (get_option('automatic_meta_extraction') == '0') {
        return '';
    }
    // These characters are considered to be word-characters
    require_code('textfiles');
    $word_chars = explode(chr(10), read_text_file('word_characters', ''));
    $strip_chars = array('\'');
    // These present problems so will be entirely stripped
    foreach ($word_chars as $i => $word_char) {
        $word_chars[$i] = trim($word_char);
    }
    $common_words = explode(chr(10), read_text_file('too_common_words', ''));
    foreach ($common_words as $i => $common_word) {
        $common_words[$i] = trim($common_word);
    }
    $keywords = array();
    // This will be filled
    foreach ($keyword_sources as $source) {
        $source = strip_comcode($source);
        foreach ($strip_chars as $strip_char) {
            $source = strtolower(str_replace($strip_char, '', $source));
        }
        $source = preg_replace('#\\-+#', ' ', $source);
        $i = 0;
        $len = strlen($source);
        $from = 0;
        $in_word = false;
        while ($i < $len) {
            $at = $source[$i];
            $word_char = in_array($at, $word_chars);
            if ($in_word) {
                // Exiting word
                if (!$word_char) {
                    if ($i - $from >= 3) {
                        $this_word = substr($source, $from, $i - $from);
                        if (!in_array($this_word, $common_words)) {
                            if (!array_key_exists($this_word, $keywords)) {
                                $keywords[$this_word] = 0;
                            }
                            $keywords[$this_word]++;
                        }
                    }
                    $in_word = false;
                }
            } else {
                // Entering word
                if ($word_char) {
                    $from = $i;
                    $in_word = true;
                }
            }
            $i++;
        }
        // Finalise
        if ($in_word && $i - $from >= 3) {
            $this_word = substr($source, $from, $i - $from);
            if (!in_array($this_word, $common_words)) {
                if (!array_key_exists($this_word, $keywords)) {
                    $keywords[$this_word] = 0;
                }
                $keywords[$this_word]++;
            }
        }
    }
    arsort($keywords);
    $imp = '';
    foreach (array_keys($keywords) as $i => $keyword) {
        if ($imp != '') {
            $imp .= ',';
        }
        $imp .= $keyword;
        if ($i == 15) {
            break;
        }
    }
    require_code('xhtml');
    $description = strip_comcode($description);
    $description = trim(preg_replace('#\\s+---+\\s+#', ' ', $description));
    seo_meta_set_for_explicit($type, $id, $imp, strlen($description) > 1000 ? substr($description, 0, 1000) . '...' : $description);
    if (function_exists('decache')) {
        decache('side_tag_cloud');
    }
    return $imp;
}
示例#10
0
/**
 * Adds an author (re-creating them if they already exist - thus it also serves to edit; the reason for this is the fluidity of authors - members are automatically authors even before an author profile is made)
 *
 * @param  ID_TEXT		The name of an author
 * @param  URLPATH		The URL to the authors home page
 * @param  ?MEMBER		The member ID of the author (NULL: no forum profile)
 * @param  LONG_TEXT		A description of the author
 * @param  LONG_TEXT		A terse string showing author skills
 * @param  ?SHORT_TEXT	Meta keywords for this resource (NULL: do not edit) (blank: implicit)
 * @param  ?LONG_TEXT	Meta description for this resource (NULL: do not edit) (blank: implicit)
 */
function add_author($author, $url, $forum_handle, $description, $skills, $meta_keywords = '', $meta_description = '')
{
    log_it('DEFINE_AUTHOR', $author, is_null($forum_handle) ? '' : strval($forum_handle));
    $rows = $GLOBALS['SITE_DB']->query_select('authors', array('description', 'skills'), array('author' => $author), '', 1);
    if (array_key_exists(0, $rows)) {
        delete_lang($rows[0]['description']);
        delete_lang($rows[0]['skills']);
        $GLOBALS['SITE_DB']->query_delete('authors', array('author' => $author), '', 1);
    }
    require_code('seo2');
    if ($meta_keywords == '' && $meta_description == '') {
        seo_meta_set_for_implicit('authors', $author, array($author, $description, $skills), $description);
    } else {
        seo_meta_set_for_explicit('authors', $author, $meta_keywords, $meta_description);
    }
    $GLOBALS['SITE_DB']->query_insert('authors', array('author' => $author, 'url' => $url, 'forum_handle' => $forum_handle, 'description' => insert_lang_comcode($description, 3), 'skills' => insert_lang_comcode($skills, 3)));
}
示例#11
0
/**
 * Edit a quiz.
 *
 * @param  AUTO_LINK		The ID
 * @param  SHORT_TEXT	The name of the quiz
 * @param  ?integer		The number of minutes allowed for completion (NULL: NA)
 * @param  LONG_TEXT		The text shown at the start of the quiz
 * @param  LONG_TEXT		The text shown at the end of the quiz
 * @param  LONG_TEXT		The text shown at the end of the quiz on failure
 * @param  LONG_TEXT		Notes
 * @param  integer		Percentage correctness required for competition
 * @param  ?TIME			The time the quiz is opened (NULL: now)
 * @param  ?TIME			The time the quiz is closed (NULL: never)
 * @param  integer		The number of winners for this if it is a competition
 * @param  integer		The minimum number of hours between attempts
 * @param  ID_TEXT		The type
 * @set    SURVEY COMPETITION TEST
 * @param  BINARY			Whether this is validated
 * @param  string			Text for questions
 * @param  SHORT_TEXT	Meta keywords
 * @param  LONG_TEXT		Meta description
 * @param  integer		The number of points awarded for completing/passing the quiz/test
 * @param  ?AUTO_LINK	Newsletter for which a member must be on to enter (NULL: none)
 */
function edit_quiz($id, $name, $timeout, $start_text, $end_text, $end_text_fail, $notes, $percentage, $open_time, $close_time, $num_winners, $redo_time, $type, $validated, $text, $meta_keywords, $meta_description, $points_for_passing = 0, $tied_newsletter = NULL)
{
    $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'];
    if (!addon_installed('unvalidated')) {
        $validated = 1;
    }
    require_code('submit');
    $just_validated = !content_validated('quiz', strval($id)) && $validated == 1;
    if ($just_validated) {
        send_content_validated_notification('quiz', strval($id));
    }
    $GLOBALS['SITE_DB']->query_update('quizzes', array('q_name' => lang_remap($_name, $name), 'q_timeout' => $timeout, 'q_start_text' => lang_remap($_start_text, $start_text), 'q_end_text' => lang_remap($_end_text, $end_text), 'q_end_text_fail' => lang_remap($_end_text_fail, $end_text_fail), 'q_notes' => $notes, 'q_percentage' => $percentage, 'q_open_time' => $open_time, 'q_close_time' => $close_time, 'q_num_winners' => $num_winners, 'q_redo_time' => $redo_time, 'q_type' => $type, 'q_validated' => $validated, 'q_points_for_passing' => $points_for_passing, 'q_tied_newsletter' => $tied_newsletter), array('id' => $id));
    handle_quiz_answers($id, $text, $type);
    require_code('urls2');
    suggest_new_idmoniker_for('quiz', 'do', strval($id), $name);
    require_code('seo2');
    seo_meta_set_for_explicit('quiz', strval($id), $meta_keywords, $meta_description);
    log_it('EDIT_QUIZ', strval($id), $name);
}
示例#12
0
/**
 * Edit the specified catalogue entry
 *
 * @param  AUTO_LINK			The ID of the entry being edited
 * @param  AUTO_LINK			The ID of the category that the entry is in
 * @param  BINARY				Whether the entry has been validated
 * @param  LONG_TEXT			Hidden notes pertaining to the entry
 * @param  BINARY				Whether the entry may be rated
 * @param  SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style)
 * @param  BINARY				Whether the entry may be trackbacked
 * @param  array				A map of field IDs, to values, that defines the entries settings
 * @param  ?SHORT_TEXT		Meta keywords for this resource (NULL: do not edit)
 * @param  ?LONG_TEXT		Meta description for this resource (NULL: do not edit)
 */
function actual_edit_catalogue_entry($id, $category_id, $validated, $notes, $allow_rating, $allow_comments, $allow_trackbacks, $map, $meta_keywords = '', $meta_description = '')
{
    $catalogue_name = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'c_name', array('id' => $category_id));
    $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => $catalogue_name)));
    $_fields = list_to_map('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id', 'cf_type'), array('c_name' => $catalogue_name)));
    $fields = collapse_2d_complexity('id', 'cf_type', $_fields);
    $original_submitter = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'ce_submitter', array('id' => $id));
    $old_category_id = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'cc_id', array('id' => $id));
    if (!addon_installed('unvalidated')) {
        $validated = 1;
    }
    require_code('submit');
    $was_validated = content_validated('catalogue_entry', strval($id));
    $just_validated = !$was_validated && $validated == 1;
    if ($just_validated) {
        send_content_validated_notification('catalogue_entry', strval($id));
    }
    $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_edit_date' => time(), 'cc_id' => $category_id, 'ce_validated' => $validated, 'notes' => $notes, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks), array('id' => $id), '', 1);
    require_code('fields');
    $title = NULL;
    foreach ($map as $field_id => $val) {
        if (is_null($title)) {
            $title = $val;
        }
        $type = $fields[$field_id];
        $ob = get_fields_hook($type);
        list(, , $sup_table_name) = $ob->get_field_value_row_bits($_fields[$field_id]);
        if (substr($sup_table_name, -6) == '_trans') {
            $_val = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_efv_' . $sup_table_name, 'cv_value', array('cf_id' => $field_id, 'ce_id' => $id));
            if (is_null($_val)) {
                $_val = insert_lang_comcode($val, 3);
            } else {
                if ($type == 'posting_field') {
                    require_code('attachments2');
                    require_code('attachments3');
                    $_val = update_lang_comcode_attachments($_val, $val, 'catalogue_entry', strval($id), NULL, false, $original_submitter);
                } else {
                    $_val = lang_remap_comcode($_val, $val);
                }
            }
            $GLOBALS['SITE_DB']->query_update('catalogue_efv_' . $sup_table_name, array('cv_value' => $_val), array('cf_id' => $field_id, 'ce_id' => $id), '', 1);
        } else {
            if ($sup_table_name == 'float') {
                $smap = array('cv_value' => is_null($val) || $val == '' ? NULL : floatval($val));
            } elseif ($sup_table_name == 'integer') {
                $smap = array('cv_value' => is_null($val) || $val == '' ? NULL : intval($val));
            } else {
                $smap = array('cv_value' => $val);
            }
            $GLOBALS['SITE_DB']->query_update('catalogue_efv_' . $sup_table_name, $smap, array('cf_id' => $field_id, 'ce_id' => $id), '', 1);
        }
    }
    require_code('urls2');
    suggest_new_idmoniker_for('catalogues', 'entry', strval($id), strip_comcode($title));
    require_code('seo2');
    seo_meta_set_for_explicit('catalogue_entry', strval($id), $meta_keywords, $meta_description);
    $self_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $id), get_module_zone('catalogues'), NULL, false, false, true);
    if ($category_id != $old_category_id || $was_validated != ($validated == 1)) {
        calculate_category_child_count_cache($category_id);
        if ($category_id != $old_category_id) {
            calculate_category_child_count_cache($old_category_id);
        }
    }
    decache('main_cc_embed');
    decache('main_recent_cc_entries');
    if ($catalogue_name[0] != '_') {
        log_it('EDIT_CATALOGUE_ENTRY', strval($id), $title);
        if ($just_validated) {
            require_lang('catalogues');
            require_code('notifications');
            $subject = do_lang('CATALOGUE_ENTRY_NOTIFICATION_MAIL_SUBJECT', get_site_name(), strip_comcode($title), array($catalogue_title));
            $mail = do_lang('CATALOGUE_ENTRY_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape(strip_comcode($title)), array(comcode_escape($self_url->evaluate()), comcode_escape($catalogue_title)));
            dispatch_notification('catalogue_entry__' . $catalogue_name, strval($id), $subject, $mail);
        }
    }
    require_code('feedback');
    update_spacer_post($allow_comments != 0, 'catalogues', strval($id), $self_url, $title, get_value('comment_forum__catalogues__' . $catalogue_name));
}