function nv_show_tab() { global $db, $db_config, $module_name, $page_title, $lang_global, $lang_module, $nv_Request; $tab = filter_text_input('tab', 'get'); $result = $db->sql_query("SHOW TABLE STATUS WHERE `Name`=" . $db->dbescape($tab)); $item = $db->sql_fetch_assoc($result); $db->sql_freeresult($result); if (empty($item)) { Header("Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name); die; } if (in_array(filter_text_input('show_highlight', 'post'), array('php', 'sql'))) { $content = nv_highlight_string($tab, filter_text_input('show_highlight', 'post')); include NV_ROOTDIR . "/includes/header.php"; echo $content; include NV_ROOTDIR . "/includes/footer.php"; } $tablename = substr($item['Name'], strlen($db_config['prefix']) + 1); $contents = array(); $contents['table']['caption'] = sprintf($lang_module['table_caption'], $tablename); $contents['table']['info']['name'] = array($lang_module['table_name'], $tablename); $contents['table']['info']['engine'] = array($lang_module['table_type'], isset($item['Engine']) ? $item['Engine'] : $item['Type']); $contents['table']['info']['row_format'] = array($lang_module['row_format'], $item['Row_format']); $contents['table']['info']['data_length'] = array($lang_module['table_size'], nv_convertfromBytes(intval($item['Data_length']) + intval($item['Index_length']))); $contents['table']['info']['max_data_length'] = array($lang_module['table_max_size'], !empty($item['Max_data_length']) ? nv_convertfromBytes(floatval($item['Max_data_length'])) : 'n/a'); $contents['table']['info']['data_free'] = array($lang_module['table_datafree'], !empty($item['Data_free']) ? nv_convertfromBytes(intval($item['Data_free'])) : 0); $contents['table']['info']['rows'] = array($lang_module['table_numrow'], $item['Rows']); $contents['table']['info']['auto_increment'] = array($lang_module['table_auto_increment'], isset($item['Auto_increment']) ? intval($item['Auto_increment']) : "n/a"); $contents['table']['info']['create_time'] = array($lang_module['table_create_time'], !empty($item['Create_time']) ? strftime("%H:%M:%S %d/%m/%Y", strtotime($item['Create_time'])) : "n/a"); $contents['table']['info']['update_time'] = array($lang_module['table_update_time'], !empty($item['Update_time']) ? strftime("%H:%M:%S %d/%m/%Y", strtotime($item['Update_time'])) : "n/a"); $contents['table']['info']['check_time'] = array($lang_module['table_check_time'], !empty($item['Check_time']) ? strftime("%H:%M:%S %d/%m/%Y", strtotime($item['Check_time'])) : "n/a"); $contents['table']['info']['collation'] = array($lang_module['table_charset'], !empty($item['Collation']) && preg_match("/^([a-z0-9]+)_/i", $item['Collation'], $m) ? $m[1] : ""); $contents['table']['show'] = nv_highlight_string($tab, "php"); $contents['table']['show_lang'] = array($lang_module['php_code'], $lang_module['sql_code']); $contents['table']['row']['caption'] = sprintf($lang_module['table_row_caption'], $tablename); $contents['table']['row']['columns'] = array($lang_module['field_name'], $lang_module['field_type'], $lang_module['field_null'], $lang_module['field_key'], $lang_module['field_default'], $lang_module['field_extra']); $contents['table']['row']['detail'] = array(); $result = $db->sql_query("SHOW COLUMNS FROM `" . $tab . "`"); while ($row = $db->sql_fetch_assoc($result)) { $row['Null'] = $row['Null'] == "NO" ? "NOT NULL" : "NULL"; $row['Key'] = empty($row['Key']) ? "" : ($row['Key'] == 'PRI' ? "PRIMARY KEY" : ($row['Key'] == 'UNI' ? "UNIQUE KEY" : "KEY")); $contents['table']['row']['detail'][] = $row; } $db->sql_freeresult($result); $contents = call_user_func("nv_show_tab_theme", $contents); $page_title = sprintf($lang_module['nv_show_tab'], $tablename); include NV_ROOTDIR . "/includes/header.php"; echo nv_admin_theme($contents); include NV_ROOTDIR . "/includes/footer.php"; }
function nv_show_tab() { global $db, $db_config, $module_name, $page_title, $lang_module, $nv_Request; $tab = $nv_Request->get_title('tab', 'get'); $sth = $db->prepare('SHOW TABLE STATUS WHERE name= :tab'); $sth->bindParam(':tab', $tab, PDO::PARAM_STR); $sth->execute(); $item = $sth->fetch(); if (empty($item)) { Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name); die; } if (in_array($nv_Request->get_title('show_highlight', 'post'), array('php', 'sql'))) { $content = nv_highlight_string($tab, $nv_Request->get_title('show_highlight', 'post')); include NV_ROOTDIR . '/includes/header.php'; echo $content; include NV_ROOTDIR . '/includes/footer.php'; } $tablename = substr($item['name'], strlen($db_config['prefix']) + 1); $contents = array(); $contents['table']['caption'] = sprintf($lang_module['table_caption'], $tablename); $contents['table']['info']['name'] = array($lang_module['table_name'], $tablename); $contents['table']['info']['engine'] = array($lang_module['table_type'], isset($item['engine']) ? $item['engine'] : $item['type']); $contents['table']['info']['row_format'] = array($lang_module['row_format'], $item['row_format']); $contents['table']['info']['data_length'] = array($lang_module['table_size'], nv_convertfromBytes(intval($item['data_length']) + intval($item['index_length']))); $contents['table']['info']['max_data_length'] = array($lang_module['table_max_size'], !empty($item['max_data_length']) ? nv_convertfromBytes(floatval($item['max_data_length'])) : 'n/a'); $contents['table']['info']['data_free'] = array($lang_module['table_datafree'], !empty($item['data_free']) ? nv_convertfromBytes(intval($item['data_free'])) : 0); $contents['table']['info']['rows'] = array($lang_module['table_numrow'], $item['rows']); $contents['table']['info']['auto_increment'] = array($lang_module['table_auto_increment'], isset($item['auto_increment']) ? intval($item['auto_increment']) : 'n/a'); $contents['table']['info']['create_time'] = array($lang_module['table_create_time'], !empty($item['create_time']) ? strftime('%H:%M:%S %d/%m/%Y', strtotime($item['create_time'])) : 'n/a'); $contents['table']['info']['update_time'] = array($lang_module['table_update_time'], !empty($item['update_time']) ? strftime('%H:%M:%S %d/%m/%Y', strtotime($item['update_time'])) : 'n/a'); $contents['table']['info']['check_time'] = array($lang_module['table_check_time'], !empty($item['check_time']) ? strftime('%H:%M:%S %d/%m/%Y', strtotime($item['check_time'])) : 'n/a'); $contents['table']['info']['collation'] = array($lang_module['table_charset'], !empty($item['collation']) && preg_match('/^([a-z0-9]+)_/i', $item['collation'], $m) ? $m[1] : ''); $contents['table']['show'] = nv_highlight_string($tab, 'php'); $contents['table']['show_lang'] = array($lang_module['php_code'], $lang_module['sql_code']); $contents['table']['row']['caption'] = sprintf($lang_module['table_row_caption'], $tablename); $contents['table']['row']['columns'] = array($lang_module['field_name'], $lang_module['field_type'], $lang_module['field_null'], $lang_module['field_key'], $lang_module['field_default'], $lang_module['field_extra']); $contents['table']['row']['detail'] = array(); $columns_array = $db->columns_array($tab); foreach ($columns_array as $row) { $row['null'] = $row['null'] == 'NO' ? 'NOT NULL' : 'NULL'; $row['key'] = empty($row['key']) ? '' : ($row['key'] == 'PRI' ? 'PRIMARY KEY' : ($row['key'] == 'UNI' ? 'UNIQUE KEY' : 'KEY')); $contents['table']['row']['detail'][] = $row; } $contents = nv_show_tab_theme($contents); $page_title = sprintf($lang_module['nv_show_tab'], $tablename); include NV_ROOTDIR . '/includes/header.php'; echo nv_admin_theme($contents); include NV_ROOTDIR . '/includes/footer.php'; }