#!/usr/bin/php
<?php

function explain() {
  echo 
"Parameter should be the name of a wave file in the current directory ";
  echo 
"to\nconvert this wave file to an mp3 file or no parameters at all to ";
  echo 
"convert all\nwave files in the current directory to an mp3 file. ";
  echo 
"Exiting.\n";
  exit(
1);
}
$found = array();
$argv1 $_SERVER["argv"][1];
if (
$argv1 != "") {
  if (
file_exists("./$argv1")) {
    if (
eregi("^.+\.[Ww][Aa][Vv]$"$fn)) {
      
$found[0] = $fn;
    } else {
      
explain();
    }
  } else {
    
explain();
  }
} else {
  
$found glob("*.[Ww][Aa][Vv]");
}
foreach (
$found as $wav) {
  
$mp3 substr($wav0, -3) . "mp3";
  
passthru(
    
"lame --cbr -b 320 -m s -h " escapeshellarg($wav) . " " .
    
escapeshellarg($mp3)
  );
}

?>