Beispiel #1
0
/**
 * Edit a flagrant text message.
 *
 * @param  AUTO_LINK		The ID of what to edit
 * @param  SHORT_TEXT	The message
 * @param  LONG_TEXT		Notes
 * @param  BINARY			Whether the message is the active message
 */
function edit_flagrant($id, $message, $notes, $validated)
{
    $_message = $GLOBALS['SITE_DB']->query_value('text', 'the_message', array('id' => $id));
    log_it('EDIT_FLAGRANT', strval($id), $message);
    $GLOBALS['SITE_DB']->query_update('text', array('notes' => $notes, 'the_message' => lang_remap_comcode($_message, $message), 'active_now' => $validated), array('id' => $id), '', 1);
    if ($validated == 1) {
        choose_flagrant($id);
    } else {
        persistant_cache_delete('FLAGRANT');
    }
}
Beispiel #2
0
/**
 * Edit an IOTD.
 *
 * @param  AUTO_LINK			The ID of the IOTD to edit
 * @param  SHORT_TEXT		The IOTD title
 * @param  LONG_TEXT			The IOTD caption
 * @param  URLPATH			The URL to the IOTD image
 * @param  URLPATH			The URL to the IOTD thumbnail image
 * @param  BINARY				Whether the IOTD may be rated
 * @param  SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style)
 * @param  BINARY				Whether the IOTD may be trackbacked
 * @param  LONG_TEXT			Notes for the IOTD
 */
function edit_iotd($id, $title, $caption, $thumb_url, $url, $allow_rating, $allow_comments, $allow_trackbacks, $notes)
{
    $_caption = $GLOBALS['SITE_DB']->query_value('iotd', 'caption', array('id' => $id));
    $_title = $GLOBALS['SITE_DB']->query_value('iotd', 'i_title', array('id' => $id));
    require_code('files2');
    delete_upload('uploads/iotds', 'iotd', 'url', 'id', $id, $url);
    delete_upload('uploads/iotds_thumbs', 'iotd', 'thumb_url', 'id', $id, $thumb_url);
    $GLOBALS['SITE_DB']->query_update('iotd', array('i_title' => lang_remap_comcode($_title, $title), 'edit_date' => time(), 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'caption' => lang_remap_comcode($_caption, $caption), 'thumb_url' => $thumb_url, 'url' => $url), array('id' => $id), '', 1);
    require_code('urls2');
    suggest_new_idmoniker_for('iotds', 'view', strval($id), $title);
    log_it('EDIT_IOTD', strval($id), get_translated_text($_caption));
    decache('main_iotd');
    require_code('feedback');
    update_spacer_post($allow_comments != 0, 'videos', strval($id), build_url(array('page' => 'iotds', 'type' => 'view', 'id' => $id), get_module_zone('iotds'), NULL, false, false, true), $title, get_value('comment_forum__iotds'));
}
Beispiel #3
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'));
}
Beispiel #4
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'));
}
Beispiel #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'));
}
Beispiel #6
0
/**
 * Edit a poll.
 *
 * @param  AUTO_LINK			The ID of the poll to edit
 * @param  SHORT_TEXT		The question
 * @param  SHORT_TEXT		The first choice
 * @range  1 max
 * @param  SHORT_TEXT		The second choice
 * @range  1 max
 * @param  SHORT_TEXT		The third choice (blank means not a choice)
 * @param  SHORT_TEXT		The fourth choice (blank means not a choice)
 * @param  SHORT_TEXT		The fifth choice (blank means not a choice)
 * @param  SHORT_TEXT		The sixth choice (blank means not a choice)
 * @param  SHORT_TEXT		The seventh choice (blank means not a choice)
 * @param  SHORT_TEXT		The eighth choice (blank means not a choice)
 * @param  SHORT_TEXT		The ninth choice (blank means not a choice)
 * @param  SHORT_TEXT		The tenth choice (blank means not a choice)
 * @param  integer			The number of choices
 * @param  BINARY				Whether to allow rating of this poll
 * @param  SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style)
 * @param  BINARY				Whether to allow trackbacking on this poll
 * @param  LONG_TEXT			Notes about this poll
 */
