Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

viernes, 22 de diciembre de 2023

setting file as asteirsk channel variables

 <?php

// Read the input string from a file

$inputString = file_get_contents('/home/voipessential/info_1.conf');


// Command line parameter

$searchValue = isset($argv[1]) ? $argv[1] : '';


// Explode the input string into an array based on the '-' delimiter

$lines = explode("\n", $inputString);

$dataArray = [];


// Iterate through each line and explode based on the '-' delimiter

foreach ($lines as $line) {

    $values = explode('-', $line);

    $dataArray[] = $values;

}


// Check if the search value is found in any array

foreach ($dataArray as $array) {

    if (in_array($searchValue, $array)) {

        // Set each value of the array as an Asterisk variable

        foreach ($array as $key => $value) {

            setAsteriskVariable($key, $value);

        }


        echo "Asterisk variables set for the array where the search value '$searchValue' is found.\n";

        break; // Stop after the first occurrence

    }

}


// Function to set Asterisk variable

function setAsteriskVariable($variableName, $variableValue) {

    // Set Asterisk variable

    echo "SET VARIABLE $variableName \"$variableValue\"\n";

}

?>


/home/voipessential/info_1.conf

59945-17542920051-600-14088772222
59955-19549063330-900-18003333330
57000-19546868344
57999-12159486620-400-18002314334
59867-17542912260
59868-18009860534



;;get  queue  time out and other values
same => n,AGI(/home/voipessential/set_variable.php,17542920051)
same => n,NoOp(Variable Value: ${1} ${2} ${3})

No hay comentarios:

Publicar un comentario