[Jspmyadmin-devs] CVS: jspmyadmin/web application_parse_log.jsp,NONE,1.1 config.inc.jsp,NONE,1.1 dat
Brought to you by:
zsolyfree
Update of /cvsroot/jspmyadmin/jspmyadmin/web
In directory usw-pr-cvs1:/tmp/cvs-serv27090/web
Added Files:
application_parse_log.jsp config.inc.jsp database.inc.jsp
db_create.jsp db_details.jsp db_dump.jsp db_printview.jsp
db_readdump.jsp db_readfile.jsp error.jsp footer.inc.jsp
functions.js header.inc.jsp index.jsp left.jsp lib.inc.jsp
main.jsp newtest.jsp sql.jsp tbl_addfield.jsp tbl_alter.jsp
tbl_change.jsp tbl_copy.jsp tbl_create.jsp tbl_dump.jsp
tbl_printview.jsp tbl_properties.inc.jsp tbl_properties.jsp
tbl_rename.jsp tbl_replace.jsp tbl_select.jsp test.jsp
Log Message:
Some re order to the CVS to make it build with ANT im preparing the build.xml and properties now, so in a week it maybe ready to workr
--- NEW FILE: application_parse_log.jsp ---
<%
cm.releaseConnection(ds_conn);
//mzsdb_conn.disconnect();
/*if ((STORE_PAGE_PARSE_TIME.equals("1")) && (EXIT_AFTER_REDIRECT.equals("0")))
{*/
jspMyAdminLogWriter parse_log=new jspMyAdminLogWriter(request.getRealPath("logs/parse_time_log"),request.getRemoteAddr());
parse_log.writeln(request.getRequestURI()+request.getQueryString()+" - "+request.getHeader("user-agent")+" - "+request.getHeader("referer")+" - "+((float)((new java.util.Date()).getTime()-parsed)/1000)+"ms");
parse_log.close();
//}
//appProperties.close();
//appLanguage.close();
%>
--- NEW FILE: config.inc.jsp ---
/* $Id: config.inc.jsp,v 1.1 2002/07/26 03:51:47 aalmenar Exp $ */
/*
* phpMyAdmin Configuration File
* All directives are explained in Documentation.html
*/
// You can disable a server config entry by setting host to ''.
// MySQL hostname
host=localhost
// MySQL port - leave blank for default port
port=
// Use advanced authentication?
adv_auth=false
// MySQL standard user (only needed with advanced auth)
stduser=root
// MySQL standard password (only needed with advanced auth)
stpass=
// MySQL user (only needed with basic auth)
user=root
// MySQL password (only needed with basic auth)
password=
// If set to a db-name, only this db is accessible
only_db=
// Verbose name for this host - leave blank to show the hostname
verbose=
host1=
port1=
adv_auth1=false
stduser1=
stpass1=
user1=
password1=
only_db1=
verbose1=
//You can put any {host,port...verbose} as you want but don't forget to
//numerate them correctly
cfgManualBase = http://www.mysql.com/documentation/mysql/bychapter/
cfgConfirm = true
cfgBorder = 0
cfgThBgcolor = #D3DCE3
cfgBgcolorOne = #CCCCCC
cfgBgcolorTwo = #DDDDDD
cfgMaxRows = 30
cfgMaxInputsize = 300px
cfgOrder = ASC
cfgShowBlob = true
cfgShowSQL = true
--- NEW FILE: database.inc.jsp ---
<%
public void mysql_query(HttpServletRequest localrequest, String query) {
Connection conn = (Connection)localrequest.getAttribute("ds_conn");
PreparedStatement pstm = conn.prepareStatement(query);
ResultSet rst = pstm.executeQuery();
}
public int mysql_num_rows(ResultSet rset) {
int number_of_rows=0;
while (rset.next()) {
number_of_rows++;
}
return number_of_rows;
}
%*>
--- NEW FILE: db_create.jsp ---
<%@ include file="lib.inc.jsp"%>
<%
String db_to_create= (var.existKey("db_to_create"))
? (String)var.get((Object)"db_to_create")
: "";
ResultSet tst = mysql_query (pageContext, "CREATE DATABASE "+ db_to_create);
tst.close();
String themessage = geti18nMessage(request,"strDatabase") +" "+ db_to_create
+" "+geti18nMessage(request,"strHasBeenCreated");
//var.setRequestAttribute("message",themessage);
//var.setRequestAttribute("db",db_to_create);
%>
<%@ include file="header.inc.jsp"%>
<jsp:include page="db_details.jsp" flush="true">
<jsp:param name="db" value="<%=db_to_create%>"/>
<jsp:param name="message" value="<%=themessage%>"/>
</jsp:include>
--- NEW FILE: db_details.jsp ---
<%@ include file="lib.inc.jsp"%>
<%
if ( (var.notEmpty( "message" )) ) {
out.println(show_message(cfg, var));
}
else {
%>
<%@ include file="header.inc.jsp"%>
<%
}
%>
<%
int num_tables=0;
Vector tablelist= new Vector();
String query="";
ResultSet rset = mysql_query(pageContext, "SHOW TABLES FROM "+db);
while (rset.next()) {
tablelist.add(rset.getString(1));
num_tables++;
}
if (rset != null) {
rset.close();
}
if (num_tables==0) {
%>
<i18n:message key="strNoTablesFound"/>
<%
}
else {
int i=0;
%>
<table border="<%=cfg.get( "cfgBorder" )%>">
<th><i18n:message key="strTable"/></th>
<th colspan=6><i18n:message key="strAction"/></th>
<th><i18n:message key="strRecords"/></th>
<%
while(i < num_tables) {
table = (String)tablelist.get( i );
query = "?server=" + server + "&db=" + db + "&table=" + table + "&goto=db_details.jsp";
String bgcolor = ((i % 2)==0 ) ? (String)cfg.get( "cfgBgcolorOne" ) : (String)cfg.get( "cfgBgcolorTwo" );
%>
<tr bgcolor="<%=bgcolor%>">
<td class=data><b><%=table%></b></td>
<td><a href="sql.jsp<%=query%>&sql_query=<%= URLEncoder.encode("SELECT * FROM " + table)%>&pos=0"><i18n:message key="strBrowse"/></a></td>
<td><a href="tbl_select.jsp<%=query%>"><i18n:message key="strSelect"/></a></td>
<td><a href="tbl_change.jsp<%=query%>"><i18n:message key="strInsert"/></a></td>
<td><a href="tbl_properties.jsp<%=query%>"><i18n:message key="strProperties"/></a></td>
<td><a href="sql.jsp<%=query%>&reload=true&sql_query=<%= URLEncoder.encode("DROP TABLE " + table)%>&zero_rows=<%= URLEncoder.encode("Table " +table +" "+ geti18nMessage(request,"strHasBeenDropped"))%>"><i18n:message key="strDrop"/></a></td>
<td><a href="sql.jsp<%=query%>&sql_query=<%= URLEncoder.encode ("DELETE FROM " + table )%>&zero_rows=<%= URLEncoder.encode("Table " +table +" "+ geti18nMessage(request,"strHasBeenDropped"))%>"><i18n:message key="strEmpty"/></a></td>
<td align="right">
<%
rset = mysql_query(pageContext, "select count(*) from "+table);
rset.next();
out.println(rset.getString(1));
if (rset != null) {
rset.close();
}
%>
</td>
</tr>
<%
i++;
}
%>
</table>
<%
}
query = "?server="+Integer.toString(server)+"&db="+db+"&goto=db_details.jsp";
%>
<hr>
<div align="left">
<ul>
<li><a href="db_printview.jsp<%=query%>"><i18n:message key="strPrintView"/></a>
<li>
<form method="post" action="db_readdump.jsp">
<input type="hidden" name="server" value="<%=server%>">
<input type="hidden" name="pos" value="0">
<input type="hidden" name="db" value="<%=var.get( "db" )%>">
<input type="hidden" name="goto" value="db_details.jsp">
<input type="hidden" name="zero_rows" value="<i18n:message key="strSuccess"/>">
<i18n:message key="strRunSQLQuery"/><%=db%> [<%=show_docu("manual_Reference.html#Select", cfg)%><i18n:message key="strDocu"/></a>]:<br>
<textarea name="sql_query" cols="40" rows="3" wrap="VIRTUAL" style="width: <%=cfg.get( "cfgMaxInputsize" )%>"></textarea><br>
<input type="submit" name="SQL" value="<i18n:message key="strGo"/>">
</form>
<form method="post" action="db_readfile.jsp" enctype="multipart/form-data">
<input type="hidden" name="server" value="<%=server%>">
<input type="hidden" name="pos" value="0">
<input type="hidden" name="db" value="<%=var.get( "db" )%>">
<input type="hidden" name="goto" value="db_details.jsp">
<input type="hidden" name="zero_rows" value="<i18n:message key="strSuccess"/>">
<i><i18n:message key="strOr"/></i> <i18n:message key="strLocationTextfile"/>:<br>
<input type="file" name="sql_file"><br>
<input type="submit" name="SQL" value="<i18n:message key="strGo"/>">
</form>
<!--<li><a href="tbl_qbe.jsp<%=query%>"><i18n:message key="strQBE"/></a>-->
<li><form method="post" action="db_dump.jsp"><i18n:message key="strViewDumpDB"/><br>
<table>
<tr>
<td>
<input type="radio" name="what" value="structure" checked><i18n:message key="strStrucOnly"/>
</td>
<td>
<input type="checkbox" name="drop" value="1"><i18n:message key="strStrucDrop"/>
</td>
<td colspan="2">
<input type="submit" value="<i18n:message key="strGo"/>">
</td>
</tr>
<tr>
<td>
<input type="radio" name="what" value="data"><i18n:message key="strStrucData"/>
</td>
<td>
<input type="checkbox" name="asfile" value="sendit"><i18n:message key="strSend"/>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="checkbox" name="showcolumns" value="yes"><i18n:message key="strCompleteInserts"/>
</td>
</tr>
</table>
<input type="hidden" name="server" value="<%=server%>">
<input type="hidden" name="db" value="<%=db%>">
</form>
<li>
<form method="post" action="tbl_create.jsp">
<input type="hidden" name="server" value="<%=server%>">
<input type="hidden" name="db" value="<%=db%>">
<i18n:message key="strCreateNewTable"/><%=db%>:<br>
<i18n:message key="strName"/>: <input type="text" name="table_to_create"><br>
<i18n:message key="strFields"/>: <input type="text" name="num_fields" size=2>
<input type="submit" value="<i18n:message key="strGo"/>">
</form>
<li>
<a href="sql.jsp?server=<%=server%>&db=<%=db%>&sql_query=<%= URLEncoder.encode("DROP DATABASE " + db)%>&zero_rows=<i18n:message key="strDatabase"/><%=db%> <i18n:message key="strHasBeenDropped"/>&goto=main.jsp&reload=true"><i18n:message key="strDropDB"/><%=db%></a> [<%=show_docu("manual_Reference.html#Drop_database",cfg)%><i18n:message key="strDocu"/></a>]
</ul>
</div>
<%@ include file="footer.inc.jsp"%>
--- NEW FILE: db_dump.jsp ---
<%@ include file="lib.inc.jsp"%>
<%
String crlf = "\n";
if ( (var.notEmpty( "asfile" )) ) {
response.setHeader("Content-disposition","filename="+db+".sql");
response.setHeader("Content-type","application/octetstream");
response.setHeader("Pragma","no-cache");
response.setHeader("Expires","0");
String client = request.getHeader("USER-AGENT");
if (client.indexOf("(")>0 && client.indexOf(")")>0) {
client = client.substring(client.indexOf("(")+1, client.indexOf(")"));
client=client.toLowerCase();
if (client.indexOf("win")>-1) {
crlf="\r\n";
}
}
}
else {
%>
<%@ include file="header.inc.jsp"%>
<div align=left><pre>
<%
}
%>
<%
ResultSet rst = mysql_query(pageContext, "SHOW TABLES FROM "+db);
if(mysql_num_rows(rst) == 0)
{
out.println(geti18nMessage(request,"strNoTablesFound"));
}
else
{
out.print("# jspMyAdmin MySQL-Dump"+crlf);
out.print("# http://sourceforge.net/projects/jspMyAdmin/"+crlf);
out.print("#"+crlf);
out.print("# "+geti18nMessage(request,"strHost")+": "+cfg.get4Server( "host", server ));
if (!cfg.get4Server( "port", server ).equals("")) {
out.print(":"+cfg.get4Server( "port", server ));
}
out.print(" "+geti18nMessage(request,"strDatabase")+": "+db+crlf);
while (rst.next()) {
String dbtable = rst.getString(1);
out.print(crlf);
out.print("# --------------------------------------------------------"+crlf);
out.print("#"+crlf);
out.print("# "+geti18nMessage(request,"strTableStructure")+" '"+dbtable+"'"+crlf);
out.print("#"+crlf);
out.print(crlf);
out.print(get_table_def(pageContext, cfg, var, dbtable,crlf)+";"+crlf+crlf);
if ((var.notEmpty("what")) && (var.get("what").equals("data"))) {
out.print("#"+crlf);
out.print("# "+geti18nMessage(request,"strDumpingData")+" '"+dbtable+"'"+crlf);
out.print("#"+crlf);
out.print(crlf);
String[] sql_inserts = (get_table_content(pageContext, cfg, var, dbtable,";"));
for (int i=0;i<sql_inserts.length ;i++ ) {
if ( !var.notEmpty( "asfile" ) ) {
out.print(jspMyAdminUtil.htmlSpecialChars(sql_inserts[i]+crlf));
}
else {
out.print(sql_inserts[i]+crlf);
}
}
}
}
}
rst.close();
if ( !var.notEmpty( "asfile" ) ) {
%>
</pre></div>
<%@ include file="footer.inc.jsp"%>
<%
}
%>
--- NEW FILE: db_printview.jsp ---
<%@ include file="lib.inc.jsp"%>
<%
if ( (var.notEmpty( "message" )) ) {
out.println(show_message(cfg, var));
}
else {
%>
<%@ include file="header.inc.jsp"%>
<%
}
ResultSet rst = mysql_query(pageContext, "SHOW TABLES FROM "+db);
if (mysql_num_rows(rst)>0) {
%>
<table border="<%=cfg.get( "cfgBorder" )%>">
<th><i18n:message key="strTable"/></th>
<th><i18n:message key="strRecords"/></th>
<%
int i = 0;
while (rst.next()) {
String name = rst.getString(1);
ResultSet count = mysql_query(pageContext, "SELECT COUNT(*) FROM "+name);
count.next();
String bgcolor = ((i % 2)==0 ) ? (String)cfg.get( "cfgBgcolorOne" ) : (String)cfg.get( "cfgBgcolorTwo" );
out.println("<tr bgcolor=\""+bgcolor+"\">");
out.println("<td class=data><b>"+name+"</b></td>");
out.println("<td align=\"right\"> "+count.getString(1)+"</td>");
out.println("</tr>");
i++;
}
out.println("</table>");
}
else {
out.println(geti18nMessage(request,"strNoTablesFound"));
}
if (rst!=null) {
rst.close();
}
%>
<%@ include file="footer.inc.jsp"%>
--- NEW FILE: db_readdump.jsp ---
<%@ include file="lib.inc.jsp"%>
<%!
/**
* Eliminate comments a String into pices
*
* @author Zsolt Mali
* @param local_sql_query
*/
public String split(String local_sql_query) {
if ((local_sql_query == null) || (local_sql_query.equals("")) ) {
return "";
}
Vector local_str = new Vector();
String toreturn = "";
int exist = 0;
do {
exist =0;
if (!(local_sql_query.indexOf('\n')<0)) {
int i = local_sql_query.indexOf('\n');
String toadd = local_sql_query.substring(0, i+1);
//toadd = toadd.trim();
//System.out.println(toadd.length());
if ((toadd.length()!=0) && (toadd.charAt(0)!='\n') && (toadd.charAt(0) != '#') ) {
local_str.addElement(toadd);
}
/* if ( (toadd.length()!=0) () ) {
local_str.addElement(toadd);
System.out.println(toadd.charAt(0));
}*/
local_sql_query = local_sql_query.substring(i + 1, local_sql_query.length());
exist = 1;
}
}
while (exist ==1);
if (local_sql_query.length()>0) {
local_str.addElement(local_sql_query);
}
for (int i=0;i<local_str.size() ;i++ ) {
toreturn += (String)local_str.elementAt(i);
}
return toreturn;
}
/**
* Splits a String into pices
*
* @author Zsolt Mali
* @param local_sql_query
*/
public String[] split_sql(String local_sql_query) {
Vector local_str = new Vector();
//local_sql_query = jspMyAdminUtil.replaceFromStrToStr(local_sql_query, "#" ,"\r\n" ,"");
local_sql_query = local_sql_query.trim();
local_sql_query = replaceFromStrToChar(local_sql_query, "#" ,'\n' ,"");
char[] buffer = new char[2];
char in_string = '\u0000';
boolean in_str = false;
for(int i=0; i<local_sql_query.length(); i++) {
char ch = local_sql_query.charAt(i);
if (ch==';' && in_str==false)
{
local_str.addElement(local_sql_query.substring(0, i));
local_sql_query = local_sql_query.substring(i + 1, local_sql_query.length());
i = 0;
}
if((in_str==true) && (ch == in_string) && buffer[0] != '\\') {
in_str = false;
}
else if ( (in_str==false) && (ch == '\"' || ch == '\'') && (buffer[0]!='\u0000' || buffer[0] != '\\') ){
in_string = ch;
}
if(buffer[1]!='\u0000') {
buffer[0] = buffer[1];
}
buffer[1] = ch;
}
String[] toreturn = (local_sql_query.length()>0)
? new String[local_str.size()+1]
: new String[local_str.size()];
for (int j=0;j<local_str.size() ;j++ ) {
toreturn[j] = (String)local_str.get(j);
}
if (local_sql_query.length()>0) {
toreturn[toreturn.length-1] = local_sql_query;
}
return toreturn;
}
/**
* Replace in a String a Substring with a replacement
* starting from a specified Substring or char (begin)
* until other specified char (end).
*
* @author Zsolt Mali
* @param source the source string
* @param begin the begin substring
* @param end the end substring
* @param replacement the replacement string
*/
public static String replaceFromStrToChar(String source, String begin, char end, String replacement) {
int bsource = source.indexOf(begin);
int esource = source.indexOf(end, source.indexOf(begin));
while ( (bsource!=-1) && bsource==0 && (esource!=-1))
{
source = source.substring(0,bsource) + replacement +source.substring(esource+1, source.length());
bsource = source.indexOf(begin);
esource = source.indexOf(end, source.indexOf(begin));
}
return source;
}//end method --> public static String replaceFromStrToChar(String source, String begin, char end, String replacement)
%>
<%
String sql_query= (var.existKey("sql_query"))
? jspMyAdminUtil.stripSlashes((String)var.get((Object)"sql_query"))
: "";
sql_query = split(sql_query);
String[] query = split_sql(sql_query);
if ( (query.length==1) && (!query[0].equals("")) ) {
sql_query = query[0].trim();
%>
<jsp:include page="sql.jsp" flush="true">
<jsp:param name="sql_query" value="<%=sql_query%>"/>
<jsp:param name="db" value="<%=db%>"/>
<jsp:param name="server" value="<%=server%>"/>
</jsp:include>
<%
}
else {
ResultSet result = null;
for (int j=0;j<query.length ;j++ ) {
result = mysql_query(pageContext,query[j]);
}
if (result != null) {
result.close();
}
String message = geti18nMessage(request,"strSuccess");
sql_query = jspMyAdminUtil.stripSlashes(sql_query.trim());
%>
<%@ include file="header.inc.jsp"%>
<jsp:include page="db_details.jsp" flush="true">
<jsp:param name="message" value="<%=message%>"/>
<jsp:param name="sql_query" value="<%=sql_query%>"/>
<jsp:param name="db" value="<%=db%>"/>
<jsp:param name="server" value="<%=server%>"/>
</jsp:include>
<%
}//end else if ( (query.length==1) && (!query[0].equals("")) )
%>
--- NEW FILE: db_readfile.jsp ---
<%@ include file="lib.inc.jsp"%>
<%!
/**
* Eliminate comments a String into pices
*
* @author Zsolt Mali
* @param local_sql_query
*/
public String split(String local_sql_query) {
if ((local_sql_query == null) || (local_sql_query.equals("")) ) {
return "";
}
Vector local_str = new Vector();
String toreturn = "";
int exist = 0;
do {
exist =0;
if (!(local_sql_query.indexOf('\n')<0)) {
int i = local_sql_query.indexOf('\n');
String toadd = local_sql_query.substring(0, i+1);
//toadd = toadd.trim();
//System.out.println(toadd.length());
if ((toadd.length()!=0) && (toadd.charAt(0)!='\n') && (toadd.charAt(0) != '#') ) {
local_str.addElement(toadd);
}
local_sql_query = local_sql_query.substring(i + 1, local_sql_query.length());
exist = 1;
}
}
while (exist ==1);
if (local_sql_query.length()>0) {
local_str.addElement(local_sql_query);
}
for (int i=0;i<local_str.size() ;i++ ) {
toreturn += (String)local_str.elementAt(i);
}
return toreturn;
}
/**
* Splits a String into pices
*
* @author Zsolt Mali
* @param local_sql_query
*/
public String[] split_sql(String local_sql_query) {
Vector local_str = new Vector();
//local_sql_query = jspMyAdminUtil.replaceFromStrToStr(local_sql_query, "#" ,"\r\n" ,"");
local_sql_query = local_sql_query.trim();
local_sql_query = replaceFromStrToChar(local_sql_query, "#" ,'\n' ,"");
char[] buffer = new char[2];
char in_string = '\u0000';
boolean in_str = false;
for(int i=0; i<local_sql_query.length(); i++) {
char ch = local_sql_query.charAt(i);
if (ch==';' && in_str==false)
{
local_str.addElement(local_sql_query.substring(0, i));
local_sql_query = local_sql_query.substring(i + 1, local_sql_query.length());
i = 0;
}
if((in_str==true) && (ch == in_string) && buffer[0] != '\\') {
in_str = false;
}
else if ( (in_str==false) && (ch == '\"' || ch == '\'') && (buffer[0]!='\u0000' || buffer[0] != '\\') ){
in_string = ch;
}
if(buffer[1]!='\u0000') {
buffer[0] = buffer[1];
}
buffer[1] = ch;
}
String[] toreturn = (local_sql_query.length()>0)
? new String[local_str.size()+1]
: new String[local_str.size()];
for (int j=0;j<local_str.size() ;j++ ) {
toreturn[j] = (String)local_str.get(j);
}
if (local_sql_query.length()>0) {
toreturn[toreturn.length-1] = local_sql_query;
}
return toreturn;
}
/**
* Replace in a String a Substring with a replacement
* starting from a specified Substring or char (begin)
* until other specified char (end).
*
* @author Zsolt Mali
* @param source the source string
* @param begin the begin substring
* @param end the end substring
* @param replacement the replacement string
*/
public static String replaceFromStrToChar(String source, String begin, char end, String replacement) {
int bsource = source.indexOf(begin);
int esource = source.indexOf(end, source.indexOf(begin));
while ( (bsource!=-1) && bsource==0 && (esource!=-1))
{
source = source.substring(0,bsource) + replacement +source.substring(esource+1, source.length());
bsource = source.indexOf(begin);
esource = source.indexOf(end, source.indexOf(begin));
}
return source;
}//end method --> public static String replaceFromStrToChar(String source, String begin, char end, String replacement)
/**
* Reads the uploaded file into a String
* and the other parameters that was send with the request into a Hashtable
*
* @author Zsolt Mali
* @param request the source request
* @param disp the hashtable that will contains the parameters
*/
public String readUploadFile(HttpServletRequest request,Hashtable disp) throws IOException {
ServletInputStream stream = request.getInputStream();
byte[] b = new byte[8 * 1024];
String toreturn = "";
Vector v = new Vector();
String type = null;
String type1 = request.getHeader("Content-Type");
String type2 = request.getContentType();
// If one value is null, choose the other value
if (type1 == null && type2 != null) {
type = type2;
}
else if (type2 == null && type1 != null) {
type = type1;
}
// If neither value is null, choose the longer value
else if (type1 != null && type2 != null) {
type = (type1.length() > type2.length() ? type1 : type2);
}
if (type == null ||
!type.toLowerCase().startsWith("multipart/form-data")) {
throw new IOException("Posted content type isn't multipart/form-data");
}
int index = type.lastIndexOf("boundary=");
if (index == -1) {
throw new IOException("No boundary");
}
String boundary = type.substring(index + 9); // 9 for "boundary="
if (boundary.charAt(0) == '"') {
// The boundary is enclosed in quotes, strip them
index = boundary.lastIndexOf('"');
boundary = boundary.substring(1, index);
}
// The real boundary is always preceeded by an extra "--"
boundary = "--" + boundary;
int read = 0;
int file = 0;
int eof = 0;
while (read!=-1) {
int donotappend = 0;
byte[] bb = new byte[8 * 1024];
read = stream.readLine(bb, 0 , bb.length);
if (read!=-1) {
String unmodifline = new String(bb, 0 , read);
String line = unmodifline.toLowerCase();
if (line.indexOf("content-disposition: ")>=0) {
int start = line.indexOf("content-disposition: ");
int end = line.indexOf(";");
if (start == -1 || end == -1) {
throw new IOException("Invalid Content disposition: " + unmodifline);
}
String disposition = line.substring(start + 21, end);
if (!disposition.equals("form-data")) {
throw new IOException("Invalid content disposition: " + disposition);
}
start = line.indexOf("name=\"", end); // start at last semicolon
end = line.indexOf("\"", start + 7); // skip name=\"
if (start == -1 || end == -1) {
throw new IOException("Invalid Content disposition: " + unmodifline);
}
String name = line.substring(start + 6, end);
read = stream.readLine(bb, 0 , bb.length);
read = stream.readLine(bb, 0 , bb.length);
String value = new String(bb, 0 , read);
disp.put(name,value);
}
if (line.indexOf("filename")>=0) {
int start = line.indexOf("filename=\"");
int end = line.indexOf("\"", start + 10);
if (start != -1 && end != -1) {
String filename = unmodifline.substring(start + 10, end);
if (filename.length()>0) {
file = 1;
}
}
donotappend = 1;
}
if (line.indexOf("Content-Type")>-1) {
donotappend = 1;
}
if (file == 1 && eof == 0 && donotappend == 0) {
if (line.indexOf(boundary)>-1) {
//out.println("We end");
eof = 1;
}
else {
if (line.equals("\n") || line.equals("\r\n") || line.length()==0 ) {
}
else {
//out.println(line+"<br><hr>");
v.add(unmodifline);
}
}
}
}
}
if (v.size()>0 && file == 1) {
toreturn = "";
for (int j=0;j<v.size() ;j++ ) {
toreturn += (String)v.elementAt(j);
}
}
return toreturn;
}//end public readUploadFile
%>
<%
Hashtable dis = new Hashtable();
String sql_query = readUploadFile(request, dis);
//out.println(dis.size());
//out.println(sql_query+"<br><BR>");
Enumeration en = dis.keys();
while (en.hasMoreElements()) {
String key = (String)en.nextElement();
String value = (String)dis.get(key);
var.set(key.trim(), value.trim());
}
db = var.get("db");
server = var.getInt("server");
sql_query = split(sql_query);
String[] query = split_sql(sql_query);
if ( (query.length==1) && (!query[0].equals("")) ) {
sql_query = query[0].trim();
%>
<jsp:include page="sql.jsp" flush="true">
<jsp:param name="sql_query" value="<%=sql_query%>"/>
<jsp:param name="db" value="<%=db%>"/>
<jsp:param name="server" value="<%=server%>"/>
</jsp:include>
<%
}
else {
mysql_select_db(pageContext, cfg, server, db);
ResultSet result = null;
for (int j=0;j<query.length ;j++ ) {
result = mysql_query(pageContext,query[j]);
}
if (result != null) {
result.close();
}
String message = geti18nMessage(request,"strSuccess");
sql_query = jspMyAdminUtil.stripSlashes(sql_query.trim());
%>
<%@ include file="header.inc.jsp"%>
<jsp:include page="db_details.jsp" flush="true">
<jsp:param name="message" value="<%=message%>"/>
<jsp:param name="sql_query" value="<%=sql_query%>"/>
<jsp:param name="db" value="<%=db%>"/>
<jsp:param name="server" value="<%=server%>"/>
</jsp:include>
<%
}//end else if ( (query.length==1) && (!query[0].equals("")) )
%>
--- NEW FILE: error.jsp ---
<%@ page isErrorPage="true" import="java.util.*,java.io.*,com.jspmyadmin.*" %>
<html>
<head>
<title><app:dsmessage key="SITE_TITLE"/>-Error</title></head>
<body bgcolor="#F5F5F5" text="#000000" background="images/bkg.gif">
<table border="0" cellspacing="0" cellpadding="5" width="100%" align="center" valign="middle">
<tr>
<td width="150" align="right"> </td>
<td align="center"> <b>Oops! an exception occurred.</b> </td>
</tr>
<tr>
<td width="150" align="right"> </td>
<td align="center">The exception was: <font color="red"><b><%=exception.toString()%></b></font></td>
</tr>
<tr>
<td width="150" align="right"> </td>
<td align="center">The exception class was : <font color="red"><b><%=exception.getClass()%></b></font></td>
</tr>
</table>
</body>
</html>
<%
/*PrintWriter tr = new PrintWriter(out);
exception.printStackTrace(tr);*/
application.log(request.getRequestURI()+request.getQueryString(), exception);
%>
--- NEW FILE: footer.inc.jsp ---
</td>
</tr>
</table>
</body>
</html>
<%@ include file="application_parse_log.jsp"%>
--- NEW FILE: functions.js ---
<!--
var isFormElementInRange;
function checkFormElementInRange (form, name, min, max ) {
isFormElementInRange = true;
var val = parseInt( eval( "form." + name + ".value" ));
if(isNaN(val)) {
isFormElementInRange = false;
return false;
}
if (val < min || val > max ) {
alert( val +" is not a valid row number!" );
isFormElementInRange = false;
eval( "form."+ name + ".focus()");
eval( "form."+ name + ".select()");
}else {
eval( "form."+ name + ".value = val" );
}
return true;
}
//-->
--- NEW FILE: header.inc.jsp ---
<html>
<head>
<title>jspMyAdmin</title>
<style type="text/css">
//<!--
body { font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
th { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: bold; background-color: <%=cfg.get( "cfgThBgcolor" )%>;}
td { font-family: Arial, Helvetica, sans-serif; font-size: 10pt;}
form { font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
h1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16pt; font-weight: bold}
A:link { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; text-decoration: none; color: blue}
A:visited { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; text-decoration: none; color: blue}
A:hover { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; text-decoration: underline; color: red}
A:link.nav { font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000}
A:visited.nav { font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000}
A:hover.nav { font-family: Verdana, Arial, Helvetica, sans-serif; color: red;}
.nav { font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000}
//-->
</style>
<!--
<META HTTP-EQUIV="Expires" CONTENT="Fri, Jun 12 1981 08:20:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
-->
</head>
<body bgcolor="#F5F5F5" text="#000000" background="images/bkg.gif">
<%
if (var.notEmpty("db_to_create")) {
var.set("db", var.get("db_to_create"));
}
if ( var.notEmpty( "db" ) ) {
%>
<h1> <i18n:message key="strDatabase"/><%=var.get( "db" )%>
<%
if ( (var.get( "table" )!=null) && (!var.get( "table" ).equals("")) ) {
%>
- <i18n:message key="strTable"/><%=var.get( "table")%>
<%
}
out.println("</h1>");
}
%>
--- NEW FILE: index.jsp ---
<%
/*
* index.jsp 0.6 2001/08/25
* Copyright (c) 2001 zso...@ya... under the GPL (www.gnu.org/copyleft/)
*
* TERMS OF USAGE:
* This file was written and developed by Zsolt Mali (zso...@ya...)
* for educational and demonstration purposes only. You have all rights to use,
* modify, and redistribute this file as you like. The only
* requirement is that you must retain this notice, without modifications, at
* the top of your source code. No warranties or guarantees are expressed or
* implied. DO NOT use this code in a production environment without
* understanding the limitations and weaknesses pretaining to or caused by the
* use of these scripts, directly or indirectly. USE AT YOUR OWN RISK!
*/
%>
<%@ include file="lib.inc.jsp"%>
<html>
<head>
<title>jspMyAdmin</title>
</head>
<%
//sendMyFile();
out.println(load_javascript());
//show_table_navigation(0,0,0,out,pageContext);
%>
<frameset cols="150,*" rows="*" border="0" frameborder="0">
<frame src="left.jsp?server=<%=server%>" name="nav">
<frame src="main.jsp?server=<%=server%>" name="jspmain">
</frameset>
<noframes>
<body bgcolor="#FFFFFF">
</body>
</noframes>
</html>
--- NEW FILE: left.jsp ---
<%@ include file="lib.inc.jsp"%>
<html>
<head>
<title>jspMyAdmin</title>
<script LANGUAGE="JavaScript" type="text/javascript">
<!--
// These scripts were originally found on cooltype.com.
// Modified 01/01/1999 by Tobias Ratschiller for linuxapps.com
// Modified 7th June 2000 by Brian Birtles for Mozilla 5.0
// compatibility for phpMyAdmin
document.onmouseover = doDocumentOnMouseOver ;
document.onmouseout = doDocumentOnMouseOut ;
function doDocumentOnMouseOver() {
var eSrc = window.event.srcElement ;
if (eSrc.className == "item") {
window.event.srcElement.className = "highlight";
}
}
function doDocumentOnMouseOut() {
var eSrc = window.event.srcElement ;
if (eSrc.className == "highlight") {
window.event.srcElement.className = "item";
}
}
var bV=parseInt(navigator.appVersion);
NS4=(document.layers) ? true : false;
IE4=((document.all)&&(bV>=4)) ? true : false;
DOM=(!document.layers && !document.all && bV>=4) ? true : false; // A hack to guess if the browser supports the DOM
capable = (NS4 || IE4 || DOM) ? true : false;
function expandIt(){return}
function expandAll(){return}
//-->
</script>
<script language="JavaScript1.2" type="text/javascript">
<!--
isExpanded = false;
function getIndex(el) {
ind = null;
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id == el) {
ind = i;
break;
}
}
return ind;
}
function arrange() {
nextY = document.layers[firstInd].pageY + document.layers[firstInd].document.height;
for (i=firstInd+1; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.visibility != "hide") {
whichEl.pageY = nextY;
nextY += whichEl.document.height;
}
}
}
function initIt(){
if (NS4) {
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
}
arrange();
} else if(IE4) {
tempColl = document.all.tags("DIV");
for (i=0; i<tempColl.length; i++) {
if (tempColl(i).className == "child") tempColl(i).style.display = "none";
}
} else if(DOM) {
tempColl = document.getElementsByTagName("DIV");
for (i=0; i<tempColl.length; i++) {
if (tempColl(i).className == "child") tempColl(i).style.visibility = "hidden";
}
}
}
function expandIt(el) {
if (!capable) return;
if (IE4) {
expandIE(el);
} else if(NS4) {
expandNS(el);
} else if(DOM) {
expandDOM(el);
}
}
function expandIE(el) {
whichEl = eval(el + "Child");
// Modified Tobias Ratschiller 01-01-99:
// event.srcElement obviously only works when clicking directly
// on the image. Changed that to use the images's ID instead (so
// you've to provide a valid ID!).
//whichIm = event.srcElement;
whichIm = eval(el+"Img");
if (whichEl.style.display == "none") {
whichEl.style.display = "block";
whichIm.src = "images/minus.gif";
}
else {
whichEl.style.display = "none";
whichIm.src = "images/plus.gif";
}
window.event.cancelBubble = true ;
}
function expandNS(el) {
whichEl = eval("document." + el + "Child");
whichIm = eval("document." + el + "Parent.document.images['imEx']");
if (whichEl.visibility == "hide") {
whichEl.visibility = "show";
whichIm.src = "images/minus.gif";
}
else {
whichEl.visibility = "hide";
whichIm.src = "images/plus.gif";
}
arrange();
}
function expandDOM(el) {
whichEl = document.getElementById(el + "Child");
whichIm = document.getElementById(el + "Img");
if (whichEl.style.visibility != "visible") {
whichEl.style.visibility = "visible";
whichIm.src = "images/minus.gif";
} else {
whichEl.style.visibility = "hidden";
whichIm.src = "images/plus.gif";
}
}
function showAll() {
for (i=firstInd; i<document.layers.length; i++) {
whichEl = document.layers[i];
whichEl.visibility = "show";
}
}
function expandAll(isBot) {
// Brian Birtles 7-Jun-00 : This fn might be unnecessary (for phpMyAdmin).
// My changes are certainly untested.
newSrc = (isExpanded) ? "images/plus.gif" : "images/minus.gif";
if (NS4) {
// TR-02-01-99: Don't need that
// document.images["imEx"].src = newSrc;
for (i=firstInd; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Parent") != -1) {
whichEl.document.images["imEx"].src = newSrc;
}
if (whichEl.id.indexOf("Child") != -1) {
whichEl.visibility = (isExpanded) ? "hide" : "show";
}
}
arrange();
if (isBot && isExpanded) scrollTo(0,document.layers[firstInd].pageY);
} else if(IE4) {
divColl = document.all.tags("DIV");
for (i=0; i<divColl.length; i++) {
if (divColl(i).className == "child") {
divColl(i).style.display = (isExpanded) ? "none" : "block";
}
}
imColl = document.images.item("imEx");
for (i=0; i<imColl.length; i++) {
imColl(i).src = newSrc;
}
} else if(DOM) {
divColl = document.getElementsByTagName("DIV");
for (i=0; i<divColl.length; i++) {
if (divColl(i).className == "child") {
divColl(i).style.visibility = (isExpanded) ? "hidden" : "visible";
}
}
imColl = document.getElementsByName("imEx");
for (i=0; i<imColl.length; i++) {
imColl(i).src = newSrc;
}
}
isExpanded = !isExpanded;
}
with (document) {
if(DOM) {
// Brian Birtles : This is not the ideal method of doing this
// but under the 7th June '00 Mozilla build (and many before
// it) Mozilla did not treat text between <style> tags as
// style information unless it was written with the one call
// to write().
var lstyle = "<style type='text/css'>";
lstyle += ".child {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration:none; visibility:hidden}";
lstyle += ".parent {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration:none;}";
lstyle += ".item { color: darkblue; text-decoration:none; font-size: 8pt;}";
lstyle += ".highlight { color: red; font-size: 8pt;}";
lstyle += ".heada { font: 12px/13px; Times}";
lstyle += "DIV { color:black; }";
lstyle += "</style>";
write(lstyle);
} else {
write("<style type='text/css'>");
if (NS4) {
write(".parent {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration:none; position:absolute; visibility:hidden; color: black;}");
write(".child {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;color: #000000; position:absolute; visibility:hidden}");
write(".item { color: darkblue; text-decoration:none;}");
write(".regular {font-family: Arial,Helvetica,sans-serif; position:absolute; visibility:hidden}");
write("DIV { color:black; }");
} else if(IE4) {
write(".child {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration:none; display:none}");
write(".parent {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration:none;}");
write(".item { color: darkblue; text-decoration:none; font-size: 8pt;}");
write(".highlight { color: red; font-size: 8pt;}");
write(".heada { font: 12px/13px; Times}");
write("DIV { color:black; }");
}
write("</style>");
}
}
onload = initIt;
//-->
</script>
<base target="jspmain">
<style type="text/css">
//<!--
body { font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
//-->
</style>
</head>
<body bgcolor="#D0DCE0">
<DIV ID="el1Parent" CLASS="parent">
<A class="item" HREF="main.jsp?server=<%=server%>">
<FONT color="black" class="heada">
<i18n:message key="strHome"/> </FONT></A>
</DIV>
<%
String[] dblist= null;
if ((cfg.get4Server( "only_db" , server ) != null) && (!cfg.get4Server( "only_db" , server ).equals("")) ) {
dblist = new String[1];
dblist[0] = cfg.get4Server( "only_db" , server );
}
String[] tablelist= null;
ResultSet rst = null;
String tmpdbname="";
int num_dbs=0;
int num_tables=0;
// Don't display database info if $server==0 (no server selected)
// This is the case when there are multiple servers and
// '$cfgServerDefault = 0' is set. In that case, we want the welcome
// to appear with no database info displayed.
if(cfg.getNumberOfServers()>=1)
{
if( dblist == null )
{
rst = mysql_query(pageContext, "SHOW DATABASES");
dblist= new String[mysql_num_rows(rst)];
//rst.beforeFirst();
while (rst.next()) {
dblist[num_dbs]=rst.getString(1);
num_dbs++;
}
rst.close();
}
else
{
num_dbs = dblist.length;
}
for(int i=0; i<num_dbs; i++)
{
String localdb = dblist[i];
int j = i + 2;
%>
<div ID="el<%=j%>Parent" CLASS="parent">
<a class="item" HREF="db_details.jsp?server=<%=server%>&db=<%=localdb%>" onClick="expandIt('el<%=j%>'); return false;">
<img NAME="imEx" SRC="images/plus.gif" BORDER="0" ALT="+" width="9" height="9" ID="el<%=j%>Img"></a>
<a class="item" HREF="db_details.jsp?server=<%=server%>&db=<%=localdb%>" onClick="expandIt('el<%=j%>');">
<font color="black" class="heada">
<%=localdb%>
</font></a>
</div>
<div ID="el<%=j%>Child" CLASS="child">
<%
rst = mysql_query(pageContext, "SHOW TABLES FROM "+localdb);
tablelist= new String[mysql_num_rows(rst)];
num_tables=0;
while (rst.next()) {
tablelist[num_tables]=rst.getString(1);
num_tables++;
}
for(int m=0; m<num_tables; m++)
{
String localtable = tablelist[m];
%>
<nobr> <a target="jspmain" href="sql.jsp?server=<%=server%>&db=<%=localdb%>&table=<%=URLEncoder.encode(localtable)%>&sql_query=<%=URLEncoder.encode("SELECT * FROM "+ localtable)%>&pos=0&goto=tbl_properties.jsp"><img src="images/browse.gif" border="0" alt="<i18n:message key="strBrowse"/>": "<%=localtable%>"></a> <a class="item" target="jspmain" HREF="tbl_properties.jsp?server=<%=server%>&db=<%=localdb%>&table=<%=URLEncoder.encode(localtable)%>"><%=localtable%></a></nobr><br>
<%
}
out.println( "</div>\n");
}
%>
<script LANGUAGE="JavaScript1.2">
<!--
if (NS4) {
firstEl = "el1Parent";
firstInd = getIndex(firstEl);
showAll();
arrange();
}
//-->
</script>
<%
}
%>
</body>
</html>
--- NEW FILE: lib.inc.jsp ---
<%
/*
* lib.inc.jsp 0.6 2001/08/25
* Copyright (c) 2001 zso...@ya... under the GPL (www.gnu.org/copyleft/)
*
* TERMS OF USAGE:
* This file was written and developed by Zsolt Mali (zso...@ya...)
* for educational and demonstration purposes only. You have all rights to use,
* modify, and redistribute this file as you like. The only
* requirement is that you must retain this notice, without modifications, at
* the top of your source code. No warranties or guarantees are expressed or
* implied. DO NOT use this code in a production environment without
* understanding the limitations and weaknesses pretaining to or caused by the
* use of these scripts, directly or indirectly. USE AT YOUR OWN RISK!
*/
%>
<%@ page language="java" import="java.text.*,java.sql.*,java.util.*,java.io.*,java.net.*,com.jspmyadmin.*" errorPage="error.jsp" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/i18n-1.0" prefix="i18n" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/regexp-1.0" prefix="rx" %>
<%
long parsed=(new java.util.Date()).getTime();
//pageContext.getRequest().setAttribute("parsed", String.valueOf(parsed));
int num_of_dbs=0;
String PROPERTIES_REQUEST_KEY =
"com.distribsoft.taglibs.PropertiesTag";
Properties myproperties = new Properties();
if (pageContext.getAttribute(PROPERTIES_REQUEST_KEY) != null) {
myproperties = (Properties) pageContext.getAttribute(PROPERTIES_REQUEST_KEY);
}
else {
try {
FileInputStream in = new FileInputStream(pageContext.getServletContext().getRealPath("/config.inc.jsp"));
myproperties.load(in);
in.close();
}
catch (IOException e) {
throw new javax.servlet.jsp.JspException(e.getMessage());
}
//set the properties to be available to the messageTag
pageContext.setAttribute(PROPERTIES_REQUEST_KEY,myproperties, pageContext.SESSION_SCOPE);
}
Hashtable all = new Hashtable();
Enumeration enum = myproperties.propertyNames();
while (enum.hasMoreElements()) {
String key= (String)enum.nextElement();
String value= myproperties.getProperty( key );
all.put( key, value );
}
jspMyAdminConfig cfg = new jspMyAdminConfig( all );
pageContext.removeAttribute("all", pageContext.SESSION_SCOPE);
jspMyAdminVar var = new jspMyAdminVar( pageContext );
int server= (var.existKey("server"))
? Integer.parseInt((String)var.get((Object)"server"))
: 0;
int pos= (var.existKey("pos2"))
? var.getInt("pos2")
: ( (var.existKey("pos")) ? var.getInt("pos") : 0);
String db= ( (var.existKey("db")) && (pageContext.getRequest().getAttribute("db")==null) )
? (String)var.get((Object)"db")
: "mysql";
if ((cfg.get4Server( "only_db" , server ) != null) && (!cfg.get4Server( "only_db" , server ).equals("")) ) {
db = cfg.get4Server( "only_db" , server );
}
String table= (var.existKey("table"))
? (String)var.get((Object)"table")
: "";
table= (var.existKey("table_to_create"))
? (String)var.get((Object)"table_to_create")
: table;
var.set("server", String.valueOf(server));
var.set("db", db);
var.set("table", table);
var.set("pos", String.valueOf(pos));
request.setAttribute("var", var);
request.setAttribute("cfg", cfg);
Connection ds_conn = null;
ConnectionPoolManager cm = null;
if (application.getAttribute("cm") == null) {
cm = new ConnectionPoolManager();
System.out.println("Creating ConnectionPoolMAnager");
cm.setDriver("org.gjt.mm.mysql.Driver");
if (cfg.get4Server("port", server) != null && !(cfg.get4Server("port", server).equals(""))) {
cm.setDbURL("jdbc:mysql://"+cfg.get4Server("host",server)+":"+cfg.get4Server("port",server)+"/"+db+"?user="+cfg.get4Server("user",server)+"&password="+cfg.get4Server("password",server));
}
else {
cm.setDbURL("jdbc:mysql://"+cfg.get4Server("host",server)+"/"+db+"?user="+cfg.get4Server("user",server)+"&password="+cfg.get4Server("password",server));
}
cm.setUser("root");
cm.setPassword("");
cm.setEnableTrace(true);
cm.setOpenConnectionCount(2);
application.setAttribute("cm", cm);
ds_conn = cm.getConnection();
pageContext.setAttribute("ds_conn", ds_conn);
}
else {
cm = (ConnectionPoolManager)application.getAttribute("cm");
if (cfg.get4Server("port", server) != null && !(cfg.get4Server("port", server).equals(""))) {
cm.setDbURL("jdbc:mysql://"+cfg.get4Server("host",server)+":"+cfg.get4Server("port",server)+"/"+db+"?user="+cfg.get4Server("user",server)+"&password="+cfg.get4Server("password",server));
}
else {
cm.setDbURL("jdbc:mysql://"+cfg.get4Server("host",server)+"/"+db+"?user="+cfg.get4Server("user",server)+"&password="+cfg.get4Server("password",server));
}
ds_conn = cm.getConnection();
pageContext.setAttribute("ds_conn", ds_conn);
}
String ds_language="";
if (request.getParameter("language")!=null) {
ds_language=request.getParameter("language");
request.getSession().setAttribute("language",ds_language);
}
else {
try {
if (request.getSession().getAttribute("language")!=null) {
ds_language=(String)request.getSession().getAttribute("language");
}
else {
ds_language="english";
request.getSession().setAttribute("language",ds_language);
}
}
catch (IllegalStateException E) {
System.out.println(E.getMessage());
}
}
String h="com.jspmyadmin.languages."+ds_language;
%>
<i18n:bundle baseName="<%=h%>" />
<%
String[] cfgColumnTypes = {
"TINYINT",
"SMALLINT",
"MEDIUMINT",
"INT",
"BIGINT",
"FLOAT",
"DOUBLE",
"DECIMAL",
"DATE",
"DATETIME",
"TIMESTAMP",
"TIME",
"YEAR",
"CHAR",
"VARCHAR",
"TINYBLOB",
"TINYTEXT",
"TEXT",
"BLOB",
"MEDIUMBLOB",
"MEDIUMTEXT",
"LONGBLOB",
"LONGTEXT",
"ENUM",
"SET"};
String[] cfgFunctions = {
"ASCII",
"CHAR",
"SOUNDEX",
"CURDATE",
"CURTIME",
"FROM_DAYS",
"FROM_UNIXTIME",
"NOW",
"PASSWORD",
"PERIOD_ADD",
"PERIOD_DIFF",
"TO_DAYS",
"USER",
"WEEKDAY",
"RAND"};
String[] cfgAttributeTypes = {
"",
"BINARY",
"UNSIGNED",
"UNSIGNED ZEROFILL"};
%>
<%!
public Connection mysql_connect(PageContext localpagectx, jspMyAdminConfig localcfg, int localserver, String localdb) throws SQLException,ClassNotFoundException {
Class.forName("org.gjt.mm.mysql.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://" +localcfg.get4Server("host", localserver)+ "/" +localdb+ "?user=" +localcfg.get4Server("user", localserver)+ "&password=" +localcfg.get4Server("password", localserver));
return conn;
}
public Connection mysql_connect(String _url) throws SQLException,ClassNotFoundException {
Class.forName("org.gjt.mm.mysql.Driver");
Connection conn = DriverManager.getConnection(_url);
return conn;
}
public void mysql_select_db(PageContext localpagectx, jspMyAdminConfig localcfg, int localserver, String localdb) throws SQLException,ClassNotFoundException {
Connection conn = (Connection)localpagectx.getAttribute("ds_conn");
conn.close();
Class.forName("org.gjt.mm.mysql.Driver");
String conn_url = (localcfg.get4Server("port", localserver) != null && !localcfg.get4Server("port", localserver).equals("") )
? "jdbc:mysql://" +localcfg.get4Server("host", localserver)+":"+localcfg.get4Server("port", localserver)+"/" +localdb+ "?user=" +localcfg.get4Server("user", localserver)+ "&password=" +localcfg.get4Server("password", localserver)
: "jdbc:mysql://" +localcfg.get4Server("host", localserver)+ "/" +localdb+ "?user=" +localcfg.get4Server("user", localserver)+ "&password=" +localcfg.get4Server("password", localserver);
Connection newconn = DriverManager.getConnection(conn_url);
localpagectx.setAttribute("ds_conn",newconn);
}
public ResultSet mysql_query(PageContext localpagectx, String query) throws SQLException {
Connection conn = (Connection)localpagectx.getAttribute("ds_conn");
PreparedStatement pstm = conn.prepareStatement(query);
ResultSet rst = pstm.executeQuery();
return rst;
}
public ResultSet mysql_query(Connection localconn, String query) throws SQLException {
Connection conn = localconn;
PreparedStatement pstm = conn.prepareStatement(query);
ResultSet rst = pstm.executeQuery();
return rst;
}
public String[] mysql_fetch_array(ResultSet rset) throws SQLException {
if (rset.next()) {
ResultSetMetaData rsdt = rset.getMetaData();
String[] fetch = new String[rsdt.getColumnCount()];
for (int i=1; i<=rsdt.getColumnCount(); i++ ) {
fetch[i-1] = rset.getString( i );
}
return fetch;
}
return null;
}
public Hashtable mysql_fetch_hashtable(ResultSet rset) throws SQLException {
if (rset.next() ) {
ResultSetMetaData rsdt = rset.getMetaData();
Hashtable fetch = new Hashtable();
for (int i=1; i<=rsdt.getColumnCount(); i++ ) {
String content = rset.getString( i );
if (content!=null) {
fetch.put(rsdt.getColumnName(i), content);
}
else {
fetch.put(rsdt.getColumnName(i), "");
}
}
return fetch;
}
return null;
}
public int mysql_num_rows(ResultSet rset) throws SQLException {
int current = 0;
try {
if (!rset.isBeforeFirst()) {
current = rset.getRow();
rset.beforeFirst();
}
}
catch (Exception e) {
return -1;
}
int number_of_rows=0;
while (rset.next()) {
number_of_rows++;
}
if (current!=0) {
rset.absolute(current);
}
else {
rset.beforeFirst();
}
return number_of_rows;
}
public String load_javascript () {
return "\n<script language=\"javascript\" src=\"functions.js\" > </script>";
}
public String geti18nMessage( ServletRequest pagesource, String key) {
ResourceBundle bundle =(ResourceBundle)pagesource.getAttribute("org.apache.taglibs.i18n.ResourceHelper.Bundle");
return bundle.getString(key);
}
public String get_table_def(PageContext localpage, jspMyAdminConfig localcfg, jspMyAdminVar localvar, String localtbl, String crlf) throws SQLException {
String schema_create = "";
Hashtable myrow = null;
Hashtable index = new Hashtable();
if(localvar.notEmpty("drop")) {
schema_create += "DROP TABLE IF EXISTS "+localtbl+";"+crlf;
}
schema_create += "CREATE TABLE "+localtbl+" ("+crlf;
ResultSet tbl_prop_rst = mysql_query(localpage, "SHOW FIELDS FROM " +localtbl);
while ( (myrow = mysql_fetch_hashtable(tbl_prop_rst))!=null ) {
schema_create += " "+myrow.get("Field")+" "+myrow.get("Type");
if (!myrow.get("Default").equals("")) {
schema_create += " DEFAULT '"+myrow.get("Default")+"'";
}
if (!myrow.get("Null").equals("YES")) {
schema_create += " NOT NULL";
}
if (!myrow.get("Extra").equals("")) {
schema_create += " "+myrow.get("Extra");
}
schema_create += ","+crlf;
}
schema_create = jspMyAdminUtil.replaceLast(schema_create,","+crlf,"");
tbl_prop_rst = mysql_query(localpage, "SHOW KEYS FROM " +localtbl);
while ((myrow=mysql_fetch_hashtable(tbl_prop_rst))!=null ) {
String keyname = (String)myrow.get("Key_name");
if ( (!keyname.equals("PRIMARY") ) && (myrow.get("Non_unique").equals("0"))) {
keyname="UNIQUE|"+keyname;
}
if (index.containsKey(keyname)==true) {
index.put(keyname,(String)index.get(keyname)+","+(String)myrow.get("Column_name"));
}
else {
index.put(keyname,myrow.get("Column_name"));
}
}
tbl_prop_rst.close();
Enumeration en = index.keys();
while (en.hasMoreElements()) {
schema_create += ","+crlf;
String key = (String)en.nextElement();
if (key.equals("PRIMARY")) {
schema_create += " PRIMARY KEY (" + index.get(key)+ ")";
}
else if ((key.length()>7) && ((key.substring(0,6)).equals("UNIQUE"))) {
schema_create += " UNIQUE "+key.substring(7)+" (" +index.get(key)+")";
}
else {
schema_create += " KEY "+key+" (" + index.get(key) + ")";
}
}
schema_create += crlf+")";
return (jspMyAdminUtil.stripSlashes(schema_create));
}
public String[] get_table_content(PageContext localpage, jspMyAdminConfig localcfg, jspMyAdminVar localvar, String localtbl, String sep) throws SQLException {
ResultSet localrst = mysql_query(localpage, "SELECT * FROM " +localtbl);
String[] insert = new String[mysql_num_rows(localrst)];
ResultSetMetaData rsmd = localrst.getMetaData();
String table_list="(";
for(int i=1; i<=rsmd.getColumnCount(); i++) {
table_list += rsmd.getColumnName(i)+", ";
}
table_list = jspMyAdminUtil.replaceLast(table_list,", ","");
table_list += ")";
if (localvar.get( "showcolumns" ) != null) {
table_list = "INSERT INTO "+localtbl+ " " +table_list+ " VALUES (";
}
else {
table_list = "INSERT INTO "+localtbl+" VALUES (";
}
int count = 0;
while (localrst.next()) {
String schema_insert = "";
for(int i=1; i<=rsmd.getColumnCount(); i++) {
String row = localrst.getStri...
[truncated message content] |