~grubng-dev/grubng/servers-dispatch-php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php

function check_login($username, $password) {
	return check_wikia_login($username, $password);
}

function check_wikia_login($username, $password) {
  $req = "action=login&lgname=". urlencode($username) . "&lgpassword=" . urlencode($password) . "&format=php";
  $fp = fsockopen("www.wikia.com", 80, $errno, $errstr, 30);
  if (!$fp) 
    {
      header("HTTP/1.0 500 Internal Server Error");
      echo "$errstr ($errno)<br />\n";
      exit;
    } 

  $out = "POST /api.php HTTP/1.0\r\n";
  $out .= "Host: www.wikia.com\r\n";
  $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
  $out .= "Content-Length: " . strlen($req) . "\r\n";
  $out .= "Connection: Close\r\n\r\n";
  $out .= $req;
  fwrite($fp, $out);

  $content = "";
  $header = true;
  while (!feof($fp)) 
    {
      $line = fgets( $fp, 128 );
      if($line == "\r\n" && $header) 
	{
	  $header = false;
	}
      if(!$header) 
	{
	  $content .= $line;
	}
    } 
  fclose($fp);

  $result = unserialize(substr($content, 2));
  if ($result['login']['result'] != "Success")
    {
	return false;
    }

  return true;
}