function edit_poll($id, $question, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $num_options, $allow_rating, $allow_comments, $allow_trackbacks, $notes)
{
    log_it('EDIT_POLL', strval($id), $question);
    persistant_cache_delete('POLL');
    $rows = $GLOBALS['SITE_DB']->query_select('poll', array('*'), array('id' => $id), '', 1);
    $_question = $rows[0]['question'];
    $_a1 = $rows[0]['option1'];
    $_a2 = $rows[0]['option2'];
    $_a3 = $rows[0]['option3'];
    $_a4 = $rows[0]['option4'];
    $_a5 = $rows[0]['option5'];
    $_a6 = $rows[0]['option6'];
    $_a7 = $rows[0]['option7'];
    $_a8 = $rows[0]['option8'];
    $_a9 = $rows[0]['option9'];
    $_a10 = $rows[0]['option10'];
    $GLOBALS['SITE_DB']->query_update('poll', array('edit_date' => time(), 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'num_options' => $num_options, 'question' => lang_remap_comcode($_question, $question), 'option1' => lang_remap_comcode($_a1, $a1), 'option2' => lang_remap_comcode($_a2, $a2), 'option3' => lang_remap_comcode($_a3, $a3), 'option4' => lang_remap_comcode($_a4, $a4), 'option5' => lang_remap_comcode($_a5, $a5), 'option6' => lang_remap_comcode($_a6, $a6), 'option7' => lang_remap_comcode($_a7, $a7), 'option8' => lang_remap_comcode($_a8, $a8), 'option9' => lang_remap_comcode($_a9, $a9), 'option10' => lang_remap_comcode($_a10, $a10)), array('id' => $id), '', 1);
    decache('main_poll');
    require_code('urls2');
    suggest_new_idmoniker_for('polls', 'view', strval($id), $question);
    require_code('feedback');
    update_spacer_post($allow_comments != 0, 'polls', strval($id), build_url(array('page' => 'polls', 'type' => 'view', 'id' => $id), get_module_zone('polls'), NULL, false, false, true), $question, get_value('comment_forum__polls'));
}
Beispiel #7
0
/**
 * Edit a banner.
 *
 * @param  ID_TEXT			The current name of the banner
 * @param  ID_TEXT			The new name of the banner
 * @param  URLPATH			The URL to the banner image
 * @param  SHORT_TEXT		The title text for the banner (only used for text banners, and functions as the 'trigger text' if the banner type is shown inline)
 * @param  SHORT_TEXT		The caption of the banner
 * @param  ?integer			The number of hits the banner may have (NULL: not applicable for this banner type)
 * @range  0 max
 * @param  URLPATH			The URL to the site the banner leads to
 * @param  integer			The banners "importance modulus"
 * @range  1 max
 * @param  LONG_TEXT			Any notes associated with the banner
 * @param  SHORT_INTEGER	The type of banner (0=permanent, 1=campaign, 2=default)
 * @set    0 1 2
 * @param  ?TIME				The banner expiry date (NULL: never)
 * @param  MEMBER				The banners submitter
 * @param  BINARY				Whether the banner has been validated
 * @param  ID_TEXT			The banner type (can be anything, where blank means 'normal')
 */
