function main($id, $mode)
 {
     global $db, $user, $auth, $template, $cache;
     global $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx;
     include $phpbb_root_path . 'includes/sgp_functions.' . $phpEx;
     $message = '';
     $search_message = '';
     $found = 0;
     $user->add_lang('acp/k_web_pages');
     $this->tpl_name = 'acp_k_web_pages';
     $this->page_title = 'ACP_K_WEB_PAGES';
     $form_key = 'acp_k_web_pages';
     add_form_key($form_key);
     $action = request_var('action', '');
     $mode = request_var('mode', '');
     $id = request_var('module', 0);
     $submit = isset($_POST['submit']) ? true : false;
     $add = isset($_POST['add']) ? true : false;
     if ($submit && !check_form_key($form_key)) {
         $submit = false;
         trigger_error('Error!' . $user->lang['FORM_INVALID'] . ' see ' . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
     }
     $template->assign_vars(array('U_EDIT' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_web_pages&mode=edit&module=", 'U_DELETE' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_web_pages&mode=delete&module=", 'U_ADD_VARS' => "{$phpbb_admin_path}index.{$phpEx}{$SID}&i=k_resource_words&mode=select"));
     $last_updated = request_var('last_updated', '');
     if ($last_updated == '') {
         $last_updated = $today = date("D d M Y");
     }
     switch (request_var('page_type', '')) {
         case 'H':
             $template->assign_vars(array('S_OPTION' => 'add', 'S_SELECT' => 'head', 'S_PAGE_TYPE' => 'H', 'S_LAST_UPDATED' => $last_updated));
             break;
         case 'B':
             $template->assign_vars(array('S_OPTION' => 'add', 'S_SELECT' => 'body', 'S_PAGE_TYPE' => 'B', 'S_LAST_UPDATED' => $last_updated));
             break;
         case 'F':
             $template->assign_vars(array('S_OPTION' => 'add', 'S_SELECT' => 'foot', 'S_PAGE_TYPE' => 'F', 'S_LAST_UPDATED' => $last_updated));
             break;
         case 'P':
             $template->assign_vars(array('S_OPTION' => 'add', 'S_SELECT' => 'foot', 'S_PAGE_TYPE' => 'P', 'S_LAST_UPDATED' => $last_updated));
             break;
         default:
     }
     s_get_vars();
     switch ($mode) {
         case 'edit':
             if ($submit) {
                 (int) ($id = request_var('id', ''));
                 $active = request_var('active', '');
                 $page_name = utf8_normalize_nfc(request_var('page_name', '', true));
                 //					$page_folder	= utf8_normalize_nfc(request_var('page_folder', '', true));
                 $page_title = utf8_normalize_nfc(request_var('page_title', '', true));
                 $page_desc = utf8_normalize_nfc(request_var('page_desc', '', true));
                 $page_meta = utf8_normalize_nfc(request_var('page_meta', '', true));
                 $page_extn = utf8_normalize_nfc(request_var('page_extn', '', true));
                 $external_file = utf8_normalize_nfc(request_var('external_file', '', true));
                 $page_type = utf8_normalize_nfc(request_var('page_type', '', true));
                 $head = utf8_normalize_nfc(request_var('head', '', true));
                 $body = utf8_normalize_nfc(request_var('body', '', true));
                 $foot = utf8_normalize_nfc(request_var('foot', '', true));
                 $last_updated = utf8_normalize_nfc(request_var('last_updated', '', true));
                 if ($head == '') {
                     $head = 0;
                 }
                 if ($foot == '') {
                     $foot = 0;
                 }
                 if ($page_extn == '') {
                     $page_extn = 0;
                 }
                 //$body = process_for_vars($body, true);
                 $message = $user->lang['SAVING_DATA'];
                 //if ($page_name == '') return;
                 if ($last_updated == '' || $last_updated == '0') {
                     $last_updated = $today = date("D d M Y");
                 }
                 $sql = "UPDATE " . K_WEB_PAGES_TABLE . "\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tactive\t\t\t= '" . (int) $active . "',\n\t\t\t\t\t\t\tpage_type\t\t= '" . $db->sql_escape($page_type) . "',\n\t\t\t\t\t\t\tpage_name\t\t= '" . $db->sql_escape($page_name) . "',\n\t\t\t\t\t\t\tpage_title\t\t= '" . $db->sql_escape($page_title) . "',\n\t\t\t\t\t\t\tpage_desc\t\t= '" . $db->sql_escape($page_desc) . "',\n\t\t\t\t\t\t\tpage_meta\t\t= '" . $db->sql_escape($page_meta) . "',\n\t\t\t\t\t\t\tpage_extn\t\t= '" . $db->sql_escape($page_extn) . "',\n\t\t\t\t\t\t\texternal_file\t= '" . $db->sql_escape($external_file) . "',\n\t\t\t\t\t\t\thead\t\t\t= '" . (int) $head . "',\n\t\t\t\t\t\t\tfoot\t\t\t= '" . (int) $foot . "',\n\t\t\t\t\t\t\tbody\t\t\t= '" . $db->sql_escape($body) . "',\n\t\t\t\t\t\t\tlast_updated\t= '" . $db->sql_escape($last_updated) . "'\n\t\t\t\t\t\tWHERE id = " . (int) $id . " LIMIT 1";
                 if (!($result = $db->sql_query($sql))) {
                     trigger_error($user->lang['ERROR_PORTAL_WEB_TABLE'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                 }
                 $template->assign_vars(array('S_OPTION' => $user->lang['SAVED'], 'MESSAGE' => $message, 'U_BACK' => $this->u_action));
                 unset($submit);
                 meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_web_pages&mode=all");
                 return;
             } else {
                 $sql = "SELECT * FROM " . K_WEB_PAGES_TABLE . " WHERE id =  '" . (int) $id . "'";
                 if (!($result = $db->sql_query($sql))) {
                     trigger_error($user->lang['ERROR_PORTAL_WEB_TABLE'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                 }
                 $row = $db->sql_fetchrow($result);
                 //					$page_folder	= $row['page_folder'];
                 $mid = $row['id'];
                 $active = $row['active'];
                 $page_name = $row['page_name'];
                 $page_title = $row['page_title'];
                 $page_desc = $row['page_desc'];
                 $page_meta = $row['page_meta'];
                 $page_extn = $row['page_extn'];
                 $external_file = $row['external_file'];
                 $page_type = $row['page_type'];
                 $head = $row['head'];
                 $body = $row['body'];
                 $foot = $row['foot'];
                 $last_updated = $row['last_updated'];
                 // if there is no date for last update use todays date //
                 if ($last_updated == '') {
                     $last_updated = $today = date("D d M Y");
                 }
                 // process html for var and replace if found //
                 //$body = process_for_vars($body, false);
                 $template->assign_block_vars('edit', array('S_ID' => $mid, 'S_ACTIVE' => $active, 'S_PAGE_NAME' => $page_name, 'S_PAGE_TITLE' => $page_title, 'S_PAGE_DESC' => $page_desc, 'S_PAGE_META' => $page_meta, 'S_PAGE_EXTN' => $page_extn, 'S_EXTERNAL_FILE' => $external_file, 'S_PAGE_TYPE' => $page_type, 'S_HEAD' => $head, 'S_BODY' => $body, 'S_FOOT' => $foot, 'S_LAST_UPDATED' => $last_updated));
                 $template->assign_vars(array('S_OPTION' => 'edit', 'L_TITLE_EXPLAIN_MORE' => sprintf($user->lang['TITLE_EXPLAIN_MORE'], $user->lang['PAGE_NAME'])));
                 get_headers_and_footers($head, $foot);
             }
             break;
         case 'add':
             get_headers_and_footers('H', 'F');
             if ($submit) {
                 //$page_folder	= utf8_normalize_nfc(request_var('page_folder', '', true));
                 $active = request_var('active', 0);
                 $page_name = utf8_normalize_nfc(request_var('page_name', '', true));
                 $page_title = utf8_normalize_nfc(request_var('page_title', '', true));
                 $page_desc = utf8_normalize_nfc(request_var('page_desc', '', true));
                 $page_meta = utf8_normalize_nfc(request_var('page_meta', '', true));
                 $page_extn = utf8_normalize_nfc(request_var('page_extn', '', true));
                 $external_file = utf8_normalize_nfc(request_var('external_file', '', true));
                 $body = utf8_normalize_nfc(request_var('body', '', true));
                 $page_type = request_var('page_type', '');
                 $head = request_var('head', 0);
                 $foot = request_var('foot', 0);
                 $last_updated = utf8_normalize_nfc(request_var('last_updated', '', true));
                 if ($page_extn == '') {
                     $page_extn = 0;
                 }
                 if ($head == '') {
                     $head = 0;
                 }
                 if ($foot == '') {
                     $foot = 0;
                 }
                 if ($page_name == '') {
                     //echo $page_title; echo $page_name;
                     return;
                 }
                 $sql_ary = array('active' => (int) $active, 'page_type' => (string) $page_type, 'page_name' => (string) $page_name, 'page_title' => (string) $page_title, 'page_desc' => (string) $page_desc, 'page_meta' => (string) $page_meta, 'page_extn' => (int) $page_extn, 'external_file' => (string) $external_file, 'head' => (int) $head, 'foot' => (int) $foot, 'body' => (int) $body, 'last_updated' => (string) $last_updated);
                 $db->sql_query('INSERT INTO ' . K_WEB_PAGES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
                 $result = $db->sql_query($sql);
                 $template->assign_vars(array('S_OPTION' => 'new', 'MESSAGE' => $user->lang['ADDED'], 'L_TITLE_EXPLAIN_MORE' => sprintf($user->lang['TITLE_EXPLAIN_MORE'], $user->lang['PAGE_NAME'])));
                 unset($submit);
                 $cache->destroy('sql', K_WEB_PAGES_TABLE);
                 meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&i=k_web_pages&mode=all");
             } else {
                 $template->assign_var('S_OPTION', 'add');
             }
             break;
         case 'delete':
             if (!$id) {
                 trigger_error($user->lang['MUST_SELECT_VALID_MODULE_DATA'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             if (confirm_box(true)) {
                 $sql = 'DELETE FROM ' . K_WEB_PAGES_TABLE . "\n\t\t\t\t\t\tWHERE id = " . (int) $id;
                 $db->sql_query($sql);
                 $template->assign_vars(array('S_OPTION' => 'delete', 'MESSAGE' => $user->lang['BLOCK_DELETED'] . ' </font><br />', 'L_TITLE_EXPLAIN_MORE' => sprintf($user->lang['TITLE_EXPLAIN_MORE'], $user->lang['PAGE_NAME'])));
                 $cache->destroy('sql', K_WEB_PAGES_TABLE);
                 meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_web_pages&amp;mode=all");
                 return;
             } else {
                 confirm_box(false, $user->lang['CONFIRM_OPERATION_MODULE'], build_hidden_fields(array('i' => 'k_web_pages', 'mode' => $mode, 'action' => 'delete')));
             }
             break;
         case 'all':
         case 'body':
         case 'head':
         case 'foot':
         case 'portal':
             // use switch?
             if ($mode == 'all') {
                 $sql = "SELECT * FROM " . K_WEB_PAGES_TABLE . ' ORDER BY page_type ASC';
             }
             if ($mode == 'body') {
                 $sql = "SELECT * FROM " . K_WEB_PAGES_TABLE . ' WHERE page_type LIKE ' . "'B'" . ' ORDER BY page_name ASC';
             }
             if ($mode == 'head') {
                 $sql = "SELECT * FROM " . K_WEB_PAGES_TABLE . ' WHERE page_type LIKE ' . "'H'" . ' ORDER BY page_name ASC';
             }
             if ($mode == 'foot') {
                 $sql = "SELECT * FROM " . K_WEB_PAGES_TABLE . ' WHERE page_type LIKE ' . "'F'" . ' ORDER BY page_name ASC';
             }
             if ($mode == 'portal') {
                 $sql = "SELECT * FROM " . K_WEB_PAGES_TABLE . ' WHERE page_type LIKE ' . "'P'" . ' ORDER BY page_name ASC';
             }
             if (!($result = $db->sql_query($sql))) {
                 trigger_error($user->lang['ERROR_PORTAL_WEB_TABLE'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
             }
             while ($row = $db->sql_fetchrow($result)) {
                 $mid = $row['id'];
                 $active = $row['active'];
                 $page_name = $row['page_name'];
                 //					$page_folder	= $row['page_folder'];
                 $page_title = $row['page_title'];
                 $page_desc = $row['page_desc'];
                 $page_meta = $row['page_meta'];
                 $page_extn = $row['page_extn'];
                 $external_file = $row['external_file'];
                 $page_type = $row['page_type'];
                 $head = $row['head'];
                 $body = $row['body'];
                 $foot = $row['foot'];
                 $last_updated = $row['last_updated'];
                 // if there is no date for last update use todays date //
                 if ($last_updated == '') {
                     $last_updated = $today = date("D d M Y");
                 }
                 // process html for var and replace if found //
                 //$body = process_for_vars($body, false);
                 $template->assign_block_vars('all', array('S_ID' => $mid, 'S_ACTIVE' => $active, 'S_PAGE_NAME' => $page_name, 'S_PAGE_TITLE' => $page_title, 'S_PAGE_DESC' => $page_desc, 'S_PAGE_META' => $page_meta, 'S_PAGE_EXTN' => $page_extn, 'S_external_file' => $external_file, 'S_PAGE_TYPE' => $page_type, 'S_HEAD' => $head, 'S_BODY' => $body, 'S_FOOT' => $foot, 'S_LAST_UPDATED' => $last_updated));
                 $found++;
             }
             $template->assign_vars(array('S_OPTION' => 'all', 'S_PAGE_TYPE' => $mode, 'L_TITLE_EXPLAIN_MORE' => sprintf($user->lang['TITLE_EXPLAIN_MORE'], $user->lang['PAGE_NAME'])));
             $db->sql_freeresult($result);
             $template->assign_var('SEARCH_MESSAGE', $user->lang['FOUND'] . $found . $user->lang['PAGES']);
             break;
         case 'default':
             break;
     }
 }
Ejemplo n.º 2
0
 function main($id, $mode)
 {
     global $db, $user, $auth, $template, $cache;
     global $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx;
     $found = 0;
     $user->add_lang('acp/k_modules');
     $this->tpl_name = 'acp_k_modules';
     $this->page_title = 'ACP_K_MODULES';
     $form_key = 'acp_k_modules';
     add_form_key($form_key);
     $action = request_var('action', '');
     $mode = request_var('mode', '');
     $id = request_var('module', 0);
     $submit = isset($_POST['submit']) ? true : false;
     $add = isset($_POST['add']) ? true : false;
     $add_style = isset($_POST['add_style']) ? true : false;
     $update_style = isset($_POST['update_style']) ? true : false;
     if ($submit && !check_form_key($form_key)) {
         $submit = false;
         trigger_error($user->lang['FORM_INVALID'] . ' ' . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
     }
     // Get current data //
     if ($mode == 'edit' || $mode == 'delete' && !$submit) {
         $sql = "SELECT * FROM " . K_MODULES_TABLE . " WHERE mod_id =  '" . (int) $id . "'";
     } else {
         if ($mode == 'all') {
             $sql = "SELECT * FROM " . K_MODULES_TABLE . " WHERE mod_id > 1 AND mod_type != 'style' AND mod_type != 'mod' AND mod_type != 'block' ORDER BY mod_type ASC";
         } else {
             if ($mode == 'select') {
                 $sql = "SELECT * FROM " . K_MODULES_TABLE . " WHERE mod_type LIKE '" . $db->sql_escape($mode) . "' AND style_id = '" . (int) $id . "' ORDER BY mod_name ASC";
             } else {
                 $sql = "SELECT * FROM " . K_MODULES_TABLE . " WHERE mod_type LIKE '" . $db->sql_escape($mode) . "'  ORDER BY mod_name ASC";
             }
         }
     }
     if (!($result = $db->sql_query($sql))) {
         trigger_error($user->lang['COULD_NOT_UPDATE_K_MODULES'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
     }
     while ($row = $db->sql_fetchrow($result)) {
         $mod_id = $row['mod_id'];
         $mod_link_id = $row['mod_link_id'];
         $mod_type = $row['mod_type'];
         $mod_origin = $row['mod_origin'];
         $mod_name = $row['mod_name'];
         $mod_filename = $row['mod_filename'];
         $mod_version = $row['mod_version'];
         $mod_author = $row['mod_author'];
         $mod_author_co = $row['mod_author_co'];
         $mod_link = $row['mod_link'];
         $mod_support_link = $row['mod_support_link'];
         $mod_copyright = $row['mod_copyright'];
         $mod_details = $row['mod_details'];
         $mod_status = $row['mod_status'];
         $mod_image = $row['mod_thumb'];
         $mod_last_update = $row['mod_last_update'];
         $mod_download_count = $row['mod_download_count'];
         $mod_details = $row['mod_details'];
         $mod_bbcode_uid = $row['mod_bbcode_uid'];
         $mod_bbcode_bitfield = $row['mod_bbcode_bitfield'];
         $mod_bbcode_options = $row['mod_bbcode_options'];
         decode_message($mod_details, $mod_bbcode_options);
         // Instantiate BBCode class
         if (!isset($bbcode) && $mod_bbcode_bitfield !== '') {
             if (!class_exists('bbcode')) {
                 include $phpbb_root_path . 'includes/bbcode.' . $phpEx;
             }
             $bbcode = new bbcode(base64_encode($mod_bbcode_bitfield));
         }
         if ($row['mod_bbcode_bitfield']) {
             $bbcode->bbcode_second_pass($mod_details, $row['mod_bbcode_uid'], $row['mod_bbcode_bitfield']);
         }
         if ($mod_last_update == '') {
             $mod_last_update = $today = date("D d M Y");
         }
         //$mod_details = process_for_vars($mod_details, false);
         switch ($mode) {
             case 'edit':
             case 'EDIT':
             case 'welcome':
             case 'WELCOME':
                 $template->assign_block_vars($mode, array('S_MOD_ID' => $mod_id, 'S_MOD_LINK_ID' => $mod_link_id, 'S_MOD_DOWNLOAD_COUNT' => $mod_download_count, 'S_MOD_TYPE' => $mod_type, 'S_MOD_ORIGIN' => $mod_origin, 'S_MOD_NAME' => $mod_name, 'S_MOD_FILENAME' => $mod_filename, 'S_MOD_VERSION' => $mod_version, 'S_MOD_AUTHOR' => $mod_author, 'S_MOD_AUTHOR_CO' => $mod_author_co, 'S_MOD_LINK' => $mod_link, 'S_MOD_SUPPORT_LINK' => $mod_support_link, 'S_MOD_COPYRIGHT' => $mod_copyright, 'S_MOD_DETAILS' => $mod_details, 'S_MOD_STATUS' => $mod_status, 'S_MOD_IMAGE' => $mod_image, 'S_MOD_LAST_UPDATED' => $mod_last_update, 'TITLE' => isset($user->lang[strtoupper($mod_name)]) ? $user->lang[strtoupper($mod_name)] : $mod_name, 'TITLE_EXPLAIN' => isset($user->lang[strtoupper($mod_name . '_EXPLAIN')]) ? $user->lang[strtoupper($mod_name . '_EXPLAIN')] : $mod_name));
                 $template->assign_var('S_OPTION', $mode);
                 break;
             default:
                 // return basic information on selected group of mods
                 $template->assign_block_vars($mode, array('S_MOD_ID' => $mod_id, 'S_MOD_TYPE' => $mod_type, 'S_MOD_NAME' => $mod_name, 'S_MOD_DETAILS' => $mod_details, 'TITLE' => isset($user->lang[strtoupper($mod_name)]) ? $user->lang[strtoupper($mod_name)] : $mod_name, 'TITLE_EXPLAIN' => isset($user->lang[strtoupper($mod_name . '_EXPLAIN')]) ? $user->lang[strtoupper($mod_name . '_EXPLAIN')] : $mod_name, 'S_MOD_DOWNLOAD_COUNT' => $mod_download_count));
                 $template->assign_vars('S_OPTION', $mode);
         }
         $found++;
     }
     $db->sql_freeresult($result);
     $template->assign_vars(array('U_EDIT' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_modules&amp;mode=edit&amp;module=", 'U_DELETE' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_modules&amp;mode=delete&amp;module=", 'U_ADD_VARS' => "{$phpbb_admin_path}index.{$phpEx}{$SID}&amp;i=k_resource_words&mode=select", 'SEARCH_MESSAGE' => $user->lang['FOUND'] . $found . $user->lang['OF_TYPE'] . strtoupper($mode), 'S_OPTION' => $mode));
     if ($add_style) {
         if ($mode = "style") {
             $mode = 'new';
         }
         $template->assign_var('S_OPTION', 'add_style');
     }
     if ($mode == 'style' && $submit) {
         $mode = 'add';
     }
     include $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
     generate_smilies('inline', 0);
     s_get_vars();
     switch ($mode) {
         case 'edit':
             if ($submit) {
                 $mod_id = request_var('mod_id', 0);
                 $mod_link_id = request_var('mod_link_id', 0);
                 $mod_download_count = request_var('mod_download_count', 0);
                 $mod_origin = request_var('mod_origin', 0);
                 $mod_status = request_var('mod_status', 0);
                 $mod_last_update = utf8_normalize_nfc(request_var('mod_last_updated', ''));
                 $available = utf8_normalize_nfc(request_var('available', ''));
                 $mod_name = utf8_normalize_nfc(request_var('mod_name', '', true));
                 $mod_filename = utf8_normalize_nfc(request_var('mod_filename', '', true));
                 $mod_version = utf8_normalize_nfc(request_var('mod_version', '', true));
                 $mod_author = utf8_normalize_nfc(request_var('mod_author', '', true));
                 $mod_author_co = utf8_normalize_nfc(request_var('mod_author_co', '', true));
                 $mod_link = utf8_normalize_nfc(request_var('mod_link', '', true));
                 $mod_support_link = utf8_normalize_nfc(request_var('mod_support_link', '', true));
                 $mod_copyright = utf8_normalize_nfc(request_var('mod_copyright', '', true));
                 $mod_type = utf8_normalize_nfc(request_var('mod_type', '', true));
                 $mod_image = utf8_normalize_nfc(request_var('mod_image', '', true));
                 $new_type = utf8_normalize_nfc(request_var('new_type', '', true));
                 $details = ready_text_for_storage(utf8_normalize_nfc(request_var('mod_details', '', true)));
                 if ($new_type != $available) {
                     $mod_type = $new_type;
                 }
                 //$mod_details		= process_for_vars($mod_details, true);
                 if ($mod_name == '' || $mod_type == '') {
                     $message = $user->lang['NO_NAME_NO_TYPE'];
                     return;
                 }
                 if ($mod_last_update == '' || $mod_last_update == '0') {
                     $mod_last_update = $user->format_date();
                 }
                 $sql = "UPDATE " . K_MODULES_TABLE . "\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tmod_link_id\t\t\t= '" . (int) $mod_link_id . "',\n\t\t\t\t\t\t\tmod_origin\t\t\t= '" . (int) $mod_origin . "',\n\t\t\t\t\t\t\tmod_type\t\t\t= '" . $db->sql_escape($mod_type) . "',\n\t\t\t\t\t\t\tmod_name\t\t\t= '" . $db->sql_escape($mod_name) . "',\n\t\t\t\t\t\t\tmod_filename\t\t= '" . $db->sql_escape($mod_filename) . "',\n\t\t\t\t\t\t\tmod_version\t\t\t= '" . $db->sql_escape($mod_version) . "',\n\t\t\t\t\t\t\tmod_author\t\t\t= '" . $db->sql_escape($mod_author) . "',\n\t\t\t\t\t\t\tmod_author_co\t\t= '" . $db->sql_escape($mod_author_co) . "',\n\t\t\t\t\t\t\tmod_copyright\t\t= '" . $db->sql_escape($mod_copyright) . "',\n\t\t\t\t\t\t\tmod_link\t\t\t= '" . $db->sql_escape($mod_link) . "',\n\t\t\t\t\t\t\tmod_support_link\t= '" . $db->sql_escape($mod_support_link) . "',\n\n\t\t\t\t\t\t\tmod_details\t\t\t= '" . $db->sql_escape($details['mod_text']) . "',\n\t\t\t\t\t\t\tmod_bbcode_uid\t\t= '" . $db->sql_escape($details['mod_bbcode_uid']) . "',\n\t\t\t\t\t\t\tmod_bbcode_bitfield\t= '" . $db->sql_escape($details['mod_bbcode_bitfield']) . "',\n\t\t\t\t\t\t\tmod_bbcode_options\t= '" . $db->sql_escape($details['mod_bbcode_options']) . "',\n\n\t\t\t\t\t\t\tmod_thumb\t\t\t= '" . $db->sql_escape($mod_image) . "',\n\t\t\t\t\t\t\tmod_status\t\t\t= '" . $db->sql_escape($mod_status) . "',\n\t\t\t\t\t\t\tmod_last_update\t\t= '" . $db->sql_escape($mod_last_update) . "',\n\t\t\t\t\t\t\tmod_download_count\t= '" . $db->sql_escape($mod_download_count) . "'\n\t\t\t\t\t\tWHERE mod_id = " . $mod_id . " LIMIT 1";
                 if (!($result = $db->sql_query($sql))) {
                     trigger_error($user->lang['COULD_NOT_UPDATE_K_MODULES'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                 }
                 $template->assign_vars(array('S_OPTION' => 'saved', 'MESSAGE' => $user->lang['SAVING_DATA'], 'U_BACK' => $this->u_action));
                 unset($submit);
                 // switch to go back to correct display (miscellaneous, if not one of the built in tyes)
                 switch ($mod_type) {
                     case 'welcome':
                     case 'block':
                     case 'mod':
                     case 'style':
                         break;
                     default:
                         $mod_type = 'all';
                         break;
                 }
                 $cache->destroy('sql', K_MODULES_TABLE);
                 meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_modules&amp;mode=' . $mod_type));
                 return;
             }
             break;
         case 'add':
         case 'new':
             if ($submit) {
                 $mod_link_id = request_var('mod_link_id', 0);
                 $mod_type = utf8_normalize_nfc(request_var('mod_type', '', true));
                 if ($mod_type == 'style' && $mod_link_id != '') {
                     get_theme_data(0);
                 }
                 $mod_link_id = request_var('mod_link_id', 0);
                 $mod_download_count = request_var('mod_download_count', 0);
                 $mod_origin = request_var('mod_origin', 0);
                 $mod_status = request_var('mod_status', 0);
                 $mod_name = utf8_normalize_nfc(request_var('mod_name', '', true));
                 $mod_filename = utf8_normalize_nfc(request_var('mod_filename', '', true));
                 $mod_version = utf8_normalize_nfc(request_var('mod_version', '', true));
                 $mod_author = utf8_normalize_nfc(request_var('mod_author', '', true));
                 $mod_author_co = utf8_normalize_nfc(request_var('mod_author_co', '', true));
                 $mod_link = utf8_normalize_nfc(request_var('mod_link', '', true));
                 $mod_support_link = utf8_normalize_nfc(request_var('mod_support_link', '', true));
                 $mod_copyright = utf8_normalize_nfc(request_var('mod_copyright', '', true));
                 $mod_image = utf8_normalize_nfc(request_var('mod_image', '', true));
                 $mod_last_update = utf8_normalize_nfc(request_var('mod_last_updated', '', true));
                 $available = utf8_normalize_nfc(request_var('available', '', true));
                 $new_type = utf8_normalize_nfc(request_var('new_type', '', true));
                 if ($new_type != $available) {
                     $mod_type = $new_type;
                 }
                 if ($mod_name == '') {
                     return;
                 }
                 $details = ready_text_for_storage(request_var('mod_details', '', true));
                 $sql_array = array('mod_link_id' => $mod_link_id ? $mod_link_id : 0, 'mod_copyright' => $mod_copyright, 'mod_name' => $mod_name, 'mod_filename' => $mod_filename, 'mod_version' => $mod_version, 'mod_type' => $mod_type, 'mod_origin' => $mod_origin, 'mod_details' => $details['mod_text'], 'mod_bbcode_uid' => $details['mod_bbcode_uid'], 'mod_bbcode_bitfield' => $details['mod_bbcode_bitfield'], 'mod_bbcode_options' => $details['mod_bbcode_options'], 'mod_author' => $mod_author, 'mod_link' => $mod_link, 'mod_status' => $mod_status ? $mod_status : 0, 'mod_thumb' => $mod_image, 'mod_last_update' => $mod_last_update, 'mod_author_co' => $mod_author_co, 'mod_support_link' => $mod_support_link, 'mod_download_count' => $mod_download_count ? $mod_download_count : 0);
                 $db->sql_query('INSERT INTO ' . K_MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_array));
                 $template->assign_vars(array('S_OPTION' => $mode, 'MESSAGE' => $user->lang['MODULES_BLOCK_ADDED']));
                 if ($mod_type == 'STYLE' && $submit) {
                     $mode = 'style';
                 }
                 unset($submit);
                 $cache->destroy('sql', K_MODULES_TABLE);
                 meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=k_modules&amp;mode=" . $mode));
             } else {
                 $list = '';
                 $sql = 'SELECT DISTINCT mod_id, mod_name, mod_type FROM ' . K_MODULES_TABLE . ' GROUP BY mod_type';
                 $result = $db->sql_query($sql);
                 while ($row = $db->sql_fetchrow($result)) {
                     if ($row['mod_id'] != 1) {
                         $list .= "'" . $row['mod_name'] . "'";
                         $list .= ",";
                     }
                 }
                 $db->sql_freeresult($result);
                 if ($add_style) {
                     get_theme_data($list);
                 } else {
                     get_mod_types();
                 }
                 if (!isset($mod_last_update)) {
                     $mod_last_update = $today = date("D d M Y");
                 }
                 $mod_type = request_var('mod_type', '');
                 $template->assign_vars(array('S_MOD_LAST_UPDATED' => $mod_last_update, 'S_NEW_TYPE' => $mod_type, 'S_OPTION' => $add_style ? 'add_style' : 'new', 'U_BACK' => $this->u_action, 'MESSAGE' => $user->lang['ADDING_MODULES']));
             }
             break;
         case 'delete':
             if (!$id) {
                 trigger_error($user->lang['MUST_SELECT_VALID_MODULE_DATA'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             if (confirm_box(true)) {
                 $sql = 'DELETE FROM ' . K_MODULES_TABLE . "\n\t\t\t\t\t\tWHERE mod_id = " . (int) $id;
                 $db->sql_query($sql);
                 $template->assign_vars(array('S_OPTION' => 'delete', 'MESSAGE' => $user->lang['MODULE_BLOCK_DELETED'] . '</font><br />'));
                 $cache->destroy('sql', K_MODULES_TABLE);
                 meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=k_modules&amp;mode=all"));
                 return;
             } else {
                 confirm_box(false, $user->lang['CONFIRM_OPERATION_MODULE'], build_hidden_fields(array('i' => 'k_modules', 'mode' => $mode, 'action' => 'delete')));
             }
             break;
         case 'default':
             break;
     }
 }