<?php
/*
    PrincipalFileGrandstream nos retorna el contenido del archivo de configuracion de los EndPoint
    Grandstream, para ello es necesario enviarle el DisplayName, id_device, secret, ipAdressServer
*/
function PrincipalFileGrandstream($DisplayName, $id_device, $secret, $ipAdressServer)
{
    $content="
# Admin password for web interface
P2 = $secret

# Account Name
P270 = $id_device

# SIP Server
P47 = $ipAdressServer

# Outbound Proxy
P48 = $ipAdressServer

# SIP User ID
P35 = $id_device

# Authenticate ID
P36 = $id_device

# Authenticate password
P34 = $secret

# Display Name (John Doe)
P3 = $DisplayName

# DHCP support. 0 - yes, 1 - no
P8 = 1

# Dial Tone
P343 = f1=425,f2=425;

# Busy Tone
P348 = f1=425,f2=425,c=33/33;

# Send DTMF. 8 - in audio, 1 - via RTP, 2 - via SIP INFO 
# 11 - In Audio & RTP & SIP INFO, 9 - In Audio & RTP
# 10 - IN Audio & SIP INFO, 3 - RTP & SIP INFO
P73 = 1

# Display Language. 0 - English, 3 - Secondary Language, 2 - Chinese
P342 = 3

# language file postfix
P399 = Spanish

# NTP Server
P30 = $ipAdressServer

# Enable Call Features.  0 - no, 1 - yes
P191 = 0

# Account Ring Tone. 0 - system ring tone, 1 - custom ring tone 1, 2 - custom ring tone 2
# 3 - custom ring tone 3.
P104 = 3

# Ringtone 1
P105 = ring1.bin

# Display CID instead of Name. 0 - no, 1 - yes
# GXP280 only
P1344 = 1

# SIP User ID is phone number. 0 - no, 1 - yes
P63 = 1

# SIP Registration. 0 - no, 1 - yes
P31 = 1

# Unregister On Reboot. 0 - no, 1 - yes
P81 = 1

# Lock Keypad Update. 0 - no, 1 - yes
P88 = 1

# Firmware Upgrade. 0 - TFTP Upgrade,  1 - HTTP Upgrade.
P212 = 0

# Firmware Server Path
P192 = $ipAdressServer 

# Config Server Path
P237 = $ipAdressServer

# Automatic Upgrade. 0 - No, 1 - Yes. Default is No.
P194 = 0

# Check for new firmware every () minutes, unit is in minute, minimnu 60 minutes, default is 7 days.
P193 = 10080

# Use firmware pre/postfix to determine if f/w is required
# 0 = Always Check for New Firmware 
# 1 = Check New Firmware only when F/W pre/suffix changes
# 2 = Always Skip the Firmware Check
P238 = 1";

    return $content;
}

function templatesFileGrandstream($ipAdressServer)
{
    $content= <<<TEMP
# SIP Server
P47 = $ipAdressServer

# Outbound Proxy
P48 = $ipAdressServer

# SIP User ID
P35 = 8000

# Authenticate ID
P36 = 8000

# Authenticate password
P34 = 0000

# Display Name (John Doe)
P3 = 

# DHCP support. 0 - yes, 1 - no
P8 = 1
TEMP;
    return $content;
}
?>
