<%@//Script头、过程和函数定义 program procode; %> <%!//声明变量 function GetDataType(F: string): string; begin Result := GetDeliBack(F, '='); Result := GetDeliPri(Result, '@0#'); end; function GetAllow_NotRep(F: string): boolean; begin F := GetDeliBack(F, '@2#'); F := GetDeliPri(F, '@3#'); Result := '1' = F; end; function GetCField(F: string): string; begin Result := GetDeliBack(F, '@0#'); Result := GetDeliPri(Result, '@1#'); end; function IsToMd5(F: string): boolean; begin F := GetDeliBack(F, '@6#'); F := GetDeliPri(F, '@7#'); Result := '1' = F; end; function IsToEncrypt(F: string): boolean; begin F := GetDeliBack(F, '@9#'); F := GetDeliPri(F, '@10#'); Result := '1' = F; end; function GetCreateType(F: string): string; begin F := GetDeliBack(F, '@7#'); F := GetDeliPri(F, '@8#'); Result := F; end; function GetMustCreate(F: string): boolean; begin F := GetDeliBack(F, '@8#'); F := GetDeliPri(F, '@9#'); Result := trim(F)='1'; end; function GetRField(F: string): string; begin Result := GetDeliPri(F, '='); Result := GetDeliBack(Result, '*'); end; function IsIntFloat(DataType: string): boolean; begin DataType := GetDataType(DataType); Result := (lowercase(datatype) = 'ftinteger') or (lowercase(datatype) = 'ftcurrency') or (lowercase(datatype) = 'ftfmtbcd') or (lowercase(datatype) = 'ftsmallint') or (lowercase(datatype) = 'ftshortint') or (lowercase(datatype) = 'ftlargeint') or (lowercase(datatype) = 'ftbcd') or (lowercase(datatype) = 'ftfloat'); end; function IsDatetime(DataType: string): boolean; begin DataType := GetDataType(DataType); Result := (LowerCase(DataType) = 'ftDate') or (LowerCase(DataType) = 'ftTime') or (LowerCase(DataType) = 'ftDateTime'); end; function IsNumfromSL(SLType: TStringlist; FieldName: string): boolean; var lp: integer; IsNum: boolean; F: string; begin isNum := false; for lp := 0 to SLType.Count - 1 do begin F := LowerCase(trim(GetRField(SLType[lp]))); if(F=LowerCase(FieldName)) then begin isNum := IsIntFloat(SLType[lp]); break; end; end; Result := IsNum; end; function GetValue(ds: THjhMemoryDataSet; Conn: TminiConnection; F, DataType: string;IsInsert: boolean;IsUpdate: boolean;FieldName: string; onlyset: boolean): string; var At: string; begin if ds = nil then Result := Request.V(F) else Result := ds.V(F); At := GetCreateType(DataType); if (trim(At) > '0') and ((trim(Result) = '') or GetMustCreate(DataType)) then begin if At = '1' then Result := GetClientUniqueCode else if At = '2' then Result := formatdatetime('yyyy-mm-dd', Now) else if At = '3' then Result := formatdatetime('hh:nn:ss', Now) else if At = '4' then Result := formatdatetime('yyyy-mm-dd hh:nn:ss', Now) else if At = '5' then Result := formatdatetime('yyyy-mm-dd hh:nn:ss.zzz', Now) else if At = '6' then Result := GetSnowID() else if At = '7' then Result := Request.Session.Values['set_Loginedusername'] else if At = '8' then begin Result := Request.Session.Values['set_Loginedusername']; if Conn <> nil then if IsUpdate then begin if (LowerCase(Conn.DbType) = 'mssql') or (LowerCase(Conn.DbType) = 'db2') then Result := 'isnull(' + FieldName + ','''')' + '+' + QuotedStr(',') + '+' + QuotedStr(Request.Session.Values['set_Loginedusername']) else if (LowerCase(Conn.DbType) = 'mysql') or (LowerCase(Conn.DbType) = 'sqlite') then Result := 'concat(IFNULL(' + FieldName + ','''')' + ',concat(' + QuotedStr(',')+',' + QuotedStr(Request.Session.Values['set_Loginedusername']) + '))' else Result := FieldName + '+' + QuotedStr(',') + '+' + QuotedStr(Request.Session.Values['set_Loginedusername']); exit; end; end else if At = '9' then begin Result := '1'; if Conn <> nil then if IsUpdate then begin if (LowerCase(Conn.DbType) = 'mssql') or (LowerCase(Conn.DbType) = 'db2') then Result := 'isnull(' + FieldName + ',0)' + '+1' else if (LowerCase(Conn.DbType) = 'mysql') or (LowerCase(Conn.DbType) = 'sqlite') then Result := 'IFNULL(' + FieldName + ',0)' + '+1' else Result := FieldName + '+1'; exit; end; end; end; if IsIntFloat(DataType) then begin if onlyset then exit; if Result = '' then Result := 'null' else StrToFloat(Result); end else if IsDatetime(DataType) then begin if onlyset then exit; if Result = '' then Result := 'null' else if Conn <> nil then begin if (LowerCase(Conn.DbType) = 'mssql') or (LowerCase(Conn.DbType) = 'db2') then Result := 'convert(datetime,' + QuotedStr(Result) + ', 20)' else begin if length(Result) < 15 then Result := 'str_to_date(' + QuotedStr(Result) + ',''%Y-%m-%d'')' else Result := 'str_to_date(' + QuotedStr(Result) + ',''%Y-%m-%d %H:%i:%s'')'; end; end; end else begin if (IsToMd5(DataType)) and (length(Result) <> 32) then Result := GetMd5(Result, false); if (IsToEncrypt(DataType)) then Result := SetPWD(Result, '#'); if onlyset then exit; if Conn <> nil then if (LowerCase(Conn.DbType) = 'mysql') or (LowerCase(Conn.DbType) = 'sqlite') then Result := StringReplace(Result, '\', '\\', [rfReplaceAll]); Result := QuotedStr(Result); if (LowerCase(Conn.DbType) = 'mssql') and (IsInsert or IsUpdate) then Result := 'N' + Result; end; end; function GetWhere(ds: THjhMemoryDataSet; Conn: TminiConnection; Sys_DB_Fields: string; SL: TStringlist; IsRepCall: boolean): string; var lp, I: integer; SLTmp, SL2: TStringlist; Dt, Value, One: string; begin SLTmp := TStringlist.Create; SL2 := TStringlist.Create; try SLTmp.CommaText := Sys_DB_Fields; SL2.CommaText := SL.Values['KEYWORD']; Result := ' where '; for lp := 0 to SL2.Count - 1 do begin Dt := ''; for I := 0 to SLTmp.Count - 1 do begin if SL2[lp] = GetRField(SLTmp[I]) then begin Dt := SLTmp[I]; break; end; end; Value := GetValue(ds, Conn, SL2[lp], Dt, false, false, '', false); if (Value = 'null') and (IsIntFloat(dt) or IsDatetime(dt)) then begin if IsRepCall then One := SL2[lp] + ' is not null ' else One := SL2[lp] + ' is null '; end else begin if IsRepCall then One := SL2[lp] + '<>' + Value else One := SL2[lp] + '=' + Value; end; if trim(Result) = 'where' then Result := Result + One else Result := Result + ' and ' + One; end; finally SL2.Free; SLTmp.Free; end; end; function DeleteData(mds: THjhMemoryDataSet; Conn: TminiConnection; Query: TminiQuery; SL, SL2: TStringlist): boolean; var lp: integer; TmpStr, TmpStr2, TmpStr3, Sys_DB_SQL, ErrStr, WhereSQL, One, V, mx, main: string; SLTmp: TStringlist; Flag: boolean; begin Result := false; Flag := (mds <> nil); if Flag then Flag := (trim(mds.V('AType'))<>'1'); if Flag then begin SLTmp := TStringlist.Create; try WhereSQL := ''; TmpStr := mds.V('mxmainkeys'); TmpStr:=StringReplace(TmpStr,';',#13#10, [rfReplaceAll]); TmpStr:=StringReplace(TmpStr,';',#13#10, [rfReplaceAll]); TmpStr:=StringReplace(TmpStr,',',#13#10, [rfReplaceAll]); TmpStr:=StringReplace(TmpStr,',',#13#10, [rfReplaceAll]); SLTmp.Text := TmpStr; for lp := 0 to SLTmp.Count - 1 do begin mx := GetDeliPri(SLTmp[lp], '='); main := GetDeliBack(SLTmp[lp], '='); v := Request.V(main); if IsNumfromSL(SL2, mx) then begin if trim(v) = '' then One := mx + ' is null ' else One := mx + '=' + v end else One := mx + '=' + QuotedStr(v); if WhereSQL = '' then WhereSQL := One else WhereSQL := WhereSQL + ' and ' + One; end; finally SLTmp.Free; end; TmpStr2 := 'where ' + trim(WhereSQL); end else TmpStr2 := GetWhere(nil, Conn, SL2.CommaText, SL, false); Sys_DB_SQL := ' delete from ' + SL.Values['WRITE_TABLE'] + ' ' + trim(TmpStr2); if not Query.E(Sys_DB_SQL, ErrStr) then begin Print('[%@clear@%]'); print('删除数据出错:' + ErrStr + Sys_DB_SQL + ''); exit; end; Print('[%@clear@%]'); print('[200ok]'); Result := true; end; var Sys_DB_Info, Sys_DB_Source, Sys_DB_SQL: string; Query: TminiQuery; ErrStr, TmpStr, TmpStr2, TmpStr3, TmpStr4, TmpStr5: string; Pooler: TminiPooler; lp, i, Sys_DB_RecordCount, Sys_DB_PageCount: integer; SL, SL2, SL3: TStringlist; mds, mds2: THjhMemoryDataSet; Sys_DB_mainform: string; Sys_DB_Fields_mainform: string; Sys_DB_Form_ID: string; flag: boolean; %> <% Sys_DB_mainform := 'WRITE_TABLE=mainsetting,"READ_TABLE_SQL=//注意:如果是excel时,表名要这样写[页名$],如 Sys_DB_SQL := ''select * from [users$] where usercode = '' + QuotedStr(Request.V(''usercode''));'''#13#10+ 'Sys_DB_SQL := '''';",KEYWORD=,SYS_DB_SOURCE=conf,SYS_DB_FORM_ID=mainform_Form'; Sys_DB_Info := 'WRITE_TABLE=mainsetting,"READ_TABLE_SQL=//注意:如果是excel时,表名要这样写[页名$],如 Sys_DB_SQL := ''select * from [users$] where usercode = '' + QuotedStr(Request.V(''usercode''));'''#13#10+ 'Sys_DB_SQL := '''';",KEYWORD=,SYS_DB_SOURCE=conf,SYS_DB_FORM_ID=mainform_Form'; Sys_DB_Source := 'conf'; Sys_DB_PageCount := 0; Sys_DB_Form_ID := 'mainform_Form'; %> <%SL3 := TStringlist.Create; try %> <%Sl3.Add('mainservicepath=ftString@0#主服务目录@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('httpport=ftString@0#HTTP服务端口@1#@2#0@3#0@4#1@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('serviceext=ftString@0#动态页面后缀@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('hosttodir=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('*starthttps=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('*usehttps=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('httpsport=ftString@0#服务端口@1#@2#0@3#0@4#1@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('secretkey=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('cert=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('rootcert=ftString@0#根证书@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('*crossdomain=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('errorpage=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('threadcount=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('quequelength=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('maxsessioncount=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('sessiontimeout=ftString@0#会话超时@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('poolermincount=ftString@0#连接池下限@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('poolermaxcount=ftString@0#连接池上限@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('poolertimeout=ftString@0#连接池超时时间@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('*autozip=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('*startlog=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('maxlogcount=ftString@0#最大记录行数@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('clientcachefile=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('*servernocachefile=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('*autopcandmobile=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('autopcandmobileext=ftString@0#根证书@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('exttoserver=ftString@0#根证书@1#@2#0@3#0@4#0@5#@6#0@7#6@8#0@9#0@10#');%> <%Sl3.Add('*openby127_0_0_1=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('blacklist=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <%Sl3.Add('whitelist=ftString@0#@1#@2#0@3#0@4#0@5#@6#0@7#0@8#0@9#0@10#');%> <% Sys_DB_Fields_mainform := SL3.CommaText; finally SL3.Free end;%> <% if Request.IsLogin('set_Logined') then begin if LowerCase(Request.V('logout')) = 'true' then begin Request.LogOut('set_Logined'); Response.Redirect('login.html'); exit; end; end else begin Response.Redirect('login.html?sourceurl=' + Urlencode(Request.URL)); exit; end; %> <% SL := TStringlist.Create; //WRITE_TABLE SL2 := TStringlist.Create; try SL.CommaText := Sys_DB_mainform; if not Pub.O(Sys_DB_Source, Pooler, Query, ErrStr) then begin Print('[%@clear@%]'); print('数据库连接出错:' + ErrStr + ''); Print(''); exit; end; try SL2.CommaText := Sys_DB_Fields_mainform; if not DeleteData(nil, Pooler.Conn, Query, SL, SL2) then exit; finally Pooler.HadUsed := false; //注意: 一定要有这行,把实例还回连接池 end; finally SL2.Free; SL.Free; end; %>