PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/test/check.php

http://clover-mana.googlecode.com/
PHP | 147 lines | 109 code | 25 blank | 13 comment | 5 complexity | 423fc36f6bb6a145aa5e321dcfed0666 MD5 | raw file
  1. <?php
  2. ini_set ("max_execution_time","3600");
  3. function curl_login($url,$data,$proxy,$proxystatus){
  4. $fp = fopen("cookie.txt", "w");
  5. fclose($fp);
  6. $login = curl_init();
  7. curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt");
  8. curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt");
  9. curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
  10. curl_setopt($login, CURLOPT_TIMEOUT, 40);
  11. curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
  12. if ($proxystatus == 'on') {
  13. curl_setopt($login, CURLOPT_SSL_VERIFYHOST, FALSE);
  14. curl_setopt($login, CURLOPT_HTTPPROXYTUNNEL, TRUE);
  15. curl_setopt($login, CURLOPT_PROXY, $proxy);
  16. }
  17. curl_setopt($login, CURLOPT_URL, $url);
  18. curl_setopt($login, CURLOPT_HEADER, TRUE);
  19. curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  20. curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
  21. curl_setopt($login, CURLOPT_POST, TRUE);
  22. curl_setopt($login, CURLOPT_POSTFIELDS, $data);
  23. ob_start(); // prevent any output
  24. return curl_exec ($login); // execute the curl command
  25. ob_end_clean(); // stop preventing output
  26. curl_close ($login);
  27. unset($login);
  28. }
  29. function curl_grab_page($site,$proxy,$proxystatus){
  30. $ch = curl_init();
  31. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  32. if ($proxystatus == 'on') {
  33. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  34. curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
  35. curl_setopt($ch, CURLOPT_PROXY, $proxy);
  36. }
  37. curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
  38. curl_setopt($ch, CURLOPT_URL, $site);
  39. ob_start(); // prevent any output
  40. return curl_exec ($ch); // execute the curl command
  41. ob_end_clean(); // stop preventing output
  42. curl_close ($ch);
  43. }
  44. function unique_url($lines){
  45. $tmp = array();
  46. foreach($lines as $line){
  47. /*** get the host name from a url ***/
  48. preg_match('#^(http://|https://)?([^/]+)#i', $line, $matches);
  49. array_push($tmp,trim($matches[0]));
  50. }
  51. sort($tmp);
  52. $tmp = array_unique($tmp);
  53. $tmp = array_values($tmp);
  54. return $tmp;
  55. }
  56. function getUrl($url){
  57. echo $cookieFile = dirname(__FILE__).DIRECTORY_SEPARATOR.'cookie.txt';
  58. $curl = curl_init();
  59. // Set CURL cookie option
  60. curl_setopt($curl, CURLOPT_COOKIEJAR, $cookieFile);
  61. curl_setopt($curl, CURLOPT_COOKIEFILE, $cookieFile);
  62. curl_setopt($curl, CURLOPT_URL, $forumUrl);
  63. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  64. curl_setopt($curl, CURLOPT_HEADER, 0);
  65. return curl_exec($curl);
  66. }
  67. $proxy = '';
  68. $proxystatus = 'off';
  69. $username = "Kai";
  70. $password = "lovecomputer";
  71. $postFields = array(
  72. "vb_login_username={$username}",
  73. "vb_login_password={$password}",
  74. "securitytoken=guest",
  75. "do=login",
  76. "cookieuser=1"
  77. );
  78. $data1 = implode('&', $postFields);
  79. $site = 'http://www.vietmanga.vn';
  80. $login = "http://www.vietmanga.vn/login.php?do=login";
  81. //$site = 'http://www.forum.gamevn.com';
  82. // $login = "http://www.forum.gamevn.com/login.php?do=login";
  83. //curl_login($login,$data1,$proxy,$proxystatus);
  84. $lines = file('a.txt');
  85. $tmp = unique_url($lines);
  86. $vbb = array();
  87. $none_vbb = array();
  88. foreach($tmp as $mytmp){
  89. $html = curl_grab_page($mytmp,'','off');
  90. $pos = strpos($html, "vBulletin");
  91. if($pos > -1){
  92. array_push($vbb,$mytmp);
  93. }
  94. else{
  95. array_push($none_vbb,$mytmp);
  96. }
  97. }
  98. // echo "<pre>";
  99. // // //print_r($lines);
  100. // print_r($tmp);
  101. // echo "</pre>";
  102. $File = "vbb.txt";
  103. $Handle = fopen($File, 'w');
  104. foreach($vbb as $myroom){
  105. $Data = "$myroom\n";
  106. fwrite($Handle, $Data);
  107. }
  108. print "Vbb Written";
  109. fclose($Handle);
  110. $File = "nonvbb.txt";
  111. $Handle = fopen($File, 'w');
  112. foreach($none_vbb as $myroom){
  113. $Data = "$myroom\n";
  114. fwrite($Handle, $Data);
  115. }
  116. print "Non Vbb Written";
  117. fclose($Handle);
  118. //vbulletin_css
  119. // echo "<pre>";
  120. // print_r($lines);
  121. // echo "</pre>";
  122. ?>