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