function edit_banner($old_name, $name, $imgurl, $title_text, $caption, $campaignremaining, $site_url, $importancemodulus, $notes, $the_type, $expiry_date, $submitter, $validated, $b_type)
{
    if ($old_name != $name) {
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => $name));
        if (!is_null($test)) {
            warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($name)));
        }
    }
    $_caption = $GLOBALS['SITE_DB']->query_value('banners', 'caption', array('name' => $old_name));
    if (!has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'cms_banners')) {
        $validated = 0;
    }
    require_code('files2');
    delete_upload('uploads/banners', 'banners', 'img_url', 'name', $old_name, $imgurl);
    log_it('EDIT_BANNER', $name);
    decache('main_banner_wave');
    decache('main_topsites');
    if (!addon_installed('unvalidated')) {
        $validated = 1;
    }
    require_code('submit');
    $just_validated = !content_validated('banner', $name) && $validated == 1;
    if ($just_validated) {
        send_content_validated_notification('banner', $name);
    }
    $GLOBALS['SITE_DB']->query_update('banners', array('b_title_text' => $title_text, 'edit_date' => time(), 'expiry_date' => $expiry_date, 'the_type' => $the_type, 'submitter' => $submitter, 'name' => $name, 'img_url' => $imgurl, 'caption' => lang_remap_comcode($_caption, $caption), 'campaign_remaining' => $campaignremaining, 'site_url' => $site_url, 'importance_modulus' => $importancemodulus, 'notes' => $notes, 'validated' => $validated, 'b_type' => $b_type), array('name' => $old_name), '', 1);
}
Beispiel #8
0
 /**
  * The actualiser to import news
  *
  * @return tempcode		The UI
  */
 function _import_news()
 {
     check_specific_permission('mass_import');
     $title = get_page_title('IMPORT_NEWS');
     require_code('rss');
     require_code('news');
     require_code('files');
     $GLOBALS['LAX_COMCODE'] = true;
     disable_php_memory_limit();
     $rss_url = post_param('rss_feed_url', NULL);
     require_code('uploads');
     if (is_swf_upload(true) && array_key_exists('file_novalidate', $_FILES) || array_key_exists('file_novalidate', $_FILES) && is_uploaded_file($_FILES['file_novalidate']['tmp_name'])) {
         $rss_url = $_FILES['file_novalidate']['tmp_name'];
     }
     if (is_null($rss_url)) {
         warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
     }
     $is_validated = post_param_integer('auto_validate', 0);
     $download_images = post_param_integer('download_images', 0);
     $rss = new rss($rss_url, true);
     if (!is_null($rss->error)) {
         warn_exit($rss->error);
     }
     $submitter = get_member();
     $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
     $NEWS_CATS = list_to_map('id', $NEWS_CATS);
     $extra_post_data = array();
     foreach ($rss->gleamed_items as $i => $item) {
         if (!array_key_exists('category', $item)) {
             $item['category'] = do_lang('NC_general');
         }
         $extra_post_data[] = $item;
         $cats_to_process = array($item['category']);
         if (array_key_exists('extra_categories', $item)) {
             $cats_to_process = array_merge($cats_to_process, $item['extra_categories']);
         }
         $cat_id = mixed();
         $extra_categories = array();
         foreach ($cats_to_process as $j => $cat) {
             $_cat_id = mixed();
             foreach ($NEWS_CATS as $_cat => $news_cat) {
                 if (get_translated_text($news_cat['nc_title']) == $cat) {
                     $_cat_id = $_cat;
                 }
             }
             if (is_null($_cat_id)) {
                 $_cat_id = add_news_category($cat, 'newscats/general', '', NULL);
                 // Need to reload now
                 $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
                 $NEWS_CATS = list_to_map('id', $NEWS_CATS);
             }
             if ($j == 0) {
                 $cat_id = $_cat_id;
             } else {
                 $extra_categories[] = $_cat_id;
             }
         }
         $rep_image = '';
         if (array_key_exists('rep_image', $item)) {
             $rep_image = $item['rep_image'];
             if ($download_images == 1) {
                 $stem = 'uploads/grepimages/' . basename(urldecode($rep_image));
                 $target_path = get_custom_file_base() . '/' . $stem;
                 $rep_image = 'uploads/grepimages/' . basename($rep_image);
                 while (file_exists($target_path)) {
                     $uniqid = uniqid('');
                     $stem = 'uploads/grepimages/' . $uniqid . '_' . basename(urldecode($rep_image));
                     $target_path = get_custom_file_base() . '/' . $stem;
                     $rep_image = 'uploads/grepimages/' . $uniqid . '_' . basename($rep_image);
                 }
                 $target_handle = fopen($target_path, 'wb') or intelligent_write_error($target_path);
                 $result = http_download_file($item['rep_image'], NULL, false, false, 'ocPortal', NULL, NULL, NULL, NULL, NULL, $target_handle);
                 fclose($target_handle);
             }
         }
         // Add news
         $ts = array_key_exists('clean_add_date', $item) ? $item['clean_add_date'] : (array_key_exists('add_date', $item) ? strtotime($item['add_date']) : time());
         if ($ts === false) {
             $ts = time();
         }
         // Seen in error email, it's if the add date won't parse by PHP
         $edit_date = array_key_exists('clean_edit_date', $item) ? $item['clean_edit_date'] : (array_key_exists('edit_date', $item) ? strtotime($item['edit_date']) : NULL);
         if ($edit_date === false) {
             $edit_date = NULL;
         }
         $news = array_key_exists('news', $item) ? html_to_comcode($item['news']) : '';
         $news_article = array_key_exists('news_article', $item) ? html_to_comcode($item['news_article']) : '';
         $news_id = add_news($item['title'], $news, array_key_exists('author', $item) ? $item['author'] : $GLOBALS['FORUM_DRIVER']->get_username(get_member()), $is_validated, 1, 1, 1, '', $news_article, $cat_id, $extra_categories, $ts, $submitter, 0, $edit_date, NULL, $rep_image);
         $rss->gleamed_items[$i]['import_id'] = $news_id;
         $rss->gleamed_items[$i]['import__news'] = $news;
         $rss->gleamed_items[$i]['import__news_article'] = $news_article;
     }
     foreach ($rss->gleamed_items as $i => $item) {
         $news = $item['import__news'];
         $news_article = $item['import__news_article'];
         $this->_grab_images_and_fix_links($download_images == 1, $news, $rss->gleamed_items);
         $this->_grab_images_and_fix_links($download_images == 1, $news_article, $rss->gleamed_items);
         lang_remap_comcode($GLOBALS['SITE_DB']->query_value('news', 'news', array('id' => $item['import_id'])), $news);
         lang_remap_comcode($GLOBALS['SITE_DB']->query_value('news', 'news_article', array('id' => $item['import_id'])), $news_article);
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_NEWS')), array('_SELF:_SELF:import', do_lang_tempcode('IMPORT_NEWS'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     if (url_is_local($rss_url)) {
         // Means it is a temp file
         @unlink($rss_url);
     }
     return inform_screen($title, do_lang_tempcode('IMPORT_NEWS_DONE'));
 }
