<%!
stc_rsyb_name stcrsyname1[];
stc_syb_inf stcsybinf1[];
%>
<%/*
string p = (string) session.getvalue("access");
if (p==null || !p.equals("1")) {
response.sendredirect("error.htm");
return;
}*/
%>
<%!
file://得到机器名字或ip
string get_myhostname(javax.servlet.http.httpservletrequest request){
string myhostname = null;
try{
myhostname = request.getremotehost();
myhostname = myhostname.touppercase();
}catch(exception e){}
return myhostname;
}
file://处理空字符串
string dealnull(string str) {
string returnstr = null;
if (str == null) returnstr = "";
else returnstr = str;
return returnstr;
}
file://处理空对象
object dealnull(object obj){
object returnstr = null;
if (obj == null) returnstr = (object)("");
else returnstr = obj;
return returnstr;
}
int dealempty(string s) {
s = dealnull(s);
if (s.equals("")) return 0;
return integer.parseint(s);
}
string replace(string str,string substr,string restr){
string[] tmp = split(str,substr);
string returnstr = null;
if(tmp.length!=0) {
returnstr = tmp[0];
for(int i = 0 ; i < tmp.length – 1 ; i++)
returnstr =dealnull(returnstr) + restr +tmp[i+1];
}
return dealnull(returnstr);
}
string htmlencode(string txt){
txt = replace(txt,"&","&");
txt = replace(txt,"&","&");
txt = replace(txt,""",""");
txt = replace(txt,"\"",""");
txt = replace(txt,"<","<");
txt = replace(txt,"<","<");
txt = replace(txt,">",">");
txt = replace(txt,">",">");
txt = replace(txt," "," ");
txt = replace(txt," "," ");
return txt;
}
string unhtmlencode(string txt){
txt = replace(txt,"&","&");
txt = replace(txt,""","\"");
txt = replace(txt,"<","<");
txt = replace(txt,">",">");
txt = replace(txt," "," ");
return txt;
}
file://alert function
void salert(string title,string msg,string focus, jspwriter out){
try {
out.println("<script language=javascript>");
out.println("alert(\"" + title + "\" + \"\\r\\n\" + \"" + replace(replace(msg,"",""),"\"","\\\"") +"\");");
out.println(focus);
out.println("</script>");
} catch(exception e) { system.out.println(e);}
}
file://confirm function
void sconfirm(string title,string msg ,string location,jspwriter out){
try{
out.println("<script language=javascript>");
out.println("if(confirm(\"" + title + "\" + \"\\r\\n\" + \"" + replace(msg,"\"","\\\"") + "\")){" );
out.println("var d = (new date()).tostring();");
out.println(location + "+ d;");
out.println("}");
out.println("parent.document.form1.text1.select();");
out.println("</script>");
} catch (exception e) { }
}
file://得到字符串长度
int getstringlength(string s) {
int p = 0;
try {
int ilength = 0;
int ireallength = 0;
int j = 0;
p = s.getbytes("shift_jis").length;
} catch(java.io.unsupportedencodingexception e) {}
return p;
}
void formatstring(string s,int b,jspwriter out){
b–;
string t = "";
try {
int leng = getstringlength(s);
int j = 0;
if (leng > b) {
for (int i = 1; i <= b ; i++) {
t = s.substring(0,i);
if (t.getbytes("shift_jis").length <= b ) {
j++;
} else break;
}
file://j = j+1;
file://system.out.println("b=" + b + "—-" + "j=" + j);
for(int i = 0;i < j; i++){
if(s.substring(i,i+1).equals(" "))
out.print(" ");
if(!s.substring(i,i+1).equals(" "))
out.print(htmlencode(s.substring(i,i+1)));
}
if (s.substring(0,j).getbytes("shift_jis").length == b){
out.print("|");
}else{
out.print(" |");
}
} else {
for (int i = 0; i < b – leng ; i++)
t = t + " ";
for (int i = 0; i < s.length(); i++){
if(s.substring(i,i+1).equals(" "))
out.print(" ");
if(!s.substring(i,i+1).equals(" "))
out.print(htmlencode(s.substring(i,i+1)));
}
out.print(htmlencode(t + "|"));
}
} catch(exception e){system.out.println("—-" + e);}
}
file://判断是否为数字
boolean isnumeric(string number)
{
try
{
integer.parseint(number);
return true;
}
catch(numberformatexception sqo)
{
return false;
}
}
file://判断是否为日期
string mk_date(string c_date,int c_mode)
{
string wk_buf= "";
string today = "";
try
{
today = integer.tostring(java.util.calendar.getinstance().get(java.util.calendar.year));
switch(c_mode)
{
case 0:
{
wk_buf = c_date.substring(2, 4) + "/" + c_date.substring(4, 6);
if (c_date.length() == 8)
{
wk_buf = wk_buf + "/" + c_date.substring(6, 8);
}
break;
}
case 1:
{
for (int i=0; i<c_date.length();i++)
{
if (c_date.substring(i, i+1) == " ")
{
wk_buf = wk_buf + "0";
}
else
{
wk_buf = wk_buf + c_date.substring(i, i+1);
}
}
c_date = wk_buf;
wk_buf = "";
if (c_date.substring(0, 1) != "0" )
{
wk_buf = "19";
}
else
{
wk_buf = "20";
}
wk_buf = wk_buf + c_date.substring(0, 2) + c_date.substring(3, 5);
if (c_date.length() == 8)
{
wk_buf = wk_buf + c_date.substring(6, 8);
}
break;
}
case 2:
{
wk_buf = c_date.substring(0, 4) + c_date.substring(5, 7) + c_date.substring(8, 10);
break;
}
case 3:
{
for(int i=0; i<c_date.length();i++ )
{
if (c_date.substring(i, i+1) == " ")
{
wk_buf = wk_buf + "0";
}
else
{
wk_buf = wk_buf + c_date.substring(i, i+1);
}
}
c_date = wk_buf;
wk_buf = "";
if (integer.parseint(c_date.substring(0,2)) > integer.parseint(today.substring(2, 4)))
{
wk_buf = integer.tostring(integer.parseint(today.substring(0,2)) – 1);
}
else
{
wk_buf = today.substring(0,2);
}
wk_buf = wk_buf + c_date.substring(0,2) + c_date.substring(3,5);
if (c_date.length() == 8)
{
wk_buf = wk_buf + c_date.substring(6,8);
}
break;
}
case 4:
{
wk_buf = c_date.substring(0,4) + "/" + c_date.substring(4,6) + "/" + c_date.substring(6, 8);
break;
}
case 5:
{
wk_buf = c_date.substring(0,4) + c_date.substring(5, 7);
break;
}
}
}
catch(exception e)
{
system.out.println("wrong : " + e);
}
return wk_buf;
}
int cint(float stsid){
int cint = 0;
try{
int stsid1 = 0;
if(stsid > 0){
if((stsid – (int)stsid > 0) && (stsid – (int)stsid != 0.5))
stsid1 = (int)(stsid + 0.5);
if(stsid – (int)stsid == 0.5){
if(((int)(stsid-0.5))%2 == 0)
stsid1 = (int)(stsid – 0.5);
else
stsid1 = (int)(stsid + 0.5);
}
if(stsid – (int)stsid ==0)
stsid1 = (int)stsid;
}else{
stsid = -stsid;
if((stsid – (int)stsid > 0) && (stsid – (int)stsid != 0.5))
stsid1 = – (int)(stsid + 0.5);
if(stsid – (int)stsid == 0.5){
if(((int)(stsid-0.5))%2 == 0)
stsid1 = – (int)(stsid – 0.5);
else
stsid1 = – (int)(stsid + 0.5);
}
if(stsid – (int)stsid ==0)
stsid1 = – (int)stsid;
}
cint = stsid1;
}catch(exception e){}
return cint;
}
long clng(float numb){
int nu = 0;
long clng = 0;
try{
nu = cint(numb);
clng = (long) nu;
}catch(exception e){}
return clng;
}
float dealfloat(string s){
s=dealnull(s);
if (s.equals(""))
return 0;
return float.parsefloat(s);
}
string[] split(string source,string div){
int arynum = 0,intidx=0,intidex=0,div_length = div.length();
if(source.compareto("")!=0){
if(source.indexof(div)!=-1){
intidx = source.indexof(div);
for(int intcount =1 ; ; intcount++){
if(source.indexof(div,intidx+div_length)!=-1){
intidx= source.indexof(div,intidx+div_length);
arynum = intcount;
}
else {arynum+=2;break;}
}
}else arynum =1;
}else arynum = 0;
intidx=0;
intidex=0;
string[] returnstr = new string[arynum];
if(source.compareto("")!=0){
if(source.indexof(div)!=-1){
intidx = (int)source.indexof(div);
returnstr[0]= (string)source.substring(0,intidx);
for(int intcount =1 ; ; intcount++){
if(source.indexof(div,intidx+div_length)!=-1){
intidex=(int)source.indexof(div,intidx+div_length);
returnstr[intcount] = (string)source.substring(intidx+div_length,intidex);
intidx = (int)source.indexof(div,intidx+div_length);
}
else {
returnstr[intcount] = (string)source.substring(intidx+div_length,source.length());
break;
}
}
}
else {returnstr[0] = (string)source.substring(0,source.length());return returnstr;}
}
else {return returnstr;}
return returnstr;
}
public class stc_rsyb_name
{
public int pos = -1;
public string name = "";
public string host = "";
public string home1 = "";
public string home2 = "";
public string home3 = "";
}
public class stc_syb_inf
{
string reg_name = "";
string g_syb = "";
string r_syb = "";
}
file://输出空格
void showblank(int num,jspwriter out){
try{
for(int i=0;i<=num;i++)
out.print(" ");
}
catch(exception e){}
}
string g_syb_mk(){
string g_syb_mk = null;
string nis_m_o = "1???????????????????????????????????????????????????????????????";
string local_m = "?1??????????????????????????????????????????????????????????????";
string winnt_dc = "????1???????????????????????????????????????????????????????????";
string nis_local = "11??????????????????????????????????????????????????????????????";
int ret = 0,reccount = 0,k = 0;
string set_ret = "ssy";
string[] domein = null;
string[] group_syb = null;
int wk_syb[];
try{
string sql = "select count(*) from 寁嶼婡 where 话兽庬暿 like "+ nis_m_o +" or 话兽庬暿 like " + local_m +" or 话兽庬暿 like "+winnt_dc +"";
rs = stmt.executequery(sql);
if(rs.next()){
reccount = rs.getint(1);
rs = null;
}
string sql2 = "select * from 寁嶼婡 where 话兽庬暿 like "+ nis_m_o +" or 话兽庬暿 like " + local_m +" or 话兽庬暿 like "+winnt_dc +"";
while(rs.next()){
int i = 0;
domein[i] = rs.getstring("霓也輺?);
i++;
}
for(int j = 0 ; j < reccount ; j++){
string sql3 = "select * from 僌儖乕僾庬暿 where 霓也輺?= " + domein[j] +"";
rs = stmt.executequery(sql3);
if(rs.next()){
k = k + 1;
group_syb[k] = rs.getstring("皋侔踢庬暿");
}
}
for(int l = 0; l < 32; l++){
for(int m = 0; m < k; m++){
if(group_syb[m].substring(l,l+1).equals("1")){
if(l==1){
set_ret = "1";
}else{
set_ret = set_ret + "1";
}
break;
}else{
if(m==k){
if(l==1){
set_ret = "0";
}else{
set_ret = set_ret + "0";
}
}
}
}
}
g_syb_mk = set_ret;
}catch(exception e) { }
return g_syb_mk;
}
int recount(string strtable,string sel)
{
string myst="";
int t = 0;
resultset rsd=null;
try
{
myst= "select count(*) ads from " + strtable + " " + sel;
rsd= conn.createstatement().executequery(myst);
if (rsd.next())
{
t=rsd.getint("ads");
}
}
catch(sqlexception sqe)
{
system.out.println("odbc wrong :" + sqe +"+" +myst);
}
rsd = null;
return t;
}
int dcount(string duan,string strtable,string strsel)
{
int t=0;
resultset rss=null;
try
{
string mysql="select count(*) ads from " + strtable + " where " + strsel + " and "+ duan +" is not null ";
rss= conn.createstatement().executequery(mysql);
if (rss.next())
{
t=rss.getint("ads");
}
}
catch(exception sqe)
{
system.out.println(sqe);
}
rss=null;
return t;
}
string dlookup(string duan,string strtable,string strsel)
{
string strreturn = null;
resultset rss = null;
try{
string strsql = "select "+duan+" from "+strtable+" where "+ strsel;
rss = conn.createstatement().executequery(strsql);
if(rss.next()){
strreturn = rss.getstring(duan);
}
}catch(java.sql.sqlexception sqle){
system.out.println("dlookup_exception:"+sqle);
}
rss = null;
return strreturn;
}
string rtrim(string str){
string rstr = str;
if(str == null)
{
rstr = "";
}
else
{
if(str.length() == 0) rstr = "";
if(str.length() > 0)
{
for(int i = str.length() ; i > 0 ; i–)
{
if(str.substring(i-1,i).equals(" "))
rstr = rstr.substring(0,i-1);
else break;
}
}
}
return rstr;
}
void sybinf_set(stc_rsyb_name in_data, stc_syb_inf out_data) throws java.sql.sqlexception{
string new_syb = "00000000000000000000000000000000";
out_data.reg_name = in_data.name;
string sql = "";
string rdomein1 = "";
string rdomein2 = "";
string rdomein3 = "";
resultset rsf = null;
statement stf = conn.createstatement();
try {
sql = "select 皋侔踢庬暿 from 僌儖乕僾庬暿 where 霓也輺?= " + in_data.host + "";
rsf = conn.createstatement().executequery(sql);
if (rsf.next()) {
out_data.g_syb = dealnull(rsf.getstring("皋侔踢庬暿"));
} else {
out_data.g_syb = "";
}
} catch(java.sql.sqlexception sqle) {
system.out.println("111111" + sqle);
}
try {
sql = "select 棙梡庬暿 from 棙梡庬暿 where 霓也輺?= " + in_data.home1 + "";
rsf = stf.executequery(sql);
if (rsf.next())
rdomein1 = dealnull(rsf.getstring("棙梡庬暿"));
} catch(java.sql.sqlexception sqle) {
system.out.println("22222" + sqle);
}
try {
sql = "select 棙梡庬暿 from 棙梡庬暿 where 霓也輺?= " + in_data.home2 + "";
rsf = stf.executequery(sql);
if (rsf.next())
rdomein2 = dealnull(rsf.getstring("棙梡庬暿"));
} catch(java.sql.sqlexception sqle) {
system.out.println("333333" + sqle);
}
try {
sql = "select 棙梡庬暿 from 棙梡庬暿 where 霓也輺?= " + in_data.home3 + "";
rsf = stf.executequery(sql);
if (rsf.next())
rdomein3 = dealnull(rsf.getstring("棙梡庬暿"));
} catch(java.sql.sqlexception sqle) {
system.out.println("444444" + sqle);
}
rsf = null;
stf = null;
string p = char_or(rdomein1, rdomein2);
if (p.equals("")) p = new_syb;
string q = char_or(p, rdomein3);
if (q.equals("")) q = new_syb;
out_data.r_syb = q;
}
string char_or(string arg1, string arg2) {
int len1 = -1, len2 = -1, max_len = -1, min_len = -1;
string ret_sts = "";
int long_f = -1;
len1 = arg1.length();
len2 = arg2.length();
if (len1 == 0 && len2 > 0)
return arg2;
else if (len1 > 0 && len2 == 0)
return arg1;
else if (len1 == 0 && len2 == 0)
return "";
ret_sts = "";
if (len1 > len2) {
max_len = len1;
min_len = len2;
long_f = 1;
} else if (len1 < len2) {
max_len = len2;
min_len = len1;
long_f = 2;
} else {
max_len = len1;
min_len = len2;
long_f = 0;
}
for (int i = 1; i <= max_len; i++) {
if (i <= min_len) {
if (arg1.substring(i-1, i).equals("1") || arg2.substring(i-1, i).equals("1"))
ret_sts = ret_sts + "1";
else
ret_sts = ret_sts + "0";
} else {
if (long_f == 1)
ret_sts = ret_sts + arg1.substring(i-1, i);
else if (long_f == 2)
ret_sts = ret_sts + arg2.substring(i-1, i);
}
}
return ret_sts;
}
%>
<%!
void writefile(string mystring,string target_file){
try {
java.io.printwriter pw = new java.io.printwriter(new java.io.fileoutputstream(target_file));
pw.println(mystring);
pw.close();
mystring="";
} catch(java.io.ioexception e) {
system.out.println(e.getmessage());
}
}
%>
