<?php
// NS2 SteamID Formatter by Whosat
// Enter each new or old-style SteamID into stdin
// The converter will automatically detect the type
// Enter them one per line
  $hi = fopen('php://stdin', "r");
  $ho = fopen('php://stdout', "w");

  while (fscanf($hi, "%s", $steamid)) {
    $parts = explode(':', $steamid);
    if(count($parts) == 1) {
      // New -> Old
      if($parts[0] % 2 > 0)
        fwrite($ho, 'STEAM_0:1:'.(($parts[0]-1)/2)."\n");
      else
        fwrite($ho, 'STEAM_0:0:'.($parts[0]/2)."\n");
    } else // Old -> New
      fwrite($ho, $parts[2]*2+$parts[1]."\n");
  }

  fclose($ho);
  fclose($hi);
?>