PHP File Visit Counter

File Visit Counter

<?
$file = "go.txt";
if (isset($_GET['go']) && $_GET['go'] != "") {
  $link = $_GET['go'];
  $b = file($file);
  $open = fopen($file, 'w');
  foreach($b as $e) {
    $ch = explode("|",$e);
    if ($ch[0] == urlencode($link)) { $r = "true"; $calc = $ch[1]+1; fwrite($open,"$ch[0]|$calc\n"); }
    else { fwrite($open,"$ch[0]|$ch[1]"); }
  }
  if ($r != "true") fwrite($open,urlencode($link)."|1\n");
  fclose($open);
  header("Location: $link");
}
if (isset($_GET['view'])) {
  if (is_file($file)) {
    $data = file($file);
    echo "<TABLE cellSpacing=\"1\" cellPadding=\"0\" width=\"300\"><TR><TD>URL</TD><TD>COUNT</TD></TR>";
    foreach($data as $show) {
      $ex = explode("|",$show);
      echo "<TR><TD>".urldecode($ex[0])."</TD><TD>$ex[1]</TD></TR>";
    }
    echo "</TABLE>";
  }
}
?>