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