js密码验证 install/js/setup.js
将内容传送页面
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
string script = "<div id=\"success\" style=\"position:absolute;z-index:300;height:120px;284px;left:50%;top:50%;margin-left:-150px;margin-top:-80px;\">\r\n" +
" <div id=\"Layer2\" style=\"position:absolute;z-index:300;270px;height:90px;background-color: #FFFFFF;border:solid #000000 1px;font-size:14px;\">\r\n" +
" <div id=\"Layer4\" style=\"height:26px;background:#333333;line-height:26px;padding:0px 3px 0px 3px;font-weight:bolder;color:#fff \">操作提示</div>\r\n" +
" <div id=\"Layer5\" style=\"height:64px;line-height:150%;padding:0px 3px 0px 3px;\" align=\"center\"><br />正在执行操作,请稍等
</div>\r\n" +
" </div>\r\n" +
" <div id=\"Layer3\" style=\"position:absolute;270px;height:90px;z-index:299;left:4px;top:5px;background-color: #cccccc;\"></div>\r\n" +
"</div>\r\n" +
"<script> \r\n" +
"document.getElementById('success').style.display ='none'; \r\n" +
"</script> \r\n" +
"<script language=\"JavaScript1.2\" src=\"../js/divcover.js\"></script>\r\n";
base.ClientScript.RegisterClientScriptBlock(this.GetType(), "Page", script);
ajax注册(各页面通用ajax,js函数):register.aspx js:
emplates\default\ajax.js
发送邮件:forum/Email.cs
创建目录
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//// <summary>
/// 创建目录
/// </summary>
/// <param name="name">名称</param>
/// <returns>创建是否成功</returns>
[DllImport("dbgHelp", SetLastError = true)]
private static extern bool MakeSureDirectoryPathExists(string name);
Cache: 现在将Discuz!NT的缓存架构说明如下,先请大家看一下Discuz!NT架构图:
![](https://daizhj.cnblogs.com/images/cnblogs_com/daizhj/discuznt_cache.JPG)
其实这个构架说白了就是一个标准的“策略”模式,为了对比方便,我把策略模式的结构
图放在下面:
![](https://daizhj.cnblogs.com/images/cnblogs_com/daizhj/strategy.JPG)
AES,DES加密解密:DISCUZ.Common
附:DES:Data Encryption Standard,是一种数据加密标准,现在已经不用了。它使用56位密钥对64位的数据块(真正数据只有57位,还有8位是校验位)进行加密,并对64位的数据块进行16轮编码。与每轮编码时,一个48位的“每轮”密钥值由56位的完整密钥得出来。
DES对64(bit)位的明文分组M进行操作,M经过一个初始置换IP置换成m0,将m0明文分成左半部分和右半部分m0=(L0,R0),各32位长。然后进行16轮完全相同的运算,这些运算被称为函数f,在运算过程中数据与密匙结合。经过16轮后,左,右半部分合在一起经过一个末置换,这样就完成了。
在每一轮中,密匙位移位,然后再从密匙的56位中选出48位。通过一个扩展置换将数据的右半部分扩展成48位,并通过一个异或操作替代成新的32位数据,在将其置换换一次。这四步运算构成了函数f。然后,通过另一个异或运算,函数f的输出与左半部分结合,其结果成为新的右半部分,原来的右半部分成为新的左半部分。将该操作重复16次,就实现了。
因为是对称加密,解密和加密的过程一样,密钥也一样。
遍历目录文件,读取删除操作(admin/global/
global_avatargrid.aspx)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
public string avatar;
public DataTable avatarfilelist;
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
protected void Page_Load(object sender, EventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
if (!Page.IsPostBack)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
LoadAvatarInfo();
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
public void LoadAvatarInfo()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
加载头像数据#region 加载头像数据
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
avatarfilelist = new DataTable("avatarlist");
avatarfilelist.Columns.Add("filenamepath", Type.GetType("System.String"));
avatarfilelist.Columns.Add("filename", Type.GetType("System.String"));
avatarfilelist.Columns.Add("_id", Type.GetType("System.Int32"));
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
DirectoryInfo dirinfo = new DirectoryInfo(Server.MapPath("http://www.cnblogs.com/avatars/common/"));
int i = 1;
foreach (FileSystemInfo file in dirinfo.GetFileSystemInfos())
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (file != null)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string extname = file.Extension.ToLower();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (extname.Equals(".jpg") || extname.Equals(".gif") || extname.Equals(".png"))
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DataRow dr = avatarfilelist.NewRow();
if (DNTRequest.GetString("path") == "1")
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
dr["filename"] = file.Name.Split('.')[0];
}
else
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
dr["filename"] = file.Name;
}
dr["filenamepath"] = "avatars\\common\\" + file.Name;
dr["_id"] = i;
i++;
avatarfilelist.Rows.Add(dr);
}
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
foreach (DataRow avatarfile in avatarfilelist.Rows)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
vatarshow.Text += " <td width=\"25%\" align=\"center\"><img width=100 height=100 src=\"../../" + avatarfile["filenamepath"].ToString().Trim() + "\" title=\"" + avatarfile["filename"].ToString() + "\" \r\n";
if (avatarfile["filename"].ToString().Trim() == "")
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
vatarshow.Text += " style=\"border-style:dashed;border-2px;border-color:#FF0000\"\r\n";
}
vatarshow.Text += " /><br />\r\n";
vatarshow.Text += " <INPUT id=\"id\" onclick=\"javascript:SH_SelectOne(this)\" type=\"checkbox\" value=\"" + avatarfile["filenamepath"].ToString() + "\" name=\"id\"\r\n";
vatarshow.Text += " /> " + avatarfile["filename"].ToString() + "</td>\r\n";
if (Utils.StrToInt(avatarfile["_id"].ToString().Trim(), 0) % 4 == 0)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
vatarshow.Text += " </tr>\r\n";
vatarshow.Text += " <tr>\r\n";
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
#endregion
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
private void DeleteAvatar_Click(object sender, EventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
删除选中的头像#region 删除选中的头像
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (this.CheckCookie())
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (DNTRequest.GetString("id") != "")
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
foreach (string filepathname in DNTRequest.GetString("id").Split(','))
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (Utils.FileExists(Utils.GetMapPath(@"..\..\" + filepathname)))
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
File.Delete(Utils.GetMapPath(@"..\..\" + filepathname));
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
cache.RemoveObject("/Forum/CommonAvatarList");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
base.RegisterStartupScript( "PAGE", "window.location.href='global_avatargrid.aspx';");
}
else
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
base.RegisterStartupScript( "", "<script>alert('您未选中任何选项');</script>");
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
#endregion
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
private void UpdateAvatarCache_Click(object sender, EventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
更新头像缓存#region 更新头像缓存
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (this.CheckCookie())
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
cache.RemoveObject("/Forum/CommonAvatarList");
base.RegisterStartupScript( "PAGE", "window.location.href='global_avatargrid.aspx';");
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
#endregion
}
操作时显示等待图片-global_templatesgrid.aspx
<script type="text/javascript">
function CreateTemplate(pathname)
{
if(confirm("生成" + pathname + "下所有模板的操作非常耗时,确认要继续吗?"))
{
document.getElementById('success').style.display = 'block';
//document.getElementById('Layer5').style.width='400px';
document.getElementById('Layer5').innerHTML='<BR /><table><tr><td valign=top><img border=0 src=../images/ajax_loading.gif /></td><td valign=middle style=font-size:14px;>正在生成'+pathname+'文件夹下的模板, <BR />请稍等...<BR /></td></tr></table><BR />';
window.location="?createtemplate=" + pathname;
}
}
</script>
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
public void RegisterAdminPageClientScriptBlock()
2![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
3
string script = "<div id=\"success\" style=\"position:absolute;z-index:300;height:120px;284px;left:50%;top:50%;margin-left:-150px;margin-top:-80px;\">\r\n" +
4
" <div id=\"Layer2\" style=\"position:absolute;z-index:300;270px;height:90px;background-color: #FFFFFF;border:solid #000000 1px;font-size:14px;\">\r\n" +
5
" <div id=\"Layer4\" style=\"height:26px;background:#f1f1f1;line-height:26px;padding:0px 3px 0px 3px;font-weight:bolder;\">操作提示</div>\r\n" +
6
" <div id=\"Layer5\" style=\"height:64px;line-height:150%;padding:0px 3px 0px 3px;\" align=\"center\"><BR /><table><tr><td valign=top><img border=\"0\" src=\"../images/ajax_loading.gif\" /></td><td valign=middle style=\"font-size: 14px;\" >正在执行当前操作, 请稍等
<BR /></td></tr></table><BR /></div>\r\n" +
7
" </div>\r\n" +
8
" <div id=\"Layer3\" style=\"position:absolute;270px;height:90px;z-index:299;left:4px;top:5px;background-color: #E8E8E8;\"></div>\r\n" +
9
"</div>\r\n" +
10
"<script> \r\n" +
11
"document.getElementById('success').style.display = \"none\"; \r\n" +
12
"</script> \r\n" +
13
"<script language=\"JavaScript1.2\" src=\"../js/divcover.js\"></script>\r\n";
14![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
#if NET1
16
RegisterClientScriptBlock("Page", script);
17
#else
18
ClientScript.RegisterClientScriptBlock(this.GetType(), "Page", script);
19
#endif
20
}
------------不断更新