/** * Get the tempcode for the form to add a banner, with the information passed along to it via the parameters already added in. * * @param boolean Whether to simplify the banner interface (for the point-store buy process) * @param ID_TEXT The name of the banner * @param URLPATH The URL to the banner image * @param URLPATH The URL to the site the banner leads to * @param SHORT_TEXT The caption of the banner * @param LONG_TEXT Any notes associated with the banner * @param integer The banners "importance modulus" * @range 1 max * @param ?integer The number of hits the banner may have (NULL: not applicable for this banner type) * @range 0 max * @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 expires) * @param ?ID_TEXT The username of the banners submitter (NULL: current member) * @param BINARY Whether the banner has been validated * @param ID_TEXT The banner type (can be anything, where blank means 'normal') * @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) * @return tempcode The input field tempcode */ function get_banner_form_fields($simplified = false, $name = '', $image_url = '', $site_url = '', $caption = '', $notes = '', $importancemodulus = 3, $campaignremaining = 50, $the_type = 1, $expiry_date = NULL, $submitter = NULL, $validated = 1, $b_type = '', $title_text = '') { require_code('images'); $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_BANNER_NAME'), 'name', $name, true)); $fields->attach(form_input_line(do_lang_tempcode('DESTINATION_URL'), do_lang_tempcode('DESCRIPTION_BANNER_URL'), 'site_url', $site_url, false)); // Blank implies iframe if (!$simplified) { $types = nice_get_banner_types($b_type); if ($types->is_empty()) { warn_exit(do_lang_tempcode('NO_CATEGORIES')); } $fields->attach(form_input_list(do_lang_tempcode('_BANNER_TYPE'), do_lang_tempcode('_DESCRIPTION_BANNER_TYPE'), 'b_type', $types, NULL, false, false)); } else { $fields->attach(form_input_hidden('b_type', $b_type)); } if (has_specific_permission(get_member(), 'full_banner_setup')) { $fields->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_SUBMITTER'), 'submitter', is_null($submitter) ? $GLOBALS['FORUM_DRIVER']->get_username(get_member()) : $submitter, false)); } if (get_value('disable_staff_notes') !== '1') { $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false)); } if (has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'cms_banners')) { if ($validated == 0) { $validated = get_param_integer('validated', 0); if ($validated == 1) { attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING')); } } if (addon_installed('unvalidated')) { $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1)); } } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SOURCE_MEDIA')))); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD_BANNER'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',swf'))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('IMAGE_URL')), do_lang_tempcode('DESCRIPTION_URL_BANNER'), 'image_url', $image_url, false)); $fields->attach(form_input_line_comcode(do_lang_tempcode('BANNER_TITLE_TEXT'), do_lang_tempcode('DESCRIPTION_BANNER_TITLE_TEXT'), 'title_text', $title_text, false)); $fields->attach(form_input_line_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_BANNER_DESCRIPTION'), 'caption', $caption, false)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('DEPLOYMENT_DETERMINATION')))); if (has_specific_permission(get_member(), 'full_banner_setup')) { $radios = new ocp_tempcode(); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_PERMANENT), $the_type == BANNER_PERMANENT, do_lang_tempcode('BANNER_PERMANENT'))); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_CAMPAIGN), $the_type == BANNER_CAMPAIGN, do_lang_tempcode('BANNER_CAMPAIGN'))); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_DEFAULT), $the_type == BANNER_DEFAULT, do_lang_tempcode('BANNER_DEFAULT'))); $fields->attach(form_input_radio(do_lang_tempcode('DEPLOYMENT_AGREEMENT'), do_lang_tempcode('DESCRIPTION_BANNER_TYPE'), 'the_type', $radios)); $fields->attach(form_input_integer(do_lang_tempcode('HITS_ALLOCATED'), do_lang_tempcode('DESCRIPTION_HITS_ALLOCATED'), 'campaignremaining', $campaignremaining, false)); $total_importance = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT SUM(importance_modulus) FROM ' . get_table_prefix() . 'banners WHERE ' . db_string_not_equal_to('name', $name)); if (is_null($total_importance)) { $total_importance = 0; } $fields->attach(form_input_integer(do_lang_tempcode('IMPORTANCE_MODULUS'), do_lang_tempcode('DESCRIPTION_IMPORTANCE_MODULUS', strval($total_importance), strval($importancemodulus)), 'importancemodulus', $importancemodulus, true)); } $fields->attach(form_input_date(do_lang_tempcode('EXPIRY_DATE'), do_lang_tempcode('DESCRIPTION_EXPIRY_DATE'), 'expiry_date', true, is_null($expiry_date), true, $expiry_date, 2)); return $fields; }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('PHOTO'); $order = 30; // Actualiser if (post_param_integer('submitting_photo_tab', 0) == 1) { require_code('ocf_members_action'); require_code('ocf_members_action2'); ocf_member_choose_photo('photo_url', 'photo_file', $member_id_of); attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } $photo_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_url'); $thumb_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_thumb_url'); // UI fields $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'photo_file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'photo_url', $photo_url, false)); if (get_option('is_on_gd') == '0' || !function_exists('imagetypes')) { $thumb_width = get_option('thumb_width'); $fields->attach(form_input_upload(do_lang_tempcode('THUMBNAIL'), do_lang_tempcode('DESCRIPTION_THUMBNAIL', escape_html($thumb_width)), 'photo_file2', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'photo_thumb_url', $thumb_url, false)); } $hidden = new ocp_tempcode(); handle_max_file_size($hidden, 'image'); $hidden->attach(form_input_hidden('submitting_photo_tab', '1')); $text = new ocp_tempcode(); require_code('images'); $max = floatval(get_max_image_size()) / floatval(1024 * 1024); if ($max < 3.0) { require_code('files2'); $config_url = get_upload_limit_config_url(); $text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), is_null($config_url) ? '' : escape_html($config_url)))); } $text = do_template('OCF_EDIT_PHOTO_TAB', array('TEXT' => $text, 'MEMBER_ID' => strval($member_id_of), 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($member_id_of), 'PHOTO' => $GLOBALS['FORUM_DRIVER']->get_member_photo_url($member_id_of))); $javascript = ''; return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * The UI to import news * * @return tempcode The UI */ function import_wordpress() { check_specific_permission('mass_import', NULL, NULL, 'cms_news'); $lang = post_param('lang', user_lang()); $title = get_page_title('IMPORT_WP_DB'); $submit_name = do_lang_tempcode('IMPORT_WP_DB'); require_code('form_templates'); //------------------------------------------------ // Build up form $fields_xml = new ocp_tempcode(); $fields_xml->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_WP_XML'), 'file_novalidate', false, NULL, NULL, true, 'xml')); $fields_xml->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'xml_url', '', false)); $hidden = form_input_hidden('lang', $lang); $javascript = 'standardAlternateFields(\'file_novalidate\',\'xml_url\');'; $xml_post_url = build_url(array('page' => '_SELF', 'type' => '_import_wordpress', 'method' => 'xml'), '_SELF'); $xml_upload_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'TEXT' => '', 'HIDDEN' => $hidden, 'FIELDS' => $fields_xml, 'SUBMIT_NAME' => $submit_name, 'URL' => $xml_post_url, 'JAVASCRIPT' => $javascript)); //-------------------------------------------- $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('WORDPRESS_HOST_NAME'), do_lang_tempcode('DESCRIPTION_WORDPRESS_HOST_NAME'), 'wp_host', 'localhost', false)); $fields->attach(form_input_line(do_lang_tempcode('WORDPRESS_DB_NAME'), do_lang_tempcode('DESCRIPTION_WORDPRESS_DB_NAME'), 'wp_db', 'wordpress', false)); $fields->attach(form_input_line(do_lang_tempcode('WORDPRESS_TABLE_PREFIX'), do_lang_tempcode('DESCRIPTION_WORDPRESS_TABLE_PREFIX'), 'wp_table_prefix', 'wp', false)); $fields->attach(form_input_line(do_lang_tempcode('WORDPRESS_DB_USERNAME'), do_lang_tempcode('DESCRIPTION_WORDPRESS_DB_USERNAME'), 'wp_db_user', 'root', false)); $fields->attach(form_input_password(do_lang_tempcode('WORDPRESS_DB_PASSWORD'), do_lang_tempcode('DESCRIPTION_WORDPRESS_DB_PASSWORD'), 'wp_db_password', false)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('ADVANCED_OPTIONS')))); $fields->attach(form_input_tick(do_lang_tempcode('IMPORT_WORDPRESS_USERS'), do_lang_tempcode('DESCRIPTION_IMPORT_WORDPRESS_USER'), 'wp_import_wordpress_users', true)); $fields->attach(form_input_tick(do_lang_tempcode('IMPORT_BLOG_COMMENTS'), do_lang_tempcode('DESCRIPTION_IMPORT_BLOG_COMMENTS'), 'wp_import_blog_comments', true)); $fields->attach(form_input_tick(do_lang_tempcode('AUTO_VALIDATE_ALL_POSTS'), do_lang_tempcode('DESCRIPTION_VALIDATE_ALL_POSTS'), 'wp_auto_validate', true)); $fields->attach(form_input_tick(do_lang_tempcode('ADD_TO_OWN_ACCOUNT'), do_lang_tempcode('DESCRIPTION_ADD_TO_OWN_ACCOUNT'), 'wp_add_to_own', false)); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('lang', $lang)); handle_max_file_size($hidden); $javascript = ''; $db_post_url = build_url(array('page' => '_SELF', 'type' => '_import_wordpress', 'method' => 'db'), '_SELF'); $db_import_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'TEXT' => '', 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $db_post_url, 'JAVASCRIPT' => $javascript)); return do_template('NEWS_WORDPRESS_IMPORT_SCREEN', array('TITLE' => get_page_title('DB_IMPORT_FORM'), 'XML_UPLOAD_FORM' => $xml_upload_form, 'DB_IMPORT_FORM' => $db_import_form)); }
/** * Get form inputter. * * @param string The field name * @param string The field description * @param array The field details * @param ?string The actual current value of the field (NULL: none) * @param boolean Whether this is for a new entry * @return ?array A pair: The Tempcode for the input field, Tempcode for hidden fields (NULL: skip the field - it's not input) */ function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new) { $say_required = $field['cf_required'] == 1 && ($actual_value == '' || is_null($actual_value)); $ffield = form_input_upload($_cf_name, $_cf_description, 'field_' . strval($field['id']), $say_required, $field['cf_required'] == 1 ? NULL : $actual_value, NULL, true, str_replace(' ', '', get_option('valid_images'))); $hidden = new ocp_tempcode(); handle_max_file_size($hidden, 'image'); return array($ffield, $hidden); }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('AVATAR'); $order = 20; // Actualiser if (post_param_integer('submitting_avatar_tab', 0) == 1) { require_code('uploads'); if (has_specific_permission($member_id_viewing, 'own_avatars')) { if (!(is_swf_upload(true) && array_key_exists('avatar_file', $_FILES) || array_key_exists('avatar_file', $_FILES) && is_uploaded_file($_FILES['avatar_file']['tmp_name']))) { $urls = array(); $stock = post_param('avatar_alt_url', ''); if ($stock == '') { $stock = post_param('avatar_stock', NULL); if (!is_null($stock)) { $urls[0] = $stock == '' ? '' : find_theme_image($stock, false, true); } else { $urls[0] = ''; } // None } else { if (url_is_local($stock) && !$GLOBALS['FORUM_DRIVER']->is_super_admin($member_id_viewing)) { $old = $GLOBALS['FORUM_DB']->query_value('f_members', 'm_avatar_url', array('id' => $member_id_of)); if ($old != $stock) { access_denied('ASSOCIATE_EXISTING_FILE'); } } $urls[0] = $stock; // URL } } else { // We have chosen an upload. Note that we will not be looking at alt_url at this point, even though it is specified below for canonical reasons $urls = get_url('avatar_alt_url', 'avatar_file', file_exists(get_custom_file_base() . '/uploads/avatars') ? 'uploads/avatars' : 'uploads/ocf_avatars', 0, OCP_UPLOAD_IMAGE, false, '', '', false, true); if ((get_base_url() != get_forum_base_url() || array_key_exists('on_msn', $GLOBALS['SITE_INFO']) && $GLOBALS['SITE_INFO']['on_msn'] == '1') && $urls[0] != '' && url_is_local($urls[0])) { $urls[0] = get_custom_base_url() . '/' . $urls[0]; } } $avatar_url = $urls[0]; } else { $stock = post_param('avatar_stock'); $avatar_url = $stock == '' ? '' : find_theme_image($stock, false, true); } require_code('ocf_members_action'); require_code('ocf_members_action2'); ocf_member_choose_avatar($avatar_url, $member_id_of); attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } // UI fields $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_avatar_url'); require_javascript('javascript_multi'); $fields = new ocp_tempcode(); require_code('form_templates'); require_code('themes2'); $ids = get_all_image_ids_type('ocf_default_avatars', true); $found_it = false; foreach ($ids as $id) { $pos = strpos($avatar_url, '/' . $id); $selected = $pos !== false; if ($selected) { $found_it = true; } } $hidden = new ocp_tempcode(); if (has_specific_permission($member_id_viewing, 'own_avatars')) { $javascript = 'standardAlternateFields(\'avatar_file\',\'avatar_alt_url\',\'avatar_stock*\',true);'; $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'avatar_file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); handle_max_file_size($hidden, 'image'); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'avatar_alt_url', $found_it ? '' : $avatar_url, false)); $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'avatar_stock', $ids, $avatar_url, NULL, NULL, true)); } else { $javascript = ''; $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('STOCK'), '', 'avatar_stock', $ids, $avatar_url, NULL, NULL, true)); } if ($avatar_url != '') { if (url_is_local($avatar_url)) { $avatar_url = get_complex_base_url($avatar_url) . '/' . $avatar_url; } $avatar = do_template('OCF_TOPIC_POST_AVATAR', array('_GUID' => '50a5902f3ab7e384d9cf99577b222cc8', 'AVATAR' => $avatar_url)); } else { $avatar = do_lang_tempcode('NONE_EM'); } $width = ocf_get_member_best_group_property($member_id_of, 'max_avatar_width'); $height = ocf_get_member_best_group_property($member_id_of, 'max_avatar_height'); $text = do_template('OCF_EDIT_AVATAR_TAB', array('_GUID' => 'dbdac6ca3bc752b54d2a24a4c6e69c7c', 'MEMBER_ID' => strval($member_id_of), 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($member_id_of), 'AVATAR' => $avatar, 'WIDTH' => integer_format($width), 'HEIGHT' => integer_format($height))); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('submitting_avatar_tab', '1')); return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * The main user interface for the file dump. * * @return tempcode The UI. */ function module_do_gui() { $title = get_page_title('FILE_DUMP'); $place = filter_naughty(get_param('place', '/')); if (substr($place, -1, 1) != '/') { $place .= '/'; } $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=filedump&filter=' . $place; // Show tree $dirs = explode('/', substr($place, 0, strlen($place) - 1)); $i = 0; $pre = ''; $file_tree = new ocp_tempcode(); while (array_key_exists($i, $dirs)) { if ($i > 0) { $d = $dirs[$i]; } else { $d = do_lang('FILE_DUMP'); } if (array_key_exists($i + 1, $dirs)) { $tree_url = build_url(array('page' => '_SELF', 'place' => $pre . $dirs[$i] . '/'), '_SELF'); if (!$file_tree->is_empty()) { $file_tree->attach(do_template('BREADCRUMB', array('_GUID' => '7ee62e230d53344a7d9667dc59be21c6'))); } $file_tree->attach(hyperlink($tree_url, $d)); } $pre .= $dirs[$i] . '/'; $i++; } if (!$file_tree->is_empty()) { breadcrumb_add_segment($file_tree, $d); } else { breadcrumb_set_self($i == 1 ? do_lang_tempcode('FILE_DUMP') : make_string_tempcode(escape_html($d))); } // Check directory exists $fullpath = get_custom_file_base() . '/uploads/filedump' . $place; if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place)) { if (has_specific_permission(get_member(), 'upload_filedump')) { @mkdir($fullpath, 0777) or warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY', escape_html($fullpath), escape_html(dirname($fullpath)))); fix_permissions($fullpath, 0777); sync_file($fullpath); } } // Find all files in the incoming directory $handle = opendir(get_custom_file_base() . '/uploads/filedump' . $place); $i = 0; $filename = array(); $description = array(); $filesize = array(); $filetime = array(); $directory = array(); $deletable = array(); while (false !== ($file = readdir($handle))) { if (!should_ignore_file('uploads/filedump' . $place . $file, IGNORE_ACCESS_CONTROLLERS | IGNORE_HIDDEN_FILES)) { $directory[$i] = !is_file(get_custom_file_base() . '/uploads/filedump' . $place . $file); $filename[$i] = $directory[$i] ? $file . '/' : $file; if ($directory[$i]) { $filesize[$i] = do_lang_tempcode('NA_EM'); } $dbrows = $GLOBALS['SITE_DB']->query_select('filedump', array('description', 'the_member'), array('name' => $file, 'path' => $place)); if (!array_key_exists(0, $dbrows)) { $description[$i] = $directory[$i] ? do_lang_tempcode('NA_EM') : do_lang_tempcode('NONE_EM'); } else { $description[$i] = make_string_tempcode(escape_html(get_translated_text($dbrows[0]['description']))); } if ($description[$i]->is_empty()) { $description[$i] = do_lang_tempcode('NONE_EM'); } $deletable[$i] = array_key_exists(0, $dbrows) && $dbrows[0]['the_member'] == get_member() || has_specific_permission(get_member(), 'delete_anything_filedump'); if ($directory[$i]) { $size = get_directory_size(get_custom_file_base() . '/uploads/filedump' . $place . $file); $timestamp = NULL; } else { $size = filesize(get_custom_file_base() . '/uploads/filedump' . $place . $file); $timestamp = filemtime(get_custom_file_base() . '/uploads/filedump' . $place . $file); } $filesize[$i] = clean_file_size($size); $filetime[$i] = is_null($timestamp) ? NULL : get_timezoned_date($timestamp); $i++; } } closedir($handle); if ($i != 0) { require_code('templates_table_table'); $header_row = table_table_header_row(array(do_lang_tempcode('FILENAME'), do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('SIZE'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTIONS'))); $rows = new ocp_tempcode(); for ($a = 0; $a < $i; $a++) { if ($directory[$a]) { $link = build_url(array('page' => '_SELF', 'place' => $place . $filename[$a]), '_SELF'); } else { $link = make_string_tempcode(get_custom_base_url() . '/uploads/filedump' . str_replace('%2F', '/', rawurlencode($place . $filename[$a]))); } if (!$directory[$a]) { if ($deletable[$a]) { $delete_url = build_url(array('page' => '_SELF', 'type' => 'ed', 'file' => $filename[$a], 'place' => $place), '_SELF'); $actions = do_template('TABLE_TABLE_ACTION_DELETE_ENTRY', array('_GUID' => '9b91e485d80417b1664145f9bca5a2f5', 'NAME' => $filename[$a], 'URL' => $delete_url)); } else { $actions = new ocp_tempcode(); } } else { $delete_url = build_url(array('page' => '_SELF', 'type' => 'ec', 'file' => $filename[$a], 'place' => $place), '_SELF'); $actions = do_template('TABLE_TABLE_ACTION_DELETE_CATEGORY', array('_GUID' => '0fa7d4090c6195328191399a14799169', 'NAME' => $filename[$a], 'URL' => $delete_url)); } $rows->attach(table_table_row(array(hyperlink($link, escape_html($filename[$a]), !$directory[$a]), escape_html($description[$a]), escape_html($filesize[$a]), is_null($filetime[$a]) ? do_lang_tempcode('NA') : make_string_tempcode(escape_html($filetime[$a])), $actions))); } $files = do_template('TABLE_TABLE', array('_GUID' => '1c0a91d47c5fc8a7c2b35c7d9b36132f', 'HEADER_ROW' => $header_row, 'ROWS' => $rows)); } else { $files = new ocp_tempcode(); } // Do a form so people can upload their own stuff if (has_specific_permission(get_member(), 'upload_filedump')) { $post_url = build_url(array('page' => '_SELF', 'type' => 'ad', 'uploading' => 1), '_SELF'); $submit_name = do_lang_tempcode('FILEDUMP_UPLOAD'); $max = floatval(get_max_file_size()); $text = new ocp_tempcode(); if ($max < 30.0) { $config_url = get_upload_limit_config_url(); $text->attach(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max / 1024.0 / 1024.0)), escape_html(is_null($config_url) ? '' : $config_url))); } require_code('form_templates'); $fields = form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('_DESCRIPTION_UPLOAD'), 'file', true); $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', '', false)); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('place', $place)); handle_max_file_size($hidden); $upload_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'HIDDEN' => $hidden, 'TEXT' => $text, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); } else { $upload_form = new ocp_tempcode(); } // Do a form so people can make folders if (get_option('is_on_folder_create') == '1') { $post_url = build_url(array('page' => '_SELF', 'type' => 'ac'), '_SELF'); require_code('form_templates'); $fields = form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', '', true); $hidden = form_input_hidden('place', $place); $submit_name = do_lang_tempcode('FILEDUMP_CREATE_FOLDER'); $create_folder_form = do_template('FORM', array('_GUID' => '043f9b595d3699b7d8cd7f2284cdaf98', 'TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'SECONDARY_FORM' => true, 'HIDDEN' => $hidden, 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); } else { $create_folder_form = new ocp_tempcode(); } return do_template('FILE_DUMP_SCREEN', array('_GUID' => '3f49a8277a11f543eff6488622949c84', 'TITLE' => $title, 'PLACE' => $place, 'FILES' => $files, 'UPLOAD_FORM' => $upload_form, 'CREATE_FOLDER_FORM' => $create_folder_form)); }
function get_form_fields($id = NULL, $name = '', $image = '', $cure = '', $cure_price = 10, $immunization = '', $immunization_price = 5, $spread_rate = 12, $points_per_spread = 10, $enabled = 0) { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line(do_lang_tempcode('DISEASE'), do_lang_tempcode('DESCRIPTION_DISEASE'), 'name', $name, true)); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'image', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'url', $image, false)); handle_max_file_size($hidden, 'image'); $fields->attach(form_input_line(do_lang_tempcode('CURE'), do_lang_tempcode('DESCRIPTION_CURE'), 'cure', $cure, true)); $fields->attach(form_input_line(do_lang_tempcode('CURE_PRICE'), '', 'cure_price', strval($cure_price), true)); $fields->attach(form_input_line(do_lang_tempcode('IMMUNIZATION'), do_lang_tempcode('DESCRIPTION_IMMUNIZATION'), 'immunization', $immunization, true)); $fields->attach(form_input_line(do_lang_tempcode('IMMUNIZATION_PRICE'), '', 'immunization_price', strval($immunization_price), true)); $fields->attach(form_input_line(do_lang_tempcode('SPREAD_RATE'), do_lang_tempcode('DESCRIPTION_SPREAD_RATE'), 'spread_rate', strval($spread_rate), true)); $fields->attach(form_input_line(do_lang_tempcode('POINTS_PER_SPREAD'), do_lang_tempcode('DESCRIPTION_POINTS_PER_SPREAD'), 'points_per_spread', strval($points_per_spread), true)); $fields->attach(form_input_tick(do_lang_tempcode('DISEASE_ENABLED'), do_lang_tempcode('DESCRIPTION_DISEASE_ENABLED'), 'enabled', $enabled == 1)); return array($fields, $hidden); }
/** * Get tempcode for a post template adding/editing form. * * @param SHORT_TEXT The emoticon code * @param SHORT_TEXT The theme image code * @param integer The relevance level of the emoticon * @range 0 4 * @param BINARY Whether the emoticon is usable as a topic emoticon * @param BINARY Whether this may only be used by privileged members * @return array A pair: The input fields, Hidden fields */ function get_form_fields($code = ':-]', $theme_img_code = '', $relevance_level = 1, $use_topics = 1, $is_special = 0) { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('CODE'), do_lang_tempcode('DESCRIPTION_EMOTICON_CODE'), 'code', $code, true)); if (get_base_url() == get_forum_base_url()) { $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); handle_max_file_size($hidden, 'image'); } require_code('themes2'); $ids = get_all_image_ids_type('ocf_emoticons', false, $GLOBALS['FORUM_DB']); $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'theme_img_code', $ids, NULL, $theme_img_code, NULL, true, $GLOBALS['FORUM_DB'])); $list = new ocp_tempcode(); for ($i = 0; $i <= 4; $i++) { $list->attach(form_input_list_entry(strval($i), $i == $relevance_level, do_lang_tempcode('EMOTICON_RELEVANCE_LEVEL_' . strval($i)))); } $fields->attach(form_input_list(do_lang_tempcode('RELEVANCE_LEVEL'), do_lang_tempcode('DESCRIPTION_RELEVANCE_LEVEL'), 'relevance_level', $list)); $fields->attach(form_input_tick(do_lang_tempcode('USE_TOPICS'), do_lang_tempcode('DESCRIPTION_USE_TOPICS'), 'use_topics', $use_topics == 1)); $fields->attach(form_input_tick(do_lang_tempcode('EMOTICON_IS_SPECIAL'), do_lang_tempcode('DESCRIPTION_EMOTICON_IS_SPECIAL'), 'is_special', $is_special == 1)); return array($fields, $hidden); }
/** * Get tempcode for a catalogue category adding/editing form. * * @param ?ID_TEXT The name of the catalogue the category is in (NULL: detect) * @param SHORT_TEXT The title of the category * @param LONG_TEXT Description for the category * @param LONG_TEXT Admin notes * @param ?AUTO_LINK The ID of the parent category (NULL: no parent) (-1: arbitrary default) * @param ?AUTO_LINK The ID of this category (NULL: we're adding, not editing) * @param URLPATH The rep-image for the catalogue category * @param integer The number of days before expiry (lower limit) * @param integer The number of days before expiry (higher limit) * @param ?AUTO_LINK The expiry category (NULL: do not expire) * @return array A pair: the tempcode for the visible fields, and the tempcode for the hidden fields */ function get_form_fields($catalogue_name = NULL, $title = '', $description = '', $notes = '', $parent_id = -1, $id = NULL, $rep_image = '', $move_days_lower = 30, $move_days_higher = 60, $move_target = NULL) { if (is_null($catalogue_name)) { $catalogue_name = get_param('catalogue_name', is_null($id) ? false : $GLOBALS['SITE_DB']->query_value('catalogues_categories', 'c_name', array('id' => $id))); } if ($parent_id == -1) { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'parent_id'; $NON_CANONICAL_PARAMS[] = 'title'; $NON_CANONICAL_PARAMS[] = 'notes'; $parent_id = get_param_integer('parent_id', -1); $title = get_param('title', $title); $notes = get_param('notes', $notes); } $fields = new ocp_tempcode(); require_code('form_templates'); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('catalogue_name', $catalogue_name)); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, false)); if (get_value('disable_staff_notes') !== '1') { $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false)); } handle_max_file_size($hidden, 'image'); $fields->attach(form_input_upload(do_lang_tempcode('REPRESENTATIVE_IMAGE'), do_lang_tempcode('DESCRIPTION_REPRESENTATIVE_IMAGE'), 'rep_image', false, $rep_image, NULL, true, str_replace(' ', '', get_option('valid_images')))); // Is the catalogue a tree? $is_tree = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_is_tree', array('c_name' => $catalogue_name)); if (is_null($is_tree)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } if ($is_tree == 1 && !is_null($parent_id)) { $fields->attach(form_input_tree_list(do_lang_tempcode('PARENT'), do_lang_tempcode('DESCRIPTION_PARENT'), 'parent_id', NULL, 'choose_catalogue_category', array('catalogue_name' => $catalogue_name), true, is_null($parent_id) || $parent_id == -1 ? '' : strval($parent_id))); } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => is_null($move_target), 'TITLE' => do_lang_tempcode('CLASSIFIED_ADS')))); $list = new ocp_tempcode(); $fields->attach(form_input_tree_list(do_lang_tempcode('EXPIRY_MOVE_TARGET'), do_lang_tempcode('DESCRIPTION_EXPIRY_MOVE_TARGET'), 'move_target', NULL, 'choose_catalogue_category', array('catalogue_name' => $catalogue_name), false, is_null($move_target) ? NULL : strval($move_target))); if (cron_installed()) { $fields->attach(form_input_integer(do_lang_tempcode('EXPIRY_MOVE_DAYS_LOWER'), do_lang_tempcode('DESCRIPTION_EXPIRY_MOVE_DAYS_LOWER'), 'move_days_lower', $move_days_lower, true)); $fields->attach(form_input_integer(do_lang_tempcode('EXPIRY_MOVE_DAYS_HIGHER'), do_lang_tempcode('DESCRIPTION_EXPIRY_MOVE_DAYS_HIGHER'), 'move_days_higher', $move_days_higher, true)); } // Permissions if (get_value('disable_cat_cat_perms') !== '1') { $fields->attach($this->get_permission_fields(is_null($id) ? '' : strval($id), NULL, is_null($id))); } return array($fields, $hidden); }
/** * Get form inputter. * * @param string The field name * @param string The field description * @param array The field details * @param ?string The actual current value of the field (NULL: none) * @param boolean Whether this is for a new entry * @return ?array A pair: The Tempcode for the input field, Tempcode for hidden fields (NULL: skip the field - it's not input) */ function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new) { if (strpos($actual_value, '::') !== false) { list($actual_value, ) = explode('::', $actual_value); } $say_required = $field['cf_required'] == 1 && ($actual_value == '' || is_null($actual_value)); $ffield = form_input_upload($_cf_name, $_cf_description, 'field_' . strval($field['id']), $say_required, $field['cf_required'] == 1 ? NULL : $actual_value); $hidden = new ocp_tempcode(); handle_max_file_size($hidden); return array($ffield, $hidden); }
/** * Get tempcode for a gallery adding/editing form. * * @param ID_TEXT The gallery codename * @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 (blank: 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 (NULL: pick statistically based on current usage of other galleries) * @param ?URLPATH The representative image of the gallery (NULL: none) * @param ?URLPATH Watermark (NULL: none) * @param ?URLPATH Watermark (NULL: none) * @param ?URLPATH Watermark (NULL: none) * @param ?URLPATH Watermark (NULL: none) * @param ?BINARY Whether rating is allowed (NULL: decide statistically, based on existing choices) * @param ?SHORT_INTEGER Whether comments are allowed (0=no, 1=yes, 2=review style) (NULL: decide statistically, based on existing choices) * @return array A pair: the tempcode for the visible fields, and the tempcode for the hidden fields */ function get_form_fields($name = '', $fullname = '', $description = '', $teaser = '', $notes = '', $parent_id = '', $accept_images = 1, $accept_videos = 1, $is_member_synched = 0, $flow_mode_interface = NULL, $rep_image = NULL, $watermark_top_left = NULL, $watermark_top_right = NULL, $watermark_bottom_left = NULL, $watermark_bottom_right = NULL, $allow_rating = NULL, $allow_comments = NULL) { list($allow_rating, $allow_comments, ) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, 1); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'cat'; $NON_CANONICAL_PARAMS[] = 'validated'; if (is_null($flow_mode_interface)) { $cnt = $GLOBALS['SITE_DB']->query_value('galleries', 'COUNT(*)'); if ($cnt < 5000) { $flow_mode_interface = intval(round($GLOBALS['SITE_DB']->query_value('galleries', 'AVG(flow_mode_interface)'))); // Determine default based on what is 'the norm' currently. Sometimes maths is beautiful :) } else { $flow_mode_interface = intval(round($GLOBALS['SITE_DB']->query_value('galleries', 'AVG(flow_mode_interface)', array('parent_id' => 'root')))); // Determine default based on what is 'the norm' currently. Sometimes maths is beautiful :) } } $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'fullname', $fullname, true)); if ($name != 'root') { $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'name', $name, true)); } $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, false)); if ($parent_id == '') { $parent_id = get_param('cat', ''); } if ($name != 'root') { $fields->attach(form_input_tree_list(do_lang_tempcode('PARENT'), do_lang_tempcode('DESCRIPTION_PARENT'), 'parent_id', NULL, 'choose_gallery', array('filter' => 'only_conventional_galleries', 'purity' => true, 'addable_filter' => true), true, $parent_id)); } $fields->attach(form_input_various_ticks(array(array(do_lang_tempcode('ACCEPT_IMAGES'), 'accept_images', $accept_images == 1, do_lang_tempcode('DESCRIPTION_ACCEPT_IMAGES')), array(do_lang_tempcode('ACCEPT_VIDEOS'), 'accept_videos', $accept_videos == 1, do_lang_tempcode('DESCRIPTION_ACCEPT_VIDEOS'))), new ocp_tempcode(), NULL, do_lang_tempcode('ACCEPTED_MEDIA_TYPES'))); $fields->attach(form_input_tick(do_lang_tempcode('FLOW_MODE_INTERFACE'), do_lang_tempcode('DESCRIPTION_FLOW_MODE_INTERFACE'), 'flow_mode_interface', $flow_mode_interface == 1)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $rep_image == '' && $teaser == '' && $is_member_synched == 0, 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_upload(do_lang_tempcode('REPRESENTATIVE_IMAGE'), do_lang_tempcode('DESCRIPTION_REPRESENTATIVE_IMAGE_GALLERY'), 'rep_image', false, $rep_image, NULL, true, str_replace(' ', '', get_option('valid_images')))); // Only show tease option if tease block being used $teaser_shows = false; $zones = find_all_zones(false, true); $pages = array(); foreach ($zones as $_zone) { $pages[$_zone[0]] = find_all_pages_wrap($_zone[0], true); } foreach ($pages as $zone => $under) { foreach ($under as $filename => $type) { if (substr(strtolower($filename), -4) == '.txt') { $matches = array(); $contents = file_get_contents(zone_black_magic_filterer((substr($type, 0, 15) == 'comcode_custom/' ? get_custom_file_base() : get_file_base()) . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/' . $type . '/' . $filename)); $fallback = get_file_base() . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/comcode/' . fallback_lang() . '/' . $filename; if (file_exists($fallback)) { $contents .= file_get_contents($fallback); } if (preg_match('#\\[block[^\\]]*\\]main_gallery_tease\\[/block\\]#', $contents, $matches) != 0) { $teaser_shows = true; } } } } if ($teaser_shows) { $fields->attach(form_input_line_comcode(do_lang_tempcode('TEASER'), do_lang_tempcode('DESCRIPTION_TEASER'), 'teaser', $teaser, false)); } $fields->attach(form_input_tick(do_lang_tempcode('IS_MEMBER_SYNCHED'), do_lang_tempcode('DESCRIPTION_IS_MEMBER_SYNCHED_GALLERY'), 'is_member_synched', $is_member_synched == 1)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => is_null($watermark_top_left) && is_null($watermark_top_right) && is_null($watermark_bottom_left) && is_null($watermark_bottom_right), 'TITLE' => do_lang_tempcode('WATERMARKING')))); $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('TOP_LEFT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('TOP_LEFT')), 'watermark_top_left', false, $watermark_top_left, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('TOP_RIGHT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('TOP_RIGHT')), 'watermark_top_right', false, $watermark_top_right, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('BOTTOM_LEFT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('BOTTOM_LEFT')), 'watermark_bottom_left', false, $watermark_bottom_left, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('BOTTOM_RIGHT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('BOTTOM_RIGHT')), 'watermark_bottom_right', false, $watermark_bottom_right, NULL, true, str_replace(' ', '', get_option('valid_images')))); $hidden = new ocp_tempcode(); handle_max_file_size($hidden, 'image'); require_code('feedback2'); $fields->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, NULL, false, $notes, $allow_comments == 2, true)); // Permissions $fields->attach($this->get_permission_fields($name, NULL, $name == '')); return array($fields, $hidden); }
/** * Get tempcode for a news category adding/editing form. * * @param SHORT_TEXT The title of the news category * @param SHORT_TEXT The news category image * @param LONG_TEXT Notes relating to the news category * @param ?MEMBER The owner of the news category (NULL: public) * @param ?AUTO_LINK The ID of this news category (NULL: we haven't added it yet) * @return array A pair: The input fields, Hidden fields */ function get_form_fields($title = '', $img = '', $notes = '', $owner = NULL, $category_id = NULL) { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line_comcode(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); if (get_base_url() == get_forum_base_url()) { $fields->attach(form_input_upload(do_lang_tempcode('IMAGE'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); handle_max_file_size($hidden, 'image'); } require_code('themes2'); $ids = get_all_image_ids_type('newscats'); $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'theme_img_code', $ids, NULL, $img, NULL, true)); if (!is_null($owner)) { $owner_username = $GLOBALS['FORUM_DRIVER']->get_username($owner); if (is_null($owner_username)) { $owner_username = do_lang('UNKNOWN'); } $fields->attach(form_input_line(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_OWNER'), 'owner', $owner_username, true)); } if (get_value('disable_staff_notes') !== '1') { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $notes == '', 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false)); } $fields->attach($this->get_permission_fields(is_null($category_id) ? '' : strval($category_id), NULL, $title == '')); return array($fields, $hidden); }
/** * Get tempcode for a post template adding/editing form. * * @param ?AUTO_LINK ID of category (NULL: new category) * @param SHORT_TEXT The title * @param SHORT_TEXT The theme image code * @param URLPATH URL to external feed to associate with this event type * @return array A pair: The input fields, Hidden fields */ function get_form_fields($id = NULL, $title = '', $logo = '', $external_feed = '') { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); require_code('themes2'); $ids = get_all_image_ids_type('calendar'); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'theme_img_code', $ids, NULL, $logo, NULL, true)); handle_max_file_size($hidden, 'image'); if (addon_installed('syndication_blocks')) { $fields->attach(form_input_line(do_lang_tempcode('EXTERNAL_FEED'), do_lang_tempcode('DESCRIPTION_EXTERNAL_FEED'), 'external_feed', $external_feed, false)); } else { $hidden->attach(form_input_hidden('external_feed', $external_feed)); } // Permissions $fields->attach($this->get_permission_fields(is_null($id) ? NULL : strval($id), NULL, $title == '')); return array($fields, $hidden); }
/** * The UI to get an addon from some source. * * @return tempcode The UI */ function addon_import() { $title = get_page_title('IMPORT_ADDON'); require_code('form_templates'); $required = false; $javascript = 'standardAlternateFields(\'file\',\'url\');'; $fields = new ocp_tempcode(); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', $required, NULL, NULL, true, 'tar')); $fields->attach(form_input_tree_list(do_lang_tempcode('DOWNLOAD'), do_lang_tempcode('DESCRIPTION_DOWNLOAD_OCPORTALCOM'), 'url', NULL, 'choose_ocportalcom_addon', array(), $required)); $hidden = new ocp_tempcode(); handle_max_file_size($hidden); $submit_name = do_lang_tempcode('IMPORT_ADDON'); $post_url = build_url(array('page' => '_SELF', 'type' => '_addon_import', 'uploading' => 1), '_SELF'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('ADDONS')))); $text = new ocp_tempcode(); require_code('files2'); $max = floatval(get_max_file_size()) / floatval(1024 * 1024); if ($max < 30.0) { $config_url = get_upload_limit_config_url(); $text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url)))); } return do_template('FORM_SCREEN', array('_GUID' => '7f50130c5a46e0f6e8a95e936ce7bf47', 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'SUBMIT_NAME' => $submit_name, 'FIELDS' => $fields, 'TEXT' => $text, 'URL' => $post_url, 'JAVASCRIPT' => $javascript)); }
/** * The UI for managing super debranding. * * @return tempcode The UI */ function misc() { $title = get_page_title('SUPER_DEBRAND'); require_code('form_templates'); $rebrand_name = get_value('rebrand_name'); if (is_null($rebrand_name)) { $rebrand_name = 'ocPortal'; } $rebrand_base_url = get_value('rebrand_base_url'); if (is_null($rebrand_base_url)) { $rebrand_base_url = 'http://ocportal.com'; } $company_name = get_value('company_name'); if (is_null($company_name)) { $company_name = 'ocProducts'; } $keyboard_map = file_exists(get_file_base() . '/pages/comcode/' . get_site_default_lang() . '/keymap.txt') ? file_get_contents(get_file_base() . '/pages/comcode/' . get_site_default_lang() . '/keymap.txt') : file_get_contents(get_file_base() . '/pages/comcode/' . fallback_lang() . '/keymap.txt'); if (file_exists(get_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/keymap.txt')) { $keyboard_map = file_get_contents(get_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/keymap.txt'); } if (file_exists(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/website.txt')) { $adminguide = file_get_contents(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/website.txt'); } else { $adminguide = do_lang('ADMINGUIDE_DEFAULT_TRAINING'); } if (file_exists(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/start.txt')) { $start_page = file_get_contents(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/start.txt'); } elseif (file_exists(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt')) { $start_page = file_exists(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt') ? file_get_contents(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt') : file_get_contents(get_file_base() . '/adminzone/pages/comcode/' . fallback_lang() . '/start.txt'); } else { $start_page = do_lang('REBRAND_FRONT_PAGE'); } $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('REBRAND_NAME'), do_lang_tempcode('DESCRIPTION_REBRAND_NAME'), 'rebrand_name', $rebrand_name, true)); $fields->attach(form_input_line(do_lang_tempcode('REBRAND_BASE_URL'), do_lang_tempcode('DESCRIPTION_BRAND_BASE_URL', escape_html('docs' . strval(ocp_version()))), 'rebrand_base_url', $rebrand_base_url, true)); $fields->attach(form_input_line(do_lang_tempcode('COMPANY_NAME'), '', 'company_name', $company_name, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('ADMINGUIDE'), do_lang_tempcode('DESCRIPTION_ADMINGUIDE'), 'adminguide', $adminguide, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('ADMINSTART_PAGE'), do_lang_tempcode('DESCRIPTION_ADMINSTART_PAGE'), 'start_page', $start_page, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('KEYBOARD_MAP'), '', 'keyboard_map', $keyboard_map, true)); $fields->attach(form_input_tick(do_lang_tempcode('DELETE_UN_PC'), do_lang_tempcode('DESCRIPTION_DELETE_UN_PC'), 'churchy', false)); $fields->attach(form_input_tick(do_lang_tempcode('SHOW_DOCS'), do_lang_tempcode('DESCRIPTION_SHOW_DOCS'), 'show_docs', get_option('show_docs') == '1')); $fields->attach(form_input_upload(do_lang_tempcode('FAVICON'), do_lang_tempcode('DESCRIPTION_FAVICON'), 'favicon', false, find_theme_image('favicon'), NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_upload(do_lang_tempcode('APPLEICON'), do_lang_tempcode('DESCRIPTION_APPLEICON'), 'appleicon', false, find_theme_image('appleicon'), NULL, true, str_replace(' ', '', get_option('valid_images')))); if (addon_installed('ocf_avatars')) { $fields->attach(form_input_upload(do_lang_tempcode('SYSTEM_AVATAR'), do_lang_tempcode('DESCRIPTION_SYSTEM_AVATAR'), 'system_avatar', false, find_theme_image('ocf_default_avatars/default_set/ocp_fanatic'), NULL, true, str_replace(' ', '', get_option('valid_images')))); } $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF'); $submit_name = do_lang_tempcode('SUPER_DEBRAND'); return do_template('FORM_SCREEN', array('HIDDEN' => '', 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'TEXT' => do_lang_tempcode('WARNING_SUPER_DEBRAND_MAJOR_CHANGES'), 'SUBMIT_NAME' => $submit_name)); }
function get_form_fields($id = NULL, $name = '', $category = '', $image = '', $price = 10, $enabled = 1) { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line(do_lang_tempcode('GIFT'), do_lang_tempcode('DESCRIPTION_GIFT'), 'name', $name, true)); $fields->attach(form_input_line(do_lang_tempcode('CATEGORY'), do_lang_tempcode('DESCRIPTION_GIFT_CATEGORY'), 'category', $category, true)); $fields->attach(form_input_upload(do_lang_tempcode('IMAGE'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'image', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'url', $image, false)); handle_max_file_size($hidden, 'image'); $fields->attach(form_input_line(do_lang_tempcode('PRICE'), '', 'price', strval($price), true)); $fields->attach(form_input_tick(do_lang_tempcode('GIFT_ENABLED'), do_lang_tempcode('DESCRIPTION_GIFT_ENABLED'), 'enabled', $enabled == 1)); return array($fields, $hidden); }
/** * Get tempcode for a theme image adding/editing form. * * @param ID_TEXT The theme the theme image is in * @param LANGUAGE_NAME The language the theme image is for * @param SHORT_TEXT The theme image ID * @param URLPATH The URL to the theme image * @return array A pair: the tempcode for the visible fields, and the tempcode for the hidden fields */ function get_image_form_fields($theme, $lang, $id = '', $path = '') { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); $hidden->attach(form_input_hidden('theme', $theme)); $hidden->attach(form_input_hidden('lang', $lang)); $fields->attach(form_input_line(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_THEME_IMAGE_NAME'), 'id', $id, true)); /* $list=combo_get_image_paths($path,get_base_url().'/themes/'.rawurlencode($theme).'/images/',get_file_base().'/themes/'.filter_naughty($theme).'/images/'); $list->attach(combo_get_image_paths($path,get_base_url().'/themes/'.rawurlencode($theme).'/images_custom/',get_file_base().'/themes/'.filter_naughty($theme).'/images_custom/')); if ($theme!='default') { $list->attach(combo_get_image_paths($path,get_base_url().'/themes/default/images/',get_file_base().'/themes/default/images/')); $list->attach(combo_get_image_paths($path,get_base_url().'/themes/default/images_custom/',get_file_base().'/themes/default/images_custom/')); }*/ handle_max_file_size($hidden, 'image'); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); // $fields->attach(form_input_radio(do_lang_tempcode('CHOOSE'),do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'),$list)); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'path', $path, false)); return array($fields, $hidden); }
/** * Get tempcode for a zone adding/editing form. * * @param boolean Whether the zone editor will be used * @param SHORT_TEXT The zone title * @param ID_TEXT The zones default page * @param SHORT_TEXT The header text * @param ?ID_TEXT The theme (NULL: no override) * @param BINARY Whether the zone is wide * @param BINARY Whether the zone requires a session for pages to be used * @param BINARY Whether the zone in displayed in the menu coded into some themes * @param ?ID_TEXT Name of the zone (NULL: unknown) * @return array A tuple: The tempcode for the fields, hidden fields, and extra Javascript */ function get_form_fields($in_zone_editor = false, $title = '', $default_page = 'start', $header_text = '', $theme = NULL, $wide = 0, $require_session = 0, $displayed_in_menu = 1, $zone = NULL) { require_lang('permissions'); $javascript = ''; $fields = ''; $hidden = new ocp_tempcode(); require_code('form_templates'); $fields .= static_evaluate_tempcode(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); $fields .= static_evaluate_tempcode(form_input_line(do_lang_tempcode('DEFAULT_PAGE'), do_lang_tempcode('DESCRIPTION_DEFAULT_PAGE'), 'default_page', $default_page, true)); $fields .= static_evaluate_tempcode(form_input_line(do_lang_tempcode('HEADER_TEXT'), do_lang_tempcode('DESCRIPTION_HEADER_TEXT'), 'header_text', $header_text, false)); $list = ''; $list .= static_evaluate_tempcode(form_input_list_entry('0', $wide == 0, do_lang_tempcode('NO'))); $list .= static_evaluate_tempcode(form_input_list_entry('1', $wide == 1, do_lang_tempcode('YES'))); $list .= static_evaluate_tempcode(form_input_list_entry('-1', is_null($wide), do_lang_tempcode('RELY_FORUMS'))); $fields .= static_evaluate_tempcode(form_input_list(do_lang_tempcode('WIDE'), do_lang_tempcode('DESCRIPTION_WIDE'), 'wide', make_string_tempcode($list))); $fields .= static_evaluate_tempcode(form_input_tick(do_lang_tempcode('DISPLAYED_IN_MENU'), do_lang_tempcode('DESCRIPTION_DISPLAYED_IN_MENU'), 'displayed_in_menu', $displayed_in_menu == 1)); // Theme require_code('themes2'); $entries = nice_get_themes($theme, false, true); $fields .= static_evaluate_tempcode(form_input_list(do_lang_tempcode('THEME'), do_lang_tempcode(get_forum_type() == 'ocf' ? '_DESCRIPTION_THEME_OCF' : '_DESCRIPTION_THEME', substr(preg_replace('#[^A-Za-z\\d]#', '_', get_site_name()), 0, 80)), 'theme', $entries)); $fields .= static_evaluate_tempcode(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields .= static_evaluate_tempcode(form_input_tick(do_lang_tempcode('REQUIRE_SESSION'), do_lang_tempcode('DESCRIPTION_REQUIRE_SESSION'), 'require_session', $require_session == 1)); if (!$in_zone_editor && !is_null($zone) && addon_installed('zone_logos')) { // Logos handle_max_file_size($hidden, 'image'); require_code('themes2'); $themes = find_all_themes(); foreach ($themes as $theme => $theme_name) { $fields .= static_evaluate_tempcode(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('THEME_LOGO', escape_html($theme_name))))); $fields .= static_evaluate_tempcode(form_input_upload(do_lang_tempcode('IMAGE'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'logo_upload_' . $theme, false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); require_code('themes2'); $ids = get_all_image_ids_type('logo', false, NULL, $theme); $current_logo = 'logo/' . $zone . '-logo'; if (!in_array($current_logo, $ids)) { $current_logo = 'logo/-logo'; } foreach ($ids as $id) { $test = find_theme_image($id, true, false, $theme); if ($test == '') { $test = find_theme_image($id, false, false, 'default'); } if ($test == '' && $id == $current_logo) { $current_logo = $ids[0]; } } $fields .= static_evaluate_tempcode(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'logo_select_' . $theme, $ids, NULL, $current_logo, NULL, true, NULL, $theme)); $javascript .= 'standardAlternateFields(\'logo_upload_' . $theme . '\',\'logo_select_' . $theme . '*\');'; } } if ($zone !== '') { $fields .= static_evaluate_tempcode(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('PERMISSIONS')))); // Permissions $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); foreach ($groups as $id => $name) { if (in_array($id, $admin_groups)) { continue; } $perhaps = is_null($zone) ? true : $GLOBALS['SITE_DB']->query_value_null_ok('group_zone_access', 'zone_name', array('zone_name' => $zone, 'group_id' => $id)); $fields .= static_evaluate_tempcode(form_input_tick(do_lang_tempcode('ACCESS_FOR', escape_html($name)), do_lang_tempcode('DESCRIPTION_ACCESS_FOR', escape_html($name)), 'access_' . strval($id), !is_null($perhaps))); } } return array(make_string_tempcode($fields), $hidden, $javascript); }
/** * Function to process the file upload process */ function incoming_uploads_script() { $is_uploaded = false; if (!file_exists(get_custom_file_base() . '/uploads/incoming')) { @mkdir(get_custom_file_base() . '/uploads/incoming', 0777); fix_permissions(get_custom_file_base() . '/uploads/incoming', 0777); sync_file(get_custom_file_base() . '/uploads/incoming'); } $savename = 'uploads/incoming/' . uniqid('', true) . '.dat'; if (array_key_exists('file', $_FILES)) { if (is_uploaded_file($_FILES['file']['tmp_name'])) { $is_uploaded = true; } else { header('HTTP/1.1 500 File Upload Error'); @error_log('ocPortal: ' . do_lang('ERROR_UPLOADING_' . strval($_FILES['file']['error'])), 0); exit('ocPortal: ' . do_lang('ERROR_UPLOADING_' . strval($_FILES['file']['error']))); } $name = $_FILES['file']['name']; if ($is_uploaded) { @move_uploaded_file($_FILES['file']['tmp_name'], get_custom_file_base() . '/' . $savename) or intelligent_write_error(get_custom_file_base() . '/' . $savename); } } elseif (post_param('name', '') != '') { header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past $name = post_param('name'); // Read binary input stream and append it to temp file $in = fopen('php://input', 'rb'); if ($in !== false) { // Open temp file $out = fopen($savename, 'wb'); if ($out !== false) { $is_uploaded = true; do { $buff = fread($in, 4096); fwrite($out, $buff); } while (!feof($out)); fclose($out); } fclose($in); } } if ($is_uploaded) { $max_length = 255; $field_type_test = $GLOBALS['SITE_DB']->query_value('db_meta', 'm_type', array('m_name' => 'i_orig_filename')); if ($field_type_test == 'ID_TEXT') { $max_length = 80; } // Legacy $name = substr($name, max(0, strlen($name) - $max_length)); header('Content-type: text/plain; charset=' . get_charset()); require_code('files'); if (get_param_integer('base64', 0) == 1) { $new = base64_decode(file_get_contents(get_custom_file_base() . '/' . $savename)); $myfile = @fopen(get_custom_file_base() . '/' . $savename, 'wb') or intelligent_write_error(get_custom_file_base() . '/' . $savename); fwrite($myfile, $new); fclose($myfile); } fix_permissions(get_custom_file_base() . '/' . $savename); sync_file(get_custom_file_base() . '/' . $savename); $member_id = get_member(); $file_db_id = $GLOBALS['SITE_DB']->query_insert('incoming_uploads', array('i_submitter' => $member_id, 'i_date_and_time' => time(), 'i_orig_filename' => $name, 'i_save_url' => $savename), true, false); // File is valid, and was successfully uploaded. Now see if there is any metadata to surface from the file. require_code('images'); $outa = array(); if (is_image($name)) { require_code('exif'); $outa += get_exif_data(get_custom_file_base() . '/' . $savename); } $outa['upload_id'] = strval($file_db_id); $outa['upload_name'] = $name; $outa['upload_savename'] = $savename; @ini_set('ocproducts.xss_detect', '0'); $outstr = '{'; $done = 0; foreach ($outa as $key => $val) { if (is_float($val)) { $val = float_to_raw_string($val); } elseif (is_integer($val)) { $val = strval($val); } if (is_string($val) && $val != '') { $val = str_replace(chr(0), '', $val); if ($done != 0) { $outstr .= ', '; } $outstr .= '"' . str_replace(chr(10), '\\n', addcslashes($key, "\\\\'\"&\n\r<>")) . '": "' . str_replace(chr(10), '\\n', addcslashes($val, "\\\\'\"&\n\r<>")) . '"'; $done++; } } $outstr .= '}'; echo $outstr; } else { //header('Content-type: text/plain'); @print('No file ('.serialize($_FILES).')'); header('HTTP/1.1 500 File Upload Error'); // Test harness $title = get_page_title('UPLOAD'); $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_upload(do_lang_tempcode('FILE'), '', 'file', true, NULL, NULL, false)); $hidden = new ocp_tempcode(); $out2 = globalise(do_template('FORM_SCREEN', array('TITLE' => $title, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'), 'TEXT' => '', 'HIDDEN' => $hidden, 'URL' => find_script('incoming_uploads', true), 'FIELDS' => $fields)), NULL, '', true); $out2->evaluate_echo(); } exit; }
/** * The UI for recommending the site. * * @return tempcode The UI. */ function gui() { require_code('form_templates'); global $EXTRA_HEAD; $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />'); // XHTMLXHTML global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'page_title'; $NON_CANONICAL_PARAMS[] = 'subject'; $NON_CANONICAL_PARAMS[] = 's_message'; $NON_CANONICAL_PARAMS[] = 'from'; $NON_CANONICAL_PARAMS[] = 'title'; $NON_CANONICAL_PARAMS[] = 'ocp'; $page_title = get_param('page_title', NULL, true); $submit_name = !is_null($page_title) ? make_string_tempcode($page_title) : do_lang_tempcode('SEND'); $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF', NULL, true); $hidden = new ocp_tempcode(); $name = post_param('name', is_guest() ? '' : $GLOBALS['FORUM_DRIVER']->get_username(get_member())); $recommender_email_address = post_param('recommender_email_address', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())); $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('YOUR_NAME'), '', 'name', $name, true)); $fields->attach(form_input_email(do_lang_tempcode('YOUR_EMAIL_ADDRESS'), '', 'recommender_email_address', $recommender_email_address, true)); $already = array(); foreach ($_POST as $key => $email_address) { if (substr($key, 0, 14) != 'email_address_') { continue; } if (get_magic_quotes_gpc()) { $email_address = stripslashes($email_address); } $already[] = $email_address; } if (is_guest()) { $fields->attach(form_input_email(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), '', 'email_address_0', array_key_exists(0, $already) ? $already[0] : '', true)); } else { $fields->attach(form_input_line_multi(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), do_lang_tempcode('THEIR_ADDRESS'), 'email_address_', $already, 1, NULL, 'email')); } if (may_use_invites() && get_forum_type() == 'ocf' && !is_guest()) { $invites = get_num_invites(get_member()); if ($invites > 0) { require_lang('ocf'); $invite = count($_POST) == 0 ? true : post_param_integer('invite', 0) == 1; $fields->attach(form_input_tick(do_lang_tempcode('USE_INVITE'), do_lang_tempcode('USE_INVITE_DESCRIPTION', $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) ? do_lang('NA_EM') : integer_format($invites)), 'invite', $invite)); } } $message = post_param('message', NULL); $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT', get_site_name()), true); if (is_null($message)) { $message = get_param('s_message', '', true); if ($message == '') { $from = get_param('from', NULL, true); if (!is_null($from)) { $resource_title = get_param('title', '', true); if ($resource_title == '') { $downloaded_at_link = http_download_file($from, 3000, false); if (is_string($downloaded_at_link)) { $matches = array(); if (preg_match('#\\s*<title[^>]*\\s*>\\s*(.*)\\s*\\s*<\\s*/title\\s*>#mi', $downloaded_at_link, $matches) != 0) { $resource_title = trim(str_replace('–', '-', str_replace('—', '-', @html_entity_decode($matches[1], ENT_QUOTES, get_charset())))); $resource_title = preg_replace('#^' . str_replace('#', '\\#', preg_quote(get_site_name())) . ' - #', '', $resource_title); $resource_title = preg_replace('#\\s+[^\\d\\s][^\\d\\s]?[^\\d\\s]?\\s+' . str_replace('#', '\\#', preg_quote(get_site_name())) . '$#i', '', $resource_title); } } } if ($resource_title == '') { $resource_title = do_lang('THIS'); // Could not find at all, so say 'this' } else { $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT_SPECIFIC', get_site_name(), $resource_title), true); } $message = do_lang('FOUND_THIS_ON', get_site_name(), comcode_escape($from), comcode_escape($resource_title)); } } if (get_param_integer('ocp', 0) == 1) { $message = do_lang('RECOMMEND_OCPORTAL'); } } $text = is_null($page_title) ? do_lang_tempcode('RECOMMEND_SITE_TEXT') : new ocp_tempcode(); if (!is_null(get_param('from', NULL, true))) { if (is_null($page_title)) { $title = get_page_title('RECOMMEND_LINK'); } else { $title = get_page_title($page_title, false); } $submit_name = do_lang_tempcode('SEND'); $text = do_lang_tempcode('RECOMMEND_AUTO_TEXT', get_site_name()); $need_message = true; } else { if (is_null($page_title)) { $title = get_page_title('_RECOMMEND_SITE', true, array(escape_html(get_site_name()))); } else { $title = get_page_title($page_title, false); } $hidden->attach(form_input_hidden('wrap_message', '1')); $need_message = false; } //add an upload CSV contacts file field $_help_url = build_url(array('page' => 'recommend_help'), get_page_zone('recommend_help')); $help_url = $_help_url->evaluate(); if (get_value('disable_csv_recommend') !== '1' && !is_guest()) { $fields->attach(form_input_upload(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('UPLOAD')), do_lang_tempcode('DESCRIPTION_UPLOAD_CSV_FILE', escape_html($help_url)), 'upload', false, NULL, NULL, false)); } handle_max_file_size($hidden); $fields->attach(form_input_line(do_lang_tempcode('SUBJECT'), '', 'subject', $subject, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('RECOMMEND_SUP_MESSAGE'), 'message', $message, $need_message)); if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $fields->attach(form_input_captcha()); $text->attach(' '); $text->attach(do_lang_tempcode('FORM_TIME_SECURITY')); } } $hidden->attach(form_input_hidden('comcode__message', '1')); if (get_value('disable_csv_recommend') !== '1' && !is_guest()) { $javascript = 'standardAlternateFields(\'upload\',\'email_address_0\');'; } else { $javascript = ''; } $javascript .= function_exists('captcha_ajax_check') ? captcha_ajax_check() : ''; return do_template('FORM_SCREEN', array('_GUID' => '08a538ca8d78597b0417f464758a59fd', 'JAVASCRIPT' => $javascript, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name, 'TEXT' => $text)); }
/** * Get form inputter. * * @param string The field name * @param string The field description * @param array The field details * @param ?string The actual current value of the field (NULL: none) * @param boolean Whether this is for a new entry * @return ?array A pair: The Tempcode for the input field, Tempcode for hidden fields (NULL: skip the field - it's not input) */ function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new) { $say_required = $field['cf_required'] == 1 && ($actual_value == '' || is_null($actual_value)); require_code('galleries'); $ffield = form_input_upload($_cf_name, $_cf_description, 'field_' . strval($field['id']), $say_required, $field['cf_required'] == 1 ? NULL : $actual_value, NULL, true, get_allowed_video_file_types()); $hidden = new ocp_tempcode(); handle_max_file_size($hidden); return array($ffield, $hidden); }
/** * The UI to send a newsletter. * * @param LONG_TEXT Default newsletter to put in * @return tempcode The UI */ function send_gui($_existing = '') { // If this is a periodic newsletter, we make some changes to the regular // language strings. $periodic_action_raw = post_param('periodic_choice', ''); $periodic_subject = ''; $defaults = mixed(); switch (preg_replace('#\\_\\d+$#', '', $periodic_action_raw)) { case 'remove_existing': // Remove whatever is already set. We don't need any changes for // this, but we do need a hidden form field. $periodic_action = 'remove'; break; case 'replace_existing': // Make the current newsletter periodic. This requires language // fiddling. $periodic_action = 'replace'; $periodic_subject = do_lang('PERIODIC_SUBJECT_HELP'); $periodic_id = intval(preg_replace('#^[^\\d]+#', '', $periodic_action_raw)); $_defaults = $GLOBALS['SITE_DB']->query_select('newsletter_periodic', array('*'), array('id' => $periodic_id), '', 1); if (!array_key_exists(0, $_defaults)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $defaults = $_defaults[0]; break; case 'make_periodic': // Make the current newsletter periodic. This requires language // fiddling. $periodic_action = 'make'; $periodic_subject = do_lang('PERIODIC_SUBJECT_HELP'); break; case 'no_change': default: // The default action is to leave the current settings as-is. $periodic_action = 'none'; break; } $title = get_page_title('NEWSLETTER_SEND'); $lang = choose_language($title); if (is_object($lang)) { return $lang; } $comcode_given = $_existing != '' && strpos($_existing, '<html') !== false; $_existing = post_param('message', $_existing); if ($_existing == '') { $from_news = get_param_integer('from_news', -1); if ($from_news != -1 && addon_installed('news')) { $rows = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('id' => $from_news), 'ORDER BY id DESC', 1); if (!array_key_exists(0, $rows)) { require_lang('news'); return warn_screen(get_page_title('NEWS'), do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $_existing = get_translated_text($myrow['news_article'], NULL, $lang); if ($_existing == '') { $_existing = get_translated_text($myrow['news'], NULL, $lang); } } $existing = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f42', 'CONTENT' => $_existing, 'LANG' => $lang)); } else { $default = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f44', 'CONTENT' => $_existing, 'LANG' => $lang)); if (strpos($default->evaluate(), '<html') !== false) { if ($comcode_given) { $default = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f46', 'CONTENT' => comcode_to_tempcode($_existing), 'LANG' => $lang)); } $existing = $default; } else { $existing = make_string_tempcode($_existing); } } $post_url = build_url(array('page' => '_SELF', 'type' => 'confirm', 'old_type' => get_param('type', '')), '_SELF'); $submit_name = do_lang_tempcode('PREVIEW'); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('lang', $lang)); // Build up form $fields = new ocp_tempcode(); require_code('form_templates'); $default_subject = get_option('newsletter_title'); if (!is_null($defaults)) { $default_subject = $defaults['np_subject']; } if ($periodic_action != 'make' && $periodic_action != 'replace') { $default_subject .= ' - ' . get_timezoned_date(time(), false, false, false, true); } $default_subject = post_param('subject', $default_subject); $fields->attach(form_input_line_comcode(do_lang_tempcode('SUBJECT'), do_lang_tempcode('NEWSLETTER_DESCRIPTION_TITLE', $periodic_subject), 'subject', $default_subject, true)); $in_full = post_param_integer('in_full', 0); $chosen_categories = post_param('chosen_categories', ''); if ($periodic_action == 'make' || $periodic_action == 'replace') { // We are making a periodic newsletter. This means we need to pass // through the chosen categories if (!is_null($defaults)) { $chosen_categories = $defaults['np_message']; $in_full = $defaults['np_in_full']; $fields->attach(form_input_tick(do_lang_tempcode('EMBED_FULL_ARTICLES'), do_lang_tempcode('DESCRIPTION_EMBED_FULL_ARTICLES'), 'in_full', $in_full == 1)); $fields->attach(form_input_huge(do_lang_tempcode('NEWSLETTER_CONTENT'), do_lang('NEWSLETTER_CONTENT_SELECT'), 'chosen_categories', $chosen_categories, true)); } else { $hidden->attach(form_input_hidden('chosen_categories', $chosen_categories)); $hidden->attach(form_input_hidden('in_full', strval($in_full))); } $hidden->attach(form_input_hidden('cutoff_day', post_param('cutoff_day'))); $hidden->attach(form_input_hidden('cutoff_month', post_param('cutoff_month'))); $hidden->attach(form_input_hidden('cutoff_year', post_param('cutoff_year'))); $hidden->attach(form_input_hidden('cutoff_hour', post_param('cutoff_hour'))); $hidden->attach(form_input_hidden('cutoff_minute', post_param('cutoff_minute'))); $hidden->attach(form_input_hidden('message', $existing->evaluate())); } else { $hidden->attach(form_input_hidden('in_full', strval($in_full))); if (strpos($existing->evaluate(), '<html') === false) { $fields->attach(form_input_huge_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('DESCRIPTION_MESSAGE_NEWSLETTER'), 'message', $existing->evaluate(), true)); } else { $fields->attach(form_input_huge(do_lang_tempcode('MESSAGE'), do_lang_tempcode('DESCRIPTION_MESSAGE_NEWSLETTER'), 'message', $existing->evaluate(), true)); } } if (addon_installed('calendar') && $periodic_action == 'none' && cron_installed()) { $fields->attach(form_input_date__scheduler(do_lang_tempcode('DEFER_TIME'), do_lang_tempcode('DESCRIPTION_DEFER_TIME'), 'schedule', true, true, true)); } $from_email = post_param('from_email', get_option('staff_address')); if (!is_null($defaults)) { $from_email = post_param('from_email', $defaults['np_from_email']); } $fields->attach(form_input_email(do_lang_tempcode('FROM_EMAIL'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_FROM_EMAIL'), 'from_email', $from_email, true)); $from_name = post_param('from_name', get_site_name()); if (!is_null($defaults)) { $from_name = post_param('from_name', $defaults['np_from_name']); } $fields->attach(form_input_line(do_lang_tempcode('FROM_NAME'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_FROM_NAME'), 'from_name', $from_name, true)); $_html_only = post_param_integer('html_only', NULL); if (is_null($_html_only)) { $html_only = strpos($existing->evaluate(), '<html') !== false; if (!is_null($defaults)) { $html_only = $defaults['np_html_only']; } } else { $html_only = $_html_only == 1; } if (get_value('force_html_only') === '1') { $hidden->attach(form_input_hidden('html_only', '1')); } else { $fields->attach(form_input_tick(do_lang_tempcode('HTML_ONLY'), do_lang_tempcode('DESCRIPTION_HTML_ONLY'), 'html_only', $html_only)); } $l = new ocp_tempcode(); $priority = post_param_integer('priority', 3); if (!is_null($defaults)) { $priority = post_param_integer('priority', $defaults['np_priority']); } for ($i = 1; $i <= 5; $i++) { $l->attach(form_input_list_entry(strval($i), $i == $priority, do_lang_tempcode('PRIORITY_' . strval($i)))); } $fields->attach(form_input_list(do_lang_tempcode('PRIORITY'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_PRIORITY'), 'priority', $l)); // Where to send to $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('CHOOSE_SEND_TO')))); $newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('*')); foreach ($newsletters as $newsletter) { $level = post_param_integer(strval($newsletter['id']), post_param_integer('level', -1)); $c4 = $this->count_level($newsletter['id'], 4, $lang); $c3 = $this->count_level($newsletter['id'], 3, $lang); $c2 = $this->count_level($newsletter['id'], 2, $lang); $c1 = $this->count_level($newsletter['id'], 1, $lang); if ($c1 != 0) { $newsletter_title = get_translated_text($newsletter['title']); $newsletter_description = get_translated_text($newsletter['description']); if ($c1 == $c2 && $c1 == $c3 && $c1 == $c4) { $fields->attach(form_input_tick(do_lang_tempcode('NEWSLETTER_PREFIX', escape_html($newsletter_title)), do_lang_tempcode('DESCRIPTION_NOSUBSCRIPTION_LEVEL', escape_html(integer_format($c4)), escape_html($newsletter_description)), strval($newsletter['id']), $level >= 1, NULL, '4')); } else { $l = new ocp_tempcode(); $l->attach(form_input_list_entry('0', $level == 0, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_0_ALT'), do_lang_tempcode('NUM_READERS', integer_format(0))))); $l->attach(form_input_list_entry('1', $level == 1, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_1'), do_lang_tempcode('NUM_READERS', integer_format($c1))))); $l->attach(form_input_list_entry('2', $level == 2, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_2'), do_lang_tempcode('NUM_READERS', integer_format($c2))))); $l->attach(form_input_list_entry('3', $level == 3, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_3'), do_lang_tempcode('NUM_READERS', integer_format($c3))))); $l->attach(form_input_list_entry('4', $level == 4, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_4'), do_lang_tempcode('NUM_READERS', integer_format($c4))))); $fields->attach(form_input_list(do_lang_tempcode('SUBSCRIPTION_LEVEL_FOR', escape_html($newsletter_title)), do_lang_tempcode('DESCRIPTION_SUBSCRIPTION_LEVEL', escape_html($newsletter_description)), strval($newsletter['id']), $l)); } } } if (get_forum_type() == 'ocf') { $c5 = $this->count_level(-1, 5, $lang); $fields->attach(form_input_tick(do_lang_tempcode('NEWSLETTER_OCF'), do_lang_tempcode('NUM_READERS', integer_format($c5)), '-1', false)); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); foreach ($groups as $group_id => $group) { if ($group_id != db_get_first_id()) { $map = array(); $map['g' . strval($group_id)] = 1; $_c = newsletter_who_send_to($map, $lang, 0, 0); $c6 = $_c[6]['g' . strval($group_id)]; if ($c6 != 0) { $fields->attach(form_input_tick(do_lang_tempcode('THIS_WITH', do_lang_tempcode('GROUP'), make_string_tempcode(escape_html($group))), do_lang_tempcode('NUM_READERS', integer_format($c6)), 'g' . strval($group_id), post_param_integer('g' . strval($group_id), 0) == 1)); } } } } $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD_CSV'), 'file', false, NULL, NULL, true, 'csv,txt')); //if ($fields->is_empty()) inform_exit(do_lang_tempcode('NOBODY_TO_SEND_TO')); handle_max_file_size($hidden); $template_choices = new ocp_tempcode(); $dh = opendir(get_custom_file_base() . '/themes/default/templates_custom'); while (($f = readdir($dh)) !== false) { if (preg_match('#^MAIL.*\\.tpl$#', $f) != 0) { $tpl = basename($f, '.tpl'); $template_choices->attach(form_input_list_entry($tpl, post_param('template', 'MAIL') == $tpl, $tpl)); } } if (!file_exists(get_custom_file_base() . '/themes/default/templates_custom/MAIL.tpl')) { $template_choices->attach(form_input_list_entry('MAIL', true, 'MAIL')); } closedir($dh); $fields->attach(form_input_list(do_lang_tempcode('NEWSLETTER_TEMPLATE'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_TEMPLATE'), 'template', $template_choices, NULL, false, true)); // If we're making a periodic newsletter then we need to know when it // should be sent if ($periodic_action == 'make' || $periodic_action == 'replace') { $hidden->attach(form_input_hidden('make_periodic', '1')); $hidden->attach(form_input_hidden('periodic_choice', post_param('periodic_choice'))); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang('PERIODIC_WHEN'), 'HELP' => do_lang('PERIODIC_WHEN_HELP')))); // The choices are given as radio buttons: weekly or bi-weekly or monthly? // In the labels for these radio buttons, we put a dropdown for day of // the week and day of the month. $frequency = post_param('periodic_when', 'weekly'); if (!is_null($defaults)) { $frequency = post_param('periodic_when', $defaults['np_frequency']); } $current_day_weekly = post_param_integer('periodic_weekly', 5); if (!is_null($defaults)) { $current_day_weekly = post_param_integer('periodic_weekly', $defaults['np_day']); } $current_day_biweekly = post_param_integer('periodic_biweekly', 5); if (!is_null($defaults)) { $current_day_biweekly = post_param_integer('periodic_biweekly', $defaults['np_day']); } $current_day_of_month = post_param_integer('periodic_monthly', 1); if (!is_null($defaults)) { $current_day_of_month = post_param_integer('periodic_monthly', $defaults['np_day']); } $radios = new ocp_tempcode(); $week_days_weekly = new ocp_tempcode(); $week_days_biweekly = new ocp_tempcode(); require_lang('dates'); $week_days = array(1 => do_lang('MONDAY'), 2 => do_lang('TUESDAY'), 3 => do_lang('WEDNESDAY'), 4 => do_lang('THURSDAY'), 5 => do_lang('FRIDAY'), 6 => do_lang('SATURDAY'), 7 => do_lang('SUNDAY')); foreach ($week_days as $i => $this_day) { $week_days_weekly->attach(form_input_list_entry(strval($i), $i == $current_day_weekly, $this_day, false, false)); $week_days_biweekly->attach(form_input_list_entry(strval($i), $i == $current_day_biweekly, $this_day, false, false)); } $weekly_desc = new ocp_tempcode(); $weekly_desc->attach(do_lang('PERIODIC_WEEKLY_ON')); $weekly_desc->attach(do_template('FORM_SCREEN_INPUT_LIST', array('TABINDEX' => strval(get_form_field_tabindex(NULL)), 'REQUIRED' => '0', 'NAME' => 'periodic_weekday_weekly', 'CONTENT' => $week_days_weekly, 'INLINE_LIST' => '0'))); $radios->attach(form_input_radio_entry('periodic_when', 'weekly', $frequency == 'weekly', $weekly_desc, NULL, '')); $weekly_desc = new ocp_tempcode(); $weekly_desc->attach(do_lang('PERIODIC_BIWEEKLY_ON')); $weekly_desc->attach(do_template('FORM_SCREEN_INPUT_LIST', array('TABINDEX' => strval(get_form_field_tabindex(NULL)), 'REQUIRED' => '0', 'NAME' => 'periodic_weekday_biweekly', 'CONTENT' => $week_days_biweekly, 'INLINE_LIST' => '0'))); $radios->attach(form_input_radio_entry('periodic_when', 'biweekly', $frequency == 'biweekly', $weekly_desc, NULL, '')); $month_days = new ocp_tempcode(); foreach (range(1, 28) as $this_day) { $suffix = gmdate('S', gmmktime(0, 0, 0, 1, $this_day, 1990)); $month_days->attach(form_input_list_entry(strval($this_day), $this_day == 1, strval($this_day) . $suffix, $current_day_of_month == $this_day)); } $monthly_desc = new ocp_tempcode(); $monthly_desc->attach(do_lang('PERIODIC_MONTHLY_ON')); $monthly_desc->attach(do_template('FORM_SCREEN_INPUT_LIST', array('TABINDEX' => strval(get_form_field_tabindex(NULL)), 'REQUIRED' => '0', 'NAME' => 'periodic_monthly', 'CONTENT' => $month_days, 'INLINE_LIST' => '0'))); $radios->attach(form_input_radio_entry('periodic_when', 'monthly', $frequency == 'monthly', $monthly_desc, NULL, '')); $fields->attach(form_input_radio(do_lang('PERIODIC_WHEN_CHOICE'), '', 'periodic_when', $radios, true)); $radios = new ocp_tempcode(); $radios->attach(form_input_radio_entry('periodic_for', 'all', false, do_lang_tempcode('CREATE_PERIODIC_FOR_ALL'), NULL, '')); $radios->attach(form_input_radio_entry('periodic_for', 'future', true, do_lang_tempcode('CREATE_PERIODIC_FOR_FUTURE'), NULL, '')); $fields->attach(form_input_radio(do_lang('CREATE_PERIODIC_FOR'), '', 'periodic_for', $radios, true)); } return do_template('FORM_SCREEN', array('_GUID' => '0b2a4825ec586d9ff557026d9a1e0cca', 'TITLE' => $title, 'TEXT' => $periodic_action == 'make' || $periodic_action == 'replace' ? do_lang_tempcode('PERIODIC_NO_EDIT') : do_lang_tempcode('NEWSLETTER_SEND_TEXT'), 'HIDDEN' => $hidden, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); }
/** * The UI for importing a CSV file. * * @return tempcode The UI */ function import_csv() { $title = get_page_title('IMPORT_MEMBER_CSV'); breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS')))); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/import_csv'; require_code('form_templates'); require_lang('ocf'); $hidden = new ocp_tempcode(); $fields = new ocp_tempcode(); handle_max_file_size($hidden); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_IMPORT_CSV'), 'file', true, NULL, NULL, true, 'csv,txt')); $fields->attach(form_input_line(do_lang_tempcode('DEFAULT_PASSWORD'), do_lang_tempcode('DESCRIPTION_DEFAULT_PASSWORD'), 'default_password', '', false)); $submit_name = do_lang_tempcode('IMPORT_MEMBER_CSV'); $post_url = build_url(array('page' => '_SELF', 'type' => '_import_csv'), '_SELF'); $text = ''; return do_template('FORM_SCREEN', array('TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name)); }
/** * Get tempcode for an IOTD adding/editing form. * * @param URLPATH The URL to the image * @param URLPATH The URL to the thumbnail * @param SHORT_TEXT The title * @param LONG_TEXT The caption * @param boolean Whether the IOTD is/will-be currently active * @param ?BINARY Whether rating is allowed (NULL: decide statistically, based on existing choices) * @param ?SHORT_INTEGER Whether comments are allowed (0=no, 1=yes, 2=review style) (NULL: decide statistically, based on existing choices) * @param ?BINARY Whether trackbacks are allowed (NULL: decide statistically, based on existing choices) * @param LONG_TEXT Notes for the IOTD * @return array A pair: the tempcode for the visible fields, and the tempcode for the hidden fields */ function get_form_fields($url = '', $thumb_url = '', $title = '', $caption = '', $current = false, $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $notes = '') { list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks); $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); handle_max_file_size($hidden, 'image'); $fields->attach(form_input_line_comcode(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'url', $url, false)); if (get_option('is_on_gd') == '0' || !function_exists('imagetypes')) { $thumb_width = get_option('thumb_width'); $fields->attach(form_input_upload(do_lang_tempcode('THUMBNAIL'), do_lang_tempcode('DESCRIPTION_THUMBNAIL', escape_html($thumb_width)), 'file2', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'thumb_url', $thumb_url, false)); } $fields->attach(form_input_text_comcode(do_lang_tempcode('CAPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'caption', $caption, false)); if (has_specific_permission(get_member(), 'choose_iotd')) { if ($caption == '') { $test = $GLOBALS['SITE_DB']->query_value_null_ok('iotd', 'is_current', array('is_current' => 1)); if (is_null($test)) { $current = true; } } $fields->attach(form_input_tick(do_lang_tempcode('IMMEDIATE_USE'), do_lang_tempcode('DESCRIPTION_IMMEDIATE_USE'), 'validated', $current)); } require_code('feedback2'); $fields->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, false, $notes, $allow_comments == 2)); return array($fields, $hidden); }
/** * Get tempcode for a adding/editing form. * * @param ?GROUP The usergroup being edited (NULL: adding, not editing) * @param SHORT_TEXT The usergroup name * @param BINARY Whether this is a default usergroup * @param BINARY Whether members of the usergroup are super-administrators * @param BINARY Whether members of the usergroup are super-moderators * @param ID_TEXT The username of the usergroup leader * @param SHORT_TEXT The default title for members with this as their primary usergroup * @param URLPATH The usergroup rank image * @param ?GROUP The target for promotion from this usergroup (NULL: no promotion prospects) * @param ?integer The point threshold upon which promotion occurs (NULL: no promotion prospects) * @param integer The number of seconds between submission flood controls * @param integer The number of seconds between access flood controls * @param integer The number of gift points members of this usergroup get when they start * @param integer The number of gift points members of this usergroup get per-day * @param integer The number of megabytes members can upload per day * @param integer The maximum number of attachments members of this usergroup may have per post * @param integer The maximum avatar width members of this usergroup may have * @param integer The maximum avatar height members of this usergroup may have * @param integer The maximum post length members of this usergroup may have * @param integer The maximum signature length members of this usergroup may have * @param BINARY Whether to lock out unverified IP addresses until e-mail confirmation * @param BINARY Whether the usergroup is presented for joining at joining (implies anyone may be in the usergroup, but only choosable at joining) * @param BINARY Whether the name and membership of the usergroup is hidden * @param ?integer The display order this usergroup will be given, relative to other usergroups. Lower numbered usergroups display before higher numbered usergroups (NULL: last). * @param BINARY Whether the rank image will not be shown for secondary membership * @param BINARY Whether members may join this usergroup without requiring any special permission * @param BINARY Whether this usergroup is a private club. Private clubs may be managed in the CMS zone, and do not have any special permissions - except over their own associated forum. * @return array A pair: The input fields, Hidden fields */ function get_form_fields($id = NULL, $name = '', $is_default = 0, $is_super_admin = 0, $is_super_moderator = 0, $group_leader = '', $title = '', $rank_image = '', $promotion_target = NULL, $promotion_threshold = NULL, $flood_control_submit_secs = 0, $flood_control_access_secs = 0, $gift_points_base = 25, $gift_points_per_day = 1, $max_daily_upload_mb = 5, $max_attachments_per_post = 20, $max_avatar_width = 80, $max_avatar_height = 80, $max_post_length_comcode = 40000, $max_sig_length_comcode = 1000, $enquire_on_new_ips = 0, $is_presented_at_install = 0, $group_is_hidden = 0, $order = NULL, $rank_image_pri_only = 1, $open_membership = 0, $is_private_club = 0) { if (is_null($group_leader)) { $group_leader = ''; } $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_USERGROUP_TITLE'), 'name', $name, true)); if (addon_installed('ocf_clubs') && !is_null($id)) { $fields->attach(form_input_tick(do_lang_tempcode('IS_PRIVATE_CLUB'), do_lang_tempcode('IS_PRIVATE_CLUB_DESCRIPTION'), 'is_private_club', $is_private_club == 1)); } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $title == '' && $group_leader == '', 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_GROUP_TITLE'), 'title', $title, false)); $fields->attach(form_input_username(do_lang_tempcode('GROUP_LEADER'), do_lang_tempcode('DESCRIPTION_GROUP_LEADER'), 'group_leader', $group_leader, false)); $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name', 'g_is_super_admin'), array('g_is_private_club' => 0)); $orderlist = new ocp_tempcode(); $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $num_groups = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)', $group_count > 200 ? array('g_is_private_club' => 0) : NULL); if (is_null($id)) { $num_groups++; } for ($i = 0; $i < $num_groups; $i++) { $orderlist->attach(form_input_list_entry(strval($i), $i === $order || is_null($id) && $i == $num_groups - 1, integer_format($i + 1))); } $fields->attach(form_input_list(do_lang_tempcode('ORDER'), do_lang_tempcode('USERGROUP_DISPLAY_ORDER_DESCRIPTION'), 'order', $orderlist)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('JOINING')))); if (is_null($id) || $id != db_get_first_id()) { $fields->attach(form_input_tick(do_lang_tempcode('IS_PRESENTED_AT_INSTALL'), do_lang_tempcode('DESCRIPTION_IS_PRESENTED_AT_INSTALL'), 'is_presented_at_install', $is_presented_at_install == 1)); $fields->attach(form_input_tick(do_lang_tempcode('DEFAULT_GROUP'), do_lang_tempcode('DESCRIPTION_IS_DEFAULT_GROUP'), 'is_default', $is_default == 1)); } $fields->attach(form_input_tick(do_lang_tempcode('OPEN_MEMBERSHIP'), do_lang_tempcode('OPEN_MEMBERSHIP_DESCRIPTION'), 'open_membership', $open_membership == 1)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('RANK')))); if (addon_installed('points')) { $promotion_target_groups = form_input_list_entry('-1', false, do_lang_tempcode('NA_EM')); foreach ($rows as $group) { if ($group['id'] != $id && $group['id'] != db_get_first_id()) { $promotion_target_groups->attach(form_input_list_entry(strval($group['id']), $group['id'] == $promotion_target, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']))); } } $fields->attach(form_input_list(do_lang_tempcode('PROMOTION_TARGET'), do_lang_tempcode('DESCRIPTION_PROMOTION_TARGET'), 'promotion_target', $promotion_target_groups)); $fields->attach(form_input_integer(do_lang_tempcode('PROMOTION_THRESHOLD'), do_lang_tempcode('DESCRIPTION_PROMOTION_THRESHOLD'), 'promotion_threshold', $promotion_threshold, false)); } if (get_base_url() == get_forum_base_url()) { handle_max_file_size($hidden, 'image'); $fields->attach(form_input_upload(do_lang_tempcode('RANK_IMAGE'), do_lang_tempcode('DESCRIPTION_RANK_IMAGE'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); } require_code('themes2'); $ids = get_all_image_ids_type('ocf_rank_images', false, $GLOBALS['FORUM_DB']); $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'theme_img_code', $ids, NULL, $rank_image, NULL, true, $GLOBALS['FORUM_DB'])); $fields->attach(form_input_tick(do_lang_tempcode('RANK_IMAGE_PRI_ONLY'), do_lang_tempcode('RANK_IMAGE_PRI_ONLY_DESCRIPTION'), 'rank_image_pri_only', $rank_image_pri_only == 1)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('BENEFITS')))); $sa_descrip = do_lang_tempcode('DESCRIPTION_IS_SUPER_ADMIN'); if ($is_super_admin == 1) { $sa_descrip->attach(do_lang_tempcode('DESCRIPTION_IS_SUPER_ADMIN_B')); } $fields->attach(form_input_tick(do_lang_tempcode('SUPER_ADMIN'), $sa_descrip, 'is_super_admin', $is_super_admin == 1)); $fields->attach(form_input_tick(do_lang_tempcode('SUPER_MODERATOR'), do_lang_tempcode('DESCRIPTION_IS_SUPER_MODERATOR'), 'is_super_moderator', $is_super_moderator == 1)); if (addon_installed('points')) { $fields->attach(form_input_integer(do_lang_tempcode('GIFT_POINTS_BASE'), do_lang_tempcode('DESCRIPTION_GIFT_POINTS_BASE'), 'gift_points_base', $gift_points_base, true)); $fields->attach(form_input_integer(do_lang_tempcode('GIFT_POINTS_PER_DAY'), do_lang_tempcode('DESCRIPTION_GIFT_POINTS_PER_DAY'), 'gift_points_per_day', $gift_points_per_day, true)); } require_lang('security'); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('SECURITY')))); $fields->attach(form_input_tick(do_lang_tempcode('HIDDEN_USERGROUP'), do_lang_tempcode('DESCRIPTION_GROUP_HIDDEN'), 'hidden', $group_is_hidden == 1)); $fields->attach(form_input_tick(do_lang_tempcode('ENQUIRE_ON_NEW_IPS'), do_lang_tempcode('DESCRIPTION_ENQUIRE_ON_NEW_IPS'), 'enquire_on_new_ips', $enquire_on_new_ips == 1)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('RESTRICTIONS')))); $fields->attach(form_input_integer(do_lang_tempcode('MAX_ATTACHMENTS_PER_POST'), do_lang_tempcode('DESCRIPTION_MAX_ATTACHMENTS_PER_POST'), 'max_attachments_per_post', $max_attachments_per_post, true)); $fields->attach(form_input_integer(do_lang_tempcode('MAX_DAILY_UPLOAD_MB'), do_lang_tempcode('DESCRIPTION_MAX_DAILY_UPLOAD_MB'), 'max_daily_upload_mb', $max_daily_upload_mb, true)); if (addon_installed('ocf_member_avatars')) { $fields->attach(form_input_integer(do_lang_tempcode('MAX_AVATAR_WIDTH'), do_lang_tempcode('DESCRIPTION_MAX_AVATAR_WIDTH'), 'max_avatar_width', $max_avatar_width, true)); $fields->attach(form_input_integer(do_lang_tempcode('MAX_AVATAR_HEIGHT'), do_lang_tempcode('DESCRIPTION_MAX_AVATAR_HEIGHT'), 'max_avatar_height', $max_avatar_height, true)); } $fields->attach(form_input_integer(do_lang_tempcode('MAX_POST_LENGTH_COMCODE'), do_lang_tempcode('DESCRIPTION_MAX_POST_LENGTH_COMCODE'), 'max_post_length_comcode', $max_post_length_comcode, true)); if (addon_installed('ocf_signatures')) { $fields->attach(form_input_integer(do_lang_tempcode('MAX_SIG_LENGTH_COMCODE'), do_lang_tempcode('DESCRIPTION_MAX_SIG_LENGTH_COMCODE'), 'max_sig_length_comcode', $max_sig_length_comcode, true)); } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('FLOOD_CONTROL')))); $fields->attach(form_input_integer(do_lang_tempcode('FLOOD_CONTROL_ACCESS_SECS'), do_lang_tempcode('DESCRIPTION_FLOOD_CONTROL_ACCESS_SECS'), 'flood_control_access_secs', $flood_control_access_secs, true)); $fields->attach(form_input_integer(do_lang_tempcode('FLOOD_CONTROL_SUBMIT_SECS'), do_lang_tempcode('DESCRIPTION_FLOOD_CONTROL_SUBMIT_SECS'), 'flood_control_submit_secs', $flood_control_submit_secs, true)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $copy_members_from_groups = new ocp_tempcode(); foreach ($rows as $row) { if ($row['id'] != db_get_first_id() && $row['id'] != $id) { $copy_members_from_groups->attach(form_input_list_entry(strval($row['id']), false, get_translated_text($row['g_name'], $GLOBALS['FORUM_DB']))); } } $fields->attach(form_input_multi_list(do_lang_tempcode('COPY_MEMBERS_INTO'), do_lang_tempcode('DESCRIPTION_COPY_MEMBERS_INTO'), 'copy_members_into', $copy_members_from_groups)); // Take permissions from $permissions_from_groups = new ocp_tempcode(); $permissions_from_groups = form_input_list_entry('-1', false, do_lang_tempcode('NA_EM')); foreach ($rows as $group) { if ($group['id'] != $id) { $permissions_from_groups->attach(form_input_list_entry(strval($group['id']), false, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']))); } } $fields->attach(form_input_list(do_lang_tempcode('DEFAULT_PERMISSIONS_FROM'), do_lang_tempcode(is_null($id) ? 'DESCRIPTION_DEFAULT_PERMISSIONS_FROM_NEW' : 'DESCRIPTION_DEFAULT_PERMISSIONS_FROM'), 'absorb', $permissions_from_groups)); $this->appended_actions_already = true; return array($fields, $hidden); }