享受一下在aspx页面弹框的装置代码,群聊音讯收发

By admin in 4858.com on 2019年3月26日

发送 poll包

4858.com 1

  14858.com 2using System.Data;
  24858.com 3using System.Data.SqlClient;
  34858.com 4using System.Configuration;
  44858.com 5using System.Web;
  54858.com 6using System.Web.Security;
  64858.com 7using System.Web.UI;
  74858.com 8using System.Web.UI.WebControls;
  84858.com 9using System.Web.UI.WebControls.WebParts;
  94858.com 10using System.Web.UI.HtmlControls;
 104858.com 11using System.Drawing;
 114858.com 12using System.IO;
 124858.com 13using System.Web.Mail;
 134858.com 14using System.Text.RegularExpressions;
 144858.com 15using System.Text;
 154858.com 16
 164858.com 174858.com 18/**//// <summary>
 174858.com 19/// CommonUI 公共艺术
 184858.com 20/// </summary>
 194858.com 21public class CommonUI : System.Web.UI.Page
 204858.com 224858.com 234858.com 24{
 214858.com 25
 224858.com 264858.com 27    只弹出音讯#region 只弹出音讯
 234858.com 284858.com 29    /**//// <summary>
 244858.com 30    /// 只弹出音讯
 254858.com 31    /// </summary>
 264858.com 32    /// <param name=”msg”>弹出的音信</param>
 274858.com 33    public static void Alert(string msg)
 284858.com 344858.com 35    4858.com 36{
 294858.com 37        string s = “<script language=’javascript’ >alert(\”” + msg + “\”);</script>”;
 304858.com 38        HttpContext.Current.Response.Write(s);
 314858.com 39    }
 324858.com 40    #endregion
 334858.com 41
 344858.com 424858.com 43    弹出并重回#region 弹出并赶回
 354858.com 444858.com 45    /**//// <summary>
 364858.com 46    /// 弹出并重返
 374858.com 47    /// </summary>
 384858.com 48    /// <param name=”msg”>弹出的新闻</param>
 394858.com 49    /// <param name=”msg”>重回哪一级的数字:如-1赶回上一页</param>
 404858.com 50    public static void AlertAndGo(string msg, int intGo)
 414858.com 514858.com 52    4858.com 53{
 424858.com 54        string s = “<script language=’javascript’ >alert(\”” + msg + “\”);history.go(” + intGo + “)</script>”;
 434858.com 55        HttpContext.Current.Response.Write(s);
 444858.com 56    }
 454858.com 57    #endregion
 464858.com 58
 474858.com 594858.com 60    只实行页面跳转#region 只实行页面跳转
 484858.com 614858.com 62    /**//// <summary>
 494858.com 63    /// 只进行页面跳转
 504858.com 64    /// </summary>
 514858.com 65    /// <param name=”url”>跳转的对象ULANDL</param>
 524858.com 66    public static void AlertRedirect(string url)
 534858.com 674858.com 68    4858.com 69{
 544858.com 70        string s = “<script language=’javascript’ >window.location='” + url + “‘;</script>”;
 554858.com 71        HttpContext.Current.Response.Write(s);
 564858.com 72    }
 574858.com 73    #endregion
 584858.com 74
 594858.com 754858.com 76    呈现音讯提醒对话框,并开始展览页面跳转#region 展现消息提醒对话框,并进行页面跳转
 604858.com 774858.com 78    /**//// <summary>
 614858.com 79    /// 显示音讯提醒对话框,并展开页面跳转 
 624858.com 80    /// </summary>
 634858.com 81    /// <param name=”msg”>提醒音信</param>
 644858.com 82    /// <param name=”url”>跳转的靶子U安德拉L</param>
 654858.com 83    public static void AlertAndRedirect(string msg, string url)
 664858.com 844858.com 85    4858.com 86{
 674858.com 87        string s = “<script language=’javascript’ >alert(\”” + msg + “\”);window.location='” + url + “‘;</script>”;
 684858.com 88        HttpContext.Current.Response.Write(s);
 694858.com 89    }
 704858.com 90    #endregion
 714858.com 91
 724858.com 924858.com 93    判断是不是日期#region 判断是不是日期
 734858.com 944858.com 95    /**//// <summary>
 744858.com 96    /// 判断是不是日期
 754858.com 97    /// </summary>
 764858.com 98    /// <param name=”strValue”>判断是不是日期</param>
 774858.com 99    /// <returns>bool</returns>
 784858.com 100    public static bool IsDateTime(string strValue)
 794858.com 1014858.com 102    4858.com 103{
 804858.com 104        bool bolReturn;
 814858.com 105        DateTime dteReturn;
 824858.com 106        if (strValue == null)
 834858.com 1074858.com 108        4858.com 109{
 844858.com 110            bolReturn = false;
 854858.com 111        }
 864858.com 112        try
 874858.com 1134858.com 114        4858.com 115{
 884858.com 116            dteReturn = Convert.ToDateTime(strValue);
 894858.com 117            bolReturn = true;
 904858.com 118        }
 914858.com 119        catch
 924858.com 1204858.com 121        4858.com 122{
 934858.com 123            bolReturn = false;
 944858.com 124        }
 954858.com 125        return bolReturn;
 964858.com 126    }
 974858.com 127    #endregion
 984858.com 128
 994858.com 1294858.com 130    将字符串转换到日期#region 将字符串转换到日期
1004858.com 1314858.com 132    /**//// <summary>
1014858.com 133    /// 将字符串转换到日期
1024858.com 134    /// </summary>
1034858.com 1354858.com,    /// <param name=”strValue”>将字符串转换来日期</param>
1044858.com 136    /// <returns>int</returns>
1054858.com 137    public static DateTime GetDateTime(string strValue)
1064858.com 1384858.com 139    4858.com 140{
1074858.com 141        return Convert.ToDateTime(strValue);
1084858.com 142    }
1094858.com 143    #endregion
1104858.com 144
1114858.com 1454858.com 146    汉字字符串转拼音缩写#region 汉字字符串转拼音缩写
1124858.com 1474858.com 148    /**//// <summary>
1134858.com 149    /// 汉字字符串转拼音缩写
1144858.com 150    /// </summary>
1154858.com 151    /// <param name=”str”>要转移的方块字字符串</param>
1164858.com 152    /// <param name=”IsSmallChar”>是或不是用小写字母</param>
1174858.com 153    /// <returns>拼音缩写</returns>
1184858.com 154    public static string GetPYString(string str,bool IsSmallChar)
1194858.com 1554858.com 156    4858.com 157{
1204858.com 158        string tempStr = “”;
1214858.com 159        foreach (char c in str)
1224858.com 1604858.com 161        4858.com 162{
1234858.com 163            if ((int)c >= 33 && (int)c <= 126)
1244858.com 1644858.com 165            4858.com 166{//字母和标志原样保留
1254858.com 167                tempStr += c.ToString();
1264858.com 168            }
1274858.com 169            else
1284858.com 1704858.com 171            4858.com 172{//累加拼音声母
1294858.com 173                tempStr += GetPYChar(c.ToString(), IsSmallChar);
1304858.com 174            }
1314858.com 175        }
1324858.com 176        return tempStr;
1334858.com 177    }
1344858.com 178    #endregion
1354858.com 179
1364858.com 1804858.com 181    将单个汉字转拼音缩写#region 将单个汉字转拼音缩写
1374858.com 1824858.com 183    /**//// <summary>
1384858.com 184    /// 将单个汉字转拼音缩写
1394858.com 185    /// </summary>
1404858.com 186    /// <param name=”c”>要更换的单个汉字</param>
1414858.com 187    /// <param name=”IsSmallChar”>是还是不是用小写字母</param>
1424858.com 188    /// <returns>拼音声母</returns>
1434858.com 189    public static string GetPYChar(string c, bool IsSmallChar)
1444858.com 1904858.com 191    4858.com 192{
1454858.com 193        byte[] array = new byte[2];
1464858.com 194        string strReturn = “*”;
1474858.com 195        array = System.Text.Encoding.Default.GetBytes(c);
1484858.com 196        int i = (short)(array[0] – ‘\0’) * 256 + ((short)(array[1] – ‘\0’));
1494858.com 197
1504858.com 198        if (i < 0xB0A1) strReturn = “*”;
1514858.com 199        if (i < 0xB0C5) strReturn = “A”;
1524858.com 200        if (i < 0xB2C1) strReturn = “B”;
1534858.com 201        if (i < 0xB4EE) strReturn = “C”;
1544858.com 202        if (i < 0xB6EA) strReturn = “D”;
1554858.com 203        if (i < 0xB7A2) strReturn = “E”;
1564858.com 204        if (i < 0xB8C1) strReturn = “F”;
1574858.com 205        if (i < 0xB9FE) strReturn = “G”;
1584858.com 206        if (i < 0xBBF7) strReturn = “H”;
1594858.com 207        if (i < 0xBFA6) strReturn = “J”;
1604858.com 208        if (i < 0xC0AC) strReturn = “K”;
1614858.com 209        if (i < 0xC2E8) strReturn = “L”;
1624858.com 210        if (i < 0xC4C3) strReturn = “M”;
1634858.com 211        if (i < 0xC5B6) strReturn = “N”;
1644858.com 212        if (i < 0xC5BE) strReturn = “O”;
1654858.com 213        if (i < 0xC6DA) strReturn = “P”;
1664858.com 214        if (i < 0xC8BB) strReturn = “Q”;
1674858.com 215        if (i < 0xC8F6) strReturn = “R”;
1684858.com 216        if (i < 0xCBFA) strReturn = “S”;
1694858.com 217        if (i < 0xCDDA) strReturn = “T”;
1704858.com 218        if (i < 0xCEF4) strReturn = “W”;
1714858.com 219        if (i < 0xD1B9) strReturn = “X”;
1724858.com 220        if (i < 0xD4D1) strReturn = “Y”;
1734858.com 221        if (i < 0xD7FA) strReturn = “Z”;
1744858.com 222
1754858.com 223        if (IsSmallChar) strReturn =strReturn.ToLower();//是或不是用小写
1764858.com 224
1774858.com 225        return strReturn;
1784858.com 226    }
1794858.com 227    #endregion
1804858.com 228
1814858.com 2294858.com 230    向地点中进入?或&#region 向地点中参与?或&
1824858.com 2314858.com 232    /**//// <summary>
1834858.com 233    /// 向地方中进入?或&
1844858.com 234    /// </summary>
1854858.com 235    /// <param name=”strValue”>要处理的字符串</param>
1864858.com 236    /// <returns>加了?或&的网址</returns>
1874858.com 237    public static string JoinChar(string strValue)
1884858.com 2384858.com 239    4858.com 240{
1894858.com 241        int intValue1, intValue2, intLen;
1904858.com 242
1914858.com 243        intLen = strValue.Length;
1924858.com 244        intValue1 = strValue.IndexOf(“?”);
1934858.com 245        intValue2 = strValue.LastIndexOf(“&”);
1944858.com 246        if (intValue1 > 0 && intValue1 < intLen – 1)
1954858.com 2474858.com 248        4858.com 249{
1964858.com 250            if ((intValue2 > 0 && intValue2 < intLen – 1) || intValue2 == -1)
1974858.com 2514858.com 252            4858.com 253{
1984858.com 254                return strValue + “&”;
1994858.com 255            }
2004858.com 256            else
2014858.com 2574858.com 258            4858.com 259{
2024858.com 260                return strValue;
2034858.com 261            }
2044858.com 262        }
2054858.com 263        else if (intValue1 == intLen – 1)
2064858.com 2644858.com 265        4858.com 266享受一下在aspx页面弹框的装置代码,群聊音讯收发。{
2074858.com 267            return strValue;
2084858.com 268        }
2094858.com 269        else
2104858.com 2704858.com 271        4858.com 272{
2114858.com 273            return strValue + “?”;
2124858.com 274        }
2134858.com 275
2144858.com 276    }
2154858.com 277    #endregion
2164858.com 278
2174858.com 2794858.com 280    去掉地址中”page=”及其背后字符#region 去掉地址中”page=”及其背后字符
2184858.com 2814858.com 282    /**//// <summary>
2194858.com 283    /// 去掉地址中&page=”及其背后字符
2204858.com 284    /// </summary>
2214858.com 285    /// <param name=”strValue”>要处理的字符串</param>
2224858.com 286    /// <returns>去掉地址中”page=”及其背后字符</returns>
2234858.com 287    public static string GetPageURL(string strValue)
2244858.com 2884858.com 289    4858.com 290{
2254858.com 291        int intValue, intLen;
2264858.com 292
2274858.com 293        intLen = strValue.Length;
2284858.com 294        intValue = strValue.IndexOf(“page=”);
2294858.com 295        if (intValue > 0 && intValue < intLen – 5)
2304858.com 2964858.com 297        4858.com 298{
2314858.com 299            return strValue.Substring(0, intValue);
2324858.com 300        }
2334858.com 301        else
2344858.com 3024858.com 303        4858.com 304{
2354858.com 305            return strValue;
2364858.com 306        }
2374858.com 307
2384858.com 308    }
2394858.com 309    #endregion
2404858.com 310
2414858.com 3114858.com 312    过滤/还原 带有 HTML-JS 的字符串#region 过滤/还原 带有 HTML-JS 的字符串
2424858.com 313    public static string htmlInputText(string inputString)//HTML过滤输入字符串
2434858.com 3144858.com 315    4858.com 316{
2444858.com 317        if ((inputString != null) && (inputString != String.Empty))
2454858.com 3184858.com 319        4858.com 320{
2464858.com 321            inputString = inputString.Trim();
2474858.com 322            inputString = inputString.Replace(“‘”, “"”);
2484858.com 323            inputString = inputString.Replace(“<“, “<“);
2494858.com 324            inputString = inputString.Replace(“>”, “>”);
2504858.com 325            inputString = inputString.Replace(” “, ” “);
2514858.com 326            inputString = inputString.Replace(“\n”, “<br>”);
2524858.com 327            return inputString.ToString();
2534858.com 328        }
2544858.com 329        return “”;
2554858.com 330    }
2564858.com 331
2574858.com 332    public static string htmlOutputText(string inputString)//HTML还原字符串
2584858.com 3334858.com 334    4858.com 335{
2594858.com 336        if ((inputString != null) && (inputString != String.Empty))
2604858.com 3374858.com 338        4858.com 339{
2614858.com 340            inputString = inputString.Trim();
2624858.com 341            inputString = inputString.Replace(“"”, “‘”);
2634858.com 342            inputString = inputString.Replace(“<“, “<“);
2644858.com 343            inputString = inputString.Replace(“>”, “>”);
2654858.com 344            inputString = inputString.Replace(” “, ” “);
2664858.com 345            inputString = inputString.Replace(“<br>”, “\n”);
2674858.com 346            return inputString.ToString();
2684858.com 347        }
2694858.com 348        return “”;
2704858.com 349    }
2714858.com 350
2724858.com 351    public static string htmlInputTextfck(string inputString)//HTML还原字符串
2734858.com 3524858.com 353    4858.com 354{
2744858.com 355        if ((inputString != null) && (inputString != String.Empty))
2754858.com 3564858.com 357        4858.com 358{
2764858.com 359            inputString = inputString.Trim();
2774858.com 360            inputString = inputString.Replace(“‘”, ” “);
2784858.com 361            inputString = inputString.Replace(” “, ”    “);
2794858.com 362            return inputString.ToString();
2804858.com 363        }
2814858.com 364        return “”;
2824858.com 365    }
2834858.com 366
2844858.com 367    public static string htmlInputface(string inputString)//HTML过滤输入字符串
2854858.com 3684858.com 369    4858.com 370{
2864858.com 371        if ((inputString != null) && (inputString != String.Empty))
2874858.com 3724858.com 373        4858.com 374{
2884858.com 375            inputString = inputString.Trim();
2894858.com 376            inputString = inputString.Replace(“‘”, “"”);
2904858.com 377            inputString = inputString.Replace(“<“, “<“);
2914858.com 378            inputString = inputString.Replace(“>”, “>”);
2924858.com 379            inputString = inputString.Replace(” “, ” “);
2934858.com 380            inputString = inputString.Replace(“\n”, “<br>”);
2944858.com 381            inputString = inputString.Replace(“{image01}”, “<IMG src=face/01.gif>”);
2954858.com 382            inputString = inputString.Replace(“{image02}”, “<IMG src=face/02.gif>”);
2964858.com 383            inputString = inputString.Replace(“{image03}”, “<IMG src=face/03.gif>”);
2974858.com 384            inputString = inputString.Replace(“{image04}”, “<IMG src=face/04.gif>”);
2984858.com 385            inputString = inputString.Replace(“{image05}”, “<IMG src=face/05.gif>”);
2994858.com 386            inputString = inputString.Replace(“{image06}”, “<IMG src=face/06.gif>”);
3004858.com 387            inputString = inputString.Replace(“{image07}”, “<IMG src=face/07.gif>”);
3014858.com 388            inputString = inputString.Replace(“{image08}”, “<IMG src=face/08.gif>”);
3024858.com 389            inputString = inputString.Replace(“{image09}”, “<IMG src=face/09.gif>”);
3034858.com 390            inputString = inputString.Replace(“{image10}”, “<IMG src=face/10.gif>”);
3044858.com 391            inputString = inputString.Replace(“{image11}”, “<IMG src=face/11.gif>”);
3054858.com 392            return inputString.ToString();
3064858.com 393        }
3074858.com 394        return “”;
3084858.com 395    }
3094858.com 396
3104858.com 397    #endregion
3114858.com 398
3124858.com 3994858.com 400    去除HTML标记#region 去除HTML标记 
3134858.com 4014858.com 402    /**//// <summary>
3144858.com 403    /// 去除HTML标记 
3154858.com 404    /// 可能用简短的,直接除去<>里面包车型客车剧情 
3164858.com 405    /// = System.Text.RegularExpressions.Regex.Replace(strHtml, “<[^>]+>”, “”); 
3174858.com 406    /// </summary>
3184858.com 407    /// <param name=”NoHTML”>包括HTML的源码 </param>
3194858.com 408    /// <returns>已经去除后的文字</returns>
3204858.com 409    public static string NoHTML(string Htmlstring)
3214858.com 4104858.com 411    4858.com 412{
3224858.com 413        //删除脚本
3234858.com 414        Htmlstring = Regex.Replace(Htmlstring, @”<script[^>]*?>.*?</script>”, “”, RegexOptions.IgnoreCase);
3244858.com 415
3254858.com 416        //删除HTML
3264858.com 417        Htmlstring = Regex.Replace(Htmlstring, @”<(.[^>]*)>”, “”, RegexOptions.IgnoreCase);
3274858.com 418        Htmlstring = Regex.Replace(Htmlstring, @”([\r\n])[\s]+”, “”, RegexOptions.IgnoreCase);
3284858.com 419        Htmlstring = Regex.Replace(Htmlstring, @”–>”, “”, RegexOptions.IgnoreCase);
3294858.com 420        Htmlstring = Regex.Replace(Htmlstring, @”<!–.*”, “”, RegexOptions.IgnoreCase);
3304858.com 421
3314858.com 422        Htmlstring = Regex.Replace(Htmlstring, @”&(quot|#34);”, “\””, RegexOptions.IgnoreCase);
3324858.com 423        Htmlstring = Regex.Replace(Htmlstring, @”&(amp|#38);”, “&”, RegexOptions.IgnoreCase);
3334858.com 424        Htmlstring = Regex.Replace(Htmlstring, @”&(lt|#60);”, “<“, RegexOptions.IgnoreCase);
3344858.com 425        Htmlstring = Regex.Replace(Htmlstring, @”&(gt|#62);”, “>”, RegexOptions.IgnoreCase);
3354858.com 426        Htmlstring = Regex.Replace(Htmlstring, @”&(nbsp|#160);”, ” “, RegexOptions.IgnoreCase);
3364858.com 427        Htmlstring = Regex.Replace(Htmlstring, @”&(iexcl|#161);”, “\xa1”, RegexOptions.IgnoreCase);
3374858.com 428        Htmlstring = Regex.Replace(Htmlstring, @”&(cent|#162);”, “\xa2”, RegexOptions.IgnoreCase);
3384858.com 429        Htmlstring = Regex.Replace(Htmlstring, @”&(pound|#163);”, “\xa3”, RegexOptions.IgnoreCase);
3394858.com 430        Htmlstring = Regex.Replace(Htmlstring, @”&(copy|#169);”, “\xa9”, RegexOptions.IgnoreCase);
3404858.com 431        Htmlstring = Regex.Replace(Htmlstring, @”(\d+);”, “”, RegexOptions.IgnoreCase);
3414858.com 432        Htmlstring.Replace(“<“, “”);
3424858.com 433        Htmlstring.Replace(“>”, “”);
3434858.com 434        Htmlstring.Replace(“\r\n”, “”);
3444858.com 435        Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();
3454858.com 436
3464858.com 437        return Htmlstring;
3474858.com 438
3484858.com 439    }
3494858.com 440    #endregion
3504858.com 441
3514858.com 4424858.com 443    从左侧取钦命长度的字符串 汉语算 2 个#region 从左侧取钦命长度的字符串 普通话算 2 个
3524858.com 4444858.com 445    /**//// <summary>
3534858.com 446    /// 从左侧取钦点长度的字符串 粤语算 2 个
3544858.com 447    /// </summary>
3554858.com 448    /// <param name=”inputString”>要截取的字符串</param>
3564858.com 449    /// <param name=”len”>要截取的长度</param>
3574858.com 450    /// <param name=”bolPoint”>是不是出示4858.com 451</param>
3584858.com 452    /// <returns>截取后的字符串</returns>
3594858.com 453    public static string CutString(string inputString, int len, bool bolPoint)
3604858.com 4544858.com 455    4858.com 456{
3614858.com 457
3624858.com 458        ASCIIEncoding ascii = new ASCIIEncoding();
3634858.com 459        int tempLen = 0;
3644858.com 460        string tempString = “”;
3654858.com 461        byte[] s = ascii.GetBytes(inputString);
3664858.com 462        for (int i = 0; i < s.Length; i++)
3674858.com 4634858.com 464        4858.com 465{
3684858.com 466            //中文算 2 个
3694858.com 467            if ((int)s[i] == 63)
3704858.com 4684858.com 469            4858.com 470{
3714858.com 471                tempLen += 2;
3724858.com 472            }
3734858.com 473            else
3744858.com 4744858.com 475            4858.com 476{
3754858.com 477                tempLen += 1;
3764858.com 478            }
3774858.com 479
3784858.com 480            try
3794858.com 4814858.com 482            4858.com 483{
3804858.com 484                tempString += inputString.Substring(i, 1);
3814858.com 485            }
3824858.com 486            catch
3834858.com 4874858.com 488            4858.com 489{
3844858.com 490                break;
3854858.com 491            }
3864858.com 492
3874858.com 493            if (tempLen > len)
3884858.com 494                break;
3894858.com 495        }
3904858.com 496
3914858.com 497        //加上半个省略号
3924858.com 498        byte[] mybyte = System.Text.Encoding.Default.GetBytes(inputString);
3934858.com 499        if (bolPoint && mybyte.Length > len)
3944858.com 5004858.com 501        4858.com 502{
3954858.com 503            tempString += “…”;
3964858.com 504        }
3974858.com 505
3984858.com 506        return tempString;
3994858.com 507    }
4004858.com 508    #endregion
4014858.com 509
4024858.com 510}

public static class MessageBox
{
/// <summary>
/// 展现音信提醒对话框
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提醒消息</param>
public static void Show(System.Web.UI.Page page, string msg)
{
page.ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page),
“message”, “<script type=\”text/javascript\”
language=\”javascript\” defer>alert(‘” + StrSafe +
“‘);</script>”);
}

public static void Login_PostPoll()
{
try
{
string url = “”;
string dat =
“{\”ptwebqq\”:\”#{ptwebqq}\”,\”clientid\”:53999199,\”psessionid\”:\”#{psessionid}\”,\”key\”:\”\”}”;
dat = dat.Replace(“#{ptwebqq}”,
Login_ptwebqq).Replace(“#{psessionid}”, Login_Psessionid);
dat = “r=” + HttpUtility.UrlEncode(dat);
HTTP.Post_Async_Action action = Message_Get;
HTTP.Post_Async(url, dat, action);
}
catch (Exception) { Login_PostPoll(); }
}
#endregion
#region 接收到音讯的回调函数
/// <summary>
/// 接收到音信的回调函数
/// </summary>
/// <param name=”data”>接收到的数目(json)</param>
private static bool Running = true;
public static void Message_Get(string data)
{
Task.Run(() => Login_PostPoll());
if (Running)
Task.Run(() =>
Message_Process(data));//那么些是处理收到新闻的其它三个艺术具体处理
在源码
}

 

/// <summary>
/// 展现音讯提醒对话框
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提醒音讯</param>
public static void Show(System.Web.UI.Page page, string key, string
msg)
{
page.ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page), key,
“<script type=\”text/javascript\” language=\”javascript\”
defer>alert(‘” + StrSafe + “‘);</script>”);
}

以上正是poll包的处理以及 收到的新闻处理

public static void Login_GetPHV()
{
string urldata =
“{\”ptwebqq\”:\”#{ptwebqq}\”,\”clientid\”:53999199,\”psessionid\”:\”\”,\”status\”:\”online\”}”.Replace(“#{ptwebqq}”,
Login_ptwebqq);
urldata = “r=” + HttpUtility.UrlEncode(urldata);
string dat = HTTP.Post(“”, urldata,
“”);

/// <summary>
/// 提醒新闻关闭页面,音信可为空不呈现。
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提醒新闻,为空则不提示</param>
public static void Close(System.Web.UI.Page page, string msg)
{
string js = “<script type=\”text/javascript\”
language=\”javascript\” defer>”;
if (msg != “”)
js += “alert(‘” + msg.ToString;”;
js += “window.close();</script>”;
page.ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page),
“message”, js);
}
/// <summary>
/// 提醒音信关闭页面,消息可为空不展现。
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提醒音讯,为空则不提示</param>
public static void Close(System.Web.UI.Page page, string key, string
msg)
{
string js = “<script type=\”text/javascript\”
language=\”javascript\” defer>”;
if (msg != “”)
js += “alert(‘” + msg.ToString;”;
js += “window.close();</script>”;
page.ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page), key,
js);
}

接下去是 发送的 

Login_Psessionid = dat.Replace(“:”, “,”).Replace(“{“, “”).Replace(“}”,
“”).Replace(“\””, “”).Split(‘,’)[10];
Login_QQ = dat.Replace(“:”, “,”).Replace(“{“, “”).Replace(“}”,
“”).Replace(“\””, “”).Split(‘,’)[14];//登录QQ
//Login_Vfwebqq = dat.Replace(“:”, “,”).Replace(“{“, “”).Replace(“}”,
“”).Replace(“\””, “”).Split(‘,’)[18];
Login_Hash = Hash2(Login_QQ, Login_ptwebqq);//
在那几个js 得到不行hash的值
JS里面包车型客车章程名是Hash2 里面是16进制
需求更换到C#的花色。第③个参数是真性QQ第一个ptwebqq
//一起头拿地点的cookie
里面包车型客车Vfwebqq,是可怜的,再请求1次,得到收获好友音讯的vfwebqq
string urlvfwebqq =
“”,
Login_ptwebqq).Replace(“#{t}”, TimeStamp());
string datVfwebqq = HTTP.Get(urlvfwebqq,
“”);
Login_Vfwebqq = datVfwebqq.Split(‘\”‘)[7];
SendOnlog(Login_QQ +”/r/n”+ Login_Vfwebqq + “/r/n” + Login_Psessionid

/// <summary>
/// 屏蔽提示关闭窗口
/// </summary>
/// <param name=”page”></param>
/// <param name=”msg”></param>
public static void DClose(System.Web.UI.Page page, string msg)
{
StringBuilder js = new StringBuilder(“<script
type=\”text/javascript\” language=\”javascript\” defer>”);
if (msg != “”)
js.AppendLine(“alert(‘” + msg.ToString;”);
js.AppendLine(“var ua = navigator.userAgent; var ie =
navigator.appName==\”Microsoft Internet Explorer\”?true:false;”);
js.AppendLine{“);
js.AppendLine(“var IEversion =
parseFloat(ua.substring(ua.indexOf(\”MSIE
\”)+5,ua.indexOf(\”;\”,ua.indexOf(\”MSIE \”))));”);
js.AppendLine(“if( IEversion< 5.5){“);
js.AppendLine(“var str = ”;”);
js.AppendLine(“document.body.insertAdjacentHTML(\”beforeEnd\”,
str);”);
js.AppendLine(“document.all.noTipClose.Click;
js.AppendLine(“} else {“);
js.AppendLine(“window.opener =null; window.close;
js.AppendLine;
js.AppendLine;
js.AppendLine(“window.close;
js.AppendLine(“</script>”);
page.ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page),
“message”, js.ToString;
}

4858.com 511

  • “/r/n” + Login_Hash);
    }

/// <summary>
/// 屏蔽提醒关闭窗口
/// </summary>
/// <param name=”page”></param>
/// <param name=”msg”></param>
public static void DClose(System.Web.UI.Page page, string key, string
msg)
{
StringBuilder js = new StringBuilder(“<script
type=\”text/javascript\” language=\”javascript\” defer>”);
if (msg != “”)
js.AppendLine(“alert(‘” + msg.ToString;”);
js.AppendLine(“var ua = navigator.userAgent; var ie =
navigator.appName==\”Microsoft Internet Explorer\”?true:false;”);
js.AppendLine{“);
js.AppendLine(“var IEversion =
parseFloat(ua.substring(ua.indexOf(\”MSIE
\”)+5,ua.indexOf(\”;\”,ua.indexOf(\”MSIE \”))));”);
js.AppendLine(“if( IEversion< 5.5){“);
js.AppendLine(“var str = ”;”);
js.AppendLine(“document.body.insertAdjacentHTML(\”beforeEnd\”,
str);”);
js.AppendLine(“document.all.noTipClose.Click;
js.AppendLine(“} else {“);
js.AppendLine(“window.opener =null; window.close;
js.AppendLine;
js.AppendLine;
js.AppendLine(“window.close;
js.AppendLine(“</script>”);
page.ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page), key,
js.ToString;
}

 

下边就能够获得 Login_ptwebqq  Login_Psessionid ,Login_Hash 这个hash 
需要

/// <summary>
/// 控件点击新闻确认提示框
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提醒新闻</param>
public static void ShowConfirm(System.Web.UI.WebControls.WebControl
Control, string msg)
{
//Control.Attributes.Add(“onClick”,”if
(!window.confirm(‘”+msg+”‘)){return false;}”);
Control.Attributes.Add(“onclick”, “return confirm(‘” + msg + “‘);”);
}

 上面是发送的连日以及 发送后回到的 poll包新闻。代码如下 

在那一个js 得到分外hash的值
JS里面包车型大巴主意名是Hash2 里面是16进制 必要更换来C# 也得以一向 
调用那些JS。第①个参数是Login_QQ 第二个Login_ptwebqq  

/// <summary>
/// 展现消息提示对话框,并进行页面跳转
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提醒音讯</param>
/// <param name=”url”>跳转的靶子UMuranoL</param>
public static void ShowAndRedirect(System.Web.UI.Page page, string msg,
string url)
{
StringBuilder Builder = new StringBuilder();
Builder.Append(“<script type=\”text/javascript\”
language=\”javascript\” defer>”);
if (msg != “”)
Builder.AppendFormat(“alert;”, msg);
Builder.AppendFormat(“window.location.href='{0}’;”, url);
Builder.Append(“</script>”);
page.ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page),
“message”, Builder.ToString;
}

/// <summary>
///
/// </summary>
/// <param name=”type”>私聊0 群聊1 讨论组2</param>
/// <param name=”uin”>uin</param>
/// <param name=”messageToSend”>消息</param>
/// <param name=”auto”></param>
/// <returns></returns>
public static bool Login_Postsend_buddy_msg(int type, string uin,
string messageToSend)
{
if (messageToSend.Equals(“”) || uin.Equals(“”))
return false;
string[] tmp = messageToSend.Split(“{}”.ToCharArray());
messageToSend = “”;
for (int i = 0; i < tmp.Length; i++)
if (!tmp[i].Trim().StartsWith(“..[face”) ||
!tmp[i].Trim().EndsWith(“]..”))
messageToSend += “\\\”” + tmp[i] + “\\\”,”;
else
messageToSend += tmp[i].Replace(“..[face”,
“[\\\”face\\\”,”).Replace(“]..”, “],”);
messageToSend = messageToSend.Remove(messageToSend.LastIndexOf(‘,’));
messageToSend = messageToSend.Replace(“\r\n”, “\n”).Replace(“\n\r”,
“\n”).Replace(“\r”, “\n”).Replace(“\n”, Environment.NewLine);
try
{
string to_groupuin_did, url;
switch (type)
{
case 0:
to_groupuin_did = “to”;
url = “”;
break;
case 1:
to_groupuin_did = “group_uin”;
url = “”;
break;
case 2:
to_groupuin_did = “did”;
url = “”;
break;
default:
return false;
}
string postData =
“{\”#{type}\”:#{id},\”content\”:\”[#{msg},[\\\”font\\\”,{\\\”name\\\”:\\\”繁体\\\”,\\\”size\\\”:10,\\\”style\\\”:[0,0,0],\\\”color\\\”:\\\”000000\\\”}]]\”,\”face\”:#{face},\”clientid\”:53999199,\”msg_id\”:#{msg_id},\”psessionid\”:\”#{psessionid}\”}”;
postData = “r=” + HttpUtility.UrlEncode(postData.Replace(“#{type}”,
to_groupuin_did).Replace(“#{id}”, uin).Replace(“#{msg}”,
messageToSend).Replace(“#{face}”,
SelfInfo.face.ToString()).Replace(“#{msg_id}”, rand.Next(10000000,
99999999).ToString()).Replace(“#{psessionid}”, Login_Psessionid));

public static string Hash2(string uin, string ptvfwebqq)
{
int[] ptbIndex = new int[4];
long QQ_Long = long.Parse(uin);
for (int i = 0; i < ptvfwebqq.Length; i++)
{
ptbIndex[i % 4] ^= ptvfwebqq.ToCharArray()[i];
}
string[] salt = { “EC”, “OK” };
long[] uinByte = new long[4];
uinByte[0] = QQ_Long >> 24 & 255 ^
salt[0].ToCharArray()[0];
uinByte[1] = QQ_Long >> 16 & 255 ^
salt[0].ToCharArray()[1];
uinByte[2] = QQ_Long >> 8 & 255 ^
salt[1].ToCharArray()[0];
uinByte[3] = QQ_Long & 255 ^ salt[1].ToCharArray()[1];

/// <summary>
/// 输出自定义脚本音讯
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”script”>输出脚本</param>
public static void ResponseScript(System.Web.UI.Page page, string
script)
{
page.ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page),
“message”, “<script type=\”text/javascript\”
language=\”javascript\” defer>” + script + “</script>”);
}
/// <summary>
/// 输出自定义脚本新闻
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”script”>输出脚本</param>
public static void ResponseScript(System.Web.UI.Page page, string key,
string script)
{
page.ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page), key,
“<script type=\”text/javascript\” language=\”javascript\”
defer>” + script + “</script>”);
}

string dat = HTTP.Post(url, postData,
“”);
return dat.Equals(“{\”errCode\”:0,\”msg\”:\”send ok\”}”);
}
catch (Exception)
{
return false;
}
}

long[] result = new long[8];

/// <summary>
/// 页面后退
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”count”>后倒退数</param>
public static void HistoryBack(System.Web.UI.Page page, int count)
{
StringBuilder Builder = new StringBuilder();
Builder.Append(“<script type=\”text/javascript\”
language=\”javascript\” defer>”);
Builder.AppendFormat(“window.history.go”, count);
Builder.Append(“</script>”);
page.ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page),
“historygo”, Builder.ToString;
}

 

for (int i = 0; i < 8; i++)
{
result[i] = i % 2 == 0 ? ptbIndex[i >> 1] : uinByte[i
>> 1];
}

/// <summary>
/// 重返上一页
/// </summary>
/// <returns></returns>
public static void HistoryBack(System.Web.UI.Page page)
{
page.ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page),
“historygo”, “<script type=\”text/javascript\”
language=\”javascript\” defer>\n window.history.go; \n
</script>”);
}

这一讲费了重重小时,中间又去查了素材。尤其是处理回来的 包的json
,不明了怎么格式化,只好替换出来,得到想要的数码。

string[] hex = { “0”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”,
“A”, “B”, “C”, “D”, “E”, “F” };
string buf = “”;

/// <summary>
/// js安全转移
/// </summary>
/// <param name=”str”>源字符</param>
/// <returns>再次回到代码</returns>
public static string StrSafe(string str)
{
StringBuilder rd = new StringBuilder;
rd.Replace(“\b”, “\\b”);
rd.Replace(“\f”, “\\f”);
rd.Replace(“\n”, “\\n”);
rd.Replace(“\r”, “\\r”);
rd.Replace(“\t”, “\\t”);
rd.Replace(“\'”, “\\'”);
rd.Replace(“\””, “\\\””);
return rd.ToString();
}

 

for (int i= 0; i < result.Length; i++)
{
buf += hex[(int)((result[i] >> 4) & 15)];
buf += hex[(int)(result[i] & 15)];
}
return buf;
}

#region Ajax
/// <summary>
/// 展现音讯提示对话框
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提醒音信</param>
public static void AjaxShow(System.Web.UI.Page page, string msg)
{
System.Web.UI.ScriptManager.RegisterStartupScript(page, page.GetType(),
“message”, “alert(‘” + StrSafe + “‘);”, true);
}
/// <summary>
/// 显示新闻提示对话框
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提醒音讯</param>
public static void AjaxShow(System.Web.UI.Page page, string key, string
msg)
{
System.Web.UI.ScriptManager.RegisterStartupScript(page, page.GetType(),
key, “alert(‘” + StrSafe + “‘);”, true);
}
/// <summary>
/// 显示音讯提醒对话框,并拓展页面跳转
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提醒消息</param>
/// <param name=”url”>跳转的目的U帕杰罗L</param>
public static void AjaxShowAndRedirect(System.Web.UI.Page page, string
msg, string url)
{
StringBuilder Builder = new StringBuilder();
if (msg != “”)
Builder.AppendFormat(“alert;”, msg);
Builder.AppendFormat(“window.location.href='{0}’;”, url);
System.Web.UI.ScriptManager.RegisterStartupScript(page, page.GetType(),
“message”, Builder.ToString;
}
/// <summary>
/// 显示音信提示对话框,并展开页面跳转
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提示音讯</param>
/// <param name=”url”>跳转的指标U翼虎L</param>
public static void AjaxShowAndRedirect(System.Web.UI.Page page, string
key, string msg, string url)
{
StringBuilder Builder = new StringBuilder();
if (msg != “”)
Builder.AppendFormat(“alert;”, msg);
Builder.AppendFormat(“window.location.href='{0}’;”, url);
System.Web.UI.ScriptManager.RegisterStartupScript(page, page.GetType(),
key, Builder.ToString;
}
/// <summary>
/// 提示新闻关闭页面,音讯可为空不显得。
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提醒音信,为空则不提醒</param>
public static void AjaxClose(System.Web.UI.Page page, string msg)
{
string js = “”;
if (msg != “”)
js += “alert(‘” + msg.ToString;”;
js += “window.close();”;
System.Web.UI.ScriptManager.RegisterStartupScript(page, page.GetType(),
“message”, js, true);
}
/// <summary>
/// 提醒消息关闭页面,新闻可为空不显得。
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”msg”>提醒音讯,为空则不提示</param>
public static void AjaxClose(System.Web.UI.Page page, string key, string
msg)
{
string js = “”;
if (msg != “”)
js += “alert(‘” + msg.ToString;”;
js += “window.close();”;
System.Web.UI.ScriptManager.RegisterStartupScript(page, page.GetType(),
key, js, true);
}
/// <summary>
/// 输出自定义脚本音讯
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”script”>输出脚本</param>
public static void AjaxResponseScript(System.Web.UI.Page page, string
script)
{
System.Web.UI.ScriptManager.RegisterStartupScript(page, page.GetType(),
“message”, script, true);
}
/// <summary>
/// 输出自定义脚本消息
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”script”>输出脚本</param>
public static void AjaxResponseScript(System.Web.UI.Page page, string
key, string script)
{
System.Web.UI.ScriptManager.RegisterStartupScript(page, page.GetType(),
key, script, true);
}
/// <summary>
/// 页面后退
/// </summary>
/// <param name=”page”>当前页面指针,一般为this</param>
/// <param name=”count”>后倒退数</param>
public static void AjaxHistoryBack(System.Web.UI.Page page, int count)
{
StringBuilder Builder = new StringBuilder();
Builder.AppendFormat(“window.history.go;”, count);
System.Web.UI.ScriptManager.RegisterStartupScript(page, page.GetType(),
“historygo”, Builder.ToString;
}
/// <summary>
/// 再次回到上一页
/// </summary>
/// <returns></returns>
public static void AjaxHistoryBack(System.Web.UI.Page page)
{
System.Web.UI.ScriptManager.RegisterStartupScript(page, page.GetType(),
“historygo”, “window.history.go\”;”, true);
}
#endregion
}

到明天了却,整个新手smart qq http 协议的教程
已经足以说成功了,因为那几个体协会议的效果十分单一,并且很多都早已被TX去掉的,就像获取好友的
真实QQ也早已是报错的。接下来就足以做图形界面,还有一部分工作了(qq机器人自动苏醒等)

 

 

以上正是C# 获取smart qq  的vfwebqq ,psessionid,hash 

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有