summaryrefslogtreecommitdiff
path: root/html/includes/clanbase.php
blob: 5ad7640c98ca45e23dbb335e0ab848cd3a4d6f6d (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/*
  This function is to get the players from a clan.
  It will return an array with all the information.
*/

function get_players($cid) {
  //Load the page where all players are listed into a var.

  $url = 'http://www.clanbase.com/claninfo.php?cid='.$cid.'&frame=1';
  $file = implode('', file($url));


  //Use an expression to get the pid + name from each player

  preg_match_all("/personinfo\.php\?pid+=(.*)(<.a>|&nbsp;)/U", $file, $out, PREG_SET_ORDER);


  //for each player split the information and put all info in one array

  for ($x=0;$x<count($out);$x++) {
    $player[$x]=explode('" class="slink">',$out[$x][1]);
  }

  //return the array

  return ($player);

  //All players are listed as:
  //$player[0]
  //$player[1]
  //$player[2]
  //etc.

  //the info for each player is listed as:
  //$player[0][0] = pid;
  //$player[0][1] = name;
}


/*
  This function is to get the clans from a war.
  It will return an array with all the information.
*/

function get_clans($wid) {
  //Load the page where all players are listed into a var.

  $url = 'http://www.clanbase.com/warinfo.php?wid='.$wid.'&frame=1';
  $file = implode('', file($url));

  //Use an expression to get the tags from each clan

  preg_match_all("/pagetitle'>Match (.*)vs (.*)<.div>/U", $file, $out, PREG_SET_ORDER);

  //Add the information to one array

  $clan[0][0]=$out[0][1];
  $clan[1][0]=$out[0][2];

  //Use an expression to get the cid + full name from each clan

  preg_match_all("/claninfo\.php\?cid+=(.*)<.a>/U", $file, $out, PREG_SET_ORDER);

  //Add the information to one array

  $temp = explode('" class="slink">', $out[0][1]);
  $clan[0][1]=$temp[0];
  $clan[0][2]=$temp[1];

  $temp = explode('" class="slink">', $out[1][1]);
  $clan[1][1]=$temp[0];
  $clan[1][2]=$temp[1];

  //return the array

  return ($clan);


  //The clans are listed as:
  //$clan[0]
  //$clan[1]

  //the info for each clan is listed as:
  //$clan[0][0] = tag
  //$clan[0][1] = cid
  //$clan[0][2] = full name

}
?>