/**
 * Set a custom profile field for a member.
 *
 * @param  MEMBER		The member.
 * @param  AUTO_LINK The field being set.
 * @param  mixed 		The value of the field. For a trans-type field, this can be either a lang-ID to be copied (from forum DB), or an actual string.
 * @param  ?ID_TEXT 	The field type (NULL: look it up).
 * @param  boolean 	Whether to defer the change, by returning a result change rather than doing it right away.
 * @return ?array		Mapping change (NULL: none / can't defer).
 */
function ocf_set_custom_field($member_id, $field, $value, $type = NULL, $defer = false)
{
    if (is_null($type)) {
        $type = $GLOBALS['FORUM_DB']->query_value('f_custom_fields', 'cf_type', array('id' => $field));
    }
    ocf_get_custom_field_mappings($member_id);
    // This will do an auto-repair if CPF storage row is missing
    global $ANY_FIELD_ENCRYPTED;
    if ($ANY_FIELD_ENCRYPTED === NULL) {
        $ANY_FIELD_ENCRYPTED = !is_null($GLOBALS['FORUM_DB']->query_value_null_ok('f_custom_fields', 'cf_encrypted', array('cf_encrypted' => 1)));
    }
    if ($ANY_FIELD_ENCRYPTED) {
        $encrypted = $GLOBALS['FORUM_DB']->query_value('f_custom_fields', 'cf_encrypted', array('id' => $field));
        if ($encrypted) {
            require_code('encryption');
            $current = $GLOBALS['FORUM_DB']->query_value('f_member_custom_fields', 'field_' . strval(intval($field)), array('mf_member_id' => $member_id));
            if (remove_magic_encryption_marker($value) == remove_magic_encryption_marker($current) && is_data_encrypted($current)) {
                return NULL;
            }
            $value = encrypt_data($value);
        }
    } else {
        $encrypted = false;
    }
    require_code('fields');
    $ob = get_fields_hook($type);
    list(, , $storage_type) = $ob->get_field_value_row_bits(array('id' => $field, 'cf_default' => '', 'cf_type' => $type));
    if (strpos($storage_type, '_trans') !== false) {
        if (is_integer($value)) {
            $value = get_translated_text($value, $GLOBALS['FORUM_DB']);
        }
        $current = $GLOBALS['FORUM_DB']->query_value('f_member_custom_fields', 'field_' . strval(intval($field)), array('mf_member_id' => $member_id));
        if (is_null($current)) {
            if ($type == 'posting_field') {
                require_code('attachments2');
                $current = insert_lang_comcode_attachments(3, $value, 'null', strval($member_id), $GLOBALS['FORUM_DB']);
            } else {
                $current = insert_lang_comcode($value, 3, $GLOBALS['FORUM_DB']);
            }
            $GLOBALS['FORUM_DB']->query_update('f_member_custom_fields', array('field_' . strval(intval($field)) => $current), array('mf_member_id' => $member_id), '', 1);
        } else {
            if ($type == 'posting_field') {
                require_code('attachments2');
                require_code('attachments3');
                update_lang_comcode_attachments($current, $value, 'null', strval($member_id), $GLOBALS['FORUM_DB'], false, $member_id);
            } else {
                lang_remap_comcode($current, $value, $GLOBALS['FORUM_DB']);
            }
        }
    } else {
        $change = array('field_' . strval(intval($field)) => $value);
        if (!$defer) {
            $GLOBALS['FORUM_DB']->query_update('f_member_custom_fields', $change, array('mf_member_id' => $member_id), '', 1);
        }
        return $change;
    }
    return NULL;
}
Beispiel #10
0
/**
 * get_translated_tempcode was asked for a lang entry that had not been parsed into Tempcode yet.
 *
 * @param  integer			The id
 * @param  ?object			The database connection to use (NULL: standard site connection)
 * @param  ?LANGUAGE_NAME	The language (NULL: uses the current language)
 * @param  boolean			Whether to force it to the specified language
 * @param  boolean			Whether to force as_admin, even if the lang string isn't stored against an admin (designed for comcode page cacheing)
 * @return ?tempcode			The parsed comcode (NULL: the text couldn't be looked up)
 */
