Asp.net源码专业站
首页->尚未分类->Ftp在线注册管理系统源码>>App-Code/Reg.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Ftp在线注册管理系统源码
当前文件:文件类型 WebFtp/App_Code/Reg.cs[10K,2009-6-12 11:58:24]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Web; 5using System.Web.Security; 6using System.Web.UI; 7using System.Web.UI.WebControls; 8using System.Web.UI.WebControls.WebParts; 9using System.Web.UI.HtmlControls; 10using System.Data.OleDb; 11//该源码首发自www.51aspx.com(51aspx.com) 12 13namespace Webftp 14{ 15 /// <summary> 16 /// reg 的摘要说明 17 /// </summary> 18 public class Reg 19 { 20 static string savepath = System.Configuration.ConfigurationManager.AppSettings["User_folder"].Trim(); 21 static string ServAccess = System.Configuration.ConfigurationManager.AppSettings["ServAccess"].Trim(); 22 static bool QuotaEnable = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["QuotaEnable"]); 23 static int QuotaMax = 1048576 * Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["QuotaMax"]); 24 static int PassType = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["PassType"]); 25 static string Email = "wzsyzx@51aspx.com"; 26 static bool Expirationtime = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["Expirationtime"]); 27 static int Expirationset = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Expiration"]); 28 static int Expirationtype = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Expirationtype"]); 29 30 public Reg() 31 { 32 // 33 // TODO: 在此处添加构造函数逻辑 34 // 35 } 36 37 /// <summary> 38 /// 如果存在账号,返回真,否则假 39 /// </summary> 40 /// <param name="username"></param> 41 /// <returns></returns> 42 public static bool Regcheck(string username) 43 { 44 string str = "SELECT * FROM User_accounts where User='"+username+"'"; 45 if (Webftp.Mydb.ExecuteSqlExist(str)) 46 { 47 System.Threading.Thread.Sleep(500); 48 return true; 49 } 50 else 51 { 52 return false; 53 } 54 } 55 56 /// <summary> 57 /// 将申请用户账号、密码存入Ftp数据库,成功返回真,否则假 58 /// </summary> 59 /// <param name="username"></param> 60 /// <param name="userpwd"></param> 61 /// <param name="savepath"></param> 62 /// <returns></returns> 63 public static bool Regsave(string username, string userpwd,string userclass) 64 { 65 string classpath = savepath + userclass; 66 string User = username; 67 string HomeDir = classpath +"\\"+ User; 68 string Access = HomeDir + ServAccess; 69 string Password =Webftp.Word.Serv_u_Md5(userpwd); 70 string RegIp = Webftp.Tool.GetUserIp(); 71 DateTime Expiration; 72 int tempyear = Int32.Parse(DateTime.Today.Year.ToString()) + Expirationset; 73 Expiration = DateTime.Parse(tempyear.ToString() + "-" + DateTime.Today.Month.ToString() + "-" + DateTime.Today.Day.ToString()); 74 string strsql = "INSERT INTO User_accounts ([User], [Access], [Password], [HomeDir], [QuotaEnable], [QuotaMax], [PassType], [RegIp],[Email], [Expiration], [Expirationtype]) VALUES ('" + User + "','" + Access + "','" + Password + "','" + HomeDir + "'," + QuotaEnable + "," + QuotaMax + "," + PassType + ",'" + RegIp + "','" + Email + "','" + Expiration + "'," + Expirationtype + ")"; 75 Webftp.Mydb.Execnonsql(strsql); 76 //System.Threading.Thread.Sleep(500); 77 return true; 78 79 } 80 81 /// <summary> 82 /// //从临时表中读取导入用户数据,在serv_u数据库中创建一个新用户 83 /// 批量Ftp用户注册专用,打开数据库,循环执行Sql语句后,关闭数据库******************************************** 84 /// </summary> 85 /// <returns></returns> 86 public static string RegExceltoFtp() 87 { 88 int createuser=0; 89 int failuser = 0; 90 string mysql = "SELECT username,userpwd,usernote,userclass FROM User_excel";//从临时表中读取导入用户数据 91 DataSet ds = Webftp.Mydb.Getdataset(mysql); 92 int countis = ds.Tables[0].Rows.Count; 93 if (countis > 0) 94 { 95 OleDbConnection conn =Webftp.Mydb.Getconn(); 96 for (int i = 0; i < countis; i++) 97 { 98 string username = ds.Tables[0].Rows[i]["username"].ToString(); 99 string userpwd = ds.Tables[0].Rows[i]["userpwd"].ToString(); 100 string usernote = ds.Tables[0].Rows[i]["usernote"].ToString(); 101 string userclass = ds.Tables[0].Rows[i]["userclass"].ToString(); 102 if (Webftp.Reg.RegsaveFtp(username, userpwd, userclass,conn)) //在serv_u数据库中创建一个新用户 103 { 104 createuser = createuser + 1; 105 } 106 else 107 { 108 failuser = failuser + 1; 109 } 110 } 111 conn.Close(); 112 conn.Dispose(); 113 } 114 System.Threading.Thread.Sleep(500); 115 string returnstr="成功添加Ftp用户账号"+createuser.ToString()+"个 失败"+failuser.ToString()+""; 116 return returnstr; 117 118 } 119 /// <summary> 120 /// 批量Ftp用户注册专用,不关闭数据库************************************************************ 121 /// </summary> 122 /// <param name="username"></param> 123 /// <param name="userpwd"></param> 124 /// <param name="userclass"></param> 125 /// <param name="conn"></param> 126 /// <returns></returns> 127 public static bool RegsaveFtp(string username, string userpwd, string userclass, OleDbConnection conn) 128 { 129 string classpath = savepath + userclass; 130 string User = username; 131 string HomeDir = classpath + "\\" + User; 132 string Access = HomeDir + ServAccess; 133 string Password = Webftp.Word.Serv_u_Md5(userpwd); 134 string RegIp = Webftp.Tool.GetUserIp(); 135 DateTime Expiration; 136 int tempyear = Int32.Parse(DateTime.Today.Year.ToString()) + Expirationset; 137 Expiration = DateTime.Parse(tempyear.ToString() + "-" + DateTime.Today.Month.ToString() + "-" + DateTime.Today.Day.ToString()); 138 string strsql = "INSERT INTO User_accounts ([User], [Access], [Password], [HomeDir], [QuotaEnable], [QuotaMax], [PassType], [RegIp],[Email], [Expiration], [Expirationtype]) VALUES ('" + User + "','" + Access + "','" + Password + "','" + HomeDir + "'," + QuotaEnable + "," + QuotaMax + "," + PassType + ",'" + RegIp + "','" + Email + "','" + Expiration + "'," + Expirationtype + ")"; 139 ExecnonsqlFtp(strsql, conn); 140 //System.Threading.Thread.Sleep(100); 141 return true; 142 143 } 144 145 /// <summary> 146 /// 传递conn,执行SQL语句查询,释放com资源 147 /// 批量Ftp用户注册专用,不关闭数据库************************************************************* 148 /// </summary> 149 /// <param name="sql"></param> 150 private static void ExecnonsqlFtp(string sql, OleDbConnection conn) 151 { 152 try 153 { 154 OleDbCommand com = new OleDbCommand(sql, conn); 155 com.ExecuteNonQuery(); 156 com.Dispose(); 157 } 158 catch (Exception e) 159 { 160 throw new Exception(e.Message); 161 } 162 163 } 164 /// <summary> 165 /// 如果存在账号,返回真 166 /// </summary> 167 /// <param name="username"></param> 168 /// <returns></returns> 169 public static bool Usercheck(string username) 170 { 171 string str = "SELECT * FROM User_accounts where [User]='" + username +"'"; 172 if (Webftp.Mydb.ExecuteSqlExist(str)) 173 { 174 System.Threading.Thread.Sleep(500); 175 return true;//如果存在账号,返回真。 176 } 177 else 178 { 179 return false; 180 } 181 } 182 183 184 /// <summary> 185 /// 如果存在账号或含非法字符,返回真;不含非法字符且账号不存在,返回假 186 /// </summary> 187 /// <param name="username"></param> 188 /// <returns></returns> 189 public static bool Usernamecheck(string username) 190 { 191 if (Webftp.Word.IsEnNum(username)) 192 { 193 string str = "SELECT * FROM User_accounts where [User]='" + username + "'"; 194 if (Webftp.Mydb.ExecuteSqlExist(str)) 195 { 196 System.Threading.Thread.Sleep(500); 197 return true;//如果存在账号,返回真。 198 } 199 else 200 { 201 return false;//不含非法字符且账号不存在,返回假 202 } 203 } 204 else 205 { 206 return true;//如果含非法字符,返回真 207 } 208 } 209 /// <summary> 210 /// 更新serv_u中用户密码 211 /// </summary> 212 /// <param name="username"></param> 213 /// <param name="newpwd"></param> 214 public static void Updatepwd(string username, string newpwd) 215 { 216 newpwd = Webftp.Word.Serv_u_Md5(newpwd); 217 string str = "UPDATE User_accounts SET [Password] = '"+newpwd+"' WHERE [User] = '"+username+"'"; 218 Webftp.Mydb.Execnonsql(str); 219 System.Threading.Thread.Sleep(500); 220 } 221 222 /// <summary> 223 /// 更新User_self中用户密码 224 /// </summary> 225 /// <param name="username"></param> 226 /// <param name="newpwd"></param> 227 public static void Updateselfpwd(string username, string newpwd) 228 { 229 string str = "UPDATE User_self SET [userpwd] = '" + newpwd + "' WHERE [username] = '" + username + "'"; 230 Webftp.Mydb.Execnonsql(str); 231 System.Threading.Thread.Sleep(500); 232 } 233 234 235 236 } 237}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:Ftp在线注册管理系统源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146