<?php

//this data source created by Tony Shiffer  11/17/09
//upgraded for 5 sources by MyKroft on 08/13/10
//converted to v3.x by Steve Forster on 2011-09-18
define("MAX_WINUNCIATORS", 5);

class Send_to_Winunciator extends superfecta_base {

    public $description = "This send-only source sends the number and the CNAM to the companion Windows Winunciator program.<br>You may configure up to 5 Winunciator installations at once.<br>This datasource should be one of the last data sources on your list, as it does not provide any data of its own, and can only send what information has been collected before it is run.";
    public $version_requirement = "2.11";
    public $source_param = array();

    function __construct() {
        for ($client = 1; $client <= MAX_WINUNCIATORS; $client++) {
            $this->source_param["URL_address_{$client}"]['desc'] = 'Specify the Enter the IP/machine name/FQDN of the windows machine running Winunciator. (Example: 192.168.0.99)';
            $this->source_param["URL_address_{$client}"]['type'] = 'text';
            $this->source_param["URL_address_{$client}"]['default'] = '';
            $this->source_param["URL_port_{$client}"]['desc'] = 'Specify the PORT to the Winunciator installation. (Example: 8080)';
            $this->source_param["URL_port_{$client}"]['type'] = 'text';
            $this->source_param["URL_port_{$client}"]['default'] = '8080';
        }
    }

    function post_processing($cache_found, $winning_source, $first_caller_id, $run_param, $thenumber) {
        for ($client = 1; $client <= MAX_WINUNCIATORS; $client++) {
            if ($run_param["URL_address_{$client}"] && $run_param["URL_port_{$client}"] != '') {
                $value = $this->get_url_contents($run_param["URL_address_{$client}"] . ':' . $run_param["URL_port_{$client}"] . '/' . $first_caller_id . '|' . $thenumber);
                $this->DebugPrint("Send to Winunciator-{$client}: " . $run_param["URL_address_{$client}"] . ':' . $run_param["URL_port_{$client}"] . '/' . $first_caller_id . '|' . $thenumber);
            }
        }
    }

}
