-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,869 changed files
with
608,734 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Text; | ||
|
||
namespace DLL | ||
{ | ||
public class AppStart | ||
{ | ||
public static void Setup() | ||
{ | ||
DataTable dt = DB.GetTable("select [t_name] from [blog_tags] order by [t_name]"); | ||
foreach (DataRow row in dt.Rows) | ||
{ | ||
Tag.Add(row[0].ToString().ToLower()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Web.SessionState; | ||
|
||
namespace DLL | ||
{ | ||
public class CKUser | ||
{ | ||
/// <summary> | ||
/// 获取当前用户名 | ||
/// </summary> | ||
public static string Username | ||
{ | ||
get { return Tools.DecryptDES(Cookie.GetCookie("username")).Replace("'", ""); } | ||
} | ||
/// <summary> | ||
/// 获取当前用户姓名 | ||
/// </summary> | ||
public static string Fullname | ||
{ | ||
get { return Cookie.GetCookie("fullname"); } | ||
} | ||
/// <summary> | ||
/// 获取当前用户email | ||
/// </summary> | ||
public static string Email | ||
{ | ||
get { return Cookie.GetCookie("email"); } | ||
} | ||
/// <summary> | ||
/// 判断用户是否登录 | ||
/// </summary> | ||
public static bool IsLogin | ||
{ | ||
get { return Username != ""; } | ||
} | ||
|
||
/// <summary> | ||
/// 写入用户信息到cookie | ||
/// </summary> | ||
/// <param name="username">用户名</param> | ||
/// <param name="fullname">姓名</param> | ||
/// <param name="email">email</param> | ||
/// <param name="remember">是否记住</param> | ||
public static void Login(string username, string fullname, string email, bool remember) | ||
{ | ||
username = Tools.EncryptDES(username); | ||
if (remember) | ||
{ | ||
DateTime expires = DateTime.Now.AddYears(1); | ||
Cookie.SetCookie("username", username, expires); | ||
Cookie.SetCookie("fullname", fullname, expires); | ||
Cookie.SetCookie("email", email, expires); | ||
} | ||
else | ||
{ | ||
Cookie.SetCookie("username", username); | ||
Cookie.SetCookie("fullname", fullname); | ||
Cookie.SetCookie("email", email); | ||
} | ||
} | ||
|
||
public static void Logout() | ||
{ | ||
Cookie.RemoveCookie("username"); | ||
Cookie.RemoveCookie("fullname"); | ||
Cookie.RemoveCookie("email"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace DLL | ||
{ | ||
public class Category | ||
{ | ||
int _id; | ||
string _name; | ||
|
||
public Category() | ||
{ | ||
} | ||
|
||
public int ID | ||
{ | ||
get { return _id; } | ||
set { _id = value; } | ||
} | ||
public string Name | ||
{ | ||
get { return _name; } | ||
set { _name = value; } | ||
} | ||
|
||
public static string GetNameById(int id) | ||
{ | ||
Dictionary<int, string> cats = AllCategory; | ||
|
||
foreach (int key in cats.Keys) | ||
{ | ||
if (key == id) return cats[key]; | ||
} | ||
return ""; | ||
} | ||
|
||
public static int GetIdByName(string name) | ||
{ | ||
Dictionary<int, string> cats = AllCategory; | ||
|
||
foreach (int key in cats.Keys) | ||
{ | ||
if (cats[key] == name) return key; | ||
} | ||
return 0; | ||
} | ||
|
||
public static Dictionary<int, string> AllCategory | ||
{ | ||
get | ||
{ | ||
Dictionary<int, string> cats = new Dictionary<int, string>(); | ||
cats[11] = "电脑/网络"; | ||
cats[12] = "生活/时尚"; | ||
cats[13] = "家庭/婚姻"; | ||
cats[14] = "电子数码"; | ||
cats[15] = "商业/理财"; | ||
cats[16] = "教育/学业"; | ||
cats[17] = "交通/旅游"; | ||
cats[18] = "社会/文化"; | ||
cats[19] = "人文学科"; | ||
cats[20] = "理工学科"; | ||
cats[21] = "休闲/娱乐"; | ||
cats[21] = "忧愁/烦恼"; | ||
return cats; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace DLL | ||
{ | ||
public class CategoryB | ||
{ | ||
int _id; | ||
string _name; | ||
|
||
public CategoryB() | ||
{ | ||
} | ||
|
||
public int ID | ||
{ | ||
get { return _id; } | ||
set { _id = value; } | ||
} | ||
public string Name | ||
{ | ||
get { return _name; } | ||
set { _name = value; } | ||
} | ||
|
||
public static string GetNameById(int id) | ||
{ | ||
Dictionary<int, string> cats = AllCategory; | ||
|
||
foreach (int key in cats.Keys) | ||
{ | ||
if (key == id) return cats[key]; | ||
} | ||
return ""; | ||
} | ||
|
||
public static int GetIdByName(string name) | ||
{ | ||
Dictionary<int, string> cats = AllCategory; | ||
|
||
foreach (int key in cats.Keys) | ||
{ | ||
if (cats[key] == name) return key; | ||
} | ||
return 0; | ||
} | ||
|
||
/// <summary> | ||
/// category_b --> category | ||
/// </summary> | ||
/// <param name="id"></param> | ||
/// <returns></returns> | ||
public static Category ToCategory(int id) | ||
{ | ||
int cid = 10; | ||
if (id == 101 || id == 108 || id == 115 || id == 116 || id == 117 || id == 118 || id == 119 || id == 121) cid = 12; | ||
else if (id == 102 || id == 106 || id == 123) cid = 21; | ||
else if (id == 103 || id == 110 || id == 111) cid = 15; | ||
else if (id == 104 || id == 109) cid = 18; | ||
else if (id == 105) cid = 11; | ||
else if (id == 107) cid = 21; | ||
else if (id == 112 || id == 113) cid = 16; | ||
else if (id == 114) cid = 17; | ||
else if (id == 120) cid = 13; | ||
else if (id == 122) cid = 18; | ||
else if (id == 124) cid = 10; | ||
|
||
Category cat = new Category(); | ||
cat.ID = cid; | ||
if (cid > 10) cat.Name = Category.AllCategory[cid]; | ||
else cat.Name = "所有类别"; | ||
|
||
return cat; | ||
} | ||
|
||
public static Dictionary<int, string> AllCategory | ||
{ | ||
get | ||
{ | ||
Dictionary<int, string> cats = new Dictionary<int, string>(); | ||
cats[101] = "生活"; | ||
cats[102] = "娱乐"; | ||
cats[103] = "职场"; | ||
cats[104] = "文化"; | ||
cats[105] = "IT"; | ||
cats[106] = "体育"; | ||
cats[107] = "情感"; | ||
cats[108] = "女人"; | ||
cats[109] = "八卦"; | ||
cats[110] = "财经"; | ||
cats[111] = "股票"; | ||
cats[112] = "校园"; | ||
cats[113] = "教育"; | ||
cats[114] = "旅游"; | ||
cats[115] = "时尚"; | ||
cats[116] = "美食"; | ||
cats[117] = "汽车"; | ||
cats[118] = "房产"; | ||
cats[119] = "家居"; | ||
cats[120] = "育儿"; | ||
cats[121] = "健康"; | ||
cats[122] = "军事"; | ||
cats[123] = "游戏"; | ||
cats[124] = "随笔"; | ||
return cats; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Web; | ||
using System.Web.SessionState; | ||
|
||
namespace DLL | ||
{ | ||
public class Cookie | ||
{ | ||
/// <summary> | ||
/// дÈëcookie£¬Ä¬ÈÏʱ¼äÒ»Ìì | ||
/// </summary> | ||
/// <param name="name"></param> | ||
/// <param name="valu"></param> | ||
public static void SetCookie(string name, string valu) | ||
{ | ||
SetCookie(name, valu, DateTime.Now.AddDays(1)); | ||
} | ||
|
||
public static void SetCookie(string name, string valu, DateTime expires) | ||
{ | ||
HttpCookie cookie = new HttpCookie(name, HttpUtility.UrlEncode(valu, Encoding.GetEncoding("GB2312"))); | ||
cookie.Expires = expires; | ||
//cookie.Domain = "cnopenblog.com"; | ||
|
||
HttpContext context = HttpContext.Current; | ||
context.Response.Cookies.Add(cookie); | ||
} | ||
|
||
public static string GetCookie(string name) | ||
{ | ||
string valu = ""; | ||
HttpContext context = HttpContext.Current; | ||
HttpCookie cookie = context.Request.Cookies[name]; | ||
if (cookie != null) | ||
{ | ||
valu = HttpUtility.UrlDecode(cookie.Value, Encoding.GetEncoding("GB2312")); | ||
} | ||
return valu; | ||
} | ||
|
||
public static void RemoveCookie(string name) | ||
{ | ||
HttpCookie cookie = new HttpCookie(name, ""); | ||
cookie.Expires = DateTime.Now.AddDays(-1); | ||
|
||
HttpContext context = HttpContext.Current; | ||
context.Response.Cookies.Add(cookie); | ||
} | ||
} | ||
} |
Oops, something went wrong.