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