<?php require "pj_select.inc"; global $database; $database = pg_Connect("", "", "", "", "qcm"); # connect to the database if (!$database) { echo "Connection to database failed."; exit; } ?> <form method="POST" action="" > <table border=0i cellpadding=15> <tr><td>Un thème<br> <?php listOptions("refthemes", "GDTC-REF"); ?> </td><td>Un niveau de pertinence<br> <?php listOptionsLabel("pertinences", "9"); ?> </td></tr> <tr><td>Un nombre maximal de questions<br> <input name="NBRMAX" size=8 type=int value=20> </td><td>Un niveau de difficulté<br> <?php listOptionsLabel("difficultes", "9"); ?> </td></tr> </table> <hr>
# connect to the database if (!$database) { echo "Connection to database failed."; exit; } ?> <hr> <?php $reftable = "refthemes"; $defo = "GDTC-REF"; listOptions($reftable, $defo); ?> <hr> <?php listOptionsLabel("pertinences", "9"); ?> <hr> <?php listOptions("refthemes", "GDTP"); ?> </form> <hr> <div><FONT COLOR="#FF6003" SIZE=-1> <?php echo "Powered by PHP version " . PHP_VERSION; ?> </FONT></div> </FONT> </body> </html>
// turn the contacts into a comma seperated list of options for each contact (simple grammar) function listOptions($theContacts) { $s = ''; foreach ($theContacts as $index => $contact) { if ($s != '') { $s .= ", "; } $s .= $index . " (" . $contact['nameChoices'] . ")"; } return $s; } // ----------- // start // ----------- // define the list of contacts $contacts = array("nicole" => array("nameChoices" => "Nicole, Nicole Williams", "number" => "12067927251"), "april" => array("nameChoices" => "April, April Smith", "number" => "14129272367"), "gina" => array("nameChoices" => "Gina, Gina Anderson", "number" => "17135744782")); // answer the phone and play the initial greeting answer(30); say("hello, and thank you for calling."); // prompt the user for the name of the person they desire $event = ask("Who would you like to call? Just say " . listNames($contacts), array("repeat" => "3", "timeout" => "7", "choices" => listOptions($contacts), "onTimeout" => create_function('$event', 'say( "I\'m sorry, I didn\'t hear anything." );'), "onBadChoice" => create_function('$event', 'say( "I\'m sorry, I didn\'t understand what you said." );'))); // if they made a choice, transfer to that person if ($event->name == 'choice') { say("ok, you said " . $event->value . ". Please hold while I transfer you."); $ne = transfer("tel:+" . $contacts[$event->value]['number'], array("answerOnMedia" => false, "callerID" => "14074181800", "timeout" => 60.3456, "playrepeat" => 3, "playvalue" => "Ring... Ring... Ring...", "choices" => "1,2,3,4,5,6,7,8,9,0,*,#", "onSuccess" => create_function('$event', '_log("*********transfered to: " . $event->value->calledId);'), "onError" => create_function('$event', '_log("*********transfer error");'), "onTimeout" => create_function('$event', '_log("*********transfer timeout");'), "onCallFailure" => create_function('$event', '_log("*********transfer failed");'), "onChoice" => create_function('$event', '_log("*********transfer canceled");'))); _log("transfer event.name = " . $ne->name); _log("transfer event.value = " . $ne->value); say("Goodbye"); } hangup();