在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
常用函数系列: public static string Get_ClientIP() 得到客户端IP public static string Get_CMac(string IP) 得到客户端 CMac 地址 public static string RequestF(string xPName,string xPType,int xLenDef) 安全接收数据系列 public static string Show_Cont(string xStr) 过滤显示字串 public static string Show_jsStr(string xStr) 过滤显示js 安全检测函数: public static string CheckUrl(string xDirPage) 上页地址认证 public static string Chk_Perm0(string xPerm,string xSys,string xAct) 权限认证系列 public static string Chk_Perm1(string xPerm,string xSys,string xAct) 权限认证系列 public static string Chk_Perm2(string xPerm,string xSys,string xAct) 权限认证系列 邮件发送函数: public void SendEmail(string xSubj,string xCont,string FmAddr,string ToAddr) public void SendSmtp(string xSubj,string xCont,string xFrom,string xTo) 加密解密函数: public static string Enc_PW(string xID,string xPW,int xLen) 改装sha1+md5加密解密函数加密函数 public static string Conv_10toXX(long xNum,int xBase) 10进制 转 XX 进制 public static long Conv_XXto10(string xStr,int xBase) xx进制 转 10 进制 public static string DESDec(string pToDecrypt, string sKey) DES解密 public static string DESEnc(string pToEncrypt, string sKey) DES加密密 public static string DESPeace(string xStr, string xType) 改装DES public static string DESSwap(string xStr, int xN) DES 改装算法 文件操作函数: public static string fCreate(string xFile,string xContent) 建立文件 public void ImgCode (Page containsPage,string validateNum) 生成图片认证码 public static string ImgShow(string xPName,int xImgW,int xImgH,int xMaxW,int xMaxH) 按比例大小显示图片 public static DataTable fList(string xPath) 显示文件列表 显示文件夹列表 public static string fRead(string xFile) 文件读取函数 public static ArrayList fUpload(HttpPostedFile xFile,string xPath,string xOrg,int xSize,string xType) 文件上传认证函数 时间/随即字串函数: public static string Get_AutoID(int xLen) 自动随机 ID 串 public static string Get_HHMMSS() 得到时间HHmmss格式 public static string Get_TimeID() 得到年月日时间YYYY-MM-DD HH:mm:ss格式 public static string Get_YYYYMMDD() 得到年月日YYYYMMDD格式 public static string Get_mSec() 得到毫秒 public static string Rnd_ID(string xType,int xLen) 自动随机 ID 串 public static int Rnd_NM(int xN,int xM) 自动随机 N ~ M 数字 数据库操作函数: public static void rs_AddLog(string xconn,string xUSID,string xAct,string xSys,string xNote) 添加 Log public static int rs_Count(string xConn,string xSQL,string xTable) 计算记录条数 public static void rs_DoSQL(string xConn,string xSQL) 执行SQL语句 public static string rs_Exist(string xConn,string xSQL,string xTable) 检查是否存在 public static void rs_List(DropDownList xDDList,string xConn,string xSql,string xDefValue,string xClear) 绑定DropDownList public static string rs_Val(string xConn,string xSQL,string xTable,string xCol) 得到特定 字段值 -------------------------------------------------------------------------------- using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.Drawing.Drawing2D; using System.IO; using System.Web; using System.Web.Mail; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Web.Security; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using PubSet; namespace Peace { public class WebCS { public static string RequestQ(string xPName,string xPType,int xLenDef) { string PValue = HttpContext.Current.Request.QueryString[xPName]; return RequestS(PValue,xPType,xLenDef); } public static string RequestF(string xPName,string xPType,int xLenDef) { string PValue = HttpContext.Current.Request.Form[xPName]; return RequestS(PValue,xPType,xLenDef); } public static string RequestA(string xPName,string xPType,int xLenDef) { string PValue = HttpContext.Current.Request[xPName]; return RequestS(PValue,xPType,xLenDef); } public static string RequestS(string xPName,string xPType,int xLenDef) { string PValue = xPName+""; string tmpType = xPType; switch (tmpType) { case "N": // Number -1,0,1 try { string tI = (int.Parse(PValue)).ToString(); } catch { PValue = xLenDef.ToString();} break; case "D": // Date try { DateTime tD = DateTime.Parse(PValue); } catch { PValue = xLenDef.ToString(); PValue = PValue.Substring(0,4)+"-"+PValue.Substring(4,2)+"-"+PValue.Substring(6,2); } break; default: // Text xLenDef = 19001231 if(PValue.Length > xLenDef) { PValue = PValue.Substring(0,xLenDef); } PValue = PValue.Replace("'","''"); break; } return PValue; } public static string Show_Text(string xStr) { string tStr = xStr; tStr = tStr.Replace("<","<"); tStr = tStr.Replace(">",">"); tStr = tStr.Replace("\r","<br>"); tStr = tStr.Replace(" "," "); tStr = tStr.Replace("\t"," "); return tStr; } public static string Show_Cont(string xStr) { string tStr = Show_Text(xStr); return tStr; } public static string Show_Form(string xStr) { string tStr = xStr; tStr = tStr.Replace("\'","'"); tStr = tStr.Replace("\"","""); tStr = tStr.Replace("<","<"); tStr = tStr.Replace(">",">"); return tStr; } public static string Show_jsStr(string xStr) { string tStr = xStr; tStr = tStr.Replace("\'","\\\'"); tStr = tStr.Replace("\"","\\\""); return tStr; } public static string Get_ClientIP() { string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (null == result || result == String.Empty) { result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; } if (null == result || result == String.Empty) { result = HttpContext.Current.Request.UserHostAddress; } return result; } public static string Get_CMac(string IP) //para IP is the client@#s IP { string dirResults=""; //IP = "192.168.37.175";//"211.156.182.34"; ProcessStartInfo psi = new ProcessStartInfo(); Process proc = new Process(); psi.FileName = "nbtstat"; psi.RedirectStandardInput = false; psi.RedirectStandardOutput = true; psi.Arguments = "-A " + IP; psi.UseShellExecute = false; proc = Process.Start(psi); dirResults = proc.StandardOutput.ReadToEnd(); proc.WaitForExit(); dirResults=dirResults.Replace("\r","").Replace("\n","").Replace("\t",""); Regex reg=new Regex("Mac[ ]{0,}Address[ ]{0,}=[ ]{0,}(?<key>((.)*?)) __MAC",RegexOptions.IgnoreCase|RegexOptions.Compiled); Match mc=reg.Match(dirResults+"__MAC"); if(mc.Success) { return mc.Groups["key"].Value; } else { reg=new Regex("Host not found",RegexOptions.IgnoreCase|RegexOptions.Compiled); mc=reg.Match(dirResults); if(mc.Success) { return "Host not found!"; } else { return "N/A"; } } } } public class WebID { public static string Get_TimeID() { string YMDHMS = System.DateTime.Now.ToString("yyyyMMddHHmmss"); string mSec = Get_mSec(); return YMDHMS+mSec; } public static string Get_YYYYMMDD() { return System.DateTime.Now.ToString("yyyyMMdd"); } public static string Get_HHMMSS() { return System.DateTime.Now.ToString("HHmmss"); } public static string Get_mSec() { string mSec = System.DateTime.Now.Millisecond.ToString(); mSec = "00" + mSec; return mSec.Substring(mSec.Length-3,3); } public static string Get_AutoID(int xLen) { long tNum = DateTime.Now.Ticks; string tStr = tNum.ToString("X16"); if(xLen<tStr.Length) { tStr = tStr.Substring(0,xLen); } else { tStr += Rnd_ID("KEY",xLen-tStr.Length); } return tStr; } public static string Rnd_ID(string xType,int xLen) { string rChar; int rMax,i; string orgNum = "0123456789"; // 10 xType = 0,A,KEY string orgCap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 26 . - _ $ | ! # [ ] string orgKey = "ABCDEFGHJKLMNPQRSTUVWXY"; // 23 I O Z string oStr = ""; string tStr = ""; switch (xType) { case "0": rMax = 10; tStr = orgNum; break; case "A": rMax = 26; tStr = orgCap; break; default: rMax = 33; tStr = orgNum + orgKey; break; } System.Random ran = new Random(System.DateTime.Now.Second + (int)System.DateTime.Now.Ticks); for (i=0;i<Math.Abs(xLen);i++) { |
请发表评论