<?php

	$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
        socket_connect($sock, "mug.phpimp.com", 80);

        $request        = "GET /event.php HTTP/1.1\n"
                        . "Host: mug.phpimp.com\n"
                        . "User-Agent: Scrapezilla/0.1 (PHP:RND)\n"
                        . "Cookie: mug=a%3A3%3A%7Bs%3A2%3A%22id%22%3Bs%3A2%3A%2258%22%3Bs%3A8%3A%22password%22%3Bs%3A32%3A%229dae697ff4af35ccc89f78e77487126d%22%3Bs%3A6%3A%22cookie%22%3Bb%3A0%3B%7D; sid=550faf91.018069d61.4061597f.39d28cd1\n\n";

        socket_write($sock, $request);

        $data = socket_read($sock, 16000, PHP_BINARY_READ);

	$data = strip_tags($data, "<TD>");
	$data = preg_replace("/<[^>]*>/", "|", $data);
	$matches = explode("|", $data);

	$title = trim($matches[14]);
	$location = trim($matches[18]);
	$planner = trim($matches[22]);
	$contact = trim($matches[26]);
	$start = trim($matches[30]);
	$end = trim($matches[34]);
	$info = trim($matches[42]);

#####################################################################
#####################################################################
	header("Content-type: text/vxml");

	print("<?xml version=\"1.0\"?>");

?>

<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN" "http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
  <help>There truely is no hope for you.</help>
  <noinput>Um, say something. <reprompt /></noinput>
  <nomatch>Right, that's not an option.  Try again <reprompt /></nomatch>

  <menu id="main_menu" scope="document" accept="approximate">
    <prompt>
	mug event information interface.  what would you like to
	know about the current event? your choices are <enumerate />
    </prompt>
    <choice next="#titleform">title</choice>
    <choice next="#locationform">location</choice>    
    <choice next="#plannerform">planner</choice>    
    <choice next="#contactform">contact</choice>    
    <choice next="#timesform">start and end times</choice>    
    <choice next="#infoform">detailed info</choice>    
  </menu>

  <form id="titleform"><block>this event is called: <?=$title?><goto next="#main_menu" /></block></form>
  <form id="locationform"><block>this event will be held at: <?=$location?>.<goto next="#main_menu" /></block></form>
  <form id="plannerform"><block>this event was planned by: <?=$planner?>.<goto next="#main_menu" /></block></form>
  <form id="contactform"><block>you can contact the planner at: <?=$contact?>.<goto next="#main_menu" /></block></form>
  <form id="timesform"><block>this event runs from: <?=$start?>, to: <?=$end?>.<goto next="#main_menu" /></block></form>
  <form id="infoform"><block>this events details are the following: <?=$info?>.<goto next="#main_menu" /></block></form>

</vxml>

