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