/** * Standard pointstore item configuration save function. */ function save_config() { $i = 0; $rows = list_to_map('id', $GLOBALS['SITE_DB']->query_select('pstore_customs', array('*'))); while (array_key_exists('custom_' . strval($i), $_POST)) { $id = post_param_integer('custom_' . strval($i)); $title = post_param('custom_title_' . strval($i)); $description = post_param('custom_description_' . strval($i)); $enabled = post_param_integer('custom_enabled_' . strval($i), 0); $cost = post_param_integer('custom_cost_' . strval($i)); $one_per_member = post_param_integer('custom_one_per_member_' . strval($i), 0); $delete = post_param_integer('delete_custom_' . strval($i), 0); $_title = $rows[$id]['c_title']; $_description = $rows[$id]['c_description']; if ($delete == 1) { delete_lang($_title); delete_lang($_description); $GLOBALS['SITE_DB']->query_delete('pstore_customs', array('id' => $id), '', 1); } else { $GLOBALS['SITE_DB']->query_update('pstore_customs', array('c_title' => lang_remap($_title, $title), 'c_description' => lang_remap($_description, $description), 'c_enabled' => $enabled, 'c_cost' => $cost, 'c_one_per_member' => $one_per_member), array('id' => $id), '', 1); } $i++; } $title = post_param('custom_title', NULL); if (!is_null($title)) { $description = post_param('custom_description'); $enabled = post_param_integer('custom_enabled', 0); $cost = post_param_integer('custom_cost'); $one_per_member = post_param_integer('custom_one_per_member', 0); $GLOBALS['SITE_DB']->query_insert('pstore_customs', array('c_title' => insert_lang($title, 2), 'c_description' => insert_lang($description, 2), 'c_enabled' => $enabled, 'c_cost' => $cost, 'c_one_per_member' => $one_per_member)); } }
/** * Delete a multi moderation. * * @param AUTO_LINK The ID of the multi moderation we are deleting. */ function ocf_delete_multi_moderation($id) { $_name = $GLOBALS['FORUM_DB']->query_value('f_multi_moderations', 'mm_name', array('id' => $id)); $name = get_translated_text($_name, $GLOBALS['FORUM_DB']); $GLOBALS['FORUM_DB']->query_delete('f_multi_moderations', array('id' => $id), '', 1); delete_lang($_name, $GLOBALS['FORUM_DB']); log_it('DELETE_MULTI_MODERATION', strval($id), $name); }
/** * Delete a flagrant text message. * * @param AUTO_LINK The ID of the flagrant text message to delete */ function delete_flagrant($id) { $message = $GLOBALS['SITE_DB']->query_value('text', 'the_message', array('id' => $id)); $_message = get_translated_text($message); log_it('DELETE_FLAGRANT', strval($id), $_message); $GLOBALS['SITE_DB']->query_delete('text', array('id' => $id), '', 1); delete_lang($message); persistant_cache_delete('FLAGRANT'); // In case it was active }
/** * Erase a seo entry... as these shouldn't be left hanging around once content is deleted. * * @param ID_TEXT The type of resource (e.g. download) * @param ID_TEXT The ID of the resource */ function seo_meta_erase_storage($type, $id) { $rows = $GLOBALS['SITE_DB']->query_select('seo_meta', array('meta_keywords', 'meta_description'), array('meta_for_type' => $type, 'meta_for_id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return; } delete_lang($rows[0]['meta_keywords']); delete_lang($rows[0]['meta_description']); $GLOBALS['SITE_DB']->query_delete('seo_meta', array('meta_for_type' => $type, 'meta_for_id' => $id), '', 1); if (function_exists('persistant_cache_delete')) { persistant_cache_delete(array('seo', $type, $id)); } }
/** * Delete a forum. * * @param AUTO_LINK The ID of the forum we are deleting. * @param AUTO_LINK The ID of the forum that topics will be moved to. * @param BINARY Whether to delete topics instead of moving them to the target forum. */ function ocf_delete_forum($forum_id, $target_forum_id, $delete_topics = 0) { if ($forum_id == db_get_first_id()) { warn_exit(do_lang_tempcode('CANNOT_DELETE_ROOT_FORUM')); } require_code('ocf_topics_action'); require_code('ocf_topics_action2'); if ($delete_topics == 0) { ocf_move_topics($forum_id, $target_forum_id); } else { $rows = $GLOBALS['FORUM_DB']->query_select('f_topics', array('id'), array('t_forum_id' => $forum_id)); foreach ($rows as $row) { ocf_delete_topic($row['id'], ''); } } $forum_info = $GLOBALS['FORUM_DB']->query_select('f_forums', array('*'), array('id' => $forum_id), '', 1); if (!array_key_exists(0, $forum_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } delete_lang($forum_info[0]['f_description'], $GLOBALS['FORUM_DB']); delete_lang($forum_info[0]['f_intro_question'], $GLOBALS['FORUM_DB']); $name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => $forum_id)); $GLOBALS['FORUM_DB']->query_update('f_multi_moderations', array('mm_move_to' => NULL), array('mm_move_to' => $forum_id)); $GLOBALS['FORUM_DB']->query_update('f_forums', array('f_parent_forum' => db_get_first_id()), array('f_parent_forum' => $forum_id)); $GLOBALS['FORUM_DB']->query_delete('f_forums', array('id' => $forum_id), '', 1); $GLOBALS['FORUM_DB']->query_delete('group_category_access', array('module_the_name' => 'forums', 'category_name' => strval($forum_id))); $GLOBALS['FORUM_DB']->query_delete('gsp', array('module_the_name' => 'forums', 'category_name' => strval($forum_id))); require_code('notifications'); delete_all_notifications_on('ocf_topic', 'forum:' . strval($forum_id)); $GLOBALS['FORUM_DB']->query_delete('f_forum_intro_member', array('i_forum_id' => $forum_id)); $GLOBALS['FORUM_DB']->query_delete('f_forum_intro_ip', array('i_forum_id' => $forum_id)); log_it('DELETE_FORUM', strval($forum_id), $name); }
/** * The actualiser for uploading a file. * * @return tempcode The UI. */ function module_do_upload() { if (!has_specific_permission(get_member(), 'upload_filedump')) { access_denied('I_ERROR'); } $title = get_page_title('FILEDUMP_UPLOAD'); if (function_exists('set_time_limit')) { @set_time_limit(0); } // Slowly uploading a file can trigger time limit, on some servers $place = filter_naughty(post_param('place')); require_code('uploads'); if (!is_swf_upload(true) && (!array_key_exists('file', $_FILES) || !is_uploaded_file($_FILES['file']['tmp_name']))) { $attach_name = 'file'; $max_size = get_max_file_size(); if (isset($_FILES[$attach_name]) && ($_FILES[$attach_name]['error'] == 1 || $_FILES[$attach_name]['error'] == 2)) { warn_exit(do_lang_tempcode('FILE_TOO_BIG', integer_format($max_size))); } elseif (isset($_FILES[$attach_name]) && ($_FILES[$attach_name]['error'] == 3 || $_FILES[$attach_name]['error'] == 6 || $_FILES[$attach_name]['error'] == 7)) { warn_exit(do_lang_tempcode('ERROR_UPLOADING_' . strval($_FILES[$attach_name]['error']))); } else { warn_exit(do_lang_tempcode('ERROR_UPLOADING')); } } $file = $_FILES['file']['name']; if (get_magic_quotes_gpc()) { $file = stripslashes($file); } if (!has_specific_permission(get_member(), 'upload_anything_filedump') || get_file_base() != get_custom_file_base()) { check_extension($file); } $file = str_replace('.', '-', basename($file, '.' . get_file_extension($file))) . '.' . get_file_extension($file); if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place . $file)) { $max_size = get_max_file_size(); if ($_FILES['file']['size'] > $max_size) { warn_exit(do_lang_tempcode('FILE_TOO_BIG', integer_format(intval($max_size)))); } $full = get_custom_file_base() . '/uploads/filedump' . $place . $file; if (is_swf_upload(true)) { @rename($_FILES['file']['tmp_name'], $full) or warn_exit(do_lang_tempcode('FILE_MOVE_ERROR', escape_html($file), escape_html('uploads/filedump' . $place))); } else { @move_uploaded_file($_FILES['file']['tmp_name'], $full) or warn_exit(do_lang_tempcode('FILE_MOVE_ERROR', escape_html($file), escape_html('uploads/filedump' . $place))); } fix_permissions($full); sync_file($full); $return_url = build_url(array('page' => '_SELF', 'place' => $place), '_SELF'); $test = $GLOBALS['SITE_DB']->query_value_null_ok('filedump', 'description', array('name' => $file, 'path' => $place)); if (!is_null($test)) { delete_lang($test); } $GLOBALS['SITE_DB']->query_delete('filedump', array('name' => $file, 'path' => $place), '', 1); $description = post_param('description'); $GLOBALS['SITE_DB']->query_insert('filedump', array('name' => $file, 'path' => $place, 'the_member' => get_member(), 'description' => insert_lang_comcode($description, 3))); require_code('notifications'); $subject = do_lang('FILEDUMP_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $file, $place); $mail = do_lang('FILEDUMP_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($file), array(comcode_escape($place), comcode_escape($description))); dispatch_notification('filedump', $place, $subject, $mail); log_it('FILEDUMP_UPLOAD', $file, $place); if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), get_page_name(), get_zone_name())) { syndicate_described_activity('filedump:ACTIVITY_FILEDUMP_UPLOAD', $place . '/' . $file, '', '', '', '', '', 'filedump'); } return redirect_screen($title, $return_url, do_lang_tempcode('SUCCESS')); } else { warn_exit(do_lang_tempcode('OVERWRITE_ERROR')); } return new ocp_tempcode(); }
/** * Deletes all language codes linked to by the specified table and attribute identifiers, if they exist. * * @param ID_TEXT The table * @param array The attributes * @param ?object The database connection to use (NULL: standard site connection) */ function mass_delete_lang($table, $attrs, $connection) { if (count($attrs) == 0) { return; } if (is_null($connection)) { $connection = $GLOBALS['SITE_DB']; } $rows = $connection->query_select($table, $attrs, NULL, '', NULL, NULL, true); if (!is_null($rows)) { foreach ($rows as $row) { foreach ($attrs as $attr) { delete_lang($row[$attr], $connection); } } } }
/** * Delete a CEDI page * * @param AUTO_LINK The page ID */ function cedi_delete_page($id) { if (function_exists('set_time_limit')) { @set_time_limit(0); } $start = 0; do { $posts = $GLOBALS['SITE_DB']->query_select('seedy_posts', array('id'), array('page_id' => $id), '', 500, $start); foreach ($posts as $post) { cedi_delete_post($post['id']); } $start += 500; } while (array_key_exists(0, $posts)); $pages = $GLOBALS['SITE_DB']->query_select('seedy_pages', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $pages)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $page = $pages[0]; $_description = $page['description']; $_title = $page['title']; delete_lang($_description); delete_lang($_title); $GLOBALS['SITE_DB']->query_delete('seedy_pages', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('seedy_children', array('parent_id' => $id)); $GLOBALS['SITE_DB']->query_delete('seedy_children', array('child_id' => $id)); $GLOBALS['SITE_DB']->query_delete('seedy_changes', array('the_page' => $id)); }
/** * Delete a Welcome E-mail. * * @param AUTO_LINK The ID */ function ocf_delete_welcome_email($id) { $_subject = $GLOBALS['SITE_DB']->query_value('f_welcome_emails', 'w_subject', array('id' => $id)); $_text = $GLOBALS['SITE_DB']->query_value('f_welcome_emails', 'w_text', array('id' => $id)); log_it('DELETE_WELCOME_EMAIL', strval($id), get_translated_text($_subject)); $GLOBALS['SITE_DB']->query_delete('f_welcome_emails', array('id' => $id), '', 1); delete_lang($_subject); delete_lang($_text); }
/** * The actualiser to edit a zone (via zone editor). * * @return tempcode The UI */ function __editor() { $title = get_page_title('ZONE_EDITOR'); $lang = choose_language($title, true); if (is_object($lang)) { return $lang; } $id = get_param('id', ''); // Edit settings $_title = post_param('title'); $default_page = post_param('default_page'); $header_text = post_param('header_text'); $theme = post_param('theme'); $wide = post_param_integer('wide'); if ($wide == -1) { $wide = NULL; } $require_session = post_param_integer('require_session', 0); $displayed_in_menu = post_param_integer('displayed_in_menu', 0); actual_edit_zone($id, $_title, $default_page, $header_text, $theme, $wide, $require_session, $displayed_in_menu, $id); if ($id != '') { $this->set_permissions($id); } // Edit pages foreach (array('panel_left', 'start', 'panel_right') as $for) { $redirect = post_param('redirect_' . $for, NULL); if (!is_null($redirect)) { if (addon_installed('redirects_editor')) { $GLOBALS['SITE_DB']->query_delete('redirects', array('r_from_page' => $for, 'r_from_zone' => $id), '', 1); if ($redirect != $id) { $GLOBALS['SITE_DB']->query_insert('redirects', array('r_from_page' => $for, 'r_from_zone' => $id, 'r_to_page' => $for, 'r_to_zone' => $redirect, 'r_is_transparent' => 1), false, true); // Avoid problem when same key entered twice } else { $redirect = NULL; } } else { $redirect = NULL; } } $comcode = post_param($for, NULL); if (!is_null($comcode)) { // Where to save to $fullpath = zone_black_magic_filterer(get_custom_file_base() . ((is_null($redirect) ? $id : $redirect) == '' ? '' : '/') . (is_null($redirect) ? $id : $redirect) . '/pages/comcode_custom/' . $lang . '/' . $for . '.txt'); // Make dir if needed if (!file_exists(dirname($fullpath))) { if (@mkdir(dirname($fullpath), 0777) === false) { warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY_REPAIR', escape_html(basename(dirname($fullpath))), escape_html(dirname(dirname($fullpath))))); } fix_permissions(dirname($fullpath), 0777); sync_file(dirname($fullpath)); } // Store revision if (file_exists($fullpath) && get_option('store_revisions') == '1') { $time = time(); @copy($fullpath, $fullpath . '.' . strval($time)) or intelligent_write_error($fullpath . '.' . strval($time)); fix_permissions($fullpath . '.' . strval($time)); sync_file($fullpath . '.' . strval($time)); } // Save $myfile = @fopen($fullpath, 'wt') or intelligent_write_error($fullpath); if (fwrite($myfile, $comcode) < strlen($comcode)) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } fclose($myfile); fix_permissions($fullpath); sync_file($fullpath); // De-cache $caches = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index'), array('the_zone' => is_null($redirect) ? $id : $redirect, 'the_page' => $for)); foreach ($caches as $cache) { delete_lang($cache['string_index']); } $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => is_null($redirect) ? $id : $redirect, 'the_page' => $for)); } } persistant_cache_empty(); // Redirect $url = get_param('redirect'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * Delete all chatrooms. */ function delete_all_chatrooms() { if (function_exists('set_time_limit')) { @set_time_limit(0); } do { $c_welcomes = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('id', 'c_welcome'), array('is_im' => 0), '', 400); foreach ($c_welcomes as $c_welcome) { delete_lang($c_welcome['c_welcome']); $GLOBALS['SITE_DB']->query_delete('chat_rooms', array('id' => $c_welcome['id'])); delete_chat_messages(array('room_id' => $c_welcome['id'])); } } while ($c_welcomes != array()); decache('side_shoutbox'); log_it('DELETE_ALL_ROOMS'); }
/** * The actualiser to edit a comcode page. * * @return tempcode The UI */ function __ed() { $simple_add = get_param_integer('simple_add', 0) == 1; $title = get_page_title($simple_add ? 'COMCODE_PAGE_ADD' : 'COMCODE_PAGE_EDIT'); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/comcode_page_edit'; $file = filter_naughty(post_param('file')); $lang = filter_naughty(post_param('lang')); $zone = filter_naughty(post_param('zone')); if (addon_installed('page_management')) { $new_file = filter_naughty(has_actual_page_access(get_member(), 'admin_sitetree') ? post_param('title', $file) : $file); } else { $new_file = filter_naughty($file); } if ($file == '') { $file = $new_file; } require_code('type_validation'); if (!is_alphanumeric($file, true)) { warn_exit(do_lang_tempcode('BAD_CODENAME')); } $fullpath = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang . '/' . $file . '.txt'); $renaming_page = $new_file != $file; if ($renaming_page) { if (!is_alphanumeric($new_file, true)) { warn_exit(do_lang_tempcode('BAD_CODENAME')); } $langs = find_all_langs(true); $rename_map = array(); $afm_needed = false; // Actually will stay false as we don't allow renaming original-pages at the moment foreach (array_keys($langs) as $lang) { $path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt', true); if (is_file(get_file_base() . '/' . $path)) { $new_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $new_file . '.txt', true); if (is_file($new_path)) { warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($zone . ':' . $new_file))); } $rename_map[$path] = $new_path; } if (is_file(get_file_base() . '/' . str_replace('/comcode_custom/', '/comcode/', $path))) { $completion_text = do_lang_tempcode('ORIGINAL_PAGE_NO_RENAME'); } } if ($afm_needed) { require_code('abstract_file_manager'); force_have_afm_details(); } } $validated = post_param_integer('validated', 0); if (!has_specific_permission(get_member(), 'bypass_validation_highrange_content')) { $validated = 0; } $parent_page = post_param('parent_page', ''); $show_as_edit = post_param_integer('show_as_edit', 0); $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file)); check_edit_permission('high', $resource_owner); if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) { $_owner = post_param('owner', $GLOBALS['FORUM_DRIVER']->get_username(get_member())); $owner = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_owner); if (is_null($owner)) { $owner = get_member(); } } else { $owner = get_member(); } if (is_null($resource_owner)) { check_submit_permission('high'); require_code('submit'); give_submit_points('COMCODE_PAGE_ADD'); if (!addon_installed('unvalidated')) { $validated = 1; } $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => $zone, 'the_page' => $file, 'p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => NULL, 'p_add_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => 0)); } else { if (!has_actual_page_access(get_member(), $file, $zone)) { access_denied('PAGE_ACCESS'); } require_code('submit'); $just_validated = !content_validated('comcode_page', $zone . ':' . $file) && $validated == 1; if ($just_validated) { send_content_validated_notification('comcode_page', $zone . ':' . $file); } if (!addon_installed('unvalidated')) { $validated = 1; } $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => $show_as_edit), array('the_zone' => $zone, 'the_page' => $file), '', 1); } if ($validated == 0) { require_code('submit'); $edit_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $new_file), '_SELF', NULL, false, false, true); if (addon_installed('unvalidated')) { send_validation_request('COMCODE_PAGE_EDIT', 'comcode_pages', true, $zone . ':' . $new_file, $edit_url); } } $new = post_param('post'); require_code('attachments2'); $_new = do_comcode_attachments($new, 'comcode_page', $zone . ':' . $file); $new = $_new['comcode']; if (!file_exists($fullpath) || $new != file_get_contents($fullpath, FILE_TEXT)) { $myfile = @fopen($fullpath, 'wt'); if ($myfile === false) { intelligent_write_error($fullpath); } final_attachments_from_preview($zone . ':' . $file); if (fwrite($myfile, $new) < strlen($new)) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } fclose($myfile); sync_file($fullpath); $file_changed = true; } else { $file_changed = false; } require_code('seo2'); $new_keywords = post_param('meta_keywords', ''); $new_description = post_param('meta_description', ''); if ($new_keywords == '' && $new_description == '') { seo_meta_set_for_implicit('comcode_page', $zone . ':' . $file, array($new), $new); } else { seo_meta_set_for_explicit('comcode_page', $zone . ':' . $file, $new_keywords, $new_description); } $completion_text = $validated == 0 ? do_lang_tempcode('SUBMIT_UNVALIDATED') : do_lang_tempcode('SUCCESS'); // Update cache NO WE CAN'T - THEY'RE MULTI-THEME NOW /* $string_index=$GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages','string_index',array('the_zone'=>$zone,'the_page'=>$file)); if (!is_null($string_index)) { lang_remap_comcode($string_index,$new); } else { $string_index=insert_lang_comcode($new,1,NULL,false,NULL,NULL,false,NULL,NULL,60,true,true); $GLOBALS['SITE_DB']->query_insert('cached_comcode_pages',array('the_zone'=>$zone,'the_page'=>$file,'string_index'=>$string_index)); }*/ require_code('permissions2'); set_page_permissions_from_environment($zone, $file); $caches = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index'), array('the_zone' => $zone, 'the_page' => $file)); $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $file)); foreach ($caches as $cache) { delete_lang($cache['string_index']); } persistant_cache_empty(); persistant_cache_delete(array('PAGE_INFO')); decache('main_comcode_page_children'); fix_permissions($fullpath); if (is_file($fullpath) && get_option('store_revisions') == '1' && $file_changed) { $time = time(); @copy($fullpath, $fullpath . '.' . strval($time)) or intelligent_write_error($fullpath . '.' . strval($time)); fix_permissions($fullpath . '.' . strval($time)); sync_file($fullpath . '.' . strval($time)); } log_it('COMCODE_PAGE_EDIT', $file, $zone); require_code('autosave'); clear_ocp_autosave(); if ($renaming_page) { $GLOBALS['SITE_DB']->query_delete('comcode_pages', array('the_zone' => $zone, 'the_page' => $new_file), '', 1); $GLOBALS['SITE_DB']->query_update('comcode_pages', array('the_page' => $new_file), array('the_zone' => $zone, 'the_page' => $file), '', 1); $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $new_file), array('the_zone' => $zone, 'p_parent_page' => $file)); foreach ($rename_map as $path => $new_path) { if ($afm_needed) { afm_move($path, $new_path); } else { rename(get_custom_file_base() . '/' . $path, get_custom_file_base() . '/' . $new_path); } } if (addon_installed('awards')) { $types = $GLOBALS['SITE_DB']->query_select('award_types', array('id'), array('a_content_type' => 'comcode_page')); foreach ($types as $type) { $GLOBALS['SITE_DB']->query_update('award_archive', array('content_id' => $new_file), array('content_id' => $file, 'a_type_id' => $type['id'])); } } $file = $new_file; } if (post_param_integer('delete', 0) == 1) { unlink(get_custom_file_base() . '/' . $path); } if (addon_installed('awards')) { require_code('awards'); handle_award_setting('comcode_page', $zone . ':' . $file); } decache('main_sitemap'); breadcrumb_set_self(do_lang_tempcode('DONE')); // Look for bad title semantics $_new['html'] = $_new['tempcode']->evaluate(); if (substr($file, 0, 1) != '_' && substr($file, 0, 6) != 'panel_' && trim($_new['html']) != '') { if (strpos($_new['html'], '<h1') === false && strpos($_new['comcode'], '[title]') === false && strpos($_new['comcode'], '[title="1"]') === false) { attach_message(do_lang_tempcode('NO_LEVEL_1_HEADERS'), 'notice'); } $matches = array(); if (strpos($_new['html'], '<h2') === false && preg_match_all('#\\n\\[(b|font|size)\\][^\\.]+\\[/(b|font|size)\\]\\n#', $_new['comcode'], $matches) >= 2) { attach_message(do_lang_tempcode('NO_LEVEL_2_HEADERS'), 'inform'); } } // Show it worked / Refresh $url = post_param('redirect', ''); if ($url != '') { return redirect_screen($title, $url, $completion_text); } return $this->do_next_manager($title, $file, $zone, $completion_text); }
/** * Delete a newsletter. * * @param AUTO_LINK The ID */ function delete_newsletter($id) { $_title = $GLOBALS['SITE_DB']->query_value('newsletters', 'title', array('id' => $id)); $_description = $GLOBALS['SITE_DB']->query_value('newsletters', 'description', array('id' => $id)); log_it('DELETE_NEWSLETTER', strval($id), get_translated_text($_title)); $GLOBALS['SITE_DB']->query_delete('newsletters', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('newsletter_subscribe', array('newsletter_id' => $id)); delete_lang($_title); delete_lang($_description); }
/** * Delete a usergroup. * * @param AUTO_LINK The ID of the usergroup to delete. * @param ?GROUP The usergroup to move primary members to (NULL: main members). */ function ocf_delete_group($group_id, $target_group = NULL) { $orig_target_group = $target_group; if (is_null($target_group)) { $target_group = get_first_default_group(); } if ($group_id == db_get_first_id() + 0 || $group_id == db_get_first_id() + 1 || $group_id == db_get_first_id() + 8) { fatal_exit(do_lang_tempcode('INTERNAL_ERROR')); } $_group_info = $GLOBALS['FORUM_DB']->query_select('f_groups', array('g_name', 'g_title', 'g_rank_image'), array('id' => $group_id), '', 1); if (!array_key_exists(0, $_group_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $_name = $_group_info[0]['g_name']; $_title = $_group_info[0]['g_title']; $name = get_translated_text($_name, $GLOBALS['FORUM_DB']); delete_lang($_name, $GLOBALS['FORUM_DB']); delete_lang($_title, $GLOBALS['FORUM_DB']); $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_promotion_target' => NULL), array('g_promotion_target' => $group_id)); $GLOBALS['FORUM_DB']->query_update('f_members', array('m_primary_group' => $target_group), array('m_primary_group' => $group_id)); if (!is_null($orig_target_group)) { $GLOBALS['FORUM_DB']->query_update('f_group_members', array('gm_group_id' => $target_group), array('gm_group_id' => $group_id), '', NULL, NULL, false, true); } $GLOBALS['FORUM_DB']->query_delete('f_group_members', array('gm_group_id' => $group_id)); $GLOBALS['FORUM_DB']->query_delete('f_groups', array('id' => $group_id), '', 1); // No need to delete ocPortal permission stuff, as it could be on any MSN site, and ocPortal is coded with a tolerance due to the forum driver system. However, to be tidy... $GLOBALS['SITE_DB']->query_delete('gsp', array('group_id' => $group_id)); $GLOBALS['SITE_DB']->query_delete('group_zone_access', array('group_id' => $group_id)); $GLOBALS['SITE_DB']->query_delete('group_category_access', array('group_id' => $group_id)); $GLOBALS['SITE_DB']->query_delete('group_page_access', array('group_id' => $group_id)); if (addon_installed('ecommerce')) { $GLOBALS['FORUM_DB']->query_delete('f_usergroup_subs', array('s_group_id' => $group_id)); } require_code('themes2'); tidy_theme_img_code(NULL, $_group_info[0]['g_rank_image'], 'f_groups', 'g_rank_image', $GLOBALS['FORUM_DB']); log_it('DELETE_GROUP', strval($group_id), $name); }
/** * Delete an author * * @param ID_TEXT The name of an author */ function delete_author($author) { $rows = $GLOBALS['SITE_DB']->query_select('authors', array('description', 'skills'), array('author' => $author), '', 1); if (array_key_exists(0, $rows)) { delete_lang($rows[0]['description']); delete_lang($rows[0]['skills']); $GLOBALS['SITE_DB']->query_delete('authors', array('author' => $author), '', 1); } else { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } log_it('DELETE_AUTHOR', $author); }
/** * Delete a poll. * * @param AUTO_LINK The ID of the poll to delete */ function delete_poll($id) { $rows = $GLOBALS['SITE_DB']->query_select('poll', array('*'), array('id' => $id), '', 1); persistant_cache_delete('POLL'); $question = get_translated_text($rows[0]['question']); log_it('DELETE_POLL', strval($id), $question); delete_lang($rows[0]['question']); for ($i = 1; $i <= 10; $i++) { delete_lang($rows[0]['option' . strval($i)]); } $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'polls', 'rating_for_id' => $id)); $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'polls', 'trackback_for_id' => $id)); $GLOBALS['SITE_DB']->query_delete('poll', array('id' => $id), '', 1); }
/** * Delete a news entry. * * @param AUTO_LINK The ID of the news to edit */ function delete_news($id) { $rows = $GLOBALS['SITE_DB']->query_select('news', array('title', 'news', 'news_article'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $title = $rows[0]['title']; $news = $rows[0]['news']; $news_article = $rows[0]['news_article']; $_title = get_translated_text($title); log_it('DELETE_NEWS', strval($id), $_title); require_code('files2'); delete_upload('uploads/grepimages', 'news', 'news_image', 'id', $id); $GLOBALS['SITE_DB']->query_delete('news', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('news_category_entries', array('news_entry' => $id)); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'news', 'rating_for_id' => $id)); $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'news', 'trackback_for_id' => $id)); delete_lang($title); delete_lang($news); require_code('attachments2'); require_code('attachments3'); if (!is_null($news_article)) { delete_lang_comcode_attachments($news_article, 'news', strval($id)); } require_code('seo2'); seo_meta_erase_storage('news', strval($id)); decache('main_news'); decache('side_news'); decache('side_news_archive'); decache('bottom_news'); }
/** * Delete a menu item. * * @param AUTO_LINK The ID of the menu item to delete. */ function delete_menu_item($id) { $_caption = $GLOBALS['SITE_DB']->query_value('menu_items', 'i_caption', array('id' => $id)); $_caption_long = $GLOBALS['SITE_DB']->query_value('menu_items', 'i_caption_long', array('id' => $id)); $GLOBALS['SITE_DB']->query_delete('menu_items', array('id' => $id), '', 1); $caption = get_translated_text($_caption); delete_lang($_caption); delete_lang($_caption_long); log_it('DELETE_MENU_ITEM', strval($id), $caption); }
/** * Standard aed_module delete actualiser. * * @param ID_TEXT The entry being deleted */ function delete_actualisation($id) { $old = $GLOBALS['SITE_DB']->query_select('custom_comcode', array('tag_title', 'tag_description'), array('tag_tag' => $id), '', 1); if (!array_key_exists(0, $old)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $_title = $old[0]['tag_title']; $_description = $old[0]['tag_description']; $GLOBALS['SITE_DB']->query_delete('custom_comcode', array('tag_tag' => $id), '', 1); log_it('DELETE_' . $this->lang_type, $id); delete_lang($_title); delete_lang($_description); }
/** * Delete an IOTD. * * @param AUTO_LINK The ID of the IOTD to delete */ function delete_iotd($id) { $caption = $GLOBALS['SITE_DB']->query_value('iotd', 'caption', array('id' => $id)); $title = $GLOBALS['SITE_DB']->query_value('iotd', 'i_title', array('id' => $id)); log_it('DELETE_IOTD', strval($id), get_translated_text($caption)); delete_lang($caption); delete_lang($title); require_code('files2'); delete_upload('uploads/iotds', 'iotd', 'url', 'id', $id); delete_upload('uploads/iotds_thumbs', 'iotd', 'thumb_url', 'id', $id); // Delete from the database $GLOBALS['SITE_DB']->query_delete('iotd', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'iotds', 'rating_for_id' => $id)); $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'iotds', 'trackback_for_id' => $id)); decache('main_iotd'); }
/** * The actualiser for deleting a message. * * @return tempcode The UI. */ function _chat_delete_message() { $title = get_page_title('DELETE_MESSAGE'); $message_id = get_param_integer('id'); $rows = $GLOBALS['SITE_DB']->query_select('chat_messages', array('the_message', 'room_id'), array('id' => $message_id)); if (!array_key_exists(0, $rows)) { return warn_screen($title, do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $message = $myrow['the_message']; $room_id = $myrow['room_id']; check_chatroom_access($room_id); $room_details = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $room_id), '', 1); if (!array_key_exists(0, $room_details)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $row = $room_details[0]; $has_mod_access = has_specific_permission(get_member(), 'edit_lowrange_content', 'cms_chat', array('chat', $room_id)) || $row['room_owner'] == get_member() && has_specific_permission(get_member(), 'moderate_my_private_rooms'); if (!$has_mod_access) { access_denied('SPECIFIC_PERMISSION', 'edit_lowrange_content'); } $GLOBALS['SITE_DB']->query_delete('chat_messages', array('id' => $message_id), '', 1); decache('side_shoutbox'); $message2 = get_translated_tempcode($message); delete_lang($message); log_it('DELETE_MESSAGE', strval($message_id), $message2->evaluate()); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE')), array('_SELF:_SELF:room:id=' . strval($room_id), do_lang_tempcode('CHAT_MOD_PANEL')))); require_code('templates_donext'); return do_next_manager($title, do_lang_tempcode('SUCCESS'), NULL, NULL, NULL, NULL, array('_SELF', array('type' => 'room', 'id' => $room_id), '_SELF'), NULL, array('_SELF', array(), '_SELF'), NULL, NULL, NULL, NULL, NULL, array(has_actual_page_access(get_member(), 'admin_chat') ? array('chatrooms', array('admin_chat', array('type' => 'misc'), get_module_zone('admin_chat')), do_lang('SETUP')) : NULL)); }
/** * Delete a banner. * * @param ID_TEXT The name of the banner */ function delete_banner($name) { $caption = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'caption', array('name' => $name)); if (is_null($caption)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } log_it('DELETE_BANNER', $name, get_translated_text($caption)); delete_lang($caption); require_code('files2'); delete_upload('uploads/banners', 'banners', 'img_url', 'name', $name); decache('main_banner_wave'); decache('main_topsites'); // Delete from database $GLOBALS['SITE_DB']->query_delete('banners', array('name' => $name), '', 1); }
/** * Delete a download. * * @param AUTO_LINK The ID of the download to delete * @param boolean Whether to leave the actual file behind */ function delete_download($id, $leave = false) { $myrows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('name', 'description', 'comments'), array('id' => $id), '', 1); if (!array_key_exists(0, $myrows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $myrows[0]; log_it('DELETE_DOWNLOAD', strval($id), get_translated_text($myrow['name'])); delete_lang($myrow['name']); delete_lang($myrow['description']); delete_lang($myrow['comments']); require_code('seo2'); seo_meta_erase_storage('downloads_download', strval($id)); if (!$leave) { require_code('files2'); delete_upload('uploads/downloads', 'download_downloads', 'url', 'id', $id); } // Delete from database $GLOBALS['SITE_DB']->query_delete('download_downloads', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('download_logging', array('id' => $id)); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'downloads', 'rating_for_id' => $id)); $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'downloads', 'trackback_for_id' => $id)); $GLOBALS['SITE_DB']->query_update('download_downloads', array('out_mode_id' => NULL), array('out_mode_id' => $id), '', 1); if (addon_installed('galleries')) { // Delete gallery $name = 'download_' . strval($id); require_code('galleries2'); $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'parent_id', array('name' => 'download_' . strval($id))); if (!is_null($test)) { delete_gallery($name); } } decache('main_recent_downloads'); decache('main_top_downloads'); decache('main_download_category'); decache('main_download_tease'); }
/** * The actualiser to edit a menu. * * @return tempcode The UI */ function _edit_menu() { $title = get_page_title('_EDIT_MENU', true, array(escape_html(get_param('id')))); post_param_integer('confirm'); // Just to make sure hackers don't try and get people to erase this form via a URL $menu_id = get_param('id'); // Find what we have on the menu first $ids = array(); foreach ($_POST as $key => $val) { if (is_string($val)) { if (substr($key, 0, 7) == 'parent_') { $ids[intval(substr($key, 7))] = $val; } } } /*// Order $orderings=array(); $ids_copy=$ids; while (count($ids_copy)!=0) { $best_value=0; // to initialise to integer type $best_value=NULL; $best_id=NULL; foreach ($ids_copy as $id=>$parent) { $value=post_param_integer('order_'.strval($id)); if ((is_null($best_id)) || ($value<$best_value)) { $best_id=$id; $best_value=$value; } } $orderings[]=$best_id; unset($ids_copy[$best_id]); }*/ $orderings = array_keys($ids); // Get language codes currently used $old_menu_bits = list_to_map('id', $GLOBALS['SITE_DB']->query_select('menu_items', array('id', 'i_caption', 'i_caption_long'), array('i_menu' => $menu_id))); // Now, process everything on the root $order = 0; foreach ($orderings as $id) { $parent = $ids[$id]; if ($parent == '') { $this->add_menu_item($menu_id, $id, $ids, NULL, $old_menu_bits, $order); $order++; } } // Erase old stuff foreach ($old_menu_bits as $menu_item_id => $lang_code) { $GLOBALS['SITE_DB']->query_delete('menu_items', array('id' => $menu_item_id)); delete_lang($lang_code['i_caption']); delete_lang($lang_code['i_caption_long']); } decache('side_stored_menu'); persistant_cache_delete(array('MENU', $menu_id)); log_it(count($_POST) == 1 ? 'DELETE_MENU' : 'EDIT_MENU', $menu_id); // Go back to editing the menu $url = get_param('redirect', '!'); if ($url == '!') { if (count($_POST) == 1) { $_url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); } else { $_url = build_url(array('page' => '_SELF', 'type' => 'edit', 'wide' => 1, 'id' => $menu_id), '_SELF'); } $url = $_url->evaluate(); } return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * Delete a specified gallery. * * @param ID_TEXT The gallery codename */ function delete_gallery($name) { if ($name == '') { warn_exit(do_lang_tempcode('NO_DELETE_ROOT')); } $rows = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('name' => $name), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } require_code('files2'); delete_upload('uploads/grepimages', 'galleries', 'rep_image', 'name', $name); delete_upload('uploads/watermarks', 'galleries', 'watermark_top_left', 'name', $name); delete_upload('uploads/watermarks', 'galleries', 'watermark_top_right', 'name', $name); delete_upload('uploads/watermarks', 'galleries', 'watermark_bottom_left', 'name', $name); delete_upload('uploads/watermarks', 'galleries', 'watermark_bottom_right', 'name', $name); log_it('DELETE_GALLERY', $name, get_translated_text($rows[0]['fullname'])); delete_lang($rows[0]['fullname']); delete_lang($rows[0]['description']); delete_lang($rows[0]['teaser']); // Images and videos are deleted, because we are deleting the _gallery_, not just a category (nobody is going to be deleting galleries with the expectation of moving the image to a different one in bulk - unlike download categories, for example). if (function_exists('set_time_limit')) { @set_time_limit(0); } do { $images = $GLOBALS['SITE_DB']->query_select('images', array('id'), array('cat' => $name), '', 200); foreach ($images as $image) { delete_image($image['id'], false); } } while ($images != array()); do { $videos = $GLOBALS['SITE_DB']->query_select('videos', array('id'), array('cat' => $name), '', 200); foreach ($videos as $video) { delete_video($video['id'], false); } } while ($images != array()); //... but the subgalleries remain $GLOBALS['SITE_DB']->query_update('galleries', array('parent_id' => $rows[0]['parent_id']), array('parent_id' => $name)); $GLOBALS['SITE_DB']->query_delete('galleries', array('name' => $name), '', 1); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'images', 'rating_for_id' => $name)); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'videos', 'rating_for_id' => $name)); require_code('seo2'); seo_meta_erase_storage('gallery', $name); $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'galleries', 'category_name' => $name)); $GLOBALS['SITE_DB']->query_delete('gsp', array('module_the_name' => 'galleries', 'category_name' => $name)); decache('main_top_galleries'); decache('main_recent_galleries'); decache('main_root_galleries'); decache('side_root_galleries'); }
/** * Delete a calendar event type. * * @param AUTO_LINK The ID of the event type */ function delete_event_type($id) { $myrows = $GLOBALS['SITE_DB']->query_select('calendar_types', array('t_title', 't_logo'), array('id' => $id), '', 1); if (!array_key_exists(0, $myrows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $myrows[0]; $lowest = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT MIN(id) FROM ' . get_table_prefix() . 'calendar_types WHERE id<>' . strval($id) . ' AND id<>' . strval(db_get_first_id())); if (is_null($lowest)) { warn_exit(do_lang_tempcode('NO_DELETE_LAST_CATEGORY')); } $GLOBALS['SITE_DB']->query_update('calendar_events', array('e_type' => $lowest), array('e_type' => $id)); $GLOBALS['SITE_DB']->query_delete('calendar_types', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('calendar_interests', array('t_type' => $id)); log_it('DELETE_EVENT_TYPE', strval($id), get_translated_text($myrow['t_title'])); delete_lang($myrow['t_title']); $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'calendar', 'category_name' => strval($id))); require_code('themes2'); tidy_theme_img_code(NULL, $myrow['t_logo'], 'calendar_types', 't_logo'); }
/** * Load up a language file, compiling it (it's not cached yet). * * @param ID_TEXT The language file name * @param ?LANGUAGE_NAME The language (NULL: uses the current language) * @param ?string The language type (lang_custom, or custom) (NULL: normal priorities are used) * @set lang_custom custom * @param PATH Where we are cacheing too * @param boolean Whether to just return if there was a loading error * @return boolean Whether we FAILED to load */ function require_lang_compile($codename, $lang, $type, $cache_path, $ignore_errors = false) { global $LANGUAGE, $REQUIRE_LANG_LOOP, $LANG_LOADED_LANG; $desire_cache = function_exists('get_option') && (get_option('is_on_lang_cache', true) == '1' || get_param_integer('keep_cache', 0) == 1 || get_param_integer('cache', 0) == 1) && get_param_integer('keep_cache', NULL) !== 0 && get_param_integer('cache', NULL) !== 0; if ($desire_cache) { if ($GLOBALS['IN_MINIKERNEL_VERSION'] == 0) { global $DECACHED_COMCODE_LANG_STRINGS; // Cleanup language strings if (!$DECACHED_COMCODE_LANG_STRINGS) { $DECACHED_COMCODE_LANG_STRINGS = true; $comcode_lang_strings = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index'), array('the_zone' => '!'), '', NULL, NULL, true); if (!is_null($comcode_lang_strings)) { $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => '!')); foreach ($comcode_lang_strings as $comcode_lang_string) { delete_lang($comcode_lang_string['string_index']); } } } } $load_target = array(); } else { $load_target =& $LANGUAGE[$lang]; } global $FILE_ARRAY; if (@is_array($FILE_ARRAY) && file_array_exists('lang/' . $lang . '/' . $codename . '.ini')) { $lang_file = 'lang/' . $lang . '/' . $codename . '.ini'; $file = file_array_get($lang_file); _get_lang_file_map($file, $load_target, NULL, true); $bad = true; } else { $bad = true; $dirty = false; // Load originals $lang_file = get_file_base() . '/lang/' . $lang . '/' . filter_naughty($codename) . '.ini'; if (file_exists($lang_file)) { _get_lang_file_map($lang_file, $load_target, NULL, false); $bad = false; } // Load overrides now if they are there if ($type != 'lang') { $lang_file = get_custom_file_base() . '/lang_custom/' . $lang . '/' . $codename . '.ini'; if (!file_exists($lang_file) && get_file_base() != get_custom_file_base()) { $lang_file = get_file_base() . '/lang_custom/' . $lang . '/' . $codename . '.ini'; } if (!file_exists($lang_file)) { $lang_file = get_custom_file_base() . '/lang_custom/' . $lang . '/' . $codename . '.po'; if (!file_exists($lang_file)) { $lang_file = get_file_base() . '/lang_custom/' . $lang . '/' . $codename . '-' . strtolower($lang) . '.po'; } } } if ($type != 'lang' && file_exists($lang_file)) { _get_lang_file_map($lang_file, $load_target, NULL, false); $bad = false; $dirty = true; // Tainted from the official pack, so can't store server wide } // NB: Merge op doesn't happen in require_lang. It happens when do_lang fails and then decides it has to force a recursion to do_lang(xx,fallback_lang()) which triggers require_lang(xx,fallback_lang()) when it sees it's not loaded if ($bad && $lang != fallback_lang()) { require_lang($codename, fallback_lang(), $type, $ignore_errors); $REQUIRE_LANG_LOOP--; $fallback_cache_path = get_custom_file_base() . '/lang_cached/' . fallback_lang() . '/' . $codename . '.lcd'; if (file_exists($fallback_cache_path)) { require_code('files'); @copy($fallback_cache_path, $cache_path); fix_permissions($cache_path); } if (!array_key_exists($lang, $LANG_LOADED_LANG)) { $LANG_LOADED_LANG[$lang] = array(); } $LANG_LOADED_LANG[$lang][$codename] = 1; return $bad; } if ($bad) { if ($ignore_errors) { return true; } if ($codename != 'critical_error' || $lang != get_site_default_lang()) { fatal_exit(do_lang_tempcode('MISSING_LANG_FILE', escape_html($codename), escape_html($lang))); } else { critical_error('CRIT_LANG'); } } } if (is_null($GLOBALS['MEM_CACHE'])) { // Cache if ($desire_cache) { $file = @fopen($cache_path, 'wt'); // Will fail if cache dir missing .. e.g. in quick installer if ($file) { if (fwrite($file, serialize($load_target)) > 0) { // Success fclose($file); require_code('files'); fix_permissions($cache_path); } else { // Failure fclose($file); @unlink($cache_path); } } } } else { persistant_cache_set(array('LANG', $lang, $codename), $load_target, !$dirty); } if ($desire_cache) { $LANGUAGE[$lang] += $load_target; } return $bad; }
/** * Get the parsed contents of a comcode page. * * @param PATH The relative (to ocPortal's base directory) path to the page (e.g. pages/comcode/EN/start.txt) * @param ID_TEXT The zone the page is being loaded from * @param ID_TEXT The codename of the page * @param ?PATH The file base to load from (NULL: standard) * @param boolean Whether the page is being included from another * @return tempcode The page */ function load_comcode_page($string, $zone, $codename, $file_base = NULL, $being_included = false) { if ($file_base === NULL) { $file_base = get_file_base(); } if (!$being_included) { $GLOBALS['TITLE_CALLED'] = true; } $is_panel = substr($codename, 0, 6) == 'panel_' || strpos($codename, 'panel_') !== false && get_param_integer('keep_theme_test', 0) == 1; if ($zone == '' && $codename == '404') { global $EXTRA_HEAD; $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />'); // XHTMLXHTML $GLOBALS['HTTP_STATUS_CODE'] = '404'; if (!headers_sent()) { if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) { header('HTTP/1.0 404 Not Found'); } } } if (($is_panel || $codename[0] == '_') && get_page_name() == $codename) { global $EXTRA_HEAD; $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />'); // XHTMLXHTML } if ($zone == 'adminzone') { require_code('site_adminzone'); adminzone_special_cases($codename); } if ($codename == 'sitemap') { $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=comcode_pages&filter=' . $zone; } global $PAGE_STRING, $COMCODE_PARSE_TITLE, $LAST_COMCODE_PARSED_TITLE; $COMCODE_PARSE_TITLE = NULL; if ($PAGE_STRING === NULL && !$being_included && !$is_panel) { $PAGE_STRING = $string; } $new_comcode_page_row = array('the_zone' => $zone, 'the_page' => $codename, 'p_parent_page' => '', 'p_validated' => 1, 'p_edit_date' => NULL, 'p_add_date' => NULL, 'p_submitter' => NULL, 'p_show_as_edit' => 0); if ((get_option('is_on_comcode_page_cache') == '1' || get_param_integer('keep_cache', 0) == 1 || get_param_integer('cache', 0) == 1 || get_param_integer('cache_blocks', 0) == 1) && get_param_integer('keep_cache', NULL) !== 0 && get_param_integer('cache_blocks', NULL) !== 0 && get_param_integer('cache', NULL) !== 0 && get_param_integer('keep_print', 0) == 0) { global $SITE_INFO; $support_smart_decaching = !isset($SITE_INFO['disable_smart_decaching']) || $SITE_INFO['disable_smart_decaching'] == '0'; if (is_browser_decacheing()) { $comcode_page = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index', 'cc_page_title'), array('the_page' => $codename, 'the_zone' => $zone, 'the_theme' => $GLOBALS['FORUM_DRIVER']->get_theme()), '', 1, 0, false, array()); if (array_key_exists(0, $comcode_page)) { if ($comcode_page[0]['string_index'] !== NULL) { delete_lang($comcode_page[0]['string_index']); } $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $codename, 'the_zone' => $zone)); } } $theme = $GLOBALS['FORUM_DRIVER']->get_theme(); if ($GLOBALS['MEM_CACHE'] !== NULL) { if ($support_smart_decaching) { $mtime = filemtime($file_base . '/' . $string); if ($mtime > time()) { $mtime = time(); } // Timezone error, we have to assume that cache is ok rather than letting us get in a loop decacheing the file. It'll get fixed automatically in a few hours when the hours of the timezone difference passes. $pcache = persistant_cache_get(array('COMCODE_PAGE', $codename, $zone, $theme, user_lang()), $mtime); } else { $pcache = persistant_cache_get(array('COMCODE_PAGE', $codename, $zone, $theme, user_lang())); } } else { $pcache = NULL; } if ($pcache === NULL) { $comcode_page = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages a JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'comcode_pages b ON (a.the_page=b.the_page AND a.the_zone=b.the_zone)', array('*'), array('a.the_page' => $codename, 'a.the_zone' => $zone, 'the_theme' => $theme), '', 1, NULL, false, array('string_index', 'cc_page_title')); if (array_key_exists(0, $comcode_page)) { if ($support_smart_decaching) { $mtime = filemtime($file_base . '/' . $string); if ($mtime > time()) { $mtime = time(); } // Timezone error, we have to assume that cache is ok rather than letting us get in a loop decacheing the file. It'll get fixed automatically in a few hours when the hours of the timezone difference passes. } if (!$support_smart_decaching || ($comcode_page[0]['p_edit_date'] !== NULL && $comcode_page[0]['p_edit_date'] >= $mtime || $comcode_page[0]['p_edit_date'] === NULL && $comcode_page[0]['p_add_date'] !== NULL && $comcode_page[0]['p_add_date'] >= $mtime)) { $comcode_page_row = $comcode_page[0]; $db_set = get_translated_tempcode($comcode_page[0]['string_index'], NULL, user_lang(), true, true, true); unset($GLOBALS['RECORDED_LANG_STRINGS_CONTENT'][$comcode_page[0]['string_index']]); } else { $mtime = filemtime($file_base . '/' . $string); if ($mtime > time()) { $mtime = time(); } // Timezone error, we have to assume that cache is ok rather than letting us get in a loop decacheing the file. It'll get fixed automatically in a few hours when the hours of the timezone difference passes. $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_edit_date' => $mtime), array('the_page' => $codename, 'the_zone' => $zone), '', 1); $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $codename)); delete_lang($comcode_page[0]['string_index']); $db_set = NULL; $comcode_page_row = NULL; } } else { $db_set = NULL; $comcode_page_row = NULL; } if ($db_set !== NULL) { $index = $comcode_page[0]['string_index']; $title_to_use = $comcode_page[0]['cc_page_title']; if ($title_to_use !== NULL) { $title_to_use = get_translated_text($title_to_use, NULL, NULL, true); if ($title_to_use === NULL) { $title_to_use = $codename; } } $html = $db_set; } else { $comcode_page = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*'), array('the_page' => $codename, 'the_zone' => $zone), '', 1); if (array_key_exists(0, $comcode_page)) { $comcode_page_row = $comcode_page[0]; } require_code('site2'); $new_comcode_page_row['p_add_date'] = filectime($file_base . '/' . $string); list($html, $title_to_use, $comcode_page_row) = _load_comcode_page_not_cached($string, $zone, $codename, $file_base, $comcode_page_row, $new_comcode_page_row, $being_included); } persistant_cache_set(array('COMCODE_PAGE', $codename, $zone, $theme, user_lang()), array($html, $title_to_use, $comcode_page_row)); } else { list($html, $title_to_use, $comcode_page_row) = $pcache; } } else { require_code('site2'); $new_comcode_page_row['p_add_date'] = filectime($file_base . '/' . $string); list($html, $comcode_page_row, $title_to_use) = _load_comcode_page_cache_off($string, $zone, $codename, $file_base, $new_comcode_page_row, $being_included); } $filtered_title_to_use = mixed(); if (!$is_panel && !$being_included) { if ($title_to_use !== NULL && $title_to_use != '') { get_page_title($title_to_use, false); // Little hack - this gets shift encoded, but shift encoding can't survive a tempcode cache. This will force it to reshift. It'll also make sure DISPLAYED_TITLE gets set. $filtered_title_to_use = @html_entity_decode(strip_tags($title_to_use), ENT_QUOTES, get_charset()); } seo_meta_load_for('comcode_page', $zone . ':' . $codename, $filtered_title_to_use); } $LAST_COMCODE_PARSED_TITLE = $title_to_use; if ($html->is_definitely_empty() && $being_included) { return $html; } if (has_actual_page_access(get_member(), 'cms_comcode_pages', NULL, NULL, $comcode_page_row['p_submitter'] == get_member() && !is_guest() ? 'edit_own_highrange_content' : 'edit_highrange_content')) { $redirect = get_self_url(true, false, array('redirect' => NULL, 'redirected' => NULL)); if (($codename == 'panel_left' || $codename == 'panel_right') && has_js() && has_actual_page_access(get_member(), 'admin_zones')) { $edit_url = build_url(array('page' => 'admin_zones', 'type' => '_editor', 'id' => get_zone_name(), 'redirect' => $redirect, 'wide' => 1), get_module_zone('admin_zones')); } else { $edit_url = build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'page_link' => $zone . ':' . $codename, 'redirect' => $redirect), get_module_zone('cms_comcode_pages')); } $add_child_url = get_option('is_on_comcode_page_children') == '1' ? build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'parent_page' => $codename, 'page_link' => $zone . ':'), get_module_zone('cms_comcode_pages')) : new ocp_tempcode(); } else { $edit_url = new ocp_tempcode(); $add_child_url = new ocp_tempcode(); } $warning_details = new ocp_tempcode(); if ($comcode_page_row['p_validated'] !== NULL && $comcode_page_row['p_validated'] == 0) { require_code('site2'); $warning_details = get_page_warning_details($zone, $codename, $edit_url); } if (!$is_panel && $title_to_use !== NULL && !$being_included) { global $PT_PAIR_CACHE_CP; $PT_PAIR_CACHE_CP[$codename]['cc_page_title'] = $title_to_use === NULL ? do_lang_tempcode('NA_EM') : make_string_tempcode($title_to_use); $PT_PAIR_CACHE_CP[$codename]['p_parent_page'] = $comcode_page_row['p_parent_page']; $comcode_breadcrumbs = comcode_breadcrumbs($codename, $zone, get_param('root', ''), $comcode_page_row['p_parent_page'] == '' || !has_specific_permission(get_member(), 'open_virtual_roots')); breadcrumb_add_segment($comcode_breadcrumbs); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $comcode_page_row['p_add_date']), 'creator' => is_guest($comcode_page_row['p_submitter']) ? '' : $GLOBALS['FORUM_DRIVER']->get_username($comcode_page_row['p_submitter']), 'publisher' => '', 'modified' => $comcode_page_row['p_edit_date'] === NULL ? '' : date('Y-m-d', $comcode_page_row['p_edit_date']), 'type' => 'Comcode page', 'title' => $title_to_use, 'identifier' => $zone . ':' . $codename, 'description' => ''); } if ($html->is_definitely_empty() && $is_panel) { return $html; } global $SCREEN_TEMPLATE_CALLED; $st = $SCREEN_TEMPLATE_CALLED; $ret = do_template('COMCODE_PAGE_SCREEN', array('_GUID' => '0fc4fe4f27e54aaaa2b7e4848c02bacb', 'IS_PANEL' => $is_panel, 'BEING_INCLUDED' => $being_included, 'SUBMITTER' => strval($comcode_page_row['p_submitter']), 'TAGS' => get_loaded_tags('comcode_pages'), 'WARNING_DETAILS' => $warning_details, 'EDIT_DATE_RAW' => $comcode_page_row['p_edit_date'] === NULL ? '' : strval($comcode_page_row['p_edit_date']), 'SHOW_AS_EDIT' => $comcode_page_row['p_show_as_edit'] == 1, 'CONTENT' => $html, 'EDIT_URL' => $edit_url, 'ADD_CHILD_URL' => $add_child_url, 'NAME' => $codename)); if ($is_panel || $being_included) { $SCREEN_TEMPLATE_CALLED = $st; } return $ret; }
/** * Delete a topic. * * @param AUTO_LINK The ID of the topic to delete. * @param LONG_TEXT The reason for this action . * @param ?AUTO_LINK Where topic to move posts in this topic to (NULL: delete the posts). * @return AUTO_LINK The forum ID the topic is in (could be found without calling the function, but as we've looked it up, it is worth keeping). */ function ocf_delete_topic($topic_id, $reason = '', $post_target_topic_id = NULL) { // Info about source $info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_pt_to', 't_pt_from', 't_cache_first_title', 't_cache_first_member_id', 't_poll_id', 't_forum_id', 't_cache_num_posts', 't_validated'), array('id' => $topic_id)); if (!array_key_exists(0, $info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $name = $info[0]['t_cache_first_title']; $poll_id = $info[0]['t_poll_id']; $forum_id = $info[0]['t_forum_id']; $num_posts = $info[0]['t_cache_num_posts']; $validated = $info[0]['t_validated']; if (!ocf_may_delete_topics_by($forum_id, get_member(), $info[0]['t_cache_first_member_id']) || !is_null($info[0]['t_pt_from']) && $info[0]['t_pt_from'] != get_member() && (!is_null($info[0]['t_pt_to']) && $info[0]['t_pt_to'] != get_member()) && !ocf_has_special_pt_access($topic_id) && !has_specific_permission(get_member(), 'view_other_pt') && is_null($forum_id)) { access_denied('I_ERROR'); } if (!is_null($post_target_topic_id)) { $to = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 't_forum_id', array('id' => $post_target_topic_id)); if (is_null($to)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } } if (!is_null($forum_id)) { // Update member post counts if we've switched between post-count countable forums $post_count_info = $GLOBALS['FORUM_DB']->query('SELECT id,f_post_count_increment FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id=' . strval((int) $forum_id) . (!is_null($post_target_topic_id) ? ' OR id=' . strval((int) $to) : ''), 2); if ($post_count_info[0]['id'] == $forum_id) { $from_cnt = $post_count_info[0]['f_post_count_increment']; $to_cnt = array_key_exists(1, $post_count_info) ? $post_count_info[1]['f_post_count_increment'] : 0; } else { $from_cnt = $post_count_info[1]['f_post_count_increment']; $to_cnt = $post_count_info[0]['f_post_count_increment']; } require_code('ocf_posts_action'); if ($from_cnt != $to_cnt) { $sql = 'SELECT p_poster FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_topic_id=' . strval((int) $topic_id); if (addon_installed('unvalidated')) { $sql .= ' AND p_validated=1'; } $_member_post_counts = collapse_1d_complexity('p_poster', $GLOBALS['FORUM_DB']->query($sql)); $member_post_counts = array_count_values($_member_post_counts); foreach ($member_post_counts as $member_id => $member_post_count) { if ($to_cnt == 0) { $member_post_count = -$member_post_count; } ocf_force_update_member_post_count($member_id, $member_post_count); } } } // What to do with our posts if (!is_null($post_target_topic_id)) { $GLOBALS['FORUM_DB']->query_update('f_posts', array('p_cache_forum_id' => $to, 'p_topic_id' => $post_target_topic_id), array('p_topic_id' => $topic_id)); require_code('ocf_posts_action2'); ocf_force_update_topic_cacheing($post_target_topic_id); if (!is_null($forum_id)) { ocf_force_update_forum_cacheing($forum_id, $to, 1, $num_posts); } } else { $_postdetails = $GLOBALS['FORUM_DB']->query('SELECT p_post FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_topic_id=' . strval((int) $topic_id)); foreach ($_postdetails as $post) { delete_lang($post['p_post'], $GLOBALS['FORUM_DB']); } $GLOBALS['FORUM_DB']->query_delete('f_posts', array('p_topic_id' => $topic_id)); } // Delete stuff if (!is_null($poll_id)) { require_code('ocf_polls_action'); require_code('ocf_polls_action2'); ocf_delete_poll($poll_id, ''); } $GLOBALS['FORUM_DB']->query_delete('f_topics', array('id' => $topic_id), '', 1); $GLOBALS['FORUM_DB']->query_delete('f_read_logs', array('l_topic_id' => $topic_id)); require_code('notifications'); delete_all_notifications_on('ocf_topics', strval($topic_id)); // Delete the ticket row if it's a ticket if (addon_installed('tickets')) { require_code('tickets'); if (!is_null($forum_id) && is_ticket_forum($forum_id)) { require_code('tickets2'); delete_ticket_by_topic_id($topic_id); } } // Update forum view cacheing if (!is_null($forum_id)) { require_code('ocf_posts_action2'); ocf_force_update_forum_cacheing($forum_id, $validated == 0 ? 0 : -1, -$num_posts); } require_code('ocf_general_action2'); ocf_mod_log_it('DELETE_TOPIC', strval($topic_id), $name, $reason); if (!is_null($forum_id)) { require_code('ocf_posts_action'); ocf_decache_ocp_blocks($forum_id); } else { decache('side_ocf_personal_topics'); decache('_new_pp'); } return $forum_id; }
/** * The actualiser to set match-key access. * * @return tempcode The UI */ function set_keys_access() { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/matchkeysecurity'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_permissions'; $title = get_page_title('PAGE_MATCH_KEY_ACCESS'); // Delete to cleanup $GLOBALS['SITE_DB']->query('DELETE FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_page_access WHERE page_name LIKE \'' . db_encode_like('%:%') . '\''); $mkeylang = collapse_2d_complexity('id', 'k_message', $GLOBALS['SITE_DB']->query_select('match_key_messages', array('id', 'k_message'))); $GLOBALS['SITE_DB']->query_delete('match_key_messages'); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); foreach ($_POST as $key => $val) { if (get_magic_quotes_gpc()) { $val = stripslashes($val); } // See if we can tidy it back to a page-link (assuming it's not one already) $page_link = url_to_pagelink($val, true); if ($page_link != '') { $val = $page_link; } if (substr($key, 0, 4) == 'key_' && $val != '') { foreach (array_keys($groups) as $gid) { if (post_param_integer('p_' . substr($key, 4) . '__' . strval($gid), 0) == 1) { $GLOBALS['SITE_DB']->query_insert('group_page_access', array('zone_name' => '/', 'page_name' => $val, 'group_id' => $gid)); } } } if (substr($key, 0, 5) == 'mkey_' && $val != '') { $id = substr($key, 5); if (substr($id, 0, 4) == 'new_' || !array_key_exists(intval($id), $mkeylang)) { $GLOBALS['SITE_DB']->query_insert('match_key_messages', array('k_message' => insert_lang(post_param('msg_' . $id), 2), 'k_match_key' => $val)); } else { $GLOBALS['SITE_DB']->query_insert('match_key_messages', array('k_message' => lang_remap($mkeylang[intval($id)], post_param('msg_' . $id)), 'k_match_key' => $val)); unset($mkeylang[intval($id)]); } } } foreach ($mkeylang as $lid) { delete_lang($lid); } decache('main_sitemap'); breadcrumb_set_parents(array(array('_SELF:_SELF:keys', do_lang_tempcode('PAGE_MATCH_KEY_ACCESS')))); breadcrumb_set_self(do_lang_tempcode('DONE')); // Show it worked / Refresh $url = build_url(array('page' => '_SELF', 'type' => 'keys'), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }