/** * 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); }
/** * Standard modular UI to edit an entry. * * @return tempcode The UI */ function _ed() { $doing = 'EDIT_' . $this->lang_type; if ($this->catalogue && get_param('catalogue_name', '') != '') { $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name')))); if ($this->type_code == 'd') { $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title)); } elseif ($this->type_code == 'c') { $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title)); } } $title = get_page_title($doing); //$submit_name=(strpos($doing,' ')!==false)?protect_from_escaping($doing):do_lang($doing); //if (!is_null($this->edit_submit_name)) $submit_name=$this->edit_submit_name; $submit_name = do_lang_tempcode('SAVE'); //$test=$this->choose_catalogue($title); //if (!is_null($test)) return $test; $id = mixed(); // Define type as mixed $id = $this->non_integer_id ? get_param('id', false, true) : strval(get_param_integer('id')); $map = array('page' => '_SELF', 'type' => '__e' . $this->type_code, 'id' => $id); if (get_param('catalogue_name', '') != '') { $map['catalogue_name'] = get_param('catalogue_name'); } if (!is_null(get_param('redirect', NULL))) { $map['redirect'] = get_param('redirect'); } if (!is_null(get_param('continue', NULL))) { $map['continue'] = get_param('continue'); } if (!is_null($this->upload) || $this->possibly_some_kind_of_upload) { $map['uploading'] = 1; } $post_url = build_url($map, '_SELF'); if (multi_lang() && has_actual_page_access(get_member(), 'admin_lang') && user_lang() != get_site_default_lang()) { require_code('lang2'); $switch_url = get_self_url(false, false, array('keep_lang' => get_site_default_lang())); attach_message(do_lang_tempcode('lang:EDITING_CONTENT_IN_LANGUAGE_STAFF', escape_html(lookup_language_full_name(user_lang())), escape_html(lookup_language_full_name(get_site_default_lang())), escape_html($switch_url->evaluate())), 'warn'); } if (method_exists($this, 'get_submitter')) { list($submitter, $date_and_time) = $this->get_submitter($id); } else { $submitter = NULL; $date_and_time = NULL; } if (!is_null($this->permissions_require)) { check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name); } if (!is_null($this->permissions_cat_require) && !has_category_access(get_member(), $this->permissions_cat_require, $this->get_cat($id))) { access_denied('CATEGORY_ACCESS'); } if (!is_null($this->permissions_cat_require_b) && !has_category_access(get_member(), $this->permissions_cat_require_b, $this->get_cat_b($id))) { access_denied('CATEGORY_ACCESS'); } $bits = $this->fill_in_edit_form($id); $delete_fields = new ocp_tempcode(); $all_delete_fields_given = false; $fields2 = new ocp_tempcode(); if (is_array($bits)) { $fields = $bits[0]; $hidden = $bits[1]; if (array_key_exists(2, $bits) && !is_null($bits[2])) { $delete_fields = $bits[2]; } if (array_key_exists(3, $bits) && !is_null($bits[3])) { $this->edit_text = $bits[3]; } if (array_key_exists(4, $bits) && $bits[4]) { $all_delete_fields_given = true; } if (array_key_exists(5, $bits) && !is_null($bits[5])) { $this->posting_form_text = $bits[5]; } if (array_key_exists(6, $bits) && !is_null($bits[6])) { $fields2 = $bits[6]; } if (array_key_exists(7, $bits)) { $this->posting_form_text_parsed = $bits[7]; } } else { $fields = $bits; $hidden = new ocp_tempcode(); } // Add in custom fields if ($this->has_tied_catalogue()) { require_code('fields'); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MORE')))); append_form_custom_fields($this->award_type, $id, $fields, $hidden); } // SEO? if (!is_null($this->seo_type)) { require_code('seo2'); $fields2->attach(seo_get_fields($this->seo_type, $id)); } // Awards? if (addon_installed('awards')) { if (!is_null($this->award_type)) { require_code('awards'); $fields2->attach(get_award_fields($this->award_type, $id)); } } // Action fields / deletion options $delete_permission = true; if (!is_null($this->permissions_require)) { $delete_permission = has_delete_permission($this->permissions_require, get_member(), $submitter, is_null($this->permission_page_name) ? get_page_name() : $this->permission_page_name, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id))); } $may_delete = (!method_exists($this, 'may_delete_this') || $this->may_delete_this($id)) && (!is_numeric($id) || intval($id) >= db_get_first_id() + $this->protect_first) && $delete_permission; // Deletion options $action_fields = new ocp_tempcode(); if ($may_delete) { if (!$all_delete_fields_given) { $action_fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); } if (addon_installed('points') && !is_null($submitter) && !is_null($date_and_time)) { $points_test = $GLOBALS['SITE_DB']->query_value_null_ok('gifts', 'id', array('date_and_time' => $date_and_time, 'gift_to' => $submitter, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id())); if (!is_null($points_test)) { require_lang('points'); $action_fields->attach(form_input_tick(do_lang_tempcode('REVERSE_TITLE'), do_lang_tempcode('REVERSE_TITLE_DESCRIPTION'), 'reverse_point_transaction', false)); } } $action_fields->attach($delete_fields); } if (!$this->appended_actions_already && !$action_fields->is_empty()) { $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); } $fields2->attach($action_fields); if (!is_object($this->edit_text)) { $this->edit_text = make_string_tempcode(is_null($this->edit_text) ? '' : $this->edit_text); } if (!is_null($this->upload)) { if ($this->upload == 'image') { 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(); $this->edit_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)))); } } else { require_code('files2'); $max = floatval(get_max_file_size()) / floatval(1024 * 1024); if ($max < 30.0) { $config_url = get_upload_limit_config_url(); $this->edit_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)))); } } } if (get_param('type', '_ed') == '_edit_catalogue') { require_javascript('javascript_catalogues'); // Existing fields $field_count = 0; $c_name = get_param('id', false, true); $rows = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $c_name), 'ORDER BY cf_order'); $fields_existing = new ocp_tempcode(); foreach ($rows as $i => $myrow) { $name = get_translated_text($myrow['cf_name']); $description = get_translated_text($myrow['cf_description']); $prefix = 'existing_field_' . strval($myrow['id']) . '_'; list($_fields_existing, $_fields_hidden) = $this->get_field_fields($i == 0 && substr($c_name, 0, 1) != '_', count($rows) + 10, $prefix, $field_count, $name, $description, $myrow['cf_type'], $myrow['cf_defines_order'], $myrow['cf_visible'], $myrow['cf_searchable'], $myrow['cf_default'], $myrow['cf_required'], $myrow['cf_put_in_category'], $myrow['cf_put_in_search']); if (!is_ecommerce_catalogue($c_name) || $i > 9) { $_fields_existing->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $_fields_existing->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), $prefix . 'delete', false)); } $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '1492d973db45cbecff892ad4ac1af28f' . get_class($this), 'NAME' => $name, 'ID' => 'FIELD_' . strval($i + 1), 'FIELDS' => $_fields_existing->evaluate())); $fields_existing->attach($temp); $hidden->attach($_fields_hidden); $field_count++; } // New field $fields_new = new ocp_tempcode(); for ($i = 0; $i < 5; $i++) { list($_fields_new, $_fields_hidden) = $this->get_field_fields(false, count($rows) + 10, 'new_field_' . strval($i) . '_', $field_count); $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '8b9a632eafae003ccc6b007eefb0ce3d' . get_class($this), 'NAME' => do_lang_tempcode('NEW_FIELD', strval($i + 1)), 'ID' => 'NEW_FIELD_' . strval($i + 1), 'FIELDS' => $_fields_new->evaluate())); $fields_new->attach($temp); $hidden->attach($_fields_hidden); $field_count++; } $fields->attach($fields2); return do_template('CATALOGUE_EDITING_SCREEN', array('_GUID' => '584d7dc7c2c13939626102374f13f508' . get_class($this), 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $this->add_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'FIELDS_EXISTING' => $fields_existing->evaluate(), 'FIELDS_NEW' => $fields_new->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript)); } list($warning_details, $ping_url) = handle_conflict_resolution(); if (!is_null($this->posting_form_title)) { $posting_form = get_posting_form($submit_name, $this->posting_form_text, $post_url, $hidden, $fields, $this->posting_form_title, '', $fields2, $this->posting_form_text_parsed, $this->javascript, NULL, $this->posting_field_required); return do_template('POSTING_SCREEN', array('_GUID' => '841b9af3aa80bcab86b907e4b942786a' . get_class($this), 'PREVIEW' => $this->do_preview, 'TITLE' => $title, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $this->add_text, 'POSTING_FORM' => $posting_form->evaluate(), 'JAVASCRIPT' => $this->javascript)); } else { $fields->attach($fields2); return do_template('FORM_SCREEN', array('_GUID' => '2d70be34595a16c6f170d966b894bfe2' . get_class($this), 'PREVIEW' => $this->do_preview, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'TITLE' => $title, 'SKIP_VALIDATION' => $this->skip_validation, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'HIDDEN' => $hidden, 'TEXT' => $this->edit_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript)); } }
/** * 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)); }
/** * The UI to edit a theme image. * * @return tempcode The UI */ function edit_image() { $title = get_page_title('EDIT_THEME_IMAGE'); $lang = choose_language($title, true, true); if (is_object($lang)) { return $lang; } $url = get_param('url', ''); if ($url != '') { $theme = get_param('theme', ''); // Editing like this happens in the theme the user is using if ($theme == '') { $theme = $GLOBALS['FORUM_DRIVER']->get_theme(''); } if (substr($url, 0, strlen(get_base_url())) == get_base_url()) { $url = substr($url, strlen(get_base_url())); } $pos = strpos($url, 'themes/'); if ($pos === false) { warn_exit(do_lang_tempcode('NOT_THEME_IMAGE')); } $path = substr($url, $pos); $id = $GLOBALS['SITE_DB']->query_value_null_ok('theme_images', 'id', array('path' => $path, 'theme' => $theme)); if (is_null($id)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } } else { $id = get_param('id'); $theme = get_param('theme'); } //if ((get_file_base()!=get_custom_file_base()) && ($theme=='default')) warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT')); $where_map = array('theme' => $theme, 'id' => $id); if ($lang != '') { $where_map['lang'] = $lang; } $path = $GLOBALS['SITE_DB']->query_value_null_ok('theme_images', 'path', $where_map); if (is_null($path)) { $path = $GLOBALS['SITE_DB']->query_value_null_ok('theme_images', 'path', array('theme' => $theme, 'lang' => get_site_default_lang(), 'id' => $id)); } if (is_null($path)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $GLOBALS['SEO_TITLE'] = $id; $unmodified = strpos($path, 'themes/default/images/') !== false; $from_file = @file_get_contents(($unmodified ? get_file_base() : get_custom_file_base()) . '/' . rawurldecode($path)); $width = do_lang_tempcode('UNKNOWN_EM'); $height = do_lang_tempcode('UNKNOWN_EM'); if ($from_file !== false && function_exists('imagecreatefromstring')) { $source = @imagecreatefromstring($from_file); unset($from_file); if ($source !== false) { $width = make_string_tempcode(strval(imagesx($source))); $height = make_string_tempcode(strval(imagesy($source))); imagedestroy($source); } } $url = ($unmodified ? get_base_url() : get_custom_base_url()) . '/' . $path; $text = do_template('THEME_IMAGE_PREVIEW', array('_GUID' => 'c71817851526064e738d5076dcd1bce1', 'WIDTH' => $width, 'HEIGHT' => $height, 'URL' => $url, 'UNMODIFIED' => $unmodified)); list($fields, $hidden) = $this->get_image_form_fields($theme, $lang, $id, $path); $hidden->attach(form_input_hidden('old_id', $id)); if (strpos($path, 'images_custom') !== false) { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE_THEME_IMAGE'), 'delete', false)); } $post_url = build_url(array('page' => '_SELF', 'type' => '_edit_image', 'uploading' => 1), '_SELF', NULL, false, true); $submit_name = do_lang_tempcode('SAVE'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_THEMES')), array('_SELF:_SELF:manage_images:theme=' . $theme, do_lang_tempcode('CHOOSE')))); 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)), escape_html(is_null($config_url) ? '' : $config_url)))); } return do_template('FORM_SCREEN', array('_GUID' => 'b0e178ad1f840a07c4967f3c266c750b', 'HIDDEN' => $hidden, 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => 'standardAlternateFields(\'file\',\'path\');')); }
/** * The UI to import into a gallery. * * @return tempcode The UI */ function _gimp() { $cat = get_param('name', 'root'); check_specific_permission('mass_import'); if (substr($cat, 0, 7) != 'member_') { $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $cat)); if (is_null($test)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } } $title = get_page_title('GALLERY_IMPORT'); require_code('form_templates'); require_lang('trackbacks'); // To choose to batch import from an attached tar or zip file (zip file only supported if zip module running on php install) $post_url = build_url(array('page' => '_SELF', 'type' => '__gimp', 'cat' => $cat, 'uploading' => 1, 'redirect' => get_param('redirect', NULL)), '_SELF'); $fields = new ocp_tempcode(); $supported = 'tar'; if (function_exists('zip_open') || get_option('unzip_cmd') != '') { $supported .= ', zip'; } $fields->attach(form_input_upload_multi(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_ARCHIVE_MEDIA', escape_html($supported), escape_html(str_replace(',', ', ', get_option('valid_images') . ',' . get_allowed_video_file_types()))), 'file', true, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',' . $supported))); $hidden = new ocp_tempcode(); handle_max_file_size($hidden); if (get_option('is_on_gd') == '1') { if ($this->has_at_least_one_watermark($cat)) { $fields->attach(form_input_tick(do_lang_tempcode('WATERMARK'), do_lang_tempcode('DESCRIPTION_WATERMARK'), 'watermark', true)); } } // Feedback require_code('feedback2'); $fields->attach(feedback_fields(true, true, true, false, '')); // Max upload limit require_code('files2'); $max = floatval(get_max_file_size()) / floatval(1024 * 1024); if ($max < 30.0) { $config_url = get_upload_limit_config_url(); $text = 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))); } else { $text = new ocp_tempcode(); } // Show form $hidden->attach(form_input_hidden('test', '1')); $form = do_template('FORM', array('_GUID' => '05de2bc134ed0b1ab703ac8bfbfabce4', 'TABINDEX' => strval(get_form_field_tabindex()), 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('BATCH_IMPORT_ARCHIVE_CONTENTS'), 'URL' => $post_url, 'TEXT' => $text, 'HIDDEN' => $hidden)); // Orphaned upload form // To choose to batch import what already exists in gallery directory, but is orphaned $orphaned_content = new ocp_tempcode(); if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) && $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)') + $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)') < 4000) { require_code('images'); $there = array(); $_dir = opendir(get_custom_file_base() . '/uploads/galleries/'); while (false !== ($file = readdir($_dir))) { if ($file != 'index.html' && !is_dir(get_custom_file_base() . '/uploads/galleries/' . $file) && (is_image($file) || is_video($file))) { $there[$file] = filemtime(get_custom_file_base() . '/uploads/galleries/' . $file); } } closedir($_dir); $_dir = @opendir(get_custom_file_base() . '/uploads/galleries/' . filter_naughty($cat)); if ($_dir !== false) { while (false !== ($file = readdir($_dir))) { if ($file != 'index.html' && !is_dir(get_custom_file_base() . '/uploads/galleries/' . $cat . '/' . $file) && (is_image($file) || is_video($file))) { $there[$cat . '/' . $file] = filemtime(get_custom_file_base() . '/uploads/galleries/' . $cat . '/' . $file); } } closedir($_dir); } if (count($there) != 0) { asort($there); $test1 = collapse_1d_complexity('url', $GLOBALS['SITE_DB']->query_select('images', array('url'))); $test2 = collapse_1d_complexity('url', $GLOBALS['SITE_DB']->query_select('videos', array('url'))); arsort($there); $temp_keys = array_keys($there); $last_time = $there[$temp_keys[0]]; foreach ($there as $file => $time) { if (!in_array('uploads/galleries/' . str_replace('%2F', '/', rawurlencode($file)), $test1) && !in_array('uploads/galleries/' . str_replace('%2F', '/', rawurlencode($file)), $test2)) { $orphaned_content->attach(form_input_list_entry($file, $time >= $last_time - 60 * 60 * 3 || strpos($file, '/') !== false, $file)); } } } $add_url = build_url(array('page' => '_SELF', 'type' => 'ss'), '_SELF'); if (!$orphaned_content->is_empty()) { $fields_2 = new ocp_tempcode(); $hidden_2 = new ocp_tempcode(); if (get_param_integer('keep_de_orphan', 0) == 1) { $cats = nice_get_gallery_tree($cat, NULL, false, false, false, false, NULL, true); $fields_2->attach(form_input_list(do_lang_tempcode('GALLERY'), '', 'cat', $cats)); } else { $hidden_2->attach(form_input_hidden('cat', $cat)); } $fields_2->attach(form_input_multi_list(do_lang_tempcode('ENTRIES'), '', 'files', $orphaned_content)); if ($this->has_at_least_one_watermark($cat)) { $fields_2->attach(form_input_various_ticks(array(array(do_lang_tempcode('WATERMARK'), 'watermark', true, ''), array(do_lang_tempcode('ALLOW_RATING'), 'allow_rating', true, ''), array(do_lang_tempcode('ALLOW_COMMENTS'), 'allow_comments', true, ''), array(do_lang_tempcode('ALLOW_REVIEWS'), 'allow_reviews', false, ''), array(do_lang_tempcode('ALLOW_TRACKBACKS'), 'allow_trackbacks', true, '')), '', NULL, do_lang_tempcode('OPTIONS'))); } $radios = new ocp_tempcode(); $radios->attach(form_input_radio_entry('type', 'sa', true, do_lang_tempcode('ADD_GALLERY_SELECTION'))); $radios->attach(form_input_radio_entry('type', 'sd', false, do_lang_tempcode('DELETE_GALLERY_SELECTION'))); $fields_2->attach(form_input_radio(do_lang_tempcode('ACTION'), '', 'type', $radios, true)); // Feedback require_code('feedback2'); $fields_2->attach(feedback_fields(true, true, true, false, '')); $form2 = do_template('FORM', array('SECONDARY_FORM' => true, 'TABINDEX' => strval(get_form_field_tabindex()), 'FIELDS' => $fields_2, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'), 'URL' => $add_url, 'TEXT' => '', 'HIDDEN' => $hidden_2)); } else { $form2 = new ocp_tempcode(); } } else { $form2 = new ocp_tempcode(); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_GALLERIES')), array('_SELF:_SELF:gimp', do_lang_tempcode('GALLERY')))); breadcrumb_set_self(do_lang_tempcode('UPLOAD')); return do_template('GALLERY_IMPORT_SCREEN', array('_GUID' => '607c819ff751268294e5e590a0d41533', 'TITLE' => $title, 'FORM2' => $form2, 'FORM' => $form)); }
/** * 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)); }