function parse_translated_text($entry, $connection, $lang, $force, $as_admin)
{
    global $SEARCH__CONTENT_BITS, $LAX_COMCODE;
    $nql_backup = $GLOBALS['NO_QUERY_LIMIT'];
    $GLOBALS['NO_QUERY_LIMIT'] = true;
    $result = $connection->query_select('translate', array('text_original', 'source_user'), array('id' => $entry, 'language' => $lang), '', 1);
    $result = array_key_exists(0, $result) ? $result[0] : NULL;
    if (is_null($result)) {
        if ($force) {
            $GLOBALS['NO_QUERY_LIMIT'] = $nql_backup;
            return NULL;
        }
        $result = $connection->query_value_null_ok('translate', 'text_parsed', array('id' => $entry, 'language' => get_site_default_lang()));
        if (is_null($result)) {
            $result = $connection->query_value_null_ok('translate', 'text_parsed', array('id' => $entry));
        }
        if (!is_null($result) && $result != '') {
            $connection->text_lookup_cache[$entry] = new ocp_tempcode();
            if (!$connection->text_lookup_cache[$entry]->from_assembly($result, true)) {
                $result = NULL;
            }
        }
        if (is_null($result) || $result == '') {
            load_user_stuff();
            require_code('comcode');
            // might not have been loaded for a quick-boot
            require_code('permissions');
            $result = $connection->query_select('translate', array('text_original', 'source_user'), array('id' => $entry, 'language' => get_site_default_lang()), '', 1);
            if (!array_key_exists(0, $result)) {
                $result = $connection->query_select('translate', array('text_original', 'source_user'), array('id' => $entry), '', 1);
            }
            $result = array_key_exists(0, $result) ? $result[0] : NULL;
            $temp = $LAX_COMCODE;
            $LAX_COMCODE = true;
            lang_remap_comcode($entry, is_null($result) ? '' : $result['text_original'], $connection, NULL, $result['source_user'], $as_admin);
            if (!is_null($SEARCH__CONTENT_BITS)) {
                $ret = comcode_to_tempcode($result['text_original'], $result['source_user'], $as_admin, 60, NULL, $connection, false, false, false, false, false, $SEARCH__CONTENT_BITS);
                $LAX_COMCODE = $temp;
                $GLOBALS['NO_QUERY_LIMIT'] = $nql_backup;
                return $ret;
            }
            $LAX_COMCODE = $temp;
            $ret = get_translated_tempcode($entry, $connection, $lang);
            $GLOBALS['NO_QUERY_LIMIT'] = $nql_backup;
            return $ret;
        }
        $GLOBALS['NO_QUERY_LIMIT'] = $nql_backup;
        return $connection->text_lookup_cache[$entry];
    } else {
        load_user_stuff();
        require_code('comcode');
        // might not have been loaded for a quick-boot
        require_code('permissions');
        $temp = $LAX_COMCODE;
        $LAX_COMCODE = true;
        global $SHOW_EDIT_LINKS, $KEEP_MARKERS;
        if (!is_null($SEARCH__CONTENT_BITS) || $SHOW_EDIT_LINKS || $KEEP_MARKERS) {
            $ret = comcode_to_tempcode($result['text_original'], $result['source_user'], $as_admin, 60, NULL, $connection, false, false, false, false, false, $SEARCH__CONTENT_BITS);
            $LAX_COMCODE = $temp;
            $GLOBALS['NO_QUERY_LIMIT'] = $nql_backup;
            return $ret;
        }
        lang_remap_comcode($entry, $result['text_original'], $connection, NULL, $result['source_user'], $as_admin);
        $LAX_COMCODE = $temp;
        $ret = get_translated_tempcode($entry, $connection, $lang);
        $GLOBALS['NO_QUERY_LIMIT'] = $nql_backup;
        return $ret;
    }
}
Beispiel #11
0
/**
 * Edit an award type
 *
 * @param  AUTO_LINK		The ID
 * @param  SHORT_TEXT	The title
 * @param  LONG_TEXT		The description
 * @param  integer		How many points are given to the awardee
 * @param  ID_TEXT		The content type the award type is for
 * @param  BINARY			Whether to not show the awardee when displaying this award
 * @param  integer		The approximate time in hours between awards (e.g. 168 for a week)
 */
function edit_award_type($id, $title, $description, $points, $content_type, $hide_awardee, $update_time_hours)
{
    $_title = $GLOBALS['SITE_DB']->query_value_null_ok('award_types', 'a_title', array('id' => $id));
    if (is_null($_title)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $_description = $GLOBALS['SITE_DB']->query_value('award_types', 'a_description', array('id' => $id));
    $GLOBALS['SITE_DB']->query_update('award_types', array('a_title' => lang_remap_comcode($_title, $title), 'a_description' => lang_remap($_description, $description), 'a_points' => $points, 'a_content_type' => filter_naughty_harsh($content_type), 'a_hide_awardee' => $hide_awardee, 'a_update_time_hours' => $update_time_hours), array('id' => $id));
    log_it('EDIT_AWARD_TYPE', strval($id), $title);
}
Beispiel #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));
}