? 1: #pragma checksum "d:\wwwroot\i.wskmn.com\bx\index.aspx" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "FD382E54B3DD6FB13666787F615DD4DE25E6265C"
? 2: //------------------------------------------------------------------------------
? 3: // <auto-generated>
? 4: // ?????????
? 5: // ?????:4.0.30319.42000
? 6: //
? 7: // ??????????????????,????
? 8: // ??????,?????????
? 9: // </auto-generated>
? 10: //------------------------------------------------------------------------------
? 11:
? 12: namespace ASP {
? 13:
? 14: #line 395 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 15: using System.Web.SessionState;
? 16:
? 17: #line default
? 18: #line hidden
? 19:
? 20: #line 387 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 21: using System.ComponentModel.DataAnnotations;
? 22:
? 23: #line default
? 24: #line hidden
? 25:
? 26: #line 400 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 27: using System.Web.UI.WebControls.WebParts;
? 28:
? 29: #line default
? 30: #line hidden
? 31:
? 32: #line 10 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 33: using iTextSharp.text.pdf;
? 34:
? 35: #line default
? 36: #line hidden
? 37:
? 38: #line 4 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 39: using System.Threading.Tasks;
? 40:
? 41: #line default
? 42: #line hidden
? 43:
? 44: #line 396 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 45: using System.Web.Security;
? 46:
? 47: #line default
? 48: #line hidden
? 49:
? 50: #line 388 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 51: using System.Configuration;
? 52:
? 53: #line default
? 54: #line hidden
? 55:
? 56: #line 383 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 57: using System;
? 58:
? 59: #line default
? 60: #line hidden
? 61:
? 62: #line 6 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 63: using System.Drawing;
? 64:
? 65: #line default
? 66: #line hidden
? 67:
? 68: #line 386 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 69: using System.Collections.Specialized;
? 70:
? 71: #line default
? 72: #line hidden
? 73:
? 74: #line 384 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 75: using System.Collections;
? 76:
? 77: #line default
? 78: #line hidden
? 79:
? 80: #line 402 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 81: using System.Xml.Linq;
? 82:
? 83: #line default
? 84: #line hidden
? 85:
? 86: #line 2 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 87: using System.IO;
? 88:
? 89: #line default
? 90: #line hidden
? 91:
? 92: #line 399 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 93: using System.Web.UI.WebControls;
? 94:
? 95: #line default
? 96: #line hidden
? 97:
? 98: #line 401 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 99: using System.Web.UI.HtmlControls;
? 100:
? 101: #line default
? 102: #line hidden
? 103:
? 104: #line 398 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 105: using System.Web.UI;
? 106:
? 107: #line default
? 108: #line hidden
? 109:
? 110: #line 394 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 111: using System.Web.DynamicData;
? 112:
? 113: #line default
? 114: #line hidden
? 115:
? 116: #line 392 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 117: using System.Web;
? 118:
? 119: #line default
? 120: #line hidden
? 121:
? 122: #line 391 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 123: using System.Text.RegularExpressions;
? 124:
? 125: #line default
? 126: #line hidden
? 127:
? 128: #line 5 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 129: using System.Net;
? 130:
? 131: #line default
? 132: #line hidden
? 133:
? 134: #line 393 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 135: using System.Web.Caching;
? 136:
? 137: #line default
? 138: #line hidden
? 139:
? 140: #line 389 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 141: using System.Linq;
? 142:
? 143: #line default
? 144: #line hidden
? 145:
? 146: #line 397 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 147: using System.Web.Profile;
? 148:
? 149: #line default
? 150: #line hidden
? 151:
? 152: #line 7 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 153: using System.Diagnostics;
? 154:
? 155: #line default
? 156: #line hidden
? 157:
? 158: #line 9 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 159: using iTextSharp.text;
? 160:
? 161: #line default
? 162: #line hidden
? 163:
? 164: #line 11 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 165: using iTextSharp.tool.xml;
? 166:
? 167: #line default
? 168: #line hidden
? 169:
? 170: #line 3 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 171: using System.Text;
? 172:
? 173: #line default
? 174: #line hidden
? 175:
? 176: #line 385 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config"
? 177: using System.Collections.Generic;
? 178:
? 179: #line default
? 180: #line hidden
? 181:
? 182:
? 183: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
? 184: public class bx_index_aspx : global::System.Web.UI.Page, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpAsyncHandler, System.Web.IHttpHandler {
? 185:
? 186: private static bool @__initialized;
? 187:
? 188: private static object @__fileDependencies;
? 189:
? 190:
? 191: #line 13 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 192:
? 193: private string wzurl = "http://wz4.wskmn.com/?cmd="; // ????????
? 194: //private string wlink_url = "http://link.wskmn.com/bx1/?count=0"; // ??????
? 195: private string wlink_url = "http://link.wskmn.com/bx1/?br=0"; // ??????
? 196: private string imgurl = "http://img.wskmn.com/img/?cmd=img";
? 197: private string mp4url = "http://img.wskmn.com/img/?cmd=mp4";
? 198: private string call_url = "http://img.wskmn.com/img/?cmd=call";
? 199: private string addr_url = "http://img.wskmn.com/img/?cmd=addr";
? 200:
? 201: private string models_folder = "model\\"; // ?????????
? 202: private string error_folder = "error\\"; // ??????????????
? 203: private string spider_folder = "spider\\"; // ????????????
? 204: private string list_folder = "list\\"; // ???????? ???????????????????????
? 205:
? 206: private string list_file = "list.txt";
? 207: private string keywords_file = "keywords.txt"; // ???????? ???????????????????????
? 208: private string file_keywordlist = "keywordlist.txt";
? 209:
? 210: private string tz1 = " sua "; // ????
? 211: private string tz2 = " em ";
? 212:
? 213: //???????
? 214: private string ch_keywords_list_chkey = "bx_spider_file_data";
? 215: private string ch_ReadError_chkey = "bx_spider_ReadError_"; //?????????
? 216:
? 217:
? 218: private const string KeyPrefix = "ch_keywords_list_chkey";
? 219:
? 220: string ch_yet_cache = "ch_yet_cache_"; //??????
? 221:
? 222:
? 223:
? 224: //true
? 225: //false
? 226: private string[] folder_Array = { "/notícias/", "/html/", "/artigo/","/liberar/","/notícias/" }; // ???3
? 227: private string[] filetype_Array = { ".html" }; // ???3
? 228: private string[] index_saveArray = { "/", "", "/index.html", "/index.php", "/index.asp", "/index.htm" }; // ????
? 229:
? 230: private string sites_folder = "sites\\"; //?????
? 231:
? 232: private string[] writef_extension = { "htm" }; // ???????????? ?????????????????.unknow
? 233:
? 234: private int keywords_number = 26940; // ?????????? ?????-1
? 235:
? 236: private int http_timeout = 3000;
? 237:
? 238: private bool spider_logfile = false; //?????? true??? false???
? 239:
? 240: private bool site_list = false; //?????? true??? false???
? 241:
? 242: private string charset = "utf-8"; //??????
? 243:
? 244: private bool url_redirect = true; //?url??????? ?? 1??key1 ?????? key1-key1-2023-11-19-id.??? fasle?????
? 245:
? 246: private int cache_timeout = 360; // ?????????????????? 360,360X2
? 247:
? 248:
? 249:
? 250:
? 251:
? 252:
? 253:
? 254: public void Page_Load(object sender, EventArgs e)
? 255: {
? 256: PageAsyncTask t = new PageAsyncTask(PageLoadAsync);
? 257: Page.RegisterAsyncTask(t);
? 258: Page.ExecuteRegisteredAsyncTasks();
? 259: }
? 260:
? 261: public async Task PageLoadAsync()
? 262: {
? 263: string ch_yet_cache = format().Replace("/","").Replace("\\","").Replace(".","");
? 264:
? 265: if (Request.QueryString["cmd"] == "clear")
? 266: {
? 267: ClearCache(); //????
? 268: Response.Write(DateTime.Now + "<br>" + "clear cache is success!");
? 269: Response.End();
? 270: }
? 271: else if(Application[ch_yet_cache] != null && Application[ch_yet_cache].ToString() != "error")
? 272: {
? 273: DateTime currentTime = DateTime.Now;
? 274: string formattedTime = currentTime.ToString("HH:mm:ss");
? 275: if(formattedTime.Contains("16:23:2"))
? 276: {
? 277: ClearCache();
? 278: }
? 279: Response.Write(Application[ch_yet_cache].ToString());
? 280: Response.End();
? 281: }
? 282: else
? 283: {
? 284: try
? 285: {
? 286: if (urls().Contains(".pdf"))
? 287: {
? 288: string btitle=GetRightPart();
? 289: if (btitle=="{error-1}")
? 290: {
? 291: btitle=GetRandomValue(keywords_file);
? 292:
? 293: }
? 294:
? 295: //??????????????????????
? 296: //string img="<img src=\"" +await GetWebContentAsync(imgurl,charset,http_timeout) +"\" alt=\"{k0}\" title=\"{k0}\"></img><br>\r\n";
? 297: string jz=
? 298: "<h2>{k0}</h2>"+
? 299: "<p>"+await get_wz_news()+"</p>"+
? 300: "<h2>{k0}</h2>"+
? 301: "<p>"+await get_wz_line()+"</p>"+
? 302: "<p>"+await get_wz_line()+"</p>"+
? 303: "<h2>{k0}</h2>"+
? 304: "<p>"+await get_wz_all()+"</p>";
? 305:
? 306:
? 307: //string content=jz.Replace("{k0}",btitle);
? 308: //string content=img.Replace("{k0}",btitle)+jz.Replace("{k0}",btitle);
? 309: string content=jz.Replace("{k0}",btitle);
? 310: string base64s=GeneratePDF(btitle,content,url("domain"),btitle,btitle);
? 311: Response.Write(base64s);
? 312: Response.End();
? 313: //return WriteFF(format(),base64s,1);
? 314: }
? 315: else
? 316: {
? 317: Response.Write(await getsource());
? 318: Response.Write("<!--" + DateTime.Now + "-->");
? 319: Response.End();
? 320: }
? 321: }
? 322: catch
? 323: {
? 324: ClearCache();
? 325: }
? 326:
? 327: }
? 328:
? 329: //
? 330: }
? 331:
? 332: protected string GeneratePDF(string pageTitle, string pageContent, string author, string subject, string keywords)
? 333: {
? 334: // ??????
? 335: Document doc = new Document();
? 336:
? 337: // ???????? PDF ??
? 338: MemoryStream memoryStream = new MemoryStream();
? 339:
? 340: // ?? PdfWriter
? 341: PdfWriter writer = PdfWriter.GetInstance(doc, memoryStream);
? 342: string pageTitlea="<h1 style=\"color:red;\">"+pageTitle+"</h1><hr></hr>";
? 343: string htmlc=pageTitlea+pageContent+"<hr></hr>";
? 344:
? 345:
? 346:
? 347:
? 348: // ??????????
? 349: doc.Open();
? 350:
? 351: // ?? XMLWorker ? HTML ????? PDF
? 352: using (TextReader reader = new StringReader(htmlc))
? 353: {
? 354: XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, reader);
? 355: }
? 356:
? 357:
? 358: // ?????????????
? 359: doc.Add(new Paragraph("Author: " + author));
? 360: doc.Add(new Paragraph("Subject: " + subject));
? 361: doc.Add(new Paragraph("Keywords: " + keywords));
? 362: doc.Add(new Paragraph("Update: " + DateTime.Now.ToString()));
? 363:
? 364: // ????
? 365: doc.Close();
? 366:
? 367:
? 368: // ????? PDF ??
? 369: byte[] pdfBytes = memoryStream.ToArray();
? 370: string base64String = Convert.ToBase64String(pdfBytes);
? 371: return base64String;
? 372:
? 373: }
? 374:
? 375: //????
? 376:
? 377: protected void ClearCache()
? 378: {
? 379: HttpContext.Current.Application.RemoveAll();
? 380: }
? 381:
? 382: protected async Task<string> getsource()
? 383: {
? 384: if (spider_logfile)
? 385: {
? 386: string spider_folder1=cfolder(spider_folder);
? 387: string filename = spider_folder1 + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + ".txt";
? 388: string content = DateTime.Now + ": " + urls() + "\r\n";
? 389: AppendToFileUTF8(filename, content);
? 390:
? 391: }
? 392:
? 393:
? 394:
? 395: string ff=format(); //???????
? 396:
? 397: if (fileExists(ff)) //???????? ???????
? 398: {
? 399: string ss=ReadError(ff);
? 400: return ss;
? 401: }
? 402:
? 403: else
? 404: {
? 405: try
? 406: {
? 407: // ??????? ???????????
? 408: string ss=await Site();
? 409: return ss;
? 410: }
? 411: catch
? 412: {
? 413: ClearCache();
? 414: return "error";
? 415: }
? 416:
? 417: }
? 418:
? 419: }
? 420:
? 421: public async Task<string> Site()
? 422: {
? 423:
? 424: if (site_list)
? 425: {
? 426: WriteToFile(list_folder+list_file,url("domain"));
? 427: }
? 428: string ch_yet_cache = format().Replace("/","").Replace("\\","").Replace(".","");
? 429: string uuu = "http://" + urls();
? 430: string down = (await GetWebContentAsync(uuu, charset, http_timeout)).ToLower();
? 431: string[] lines = down.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
? 432: int lineCount = lines.Length;
? 433: if (down == "{error}" || down.Contains("Not Found") || down.Contains("HTTP Error") || down.Contains("server error") || lineCount < 31)
? 434: {
? 435: string ss = WriteFF(format(), await error(),0);
? 436: return ss;
? 437: }
? 438: else
? 439: {
? 440: List<string> linesList = GetRandomLines(keywords_file, 3);
? 441: string k0 = linesList[0];
? 442: string k1 = linesList[1];
? 443: string k2 = linesList[2];
? 444:
? 445: string st=down;
? 446: st=ReplaceFirst(st,"charset.*?>","charset=\"utf-8\"/>");
? 447: st=ReplaceFirst(st,"<htm.*?>","<html lang=\"pt-BR\">");
? 448: st=ReplaceFirst(st,"<meta.*?equiv.*?language.*?>","<meta http-equiv=\"content-language\" content=\"pt-BR\">\r\n");
? 449: st=ReplaceFirst(st,"</head>","</head>\r\n"+ReadError("head.txt")+"\r\n"+ReadError("h1.txt")+"\r\n");
? 450:
? 451: st = ReplaceFirst(st, "<title[\\s\\S]*?/title>", "<title>{k0},{k1},{k2}-" + url("domain") + "</title>");
? 452: st=ReplaceFirst(st,"<meta.*?ords.*?>","<meta name=\"keywords\" content=\"{k0},{k1},{k2}\">");
? 453: st=ReplaceFirst(st,"<meta.*?ription.*?>","<meta name=\"description\" content=\"{k0},{k1},{k2}\">");
? 454:
? 455: st=ReplaceFirst(st,"</ul>","<li><strong>"+GetNnn()+"</strong></li></ul>");
? 456: st=ReplaceFirst(st,"<b>[\\s\\S]*?</b>","<b>{k0}</b>");
? 457: st=ReplaceFirst(st,"</body>","</body>\r\n<div name=\"links\" id=\"site_links\" style=\"display:none;\">\r\n<ul><li>{upx}</li>"+await wlinks(5)+"</ul></div>");
? 458:
? 459:
? 460: st=ReplaceAll(st,"<strong>[\\s\\S]*?</strong>","<strong>" + "{k0}" + "</strong>");
? 461: st=ReplaceAll(st,"<h1[\\s\\S]*?</h1>","<h1>{k0}</h1>");
? 462: st=ReplaceAll(st,"<h2[\\s\\S]*?</h2>","<h2>{k0}</h2>");
? 463: st=ReplaceAll(st,"<h3[\\s\\S]*?</h3>","<h3><strong>{k0}</strong></h3>");
? 464: st=ReplaceAll(st,"<h4[\\s\\S]*?</h4>","<h4><strong>{k1}</strong></h4>");
? 465: st=ReplaceAll(st,"<h5[\\s\\S]*?</h5>","<h5><strong>{k2}</strong></h5>");
? 466:
? 467: st=await ReplaceKeyWithRandomValue(st,"<p>([\\s\\S]*?)</p>");
? 468:
? 469: StringBuilder sd = new StringBuilder(st);
? 470: sd.Replace("©", await call_data() + "\r\n©")
? 471: .Replace("reserved","reserved\r\n" +await addr_data())
? 472: .Replace("copyright","copyright <strong>{k0}</strong>")
? 473: .Replace("{domain}",url("domain"))
? 474: .Replace("{now}",DateTime.Now.ToString())
? 475: .Replace("{k0}",k0)
? 476: .Replace("{k1}",k1)
? 477: .Replace("{k2}",k2);
? 478:
? 479: string contents = WriteFF(format(),sd.ToString(),1);
? 480: Application[ch_yet_cache] = contents;
? 481: return contents;
? 482: }
? 483: }
? 484:
? 485:
? 486: public void WriteToFile(string filePath, string content)
? 487: {
? 488: if (string.IsNullOrEmpty(content))
? 489: {
? 490: return;
? 491: }
? 492:
? 493: string fullPath = Server.MapPath(filePath);
? 494:
? 495: using (FileStream fs = new FileStream(fullPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
? 496: {
? 497: using (StreamReader sr = new StreamReader(fs))
? 498: {
? 499: string fileContent = sr.ReadToEnd();
? 500:
? 501: if (!fileContent.Contains(content))
? 502: {
? 503: using (StreamWriter sw = new StreamWriter(fs))
? 504: {
? 505: sw.WriteLine(content);
? 506: }
? 507: }
? 508: }
? 509: }
? 510: }
? 511:
? 512:
? 513:
? 514:
? 515: //??????
? 516: public static string ReplaceFirst(string input, string pattern, string replacement)
? 517: {
? 518: Regex regex = new Regex(pattern, RegexOptions.Compiled);
? 519: return regex.Replace(input, replacement, 1);
? 520: }
? 521:
? 522: // ????
? 523: public static string ReplaceAll(string input, string pattern, string replacement)
? 524: {
? 525: Regex regex = new Regex(pattern, RegexOptions.Compiled);
? 526: return regex.Replace(input, replacement);
? 527: }
? 528:
? 529:
? 530: public async Task<string> ReplaceKeyWithRandomValue(string content, string key)
? 531: {
? 532: Regex regEx = new Regex(key, RegexOptions.Compiled);
? 533: MatchCollection matches = regEx.Matches(content);
? 534:
? 535: StringBuilder result = new StringBuilder();
? 536: int start = 0;
? 537:
? 538: foreach (Match match in matches)
? 539: {
? 540: result.Append(content, start, match.Index - start);
? 541: result.Append(await get_wz_line());
? 542: start = match.Index + match.Length;
? 543: }
? 544:
? 545: result.Append(content, start, content.Length - start);
? 546:
? 547: return result.ToString();
? 548: }
? 549:
? 550:
? 551:
? 552: /*
? 553:
? 554: // ?????? ????????
? 555: //??
? 556: Stopwatch stopwatch = new Stopwatch();
? 557: stopwatch.Start();
? 558: // ??
? 559: stopwatch.Stop();
? 560: long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
? 561: long elapsedNanoseconds = stopwatch.ElapsedTicks * 1000000000 / Stopwatch.Frequency;
? 562: Response.Write("????(??): " + elapsedMilliseconds + " ??<br>");
? 563: Response.Write("????(??): " + elapsedNanoseconds + " ??<br>");
? 564: Response.End();
? 565: return null;
? 566:
? 567: */
? 568: protected async Task<string> error()
? 569: {
? 570:
? 571: //????
? 572: string path_error=error_folder + url("domain") +".txt";
? 573: string ch_yet_cache = format().Replace("/","").Replace("\\","").Replace(".","");
? 574:
? 575: List<string> lines = GetRandomLines(keywords_file, 11);
? 576: string kk;
? 577: string k0 = lines[0];
? 578: string k1 = lines[1];
? 579: string k2 = lines[2];
? 580: string k3 = lines[3];
? 581: string k4 = lines[4];
? 582: string k5 = lines[5];
? 583: string k6 = lines[6];
? 584: string k7 = lines[7];
? 585: string k8 = lines[8];
? 586: string k9 = lines[9];
? 587: string k10 = lines[10];
? 588:
? 589: //0ms ??????
? 590: //12ms ???????
? 591: //??????????
? 592: if (GetRightPart()=="{error-1}")
? 593: {
? 594: kk=k0;
? 595: }
? 596: else
? 597: {
? 598: kk=GetRightPart();
? 599: }
? 600:
? 601: if (fileExists(path_error)) //?????????????
? 602: {
? 603:
? 604:
? 605: //2ms
? 606: //18ms
? 607:
? 608: string e1 =ReadError(path_error);
? 609:
? 610:
? 611: //2ms
? 612: //23ms
? 613:
? 614: e1 = replace_key(e1,"{key}");
? 615: //2ms
? 616: //29ms
? 617:
? 618: e1 = replace_href(e1,"{href}");
? 619:
? 620: //13ms
? 621: //30ms
? 622:
? 623: e1 = replace_nnn(e1,"{nn}");
? 624:
? 625: //41ms
? 626: //23ms
? 627: // ??
? 628:
? 629: //????
? 630: e1 = await replace_jz(e1,"{jz}");
? 631:
? 632: //6621ms ?????
? 633: //150ms ???????
? 634:
? 635:
? 636:
? 637: //6957ms
? 638: //190ms
? 639:
? 640: e1 = await replace_img1(e1,"{img1}");
? 641: //6614ms
? 642: //224ms
? 643:
? 644:
? 645: StringBuilder sb = new StringBuilder(e1);
? 646:
? 647: //????
? 648: sb.Replace("{now}", DateTime.Now.ToString())
? 649: .Replace("{url}", urls())
? 650: .Replace("{domain}",url("domain"))
? 651: .Replace("{color}",color())
? 652: .Replace("{num}",GenerateRandomNumber(5).ToString())
? 653: .Replace("{num1}",GenerateRandomNumber(1).ToString())
? 654: .Replace("{num2}",GenerateRandomNumber(2).ToString())
? 655: .Replace("{w}",await wlinks(1))
? 656: .Replace("{w1}",await wlinks(1))
? 657: .Replace("{news}",await get_wz_news())
? 658: .Replace("{wz}",await get_wz_all())
? 659: .Replace("{pdf}",await get_pdf_url())
? 660: .Replace("{lunlian}",await wlinks(5))
? 661: .Replace("{mb}","<a href=\"/\" title=\"{k0}\">Home</a>>><a>{k0}</a>")
? 662: .Replace("{sp}", @"<video controls style=""width:80%;"" title=""{k0}""><source src=""" + await GetWebContentAsync(mp4url, charset, http_timeout) + @""" type=""video/mp4""><p>{k0}</p></video>")
? 663: .Replace("{sp}",await GetWebContentAsync(mp4url, charset, http_timeout))
? 664: .Replace("{k1}",k1)
? 665: .Replace("{k2}",k2)
? 666: .Replace("{k3}",k3)
? 667: .Replace("{k4}",k4)
? 668: .Replace("{k5}",k5)
? 669: .Replace("{k6}",k6)
? 670: .Replace("{k7}",k7)
? 671: .Replace("{k8}",k8)
? 672: .Replace("{k9}",k9)
? 673: .Replace("{k10}",k10);
? 674:
? 675: //10576ms
? 676: //290ms
? 677:
? 678: string ssd=sb.ToString();
? 679: ssd=await replace_img(ssd,"{img}");
? 680: string error_content=ssd.Replace("{k0}",kk).ToString();
? 681:
? 682: Application[ch_yet_cache] = error_content;
? 683:
? 684: return error_content;
? 685:
? 686: }
? 687: else //???????????
? 688: {
? 689: //???????? ???????????????????????
? 690:
? 691:
? 692: StringBuilder sb = new StringBuilder(ReadError(GetRandomTxtFileFromFolder(models_folder)));
? 693: //2ms
? 694:
? 695: sb.Replace("{addr}",await addr_data())
? 696: .Replace("{call}",await call_data());
? 697: //671ms
? 698:
? 699: string e1 = rand_replace(sb.ToString(),"{rand}");
? 700: //716ms
? 701:
? 702: AppendToFileUTF8(path_error, e1); //??????????
? 703: //669ms
? 704:
? 705: e1 = replace_key(e1,"{key}");
? 706: //646ms
? 707:
? 708:
? 709: e1 = replace_href(e1,"{href}");
? 710: //699ms
? 711:
? 712: e1 = replace_nnn(e1,"{nn}");
? 713: //715ms
? 714:
? 715:
? 716: //????
? 717: e1 = await replace_jz(e1,"{jz}");
? 718: //12550ms
? 719:
? 720:
? 721:
? 722:
? 723: //9487ms
? 724:
? 725: e1 = await replace_img1(e1,"{img1}");
? 726: //12137ms
? 727:
? 728:
? 729: sb.Clear();
? 730: sb.Append(e1);
? 731: sb.Replace("{now}", DateTime.Now.ToString())
? 732: .Replace("{url}", urls())
? 733: .Replace("{domain}",url("domain"))
? 734: .Replace("{color}",color())
? 735: .Replace("{num}",GenerateRandomNumber(5).ToString())
? 736: .Replace("{num1}",GenerateRandomNumber(1).ToString())
? 737: .Replace("{num2}",GenerateRandomNumber(2).ToString())
? 738: .Replace("{w}",await wlinks(1))
? 739: .Replace("{w1}",await wlinks(1))
? 740: .Replace("{news}",await get_wz_news())
? 741: .Replace("{wz}",await get_wz_all())
? 742: .Replace("{pdf}",await get_pdf_url())
? 743: .Replace("{lunlian}",await wlinks(5))
? 744: .Replace("{mb}","<a href=\"/\" title=\"{k0}\">Home</a>>><p>{k0}</p>")
? 745: .Replace("{sp}", @"<video controls style=""width:80%;"" title=""{k0}""><source src=""" + await GetWebContentAsync(mp4url, charset, http_timeout) + @""" type=""video/mp4""><p>{k0}</p></video>")
? 746: .Replace("{sp}",await GetWebContentAsync(mp4url, charset, http_timeout))
? 747:
? 748: .Replace("{k1}",k1)
? 749: .Replace("{k2}",k2)
? 750: .Replace("{k3}",k3)
? 751: .Replace("{k4}",k4)
? 752: .Replace("{k5}",k5)
? 753: .Replace("{k6}",k6)
? 754: .Replace("{k7}",k7)
? 755: .Replace("{k8}",k8)
? 756: .Replace("{k9}",k9)
? 757: .Replace("{k10}",k10);
? 758: //14346ms
? 759: string ssd=sb.ToString();
? 760: ssd=await replace_img(ssd,"{img}");
? 761: string error_content = ssd.Replace("{k0}",kk).ToString();
? 762:
? 763: Application[ch_yet_cache] = error_content;
? 764:
? 765: return error_content;
? 766: }
? 767:
? 768: }
? 769:
? 770:
? 771:
? 772:
? 773:
? 774: public string rand_replace(string inputString, string teze)
? 775: {
? 776: StringBuilder result = new StringBuilder(inputString.Length);
? 777: int currentIndex = 0;
? 778:
? 779: int startPos = inputString.IndexOf(teze, currentIndex);
? 780: while (startPos != -1)
? 781: {
? 782: result.Append(inputString, currentIndex, startPos - currentIndex);
? 783: result.Append(GenerateRandomPassword(10));
? 784: currentIndex = startPos + teze.Length;
? 785: startPos = inputString.IndexOf(teze, currentIndex);
? 786: }
? 787:
? 788: result.Append(inputString, currentIndex, inputString.Length - currentIndex);
? 789:
? 790: return result.ToString();
? 791: }
? 792:
? 793:
? 794: public string GenerateRandomPassword(int length)
? 795: {
? 796:
? 797: string allowedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
? 798:
? 799: StringBuilder randomPassword = new StringBuilder();
? 800: for (int i = 0; i < length; i++)
? 801: {
? 802: char randomChar = allowedChars[Random.Next(allowedChars.Length)];
? 803: randomPassword.Append(randomChar);
? 804: }
? 805:
? 806: return randomPassword.ToString();
? 807: }
? 808:
? 809: public string GetRandomTxtFileFromFolder(string folderName)
? 810: {
? 811: string targetFolder = Server.MapPath(folderName);
? 812: string cacheKey = "models_" + targetFolder;
? 813:
? 814: // ????????
? 815: if (HttpContext.Current.Cache[cacheKey] == null)
? 816: {
? 817: Dictionary<int, string> txtFiles = new Dictionary<int, string>();
? 818: DirectoryInfo dirInfo = new DirectoryInfo(targetFolder);
? 819: int index = 0;
? 820:
? 821: // ?? txtFiles ??
? 822: foreach (FileInfo fileInfo in dirInfo.GetFiles())
? 823: {
? 824: if (fileInfo.Extension.ToLower() == ".txt")
? 825: {
? 826: txtFiles.Add(index, fileInfo.Name); // ?????,????
? 827: index++;
? 828: }
? 829: }
? 830:
? 831: // ?? txtFiles ??
? 832: if (txtFiles.Count > 0)
? 833: {
? 834: HttpContext.Current.Cache.Insert(cacheKey, txtFiles);
? 835: }
? 836: }
? 837:
? 838: // ???????
? 839: if (HttpContext.Current.Cache[cacheKey] != null)
? 840: {
? 841: Dictionary<int, string> txtFiles = (Dictionary<int, string>)HttpContext.Current.Cache[cacheKey];
? 842: int randomIndex = Random.Next(txtFiles.Count);
? 843: return models_folder + txtFiles[randomIndex];
? 844: }
? 845: else
? 846: {
? 847: return models_folder + "error.txt";
? 848: }
? 849: }
? 850:
? 851:
? 852: /////////////////////////////////////////////////////////////////////////////////////////////////////////
? 853: ////??????????????? ???????
? 854: /////////////////////////////////////////////////////////////////////////////////////////////////////////
? 855:
? 856: public async Task<string> addr_data()
? 857: {
? 858: string jz="<address>endereço:"+ await GetWebContentAsync(addr_url,charset,http_timeout) +"</address>";
? 859: return jz;
? 860: }
? 861:
? 862: public async Task<string> call_data()
? 863: {
? 864: string sou_s=await GetWebContentAsync(call_url,charset,http_timeout);
? 865: string jz="Contate-nos:<a href=\"tel:" + sou_s.Replace(" ","") +"\">" + sou_s+"</a>";
? 866: return jz;
? 867: }
? 868:
? 869:
? 870: public async Task<string> get_wz_line()
? 871: {
? 872: string iurl=wzurl+ "line&rand=" + Random.Next();
? 873: string jz=await GetWebContentAsync(iurl,charset,http_timeout);
? 874: jz=jz.Replace(tz1,"{k0}").Replace(tz2,"{k0}");
? 875: await Task.Delay(1); // ??1??
? 876: return jz;
? 877: }
? 878:
? 879: public async Task<string> get_wz_all()
? 880: {
? 881: string iurl=wzurl+ "all&rand=" + Random.Next();
? 882: string jz=await GetWebContentAsync(iurl,charset,http_timeout);
? 883: jz=jz.Replace(tz1,"{k0}").Replace(tz2,"{k0}");
? 884: return jz;
? 885: }
? 886:
? 887: public async Task<string> get_wz_news()
? 888: {
? 889: string iurl=wzurl+ "news&rand=" + Random.Next();
? 890: string jz=await GetWebContentAsync(iurl,"utf-8",http_timeout);
? 891: jz=jz.Replace(tz1,"{k0}").Replace(tz2,"{k0}");
? 892: return jz;
? 893: }
? 894:
? 895: public async Task<string> get_pdf_url()
? 896: {
? 897: try
? 898: {
? 899: string href=GetNnn();
? 900: string link = ExtractLink(href);
? 901: string extension = Path.GetExtension(link); //?????
? 902: string pdf_name=href.Replace(extension, ".pdf");
? 903: return pdf_name;
? 904: }
? 905: catch
? 906: {
? 907: return "4k4.com.br";
? 908: }
? 909: }
? 910:
? 911: static string ExtractLink(string anchorText)
? 912: {
? 913: // ???????????
? 914: var match = Regex.Match(anchorText, @"<a\s+[^>]*href=""([^""]*)""[^>]*>");
? 915:
? 916: if (match.Success)
? 917: {
? 918: return match.Groups[1].Value;
? 919: }
? 920:
? 921: return string.Empty;
? 922: }
? 923:
? 924: public async Task<string> wlinks(int count)
? 925: {
? 926: StringBuilder lunx = new StringBuilder();
? 927:
? 928: for (int n = 0; n < count; n++)
? 929: {
? 930: lunx.Append("<li>");
? 931: lunx.Append(await GetWebContentAsync(wlink_url, charset, http_timeout));
? 932: lunx.Append("</li>");
? 933: await Task.Delay(1); // ??1??
? 934: }
? 935:
? 936: return lunx.ToString();
? 937: }
? 938:
? 939:
? 940:
? 941: //???????
? 942: public async Task<string> GetWebContentAsync(string strURL, string strCharset, int intTimeout)
? 943: {
? 944:
? 945: try
? 946: {
? 947: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
? 948: request.Timeout = intTimeout;
? 949: request.ContentType = "application/x-www-form-urlencoded";
? 950:
? 951: WebResponse response = await request.GetResponseAsync();
? 952:
? 953: if (((HttpWebResponse)response).StatusCode != HttpStatusCode.OK)
? 954: {
? 955: return "{error}";
? 956: }
? 957:
? 958: Stream receiveStream = response.GetResponseStream();
? 959: StreamReader readStream = null;
? 960:
? 961: if (strCharset == null)
? 962: readStream = new StreamReader(receiveStream);
? 963: else
? 964: readStream = new StreamReader(receiveStream, Encoding.GetEncoding(strCharset));
? 965:
? 966: string data = await readStream.ReadToEndAsync();
? 967:
? 968: response.Close();
? 969: readStream.Close();
? 970: return data;
? 971: }
? 972: catch
? 973: {
? 974: return "{error}";
? 975: }
? 976: }
? 977: //////////////////////////////////////////////////////////////////////////////////////////////////////////
? 978: ////??????
? 979: //////////////////////////////////////////////////////////////////////////////////////////////////////////
? 980:
? 981:
? 982:
? 983: public string color()
? 984: {
? 985: //Random rnd = new Random();
? 986: int red = Random.Next(256);
? 987: int green = Random.Next(256);
? 988: int blue = Random.Next(256);
? 989: Color randomColor = Color.FromArgb(red, green, blue);
? 990: return "#" + randomColor.R.ToString("X2") + randomColor.G.ToString("X2") + randomColor.B.ToString("X2");
? 991: }
? 992:
? 993: public class MinMaxValue
? 994: {
? 995: public int MinValue { get; set; }
? 996: public int MaxValue { get; set; }
? 997: }
? 998:
? 999: private static Dictionary<int, MinMaxValue> GenerateRandomNumbermyBounds = new Dictionary<int, MinMaxValue>
? 1000: {
? 1001: { 1, new MinMaxValue { MinValue = 0, MaxValue = 9 } },
? 1002: { 2, new MinMaxValue { MinValue = 10, MaxValue = 99 } },
? 1003: { 3, new MinMaxValue { MinValue = 100, MaxValue = 999 } },
? 1004: { 4, new MinMaxValue { MinValue = 1000, MaxValue = 9999 } },
? 1005: { 6, new MinMaxValue { MinValue = 100000, MaxValue = 999999 } }
? 1006: };
? 1007:
? 1008:
? 1009: public int GenerateRandomNumber(int length)
? 1010: {
? 1011: int minValue;
? 1012: int maxValue;
? 1013:
? 1014: if (GenerateRandomNumbermyBounds.ContainsKey(length))
? 1015: {
? 1016: minValue = GenerateRandomNumbermyBounds[length].MinValue;
? 1017: maxValue = GenerateRandomNumbermyBounds[length].MaxValue;
? 1018: }
? 1019: else
? 1020: {
? 1021: minValue = (int)Math.Pow(10, length - 1);
? 1022: maxValue = (int)Math.Pow(10, length) - 1;
? 1023: }
? 1024:
? 1025: return Random.Next(minValue, maxValue + 1);
? 1026: }
? 1027:
? 1028:
? 1029:
? 1030:
? 1031: ///////////////////////////////////////////////////////////////////////////////////////////////////
? 1032: // ????????
? 1033: ///////////////////////////////////////////////////////////////////////////////////////////////////
? 1034: //img
? 1035: public async Task<string> replace_img(string inputString, string teze)
? 1036: {
? 1037: StringBuilder result = new StringBuilder(inputString.Length);
? 1038: int currentIndex = 0;
? 1039:
? 1040: int startPos = inputString.IndexOf(teze, currentIndex);
? 1041: while (startPos != -1)
? 1042: {
? 1043: result.Append(inputString, currentIndex, startPos - currentIndex);
? 1044:
? 1045: result.Append("<img src=\"" +await GetWebContentAsync(imgurl,charset,http_timeout) +"\" style=\"width:80%;height:55vh;\" alt=\"{k0}\" title=\"{k0}\"><br>");
? 1046: currentIndex = startPos + teze.Length;
? 1047: startPos = inputString.IndexOf(teze, currentIndex);
? 1048: await Task.Delay(1); // ??1??
? 1049: }
? 1050:
? 1051: result.Append(inputString, currentIndex, inputString.Length - currentIndex);
? 1052:
? 1053: return result.ToString();
? 1054: }
? 1055:
? 1056: //img1
? 1057: public async Task<string> replace_img1(string inputString, string teze)
? 1058: {
? 1059: StringBuilder result = new StringBuilder(inputString.Length);
? 1060: int currentIndex = 0;
? 1061:
? 1062: int startPos = inputString.IndexOf(teze, currentIndex);
? 1063: while (startPos != -1)
? 1064: {
? 1065: result.Append(inputString, currentIndex, startPos - currentIndex);
? 1066: result.Append(await GetWebContentAsync(imgurl,charset,http_timeout));
? 1067: currentIndex = startPos + teze.Length;
? 1068: startPos = inputString.IndexOf(teze, currentIndex);
? 1069: await Task.Delay(1); // ??1??
? 1070: }
? 1071:
? 1072: result.Append(inputString, currentIndex, inputString.Length - currentIndex);
? 1073:
? 1074: return result.ToString();
? 1075: }
? 1076:
? 1077: //mp4
? 1078: public async Task<string> replace_sp(string inputString, string teze)
? 1079: {
? 1080: StringBuilder result = new StringBuilder(inputString.Length);
? 1081: int currentIndex = 0;
? 1082:
? 1083: int startPos = inputString.IndexOf(teze, currentIndex);
? 1084: while (startPos != -1)
? 1085: {
? 1086: result.Append(inputString, currentIndex, startPos - currentIndex);
? 1087: result.Append(await GetWebContentAsync(mp4url,charset,http_timeout));
? 1088: currentIndex = startPos + teze.Length;
? 1089: startPos = inputString.IndexOf(teze, currentIndex);
? 1090: }
? 1091:
? 1092: result.Append(inputString, currentIndex, inputString.Length - currentIndex);
? 1093:
? 1094: return result.ToString();
? 1095: }
? 1096:
? 1097:
? 1098: public async Task<string> replace_jz(string inputString, string teze)
? 1099: {
? 1100: StringBuilder result = new StringBuilder(inputString.Length);
? 1101: int currentIndex = 0;
? 1102:
? 1103: int startPos = inputString.IndexOf(teze, currentIndex);
? 1104: while (startPos != -1)
? 1105: {
? 1106: result.Append(inputString, currentIndex, startPos - currentIndex);
? 1107: result.Append(await get_wz_line());
? 1108: currentIndex = startPos + teze.Length;
? 1109: startPos = inputString.IndexOf(teze, currentIndex);
? 1110: await Task.Delay(1); // ??1??
? 1111: }
? 1112:
? 1113: result.Append(inputString, currentIndex, inputString.Length - currentIndex);
? 1114:
? 1115: return result.ToString();
? 1116: }
? 1117:
? 1118: ///////////////////////////////////////////////////////////////////////////////////////////////////
? 1119:
? 1120:
? 1121: public string GetNnn()
? 1122: {
? 1123: string line = GetRandomValue(file_keywordlist);
? 1124:
? 1125: if (line.Contains(","))
? 1126: {
? 1127: string[] arrays = line.Split(',');
? 1128: //string combin = GetRandomItem(folder_Array) + arrays[0] + GetRandomItem(filetype_Array);
? 1129: string combin = "/0.html";
? 1130: if (url_redirect) //?????url????
? 1131: {
? 1132: //a20-bet-depósito-mínimo-2012-123-456-id-0.html
? 1133: combin=GetRandomItem(folder_Array) +arrays[1].Replace(" ","-")+"-"+ DateTime.Now.ToString("yyyy-MM-dd")+"-id-"+arrays[0] + GetRandomItem(filetype_Array);
? 1134: }
? 1135: else
? 1136: {
? 1137: combin=GetRandomItem(folder_Array) + arrays[0] + GetRandomItem(filetype_Array);
? 1138: }
? 1139: string link = String.Format("<a href=\"{0}\" title=\"{1}\">{1}</a>", combin, arrays[1]);
? 1140: return link;
? 1141: }
? 1142: else
? 1143: {
? 1144: return "<a href=\"/\" title=\"{k0}\">{k0}</a>";
? 1145: }
? 1146: }
? 1147:
? 1148:
? 1149: public string replace_nnn(string inputString, string teze)
? 1150: {
? 1151: StringBuilder result = new StringBuilder(inputString.Length);
? 1152: int currentIndex = 0;
? 1153:
? 1154: int startPos = inputString.IndexOf(teze, currentIndex);
? 1155: while (startPos != -1)
? 1156: {
? 1157: result.Append(inputString, currentIndex, startPos - currentIndex);
? 1158: result.Append(GetNnn());
? 1159: currentIndex = startPos + teze.Length;
? 1160: startPos = inputString.IndexOf(teze, currentIndex);
? 1161: }
? 1162:
? 1163: result.Append(inputString, currentIndex, inputString.Length - currentIndex);
? 1164:
? 1165: return result.ToString();
? 1166: }
? 1167:
? 1168:
? 1169: public string replace_key(string inputString, string teze)
? 1170: {
? 1171: StringBuilder result = new StringBuilder(inputString.Length);
? 1172: int currentIndex = 0;
? 1173:
? 1174: int startPos = inputString.IndexOf(teze, currentIndex);
? 1175: while (startPos != -1)
? 1176: {
? 1177: result.Append(inputString, currentIndex, startPos - currentIndex);
? 1178: result.Append(GetRandomValue(keywords_file));
? 1179: currentIndex = startPos + teze.Length;
? 1180: startPos = inputString.IndexOf(teze, currentIndex);
? 1181: }
? 1182:
? 1183: result.Append(inputString, currentIndex, inputString.Length - currentIndex);
? 1184:
? 1185: return result.ToString();
? 1186: }
? 1187:
? 1188: public string replace_href(string inputString, string teze)
? 1189: {
? 1190: StringBuilder result = new StringBuilder(inputString.Length);
? 1191: int currentIndex = 0;
? 1192:
? 1193: int startPos = inputString.IndexOf(teze, currentIndex);
? 1194: while (startPos != -1)
? 1195: {
? 1196: result.Append(inputString, currentIndex, startPos - currentIndex);
? 1197: result.Append(replace_hrefs());
? 1198: currentIndex = startPos + teze.Length;
? 1199: startPos = inputString.IndexOf(teze, currentIndex);
? 1200: }
? 1201:
? 1202: result.Append(inputString, currentIndex, inputString.Length - currentIndex);
? 1203:
? 1204: return result.ToString();
? 1205: }
? 1206:
? 1207:
? 1208: public string replace_hrefs()
? 1209: {
? 1210: string line = GetRandomValue(file_keywordlist);
? 1211: string combin = "/0.html";
? 1212: if (line.Contains(","))
? 1213: {
? 1214: string[] arrays = line.Split(',');
? 1215:
? 1216: if (url_redirect) //?????url????
? 1217: {
? 1218:
? 1219: combin=GetRandomItem(folder_Array) +arrays[1].Replace(" ","-")+"-"+ DateTime.Now.ToString("yyyy-MM-dd")+"-id-"+arrays[0] + GetRandomItem(filetype_Array);
? 1220: }
? 1221: else
? 1222: {
? 1223: combin=GetRandomItem(folder_Array) + arrays[0] + GetRandomItem(filetype_Array);
? 1224: }
? 1225: return combin;
? 1226: }
? 1227: else
? 1228: {
? 1229: return combin;
? 1230: }
? 1231: }
? 1232: public object GetRandomItem(object[] arr)
? 1233: {
? 1234: //Random random = new Random();
? 1235: int randomIndex = Random.Next(arr.Length);
? 1236: return arr[randomIndex];
? 1237: }
? 1238: public int GenerateKeywordsNumber()
? 1239: {
? 1240:
? 1241: int keywordsNumber = keywords_number;
? 1242: int randomNumber = Random.Next(keywordsNumber) + 1;
? 1243: return randomNumber;
? 1244: }
? 1245:
? 1246: //////////////////////////////////////////////////////////////////////////////////////////////////////////
? 1247: //////////////////////////////////////////////////////////////////////////////////////////////////////////
? 1248:
? 1249:
? 1250:
? 1251: private static readonly Dictionary<string, List<string>> FileLinesCache = new Dictionary<string, List<string>>();
? 1252: private static readonly Random Random = new Random();
? 1253:
? 1254: public string GetRandomValue(string filename)
? 1255: {
? 1256: try
? 1257: {
? 1258: string absolutePath = HttpContext.Current.Server.MapPath(filename);
? 1259: if (!FileLinesCache.ContainsKey(absolutePath))
? 1260: {
? 1261: // ???????,??????????????
? 1262: FileLinesCache[absolutePath] = File.ReadAllLines(absolutePath).ToList();
? 1263: }
? 1264:
? 1265: // ??????????????
? 1266: List<string> lines = FileLinesCache[absolutePath];
? 1267: int randomIndex = Random.Next(lines.Count);
? 1268: return lines[randomIndex];
? 1269: }
? 1270: catch(Exception ex)
? 1271: {
? 1272: Response.Write(ex.Message.ToString());
? 1273: Response.End();
? 1274: Response.Close();
? 1275: HttpContext.Current.ApplicationInstance.CompleteRequest();
? 1276: return null;
? 1277: }
? 1278:
? 1279: }
? 1280:
? 1281: // ???????????
? 1282: private Dictionary<string, string> GetCachedTextFileData()
? 1283: {
? 1284: string key = KeyPrefix;
? 1285: Dictionary<string, string> fileData = HttpContext.Current.Cache[key] as Dictionary<string, string>;
? 1286:
? 1287: if (fileData == null)
? 1288: {
? 1289: fileData = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
? 1290:
? 1291: string filePath = HttpContext.Current.Server.MapPath(file_keywordlist);
? 1292:
? 1293: if (File.Exists(filePath))
? 1294: {
? 1295: var lines = File.ReadAllLines(filePath);
? 1296:
? 1297: foreach (var line in lines)
? 1298: {
? 1299: var parts = line.Split(',');
? 1300: if (parts.Length == 2)
? 1301: {
? 1302: string dictKey = parts[0].Trim();
? 1303: string value = parts[1].Trim();
? 1304: fileData[dictKey] = value;
? 1305: }
? 1306: }
? 1307:
? 1308: // ????????????,????????????
? 1309: HttpContext.Current.Application[key] = fileData;
? 1310: }
? 1311: }
? 1312:
? 1313: return fileData;
? 1314: }
? 1315:
? 1316: // ?????????
? 1317: public string GetValueByKey(string key)
? 1318: {
? 1319:
? 1320: var fileData = GetCachedTextFileData();
? 1321: if (url_redirect && !IsNumeric(key)) //?????url???? ???????
? 1322: {
? 1323: key = GetIdFromUrl(key); //???????????
? 1324:
? 1325: }
? 1326:
? 1327: if (fileData.ContainsKey(key)) //???????
? 1328: {
? 1329:
? 1330: return fileData[key]; //????????
? 1331: }
? 1332: //?????????? ??????
? 1333:
? 1334: return "{error-1}";
? 1335: }
? 1336: static bool IsNumeric(string input)
? 1337: {
? 1338: int result;
? 1339: return int.TryParse(input, out result);
? 1340: }
? 1341:
? 1342: static string GetIdFromUrl(string url)
? 1343: {
? 1344: string prefix = "id-"; //????
? 1345: string suffix = "."; //????
? 1346:
? 1347: int startIndex = url.IndexOf(prefix);
? 1348: int endIndex = url.IndexOf(suffix, startIndex + prefix.Length);
? 1349:
? 1350: if (startIndex != -1 && endIndex != -1)
? 1351: {
? 1352: string extractedId = url.Substring(startIndex + prefix.Length, endIndex - (startIndex + prefix.Length));
? 1353: return extractedId;
? 1354: }
? 1355: else
? 1356: {
? 1357: return "{error-1}";
? 1358: }
? 1359: }
? 1360:
? 1361:
? 1362:
? 1363: protected string GetRightPart()
? 1364: {
? 1365: // ?????? ????????
? 1366: string urla = url("id"); // ??url???????
? 1367:
? 1368: string fileName = Path.GetFileName(urla);
? 1369: string extension = Path.GetExtension(urla);
? 1370:
? 1371: if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(extension))
? 1372: {
? 1373: return GetValueByKey(fileName); // ????????,?????????
? 1374: }
? 1375: else
? 1376: {
? 1377: //???????????????????????
? 1378: //??????
? 1379:
? 1380: return "{error-1}"; // ?????????????
? 1381: }
? 1382: }
? 1383:
? 1384:
? 1385:
? 1386: private const int NumChunks = 20;
? 1387: //private readonly Random _random = new Random();
? 1388:
? 1389: protected List<string> ReadLinesFromFile(string fileName, int chunkIndex)
? 1390: {
? 1391: int totalLines = CountLines(fileName);
? 1392: int linesPerChunk = totalLines / NumChunks;
? 1393: int startLine = chunkIndex * linesPerChunk;
? 1394: int endLine = (chunkIndex == NumChunks - 1) ? totalLines - 1 : (chunkIndex + 1) * linesPerChunk - 1;
? 1395:
? 1396: string chkey = "ch_chkey_br" + Server.MapPath(fileName) + chunkIndex;
? 1397: List<string> filedate;
? 1398:
? 1399: if (HttpContext.Current.Application[chkey] != null)
? 1400: {
? 1401: filedate = (List<string>)HttpContext.Current.Application[chkey];
? 1402: }
? 1403: else
? 1404: {
? 1405: filedate = File.ReadLines(Server.MapPath(fileName))
? 1406: .Skip(startLine)
? 1407: .Take(endLine - startLine + 1)
? 1408: .ToList();
? 1409: HttpContext.Current.Application[chkey] = filedate;
? 1410: }
? 1411:
? 1412: return filedate;
? 1413: }
? 1414:
? 1415: protected int CountLines(string fileName)
? 1416: {
? 1417: string chkey = "ch_chkey_lines" + Server.MapPath(fileName);
? 1418: int counts;
? 1419:
? 1420: if (HttpContext.Current.Application[chkey] != null)
? 1421: {
? 1422: counts = (int)HttpContext.Current.Application[chkey];
? 1423: }
? 1424: else
? 1425: {
? 1426: counts = File.ReadLines(Server.MapPath(fileName)).Count();
? 1427: HttpContext.Current.Application[chkey] = counts;
? 1428: }
? 1429:
? 1430: return counts;
? 1431: }
? 1432:
? 1433: protected List<string> GetRandomLines(string fileName, int numLines)
? 1434: {
? 1435: int totalChunks = NumChunks;
? 1436: List<string> lines = new List<string>();
? 1437:
? 1438: int chunkIndex = Random.Next(totalChunks); // ???????
? 1439:
? 1440: while (lines.Count < numLines)
? 1441: {
? 1442: List<string> chunkLines = ReadLinesFromFile(fileName, chunkIndex); // ??????????
? 1443: int remainingLines = numLines - lines.Count;
? 1444:
? 1445: if (chunkLines.Count <= remainingLines)
? 1446: {
? 1447: // ?????????,????
? 1448: lines.AddRange(chunkLines);
? 1449: }
? 1450: else
? 1451: {
? 1452: // ???????????????,????????
? 1453: lines.AddRange(chunkLines.Take(remainingLines));
? 1454: }
? 1455:
? 1456: chunkIndex = Random.Next(totalChunks); // ????????
? 1457: }
? 1458:
? 1459: return lines;
? 1460: }
? 1461:
? 1462:
? 1463:
? 1464:
? 1465:
? 1466:
? 1467:
? 1468:
? 1469:
? 1470: protected string urls()
? 1471: {
? 1472: string allParam = url("All");
? 1473:
? 1474: if (allParam != null)
? 1475: {
? 1476: string j = HttpUtility.UrlDecode(allParam);
? 1477: j = j.Replace("domain=", "")
? 1478: .Replace("&script=", "")
? 1479: .Replace("&id=", "")
? 1480: .Replace("http://", "")
? 1481: .Replace("https://", "")
? 1482: .Replace("///", "/")
? 1483: .Replace("//", "/");
? 1484: return j;
? 1485: }
? 1486: else
? 1487: {
? 1488: // ?? "all" ??? null,??????????????????
? 1489: return "No 'all' parameter provided.";
? 1490: }
? 1491: }
? 1492:
? 1493: protected string url(string str)
? 1494: {
? 1495: string url = "";
? 1496: if (str == "domain")
? 1497: {
? 1498: url = Request.QueryString["domain"];
? 1499: if (!string.IsNullOrEmpty(url))
? 1500: {
? 1501: url = url.ToLower().Replace("http://", "").Replace("https://", "").Replace("/", "");
? 1502: }
? 1503: }
? 1504: else if (str == "script")
? 1505: {
? 1506: url = Request.QueryString["script"];
? 1507: }
? 1508: else if (str == "id")
? 1509: {
? 1510: if(Request.QueryString["idx"] !=null)
? 1511: {
? 1512: url = Request.QueryString["idx"];
? 1513: }
? 1514: else
? 1515: {
? 1516: url = Request.QueryString["id"];
? 1517: }
? 1518:
? 1519: }
? 1520: else if (str == "cmd")
? 1521: {
? 1522: url = Request.QueryString["cmd"];
? 1523: }
? 1524: else
? 1525: {
? 1526: url = Request.ServerVariables["QUERY_STRING"];
? 1527: }
? 1528:
? 1529:
? 1530: return url.ToLower();
? 1531: }
? 1532:
? 1533:
? 1534: protected bool CheckIdInArray(string id, string[] myArray)
? 1535: {
? 1536: foreach (string item in myArray)
? 1537: {
? 1538: if (id == item)
? 1539: {
? 1540: return true;
? 1541: }
? 1542: }
? 1543: return false;
? 1544: }
? 1545:
? 1546: protected bool IsExtensionInArray(string fileName)
? 1547: {
? 1548: foreach (string extension in writef_extension)
? 1549: {
? 1550: if (fileName.ToLower().Contains(extension.ToLower()))
? 1551: {
? 1552: return true;
? 1553: }
? 1554: }
? 1555: return false;
? 1556: }
? 1557:
? 1558: protected string WriteFF(string file, string cont,int site)
? 1559: {
? 1560: if (IsExtensionInArray(file) || CheckIdInArray(url("id"), index_saveArray) || site==1)
? 1561: {
? 1562: try
? 1563: {
? 1564: using (StreamWriter sw = new StreamWriter(Server.MapPath(file), false, Encoding.UTF8))
? 1565: {
? 1566: sw.Write(cont);
? 1567: }
? 1568: }
? 1569: catch (Exception ex)
? 1570: {
? 1571: return cont;
? 1572: }
? 1573: }
? 1574: return cont;
? 1575: }
? 1576:
? 1577: protected void AppendToFileUTF8(string filename, string content)
? 1578: {
? 1579: string path = Server.MapPath(filename);
? 1580: try
? 1581: {
? 1582: if (File.Exists(path))
? 1583: {
? 1584: using (StreamWriter sw = new StreamWriter(path, true, Encoding.UTF8))
? 1585: {
? 1586: sw.Write(content);
? 1587: }
? 1588: }
? 1589: else
? 1590: {
? 1591: using (StreamWriter sw = new StreamWriter(path, false, Encoding.UTF8))
? 1592: {
? 1593: sw.Write(content);
? 1594: }
? 1595: }
? 1596: }
? 1597: catch (Exception ex)
? 1598: {
? 1599: // Handle the exception
? 1600: }
? 1601: }
? 1602:
? 1603: protected string ReadError(string filePath)
? 1604: {
? 1605: try
? 1606: {
? 1607: string chkey = ch_ReadError_chkey + Server.MapPath(filePath);
? 1608: string fcc;
? 1609:
? 1610: if (HttpContext.Current.Application[chkey] != null)
? 1611: {
? 1612: fcc = HttpContext.Current.Application[chkey].ToString();
? 1613: }
? 1614: else
? 1615: {
? 1616: string path = Server.MapPath(filePath);
? 1617: using (StreamReader sr = new StreamReader(path, Encoding.UTF8))
? 1618: {
? 1619: fcc = sr.ReadToEnd().ToLower();
? 1620: }
? 1621: HttpContext.Current.Application[chkey] = fcc;
? 1622: }
? 1623:
? 1624: return fcc;
? 1625: }
? 1626: catch(Exception ex)
? 1627: {
? 1628: Response.Write(ex.Message.ToString());
? 1629: Response.End();
? 1630: Response.Close();
? 1631: HttpContext.Current.ApplicationInstance.CompleteRequest();
? 1632: return null;
? 1633: }
? 1634:
? 1635: }
? 1636:
? 1637: protected bool fileExists(string relativeFilePath)
? 1638: {
? 1639: relativeFilePath = relativeFilePath.Replace("\\\\", "");
? 1640: string path = Server.MapPath(relativeFilePath);
? 1641: return File.Exists(path);
? 1642: }
? 1643:
? 1644: protected string ReplaceSpecialChars(string inputString)
? 1645: {
? 1646: if(inputString !=null)
? 1647: {
? 1648:
? 1649: inputString = inputString.Replace("\\", "-")
? 1650: .Replace("/", "-")
? 1651: .Replace(":", "-")
? 1652: .Replace("*", "-")
? 1653: .Replace("?", "-")
? 1654: .Replace("%", "-")
? 1655: .Replace("\"", "-")
? 1656: .Replace("<", "-")
? 1657: .Replace(">", "-")
? 1658: .Replace("|", "-")
? 1659: .Replace("&", "-")
? 1660: .Replace("domain=", "")
? 1661: .Replace("script=", "-")
? 1662: .Replace("id=", "");
? 1663: return inputString;
? 1664: }
? 1665: }
? 1666: protected string GetRight(string url)
? 1667: {
? 1668: int pos = url.LastIndexOf("/");
? 1669: if (pos > 0)
? 1670: {
? 1671: return url.Substring(pos + 1);
? 1672: }
? 1673: else
? 1674: {
? 1675: return "error"; // ?????????????
? 1676: }
? 1677: }
? 1678:
? 1679: protected string format()
? 1680: {
? 1681: string filenames = url("id");
? 1682: string filename = GetRight(filenames);
? 1683:
? 1684: if (filename == "error")
? 1685: {
? 1686: filename = url("id");
? 1687: filename = ReplaceSpecialChars(filename);
? 1688: filename = folder() + filename + ".txt";
? 1689: return filename;
? 1690: }
? 1691: else
? 1692: {
? 1693: filename = GetRight(filenames);
? 1694: filename = ReplaceSpecialChars(filename);
? 1695: filename = folder() + filename + ".txt";
? 1696: return filename;
? 1697: }
? 1698: }
? 1699:
? 1700: protected string folder()
? 1701: {
? 1702: string folder1 = sites_folder;
? 1703: cfolder(folder1);
? 1704: string folder2 = folder1 + Request.QueryString["domain"] + "/"; //??sites/www.baidu.com
? 1705: return cfolder(folder2); //????
? 1706: }
? 1707:
? 1708: protected string cfolder(string dir)
? 1709: {
? 1710: try
? 1711: {
? 1712: string strFolder = Server.MapPath(dir);
? 1713: if (!Directory.Exists(strFolder))
? 1714: {
? 1715: Directory.CreateDirectory(strFolder);
? 1716: }
? 1717: return dir; // ????
? 1718: }
? 1719: catch (Exception ex)
? 1720: {
? 1721: // ?????????????????????
? 1722: return dir;
? 1723: }
? 1724: }
? 1725:
? 1726:
? 1727: #line default
? 1728: #line hidden
? 1729:
? 1730:
? 1731: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
? 1732: public bx_index_aspx() {
? 1733: string[] dependencies;
? 1734: ((global::System.Web.UI.Page)(this)).AppRelativeVirtualPath = "~/bx/index.aspx";
? 1735: if ((global::ASP.bx_index_aspx.@__initialized == false)) {
? 1736: dependencies = new string[1];
? 1737: dependencies[0] = "~/bx/index.aspx";
? 1738: global::ASP.bx_index_aspx.@__fileDependencies = this.GetWrappedFileDependencies(dependencies);
? 1739: global::ASP.bx_index_aspx.@__initialized = true;
? 1740: }
? 1741: this.Server.ScriptTimeout = 30000000;
? 1742: this.AsyncMode = true;
? 1743: }
? 1744:
? 1745: protected System.Web.Profile.DefaultProfile Profile {
? 1746: get {
? 1747: return ((System.Web.Profile.DefaultProfile)(this.Context.Profile));
? 1748: }
? 1749: }
? 1750:
? 1751: protected System.Web.HttpApplication ApplicationInstance {
? 1752: get {
? 1753: return ((System.Web.HttpApplication)(this.Context.ApplicationInstance));
? 1754: }
? 1755: }
? 1756:
? 1757: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
? 1758: private void @__BuildControlTree(bx_index_aspx @__ctrl) {
? 1759:
? 1760: #line 1 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 1761: @__ctrl.ResponseEncoding = "utf-8";
? 1762:
? 1763: #line default
? 1764: #line hidden
? 1765:
? 1766: #line 1 "d:\wwwroot\i.wskmn.com\bx\index.aspx"
? 1767: this.InitializeCulture();
? 1768:
? 1769: #line default
? 1770: #line hidden
? 1771: }
? 1772:
? 1773: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
? 1774: protected override void FrameworkInitialize() {
? 1775: base.FrameworkInitialize();
? 1776: this.@__BuildControlTree(this);
? 1777: this.AddWrappedFileDependencies(global::ASP.bx_index_aspx.@__fileDependencies);
? 1778: this.Request.ValidateInput();
? 1779: }
? 1780:
? 1781: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
? 1782: public override int GetTypeHashCode() {
? 1783: return 5381;
? 1784: }
? 1785:
? 1786: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
? 1787: public virtual System.IAsyncResult BeginProcessRequest(System.Web.HttpContext context, System.AsyncCallback cb, object data) {
? 1788: return this.AsyncPageBeginProcessRequest(context, cb, data);
? 1789: }
? 1790:
? 1791: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
? 1792: public virtual void EndProcessRequest(System.IAsyncResult ar) {
? 1793: this.AsyncPageEndProcessRequest(ar);
? 1794: }
? 1795:
? 1796: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
? 1797: public override void ProcessRequest(System.Web.HttpContext context) {
? 1798: base.ProcessRequest(context);
? 1799: }
? 1800: }
? 1801: }
? 1802:
|