private static void AutoGenerateTemplate() { var templateGenerated = Convert.ToBoolean(MemoryCache.Default["auto_template_generated"]); // Global 不能保存成员变量,每次都会初始化 if (!templateGenerated && !Utils.IsDebugging()) { MemoryCache.Default["auto_template_generated"] = true; var stopwatch = new Stopwatch(); stopwatch.Start(); var config = new siteconfig().loadConfig(); templet_list.MarkTemplates("main", "Agp2p", config); if (config.mobilestatus == 1) { templet_list.MarkTemplates("mobile", "weChat", config); } stopwatch.Stop(); new Agp2pDataContext().AppendAdminLogAndSave(DTEnums.ActionEnum.Build.ToString(), "自动生成模版成功,耗时:" + stopwatch.Elapsed); } }
public void ProcessRequest(HttpContext context) { int aid = DTRequest.GetQueryInt("id"); //获得广告位的ID if (aid < 1) { context.Response.Write("document.write('错误提示,请勿提交非法字符!');"); return; } //检查广告位是否存在 BLL.advert abll = new BLL.advert(); if (!abll.Exists(aid)) { context.Response.Write("document.write('错误提示,该广告位不存在!');"); return; } //取得该广告位详细信息 Model.advert aModel = abll.GetModel(aid); //输出该广告位下的广告条,不显示未开始、过期、暂停广告 BLL.advert_banner bbll = new BLL.advert_banner(); DataSet ds = bbll.GetList("is_lock=0 and datediff(d,start_time,getdate())>=0 and datediff(d,end_time,getdate())<=0 and aid=" + aid); if (ds.Tables[0].Rows.Count < 1) { context.Response.Write("document.write('该广告位下暂无广告内容');"); return; } //=================判断广告位类别,输出广告条====================== //新增,取得站点配置信息 Agp2p.Model.siteconfig siteConfig = new Agp2p.BLL.siteconfig().loadConfig(); switch (aModel.type) { case 1: //文字 context.Response.Write("document.write('<ul>');\n"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= aModel.view_num) { break; } DataRow dr = ds.Tables[0].Rows[i]; context.Response.Write("document.write('<li>');"); context.Response.Write("document.write('<a title=\"" + dr["title"] + "\" target=\"" + aModel.target + "\" href=\"" + dr["link_url"] + "\">" + dr["title"] + "</a>');"); context.Response.Write("document.write('</li>');\n"); } context.Response.Write("document.write('</ul>');\n"); break; case 2: //图片 if (ds.Tables[0].Rows.Count == 1) { DataRow dr = ds.Tables[0].Rows[0]; context.Response.Write("document.write('<a title=\"" + dr["title"] + "\" target=\"" + aModel.target + "\" href=\"" + dr["link_url"] + "\">');"); context.Response.Write("document.write('<img src=\"" + dr["file_path"] + "\" width=" + aModel.view_width + " height=" + aModel.view_height + " border=0 />');"); context.Response.Write("document.write('</a>');"); } else { context.Response.Write("document.write('<ul>');\n"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= aModel.view_num) { break; } DataRow dr = ds.Tables[0].Rows[i]; context.Response.Write("document.write('<li>');"); context.Response.Write("document.write('<a title=\"" + dr["title"] + "\" target=\"" + aModel.target + "\" href=\"" + dr["link_url"] + "\">');"); context.Response.Write("document.write('<img src=\"" + dr["file_path"] + "\" width=" + aModel.view_width + " height=" + aModel.view_height + " border=0 />');"); context.Response.Write("document.write('</a>');\n"); context.Response.Write("document.write('</li>');\n"); } context.Response.Write("document.write('</ul>');\n"); } break; case 3: //幻灯片 StringBuilder picTitle = new StringBuilder(); StringBuilder picUrl = new StringBuilder(); StringBuilder picLink = new StringBuilder(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= aModel.view_num) { break; } DataRow dr = ds.Tables[0].Rows[i]; picUrl.Append(dr["file_path"].ToString()); picLink.Append(dr["link_url"].ToString()); if (i < ds.Tables[0].Rows.Count - 1) { picUrl.Append("|"); picLink.Append("|"); } } context.Response.Write("document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" d=scriptmain name=scriptmain codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + aModel.view_width + "\" height=\"" + aModel.view_height + "\">');\n"); context.Response.Write("document.write('<param name=\"movie\" value=\"" + siteConfig.webpath + "plugins/advert/focus.swf?width=" + aModel.view_width + "&height=" + aModel.view_height + "&bigSrc=" + picUrl + "&href=" + picLink + "\">');\n"); context.Response.Write("document.write('<param name=\"quality\" value=\"high\">');\n"); context.Response.Write("document.write('<param name=\"loop\" value=\"false\">');\n"); context.Response.Write("document.write('<param name=\"menu\" value=\"false\">');\n"); context.Response.Write("document.write('<param name=\"wmode\" value=\"transparent\">');\n"); context.Response.Write("document.write('<embed src=\"" + siteConfig.webpath + "plugins/advert/focus.swf?width=" + aModel.view_width + "&height=" + aModel.view_height + "&bigSrc=" + picUrl + "&href=" + picLink + "\" width=\"" + aModel.view_width + "\" height=\"" + aModel.view_height + "\" loop=\"false\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" menu=\"false\"></embed>');\n"); context.Response.Write("document.write('</object>');\n"); break; case 4: //动画 if (ds.Tables[0].Rows.Count == 1) { DataRow dr = ds.Tables[0].Rows[0]; context.Response.Write("document.write('<object classid=\"clsid:D27CDB6E-AE6D-11CF-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" width=\"" + aModel.view_width + "\" height=\"" + aModel.view_height + "\">');\n"); context.Response.Write("document.write('<param name=\"movie\" value=\"" + dr["file_path"] + "\">');\n"); context.Response.Write("document.write('<param name=\"quality\" value=\"high\">');\n"); context.Response.Write("document.write('<param name=\"wmode\" value=\"transparent\">');\n"); context.Response.Write("document.write('<param name=\"menu\" value=\"false\">');\n"); context.Response.Write("document.write('<embed src=\"" + dr["file_path"] + "\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + aModel.view_width + "\" height=\"" + aModel.view_height + "\" quality=\"High\" wmode=\"transparent\">');\n"); context.Response.Write("document.write('</embed>');\n"); context.Response.Write("document.write('</object>');\n"); } else { context.Response.Write("document.write('<ul>');\n"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= aModel.view_num) { break; } DataRow dr = ds.Tables[0].Rows[i]; context.Response.Write("document.write('<li>');"); context.Response.Write("document.write('<object classid=\"clsid:D27CDB6E-AE6D-11CF-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" width=\"" + aModel.view_width + "\" height=\"" + aModel.view_height + "\">');\n"); context.Response.Write("document.write('<param name=\"movie\" value=\"" + dr["file_path"] + "\">');\n"); context.Response.Write("document.write('<param name=\"quality\" value=\"high\">');\n"); context.Response.Write("document.write('<param name=\"wmode\" value=\"transparent\">');\n"); context.Response.Write("document.write('<param name=\"menu\" value=\"false\">');\n"); context.Response.Write("document.write('<embed src=\"" + dr["file_path"] + "\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + aModel.view_width + "\" height=\"" + aModel.view_height + "\" quality=\"High\" wmode=\"transparent\">');\n"); context.Response.Write("document.write('</embed>');\n"); context.Response.Write("document.write('</object>');\n"); context.Response.Write("document.write('</li>');\n"); } context.Response.Write("document.write('</ul>');\n"); } break; case 5: //视频 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= 1) { break; } DataRow dr = ds.Tables[0].Rows[i]; context.Response.Write("document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" width=" + aModel.view_width + " height=" + aModel.view_height + " viewastext>');\n"); context.Response.Write("document.write('<param name=\"movie\" value=\"" + siteConfig.webpath + "plugins/advert/player.swf\" />');\n"); context.Response.Write("document.write('<param name=\"quality\" value=\"high\" />');\n"); context.Response.Write("document.write('<param name=\"allowFullScreen\" value=\"true\" />');\n"); context.Response.Write("document.write('<param name=\"FlashVars\" value=\"vcastr_file=" + dr["file_path"].ToString() + "&LogoText=www.auto.cn&BarTransparent=30&BarColor=0xffffff&IsAutoPlay=1&IsContinue=1\" />');\n"); context.Response.Write("document.write('</object>');\n"); } break; case 6: //代码 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //如果超出限制广告数量,则退出循环 if (i >= 1) { break; } DataRow dr = ds.Tables[0].Rows[i]; StringBuilder sb = new StringBuilder(dr["content"].ToString()); sb.Replace("<", "<"); sb.Replace(">", ">"); sb.Replace("\"", "'"); context.Response.Write("document.write(\"" + sb.ToString() + "\")"); } break; } }
private void sendMobileVerifyCode(string picCode, string mobile, int sendSecondsSpan, bool checkConflict, Action <int, string> callback) { if (string.IsNullOrWhiteSpace(mobile)) { callback((int)HttpStatusCode.Unauthorized, "参数不正确"); return; } // verifying_mobile : string | last_send_verifying_sms_at : DateTime? | mobile_verify_code : string // 限制发送时间间隔 var lastSendVerifyingSMSAt = (DateTime?)SessionHelper.Get("last_send_verifying_sms_at"); if (lastSendVerifyingSMSAt != null && DateTime.Now.Subtract(lastSendVerifyingSMSAt.Value).TotalSeconds < sendSecondsSpan) { callback(429, "发送短信的间隔为 " + sendSecondsSpan + " 秒,您刚才已经发送过啦,休息一下再来吧!"); return; } // 验证图形验证码 if (string.IsNullOrWhiteSpace(picCode) || !string.Equals((string)HttpContext.Current.Session[DTKeys.SESSION_CODE], picCode, StringComparison.CurrentCultureIgnoreCase)) { callback((int)HttpStatusCode.BadRequest, "图形验证码不正确"); return; } HttpContext.Current.Session[DTKeys.SESSION_CODE] = null; // 判断电话是否已经被验证过了 var context = new Agp2pDataContext(); if (checkConflict && context.dt_users.Count(u => u.mobile == mobile) != 0) { callback((int)HttpStatusCode.Conflict, "这个电话号码已经被其他用户绑定了"); return; } var strCode = Utils.Number(4); SessionHelper.Set("verifying_mobile", mobile); SessionHelper.Set("last_send_verifying_sms_at", DateTime.Now); SessionHelper.Set("mobile_verify_code", strCode); //获得短信模版内容 var smsModel = new sms_template().GetModel("mobile_verify_code"); if (smsModel == null) { callback((int)HttpStatusCode.Gone, "短信发送失败,短信模板不存在!"); return; } //替换模板内容 var siteConfig = new siteconfig().loadConfig(); var msgContent = smsModel.content .Replace("{webname}", siteConfig.webname) .Replace("{webtel}", siteConfig.webtel) .Replace("{code}", strCode) .Replace("{valid}", SessionHelper.GetSessionTimeout().ToString()); try { //发送短信 var tipMsg = string.Empty; bool result = false; /*if (Utils.IsDebugging()) * { * Debug.WriteLine("向手机 {0} 发送短信:{1}", mobile, msgContent); * result = true; * } * else*/ result = SMSHelper.SendSmsCode(mobile, msgContent, out tipMsg); if (result) { callback((int)HttpStatusCode.OK, "短信发送成功,请查收!"); } else { callback((int)HttpStatusCode.InternalServerError, tipMsg); } } catch { callback((int)HttpStatusCode.InternalServerError, "短信发送失败,请联系本站管理员!"); } }