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