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