source: subversion/sites/other/tilesAtHome/lib/versions.inc @ 3655

Last change on this file since 3655 was 2569, checked in by ojw, 13 years ago

special-case for x_ version names

File size: 1.3 KB
Line 
1<?php
2
3function checkVersion($VersionString){
4
5  # x_ prefix means an experimental client (ID=11) which is default-accept
6  if(substr($VersionString, 0, 2) == "x_"){
7    return(11);
8  }
9
10  # Look in the list of versions
11  $fp = fopen(versionFilename(), "r");
12  if(!$fp){
13    return(-1);
14  }
15  while(($Line = fgets($fp, 100)) !== false){
16    if(preg_match("/(\d+)\|(\w+)\|(\w+)/", $Line, $Matches)){
17        if($Matches[3] == $VersionString){
18          fclose($fp);
19
20          # Disabled versions
21          if($Matches[2] != "OK"){
22            return(-2);
23          }
24 
25          # Version name found
26          return($Matches[1]);
27        }
28      }
29    }
30
31  fclose($fp);
32
33  # None found
34  return(-1);
35}
36
37function getVersions(){
38  $fp = fopen(versionFilename(), "r");
39  if(!$fp){
40    return(Array());
41  }
42  $Versions = Array();
43  while(($Line = fgets($fp, 100)) !== false){
44    if(preg_match("/(\d+)\|(\w+)\|(\w+)/", $Line, $Matches)){
45      $Versions[$Matches[1]]["name"] = $Matches[3];
46      $Versions[$Matches[1]]["ok"] = ($Matches[2] == "OK" ? 1 : 0);
47    }
48  }
49  fclose($fp);
50  return($Versions);
51}
52
53function versionName($ID){
54  $Versions = getVersions();
55  $Version = $Versions[$ID]["name"];
56  if(!$Version)
57    return("unknown");
58  return($Version);
59}
60
61function versionFilename(){
62  return("/home/ojw/public_html/Data/Versions/versions.txt");
63}
64
65?>
Note: See TracBrowser for help on using the repository browser.