<?
if(isset($_GET['submit'])) {
 if(
is_numeric($_POST['maxcalls'])) {
  
$numberofcalls $_POST['maxcalls'];
 } else {
  
$numberofcalls "1";
 } 
$i 1;
$time date('YmdHis');
while (
$i <= $numberofcalls) {
 
$myFile "/var/spool/asterisk/outgoing/".$time."-".$i.".call";
 
$fh fopen($myFile'w') or die("can't open file");
 
$stringData "Channel:  SIP/".$_POST['phonenumber']."@voipbuster\nMaxRetries: 1\nRetryTime: 30\nWaitTime: 30\nContext: wargames\nExtension: s\nPriority: 1\n";

 
fwrite($fh$stringData);
  
fclose($fh);
   if(
$fh) { echo"Placed call number ".$i.".<br />"; }
   else    { echo
"BOOH!"; }
  
$i++;
  
sleep(10);
  }
} else {
?>
<html>
 <head>
  <title>Asterisk Wargames Script</title>
 </head>
 <body>
  <form method="post" name="wargames" action="?submit">
   <table>
    <tr>
     <td>Number:</td>
     <td><input name="phonenumber" id="phonenumber" /></td>
    </tr>
     <th colspan="2">Example: 17025551212</th>
    <tr>
     <td>Max Calls:</td>
     <td>
      <input name="maxcalls" id="maxcalls" size="2" /></td>
     </td>
    </tr>
    <tr>
     <th colspan="2"><input type="submit" value="Submit" /><input type="reset" value="Reset" /></th>
    </tr>
</table>
  </form>
 </body>
</html>
<?
}
?>