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