Пример #1
0
        if (count($errors) == 0) {
            header('Location:index.php');
            die;
        }
    }
    $smarty->assign('Errors', $errors);
    return $smarty->fetch('Login.tpl');
}
function formdata_from_post()
{
    return $_REQUEST;
}
function formdata_validate($data)
{
    global $mysqli;
    $errors = array();
    $enc_pw = md5($data['Password']);
    // Check if there is a user with that extension
    if (count($errors) == 0) {
        $query = "\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM \n\t\t\t\tAdmins\n\t\t\tWHERE \n\t\t\t\tname = '" . $mysqli->real_escape_string($data['User']) . "' \n\t\t\t\tAND \n\t\t\t\tpassword = '******' \n\t\t\tLIMIT 1\n\t\t";
        $result = $mysqli->query($query) or die($mysqli->error . $query);
        if ($result->num_rows != 1) {
            $errors['Wrong'] = true;
        } else {
            $_SESSION["_ADMIN"] = $data['User'];
        }
    }
    return $errors;
}
admin_run('Login', 'AdminLogin.tpl', false);
    $Order = 'asc';
    $session['Order'] = $Order;
    // Init sort field (Sort)
    $Sort = 'Order';
    $session['Sort'] = $Sort;
    // Init files list (Files)
    $Files = array();
    $query = "\n\t\tSELECT\n\t\t\tPK_File               AS `_PK_`, \n\t\t\tFilename              AS `Filename`, \n\t\t\tFileext               AS `Fileext`, \n\t\t\t`Order`               AS `Order`, \t\t\t\n\t\t\tMoh_Files.DateCreated AS `DateCreated`,\n\t\t\tMoh_Groups.Name       AS `Group`,\n\t\t\tMoh_Groups.PK_Group   AS `_PK_Group_`\n\t\tFROM\n\t\t\tMoh_Files \n\t\t\tINNER JOIN Moh_Groups ON FK_Group = PK_Group\n\t\tWHERE\n\t\t\tFK_Group={$selectedGroup}\n\t\tORDER BY \n\t\t\t`{$Sort}` {$Order}\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $Files[] = $row;
    }
    // Init available groups (Groups)
    $query = "SELECT * FROM Moh_Groups ORDER BY Name";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $Groups[] = $row;
    }
    $smarty->assign('selectedGroup', $selectedGroup);
    $smarty->assign('Errors', $errors);
    $smarty->assign('Link', '/admin/MOH_Files_ListGroup.php?PK_Group=' . $_REQUEST['PK_Group']);
    $smarty->assign('Files', $Files);
    $smarty->assign('Groups', $Groups);
    $smarty->assign('Sort', $Sort);
    $smarty->assign('Order', $Order);
    $smarty->assign('Message', $Message);
    $smarty->assign('Hilight', isset($_REQUEST['hilight']) ? $_REQUEST['hilight'] : "");
    return $smarty->fetch('MOH_Files_ListGroup.tpl');
}
admin_run('MOH_Files_ListGroup', 'Admin.tpl');
    $errors = array();
    if ($data['PK_Extension'] == '') {
        $create_new = true;
    }
    if ($create_new) {
        // Check if extension is empty
        if ($data['Extension'] == "") {
            $errors['Extension']['Invalid'] = true;
            // Check if Extension is numeric
        } elseif (intval($data['Extension']) . "" != $data['Extension']) {
            $errors['Extension']['Invalid'] = true;
            // Check if extension is proper length
        } elseif (strlen($data['Extension']) < 3 || strlen($data['Extension']) > 5) {
            $errors['Extension']['Invalid'] = true;
            // Check if extension in unique
        } else {
            $query = "SELECT Extension FROM Extensions WHERE Extension = '{$data['Extension']}' LIMIT 1";
            $result = $mysqli->query($query) or die($mysqli->error . $query);
            if ($result->num_rows > 0) {
                $errors['Extension']['Duplicate'] = true;
            }
        }
    }
    // Check if first name is proper length
    if (strlen($data['Name']) < 1 || strlen($data['Name']) > 32) {
        $errors['Name']['Invalid'] = true;
    }
    return $errors;
}
admin_run('Extensions_Virtual_Modify', 'Admin.tpl');
include_once dirname(__FILE__) . '/../include/db_utils.inc.php';
include_once dirname(__FILE__) . '/../include/smarty_utils.inc.php';
include_once dirname(__FILE__) . '/../include/admin_utils.inc.php';
function Extensions_FC_DirectedPickup_Delete()
{
    global $mysqli;
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    $PK_Extension = $_REQUEST['PK_Extension'];
    // In confirmed, do the actual delete
    if (@$_REQUEST['submit'] == 'delete_confirm') {
        $query = "DELETE FROM FC_DirectedPickup WHERE FK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM FC_DirectedPickup_Admins WHERE FK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM FC_DirectedPickup_Members WHERE FK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM Extensions WHERE PK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        header('Location: Extensions_List.php?msg=DELETE_FC_DIRECTEDPICKUP_EXTENSION');
        die;
    }
    // Init extension info (Extension)
    $query = "\n\t\tSELECT\n\t\t\tPK_Extension,\n\t\t\tExtension\n\t\tFROM\n\t\t\tExtensions\n\t\tWHERE\n\t\t\tPK_Extension = {$PK_Extension}\n\t\tLIMIT 1\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    $Extension = $result->fetch_assoc();
    $smarty->assign('Extension', $Extension);
    return $smarty->fetch('Extensions_FC_DirectedPickup_Delete.tpl');
}
admin_run('Extensions_FC_DirectedPickup_Delete', 'Admin.tpl');
        }
    }
    $query = "\n\t\tUPDATE\n\t\t\tOutgoingRules\n\t\tSET\n\t\t\tName            = '" . $mysqli->real_escape_string($data['Name']) . "',\n\t\t\tFinal           =  " . ($data['Final'] ? '1' : '0') . ",\n\t\t\tBeginWith       = '" . $mysqli->real_escape_string($data['BeginWith']) . "',\n\t\t\tRestBetweenLow  = '" . intval($data['RestBetweenLow']) . "',\n\t\t\tRestBetweenHigh = '" . intval($data['RestBetweenHigh']) . "',\n\t\t\tPrependDigits   = '" . $mysqli->real_escape_string($data['PrependDigits']) . "',\n\t\t\tProviderType    = '" . $mysqli->real_escape_string($data['ProviderType']) . "',\n\t\t\tTrimFront       = '" . $mysqli->real_escape_string($data['TrimFront']) . "',\n\t\t\tProviderID      =  " . intval($data['ProviderID']["{$data['ProviderType']}"]) . "\n\t\tWHERE\n\t\t\tPK_OutgoingRule = " . $mysqli->real_escape_string($data['PK_OutgoingRule']) . "\n\t\tLIMIT 1\n\t";
    $mysqli->query($query) or die($mysqli->error . $query);
    return $data['PK_OutgoingRule'];
}
function formdata_validate($data)
{
    $errors = array();
    if ($data['Name'] == "") {
        $errors['Name'] = true;
    }
    if (!preg_match('/^[0-9]+$/', $data['RestBetweenLow'])) {
        $errors['RestBetweenLow'] = true;
    }
    if (!preg_match('/^[0-9]+$/', $data['RestBetweenHigh'])) {
        $errors['RestBetweenHigh'] = true;
    }
    if (!preg_match('/^[0-9]{0,2}$/', $data['TrimFront'])) {
        $errors['TrimFront'] = true;
    }
    if (!preg_match('/^[+]{0,1}[*#0-9]{0,20}$/', $data['PrependDigits'])) {
        $errors['PrependDigits'] = true;
    }
    /* if (!preg_match('/^[*#(|)^0-9]{1,24}$/', $data['BeginWith'])) {
       $errors['BeginWith'] = true;
       } */
    return $errors;
}
admin_run('OutgoingCalls_Rule_Modify', 'Admin.tpl');
Пример #6
0
    return $data;
}
function formdata_from_db()
{
    $variables = array('Agent_AckCall', 'Agent_MissedCalls');
    foreach ($variables as $name) {
        $data[$name] = pbx_var_get($name);
    }
    return $data;
}
function formdata_save($data)
{
    $variables = array('Agent_AckCall', 'Agent_MissedCalls');
    if (is_array($data)) {
        foreach ($data as $name => $value) {
            if (in_array($name, $variables)) {
                pbx_var_set($name, $value);
            }
        }
    }
}
function formdata_validate($data)
{
    $errors = array();
    if (!preg_match('/^[0-9]{1,3}$/', $data['Agent_MissedCalls'])) {
        $errors['Agent_MissedCalls']['Invalid'] = true;
    }
    return $errors;
}
admin_run('AgentSettings', 'Admin.tpl');
Пример #7
0
<?php

include_once dirname(__FILE__) . '/../include/db_utils.inc.php';
include_once dirname(__FILE__) . '/../include/smarty_utils.inc.php';
include_once dirname(__FILE__) . '/../include/admin_utils.inc.php';
function TimeFrames_Delete()
{
    global $mysqli;
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    $PK_Timeframe = $_REQUEST['PK_Timeframe'];
    // In confirmed, do the actual delete
    if (@$_REQUEST['submit'] == 'delete_confirm') {
        $query = "DELETE FROM Timeframes WHERE PK_Timeframe = {$PK_Timeframe} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM Timeframe_Intervals WHERE FK_Timeframe = {$PK_Timeframe}";
        $mysqli->query($query) or die($mysqli->error);
        header('Location: TimeFrames.php?msg=DELETE_TIMEFRAME');
        die;
    }
    // Init template info (Template)
    $query = "SELECT * FROM Timeframes WHERE PK_Timeframe = {$PK_Timeframe} LIMIT 1";
    $result = $mysqli->query($query) or die($mysqli->error);
    $Timeframe = $result->fetch_assoc();
    $smarty->assign('Timeframe', $Timeframe);
    return $smarty->fetch('TimeFrames_Delete.tpl');
}
admin_run('TimeFrames_Delete', 'Admin.tpl');
include_once dirname(__FILE__) . '/../include/db_utils.inc.php';
include_once dirname(__FILE__) . '/../include/smarty_utils.inc.php';
include_once dirname(__FILE__) . '/../include/admin_utils.inc.php';
include_once dirname(__FILE__) . '/../include/asterisk_utils.inc.php';
function Extensions_Queue_Delete()
{
    global $mysqli;
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    $PK_Extension = $_REQUEST['PK_Extension'];
    // In confirmed, do the actual delete
    if (@$_REQUEST['submit'] == 'delete_confirm') {
        $query = "DELETE FROM Extensions WHERE PK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM Ext_Queues WHERE PK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM Ext_Queue_Members WHERE FK_Extension = {$PK_Extension}";
        $mysqli->query($query) or die($mysqli->error);
        asterisk_UpdateConf('queues.conf');
        asterisk_Reload();
        header('Location: Extensions_List.php?msg=DELETE_QUEUE_EXTENSION');
        die;
    }
    // Init extension info (Extension)
    $query = "\n\t\tSELECT\n\t\t\tPK_Extension,\n\t\t\tName\n\t\tFROM\n\t\t\tExt_Queues\n\t\tWHERE\n\t\t\tPK_Extension = {$PK_Extension}\n\t\tLIMIT 1\n\t";
    $result = $mysqli->query($query) or die($mysqli->error);
    $Queue = $result->fetch_assoc();
    $smarty->assign('Queue', $Queue);
    return $smarty->fetch('Extensions_Queue_Delete.tpl');
}
admin_run('Extensions_Queue_Delete', 'Admin.tpl');
    } elseif (count(explode(" ", $data['AccountID'])) > 1) {
        $errors['AccountID']['Invalid'] = true;
    }
    // Check if password is 1-32 chars long
    if (strlen($data['Password']) < 1 || strlen($data['Password']) > 32) {
        $errors['Password']['Invalid'] = true;
    }
    if ($data['ApplyIncomingRules'] == 1) {
        // Check if callback extension is formed of digits only
        if ($data['CallbackExtension'] != "" . intval($data['CallbackExtension'])) {
            $errors['CallbackExtension']['Invalid'] = true;
            // Check if extension is 3-5 digits long
        } elseif (strlen($data['CallbackExtension']) < 3 || strlen($data['CallbackExtension']) > 5) {
            $errors['CallbackExtension']['Invalid'] = true;
            // Check if extension is valid on the system
        } else {
            $query = "SELECT PK_Extension FROM Extensions WHERE Extension = '" . $mysqli->real_escape_string($data['CallbackExtension']) . "' LIMIT 1";
            $result = $mysqli->query($query) or die($mysqli->error . $query);
            if ($result->num_rows < 1) {
                $errors['CallbackExtension']['NoMatch'] = true;
            }
        }
    }
    // Check if a hostaname was supplied for this provider
    if (!preg_match("/^([a-z0-9][a-z0-9-.]{0,62})\$/i", $data['Host'])) {
        $errors['Host']['Invalid'] = true;
    }
    return $errors;
}
admin_run('VoipProviders_Modify', 'Admin.tpl');
Пример #10
0
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    // Init Message
    $Message = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : "";
    // If requested, create new timeframe
    if (isset($_POST['sumbit'])) {
        $data = $_POST;
        if (strlen($data['Name']) < 1 || strlen($data['Name']) > 30) {
            $errors['Name'] = true;
        }
        if (count($errors) == 0) {
            $query = "INSERT INTO Timeframes(Name) VALUES('" . $mysqli->real_escape_string($_POST['Name']) . "')";
            $mysqli->query($query) or die($mysqli->error . $query);
            $PK_Timeframe = $mysqli->insert_id;
            header("Location: TimeFrames_Modify.php?msg=CREATE_TIMEFRAME&FK_Timeframe={$PK_Timeframe}");
            die;
        }
    }
    // Init table fields (Timeframes)
    $Timeframes = array();
    $query = "\n\t\tSELECT\n\t\t\tPK_Timeframe AS _PK_,\n\t\t\tName         AS Name\n\t\tFROM\n\t\t\tTimeframes\n\t\tWHERE\n\t\t\tFK_Extension = 0\n\t\tORDER BY Name\n\t";
    $result = $mysqli->query($query) or die($mysqli->error);
    while ($row = $result->fetch_assoc()) {
        $Timeframes[] = $row;
    }
    $smarty->assign('Timeframes', $Timeframes);
    $smarty->assign('Errors', $errors);
    $smarty->assign('Message', $Message);
    return $smarty->fetch('TimeFrames.tpl');
}
admin_run('TimeFrames', 'Admin.tpl');
{
    global $mysqli;
    $query = "SELECT * FROM SoundLanguages WHERE PK_SoundLanguage = {$id}\tLIMIT 1";
    $result = $mysqli->query($query) or die($mysqli->error);
    $data = $result->fetch_assoc();
    return $data;
}
function formdata_from_post()
{
    return $_POST;
}
function formdata_save($data)
{
    global $mysqli;
    if (empty($data['PK_SoundLanguage'])) {
        $query = "INSERT INTO SoundLanguages(Type) VALUES('User')";
        $mysqli->query($query) or die($mysqli->error . $query);
        $data['PK_SoundLanguage'] = $mysqli->insert_id;
    }
    // Update 'SoundFolders'
    $query = "\n\t\tUPDATE\n\t\t\tSoundLanguages\n\t\tSET\n\t\t\tName        = '" . $mysqli->real_escape_string($data['Name']) . "'\n\t\tWHERE\n\t\t\tPK_SoundLanguage = " . $mysqli->real_escape_string($data['PK_SoundLanguage']) . "\n\t\tLIMIT 1\n\t";
    $mysqli->query($query) or die($mysqli->error . $query);
    return $data['PK_SoundLanguage'];
}
function formdata_validate($data)
{
    $errors = array();
    return $errors;
}
admin_run('SoundLanguages_Modify', 'Admin.tpl');
include_once dirname(__FILE__) . '/../include/config.inc.php';
include_once dirname(__FILE__) . '/../include/asterisk_utils.inc.php';
function Recordings_DeleteRule()
{
    global $mysqli;
    include dirname(__FILE__) . '/../include/config.inc.php';
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    $path = $conf['dirs']['moh'];
    $PK_Rule = $_REQUEST['PK_Rule'];
    // In confirmed, do the actual delete
    if (@$_REQUEST['submit'] == 'delete_confirm') {
        //delete files from database
        $query = "DELETE FROM RecordingRules WHERE PK_Rule = {$PK_Rule}";
        $mysqli->query($query) or die($mysqli->error . $query);
        $query = "DELETE FROM RecordingRules_Extensions WHERE FK_Rule = {$PK_Rule}";
        $mysqli->query($query) or die($mysqli->error . $query);
        $query = "DELETE FROM RecordingRules_Groups WHERE FK_Rule = {$PK_Rule}";
        $mysqli->query($query) or die($mysqli->error . $query);
        asterisk_UpdateConf('musiconhold.conf');
        asterisk_Reload();
        header('Location: Recordings_List.php?msg=DELETE_REC_RULE');
    } else {
        $query = "SELECT * FROM RecordingRules WHERE PK_Rule =  {$PK_Rule};";
        $result = $mysqli->query($query) or die($mysqli->error);
        $RecordingRule = $result->fetch_assoc();
        $smarty->assign('RecordingRule', $RecordingRule);
        return $smarty->fetch('Recordings_DeleteRule.tpl');
    }
}
admin_run('Recordings_DeleteRule', 'Admin.tpl');
Пример #13
0
    $data = $result->fetch_assoc();
    return $data;
}
function formdata_from_default()
{
    $data = array();
    return $data;
}
function formdata_from_post()
{
    return $_REQUEST;
}
function formdata_save($data)
{
    global $mysqli;
    if ($data['PK_Menu'] == "") {
        $query = "INSERT INTO IVR_Menus() VALUES()";
        $mysqli->query($query) or die($mysqli->error . $query);
        $data['PK_Menu'] = $mysqli->insert_id;
    }
    $query = "\n\t\tUPDATE\n\t\t\tIVR_Menus\n\t\tSET\n\t\t\tName        = '" . $mysqli->real_escape_string($data['Name']) . "',\n\t\t\tDescription = '" . $mysqli->real_escape_string($data['Description']) . "'\n\t\tWHERE\n\t\t\tPK_Menu = {$data['PK_Menu']}\n\t\tLIMIT 1\n\t";
    $mysqli->query($query) or die($mysqli->error . $query);
    return $data['PK_Menu'];
}
function formdata_validate($data)
{
    $errors = array();
    return $errors;
}
admin_run('IVR_Menus_Modify', 'Admin.tpl');
}
function formdata_validate($data)
{
    global $mysqli;
    $errors = array();
    if ($data['PK_Extension'] == '') {
        $create_new = true;
    }
    if ($create_new) {
        // Check if extension is empty
        if ($data['Extension'] == "") {
            $errors['Extension']['Invalid'] = true;
            // Check if Extension is numeric
        } elseif (intval($data['Extension']) . "" != $data['Extension']) {
            $errors['Extension']['Invalid'] = true;
            // Check if extension is proper length
        } elseif (strlen($data['Extension']) < 3 || strlen($data['Extension']) > 5) {
            $errors['Extension']['Invalid'] = true;
            // Check if extension in unique
        } else {
            $query = "SELECT Extension FROM Extensions WHERE Extension = '{$data['Extension']}' LIMIT 1";
            $result = $mysqli->query($query) or die($mysqli->error . $query);
            if ($result->num_rows > 0) {
                $errors['Extension']['Duplicate'] = true;
            }
        }
    }
    return $errors;
}
admin_run('Extensions_Voicemail_Modify', 'Admin.tpl');
Пример #15
0
    // Init sort order (Order)
    if ($session['Sort'] == $_REQUEST['Sort']) {
        $Order = $session['Order'] == "asc" ? "desc" : "asc";
    } elseif ($session['Sort'] != $_REQUEST['Sort']) {
        $Order = 'asc';
    }
    $session['Order'] = $Order;
    // Init sort field (Sort)
    if (isset($_REQUEST['Sort'])) {
        $Sort = $_REQUEST['Sort'];
    } else {
        $Sort = 'Name';
    }
    $session['Sort'] = $Sort;
    // Init table fields (Extensions)
    $Providers = array();
    $query = "\n\t\t\tSELECT\n\t\t\t\tPK_SipProvider    AS _PK_,\n\t\t\t\tName              AS Name,\n\t\t\t\t'SIP'             AS Type,\n\t\t\t\tAccountID         AS AccountID,\n\t\t\t\tHost              AS Host,\n\t\t\t\tCallbackExtension AS CallbackExtension\n\t\t\tFROM\n\t\t\t\tSipProviders\n\t\tORDER BY\n\t\t\t{$Sort} {$Order}\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $Providers[] = $row;
    }
    $smarty->assign('Errors', $Errors);
    $smarty->assign('Providers', $Providers);
    $smarty->assign('Sort', $Sort);
    $smarty->assign('Order', $Order);
    $smarty->assign('Message', $Message);
    $smarty->assign('Hilight', isset($_REQUEST['hilight']) ? $_REQUEST['hilight'] : "");
    return $smarty->fetch('VoipProviders_List.tpl');
}
admin_run('VoipProviders_List', 'Admin.tpl');
<?php

include_once dirname(__FILE__) . '/../include/db_utils.inc.php';
include_once dirname(__FILE__) . '/../include/smarty_utils.inc.php';
include_once dirname(__FILE__) . '/../include/admin_utils.inc.php';
function Extensions_DialTone_Delete()
{
    global $mysqli;
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    $PK_Extension = $_REQUEST['PK_Extension'];
    // In confirmed, do the actual delete
    if (@$_REQUEST['submit'] == 'delete_confirm') {
        $query = "DELETE FROM Ext_DialTone WHERE PK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM Extensions WHERE PK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        header('Location: Extensions_List.php?msg=DELETE_DIALTONE_EXTENSION');
        die;
    }
    // Init extension info (Extension)
    $query = "\n\t\tSELECT\n\t\t\tPK_Extension,\n\t\t\tExtension\n\t\tFROM\n\t\t\tExtensions\n\t\tWHERE\n\t\t\tPK_Extension = {$PK_Extension}\n\t\tLIMIT 1\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    $Extension = $result->fetch_assoc();
    $smarty->assign('Extension', $Extension);
    return $smarty->fetch('Extensions_DialTone_Delete.tpl');
}
admin_run('Extensions_DialTone_Delete', 'Admin.tpl');
Пример #17
0
    $variables = array('Current_TimeZone', 'Current_SysTime', 'NTPServer', 'DisableNTP');
    if (is_array($data)) {
        foreach ($data as $name => $value) {
            if (in_array($name, $variables)) {
                pbx_var_set($name, $value);
            }
        }
    }
}
function formdata_validate($data)
{
    $errors = array();
    if (!validateHostName($data['NTPServer'])) {
        $errors['NTPServer'] = true;
    }
    return $errors;
}
function get_timezone_list()
{
    $path = realpath('/usr/share/zoneinfo');
    $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::LEAVES_ONLY);
    foreach ($objects as $name => $object) {
        if ($name != $path . "/zone.tab") {
            $data[] = str_replace($path . "/", "", $name);
        }
    }
    sort($data);
    return $data;
}
admin_run('SystemClockSettings', 'Admin.tpl');
<?php

include_once dirname(__FILE__) . '/../include/db_utils.inc.php';
include_once dirname(__FILE__) . '/../include/smarty_utils.inc.php';
include_once dirname(__FILE__) . '/../include/admin_utils.inc.php';
function Extensions_IVR_Delete()
{
    global $mysqli;
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    $PK_Extension = $_REQUEST['PK_Extension'];
    // In confirmed, do the actual delete
    if (@$_REQUEST['submit'] == 'delete_confirm') {
        $query = "DELETE FROM Extensions WHERE PK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM Ext_IVR WHERE PK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        if ($mysqli->affected_rows != 1) {
            return;
        }
        header('Location: Extensions_List.php?msg=DELETE_IVR_EXTENSION');
        die;
    }
    // Init extension info (Extension)
    $query = "\n\t\tSELECT\n\t\t\tPK_Extension,\n\t\t\tExtension\n\t\tFROM\n\t\t\tExtensions\n\t\tWHERE\n\t\t\tPK_Extension = {$PK_Extension}\n\t\tLIMIT 1\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    $Extension = $result->fetch_assoc();
    $smarty->assign('Extension', $Extension);
    return $smarty->fetch('Extensions_IVR_Delete.tpl');
}
admin_run('Extensions_IVR_Delete', 'Admin.tpl');
Пример #19
0
    if (!preg_match("/^[0-9]{15,16}\$/", $data['IMEI'])) {
        $errors['IMEI']['Invalid'] = true;
    }
    // Check if account id is 1-32 chars long
    if (!preg_match("/^[0-9]{14,15}\$/", $data['IMSI'])) {
        $errors['IMSI']['Invalid'] = true;
    }
    // Check if account id is 1-32 chars long
    if (!preg_match("/^[0-9]{3,15}\$/", $data['MSISDN'])) {
        $errors['MSISDN']['Invalid'] = true;
    }
    if ($data['ApplyIncomingRules'] == 1) {
        // Check if callback extension is formed of digits only
        if ($data['CallbackExtension'] != "" . intval($data['CallbackExtension'])) {
            $errors['CallbackExtension']['Invalid'] = true;
            // Check if extension is 3-5 digits long
        } elseif (strlen($data['CallbackExtension']) < 3 || strlen($data['CallbackExtension']) > 5) {
            $errors['CallbackExtension']['Invalid'] = true;
            // Check if extension is valid on the system
        } else {
            $query = "SELECT PK_Extension FROM Extensions WHERE Extension = '" . $mysqli->real_escape_string($data['CallbackExtension']) . "' LIMIT 1";
            $result = $mysqli->query($query) or die($mysqli->error . $query);
            if ($result->num_rows < 1) {
                $errors['CallbackExtension']['NoMatch'] = true;
            }
        }
    }
    return $errors;
}
admin_run('Dongles_Modify', 'Admin.tpl');
include_once dirname(__FILE__) . '/../include/db_utils.inc.php';
include_once dirname(__FILE__) . '/../include/smarty_utils.inc.php';
include_once dirname(__FILE__) . '/../include/admin_utils.inc.php';
include_once dirname(__FILE__) . '/../include/asterisk_utils.inc.php';
function SoundLanguages_Delete()
{
    global $mysqli;
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    $PK_SoundLanguage = $_REQUEST['PK_SoundLanguage'];
    if ($PK_SoundLanguage == "") {
        $PK_SoundLanguage = $_REQUEST['PK'];
    }
    // In confirmed, do the actual delete
    if (@$_REQUEST['submit'] == 'delete_confirm') {
        $query = "DELETE FROM SoundLanguages WHERE PK_SoundLanguage = {$PK_SoundLanguage} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        if ($mysqli->affected_rows != 1) {
            return;
        }
        header('Location: SoundLanguages_List.php?msg=DELETE_LANGUAGE');
        die;
    }
    // Init extension info (Extension)
    $query = "SELECT * FROM SoundLanguages WHERE PK_SoundLanguage = {$PK_SoundLanguage} LIMIT 1";
    $result = $mysqli->query($query) or die($mysqli->error);
    $SoundLanguage = $result->fetch_assoc();
    $smarty->assign('SoundLanguage', $SoundLanguage);
    return $smarty->fetch('SoundLanguages_Delete.tpl');
}
admin_run('SoundLanguages_Delete', 'Admin.tpl');
    if ($data['PK_Extension'] == '') {
        $create_new = true;
    }
    if ($create_new) {
        // Check if extension is empty
        if ($data['Extension'] == "") {
            $errors['Extension']['Invalid'] = true;
            // Check if Extension is numeric
        } elseif (intval($data['Extension']) . "" != $data['Extension']) {
            $errors['Extension']['Invalid'] = true;
            // Check if extension is proper length
        } elseif (strlen($data['Extension']) < 3 || strlen($data['Extension']) > 5) {
            $errors['Extension']['Invalid'] = true;
            // Check if extension in unique
        } else {
            $query = "SELECT Extension FROM Extensions WHERE Extension = '{$data['Extension']}' LIMIT 1";
            $result = $mysqli->query($query) or die($mysqli->error . $query);
            if ($result->num_rows > 0) {
                $errors['Extension']['Duplicate'] = true;
            }
        }
    }
    if (!empty($data['Password'])) {
        if (!preg_match('/^[0-9]{3,10}$/', $data['Password'])) {
            $errors['Password']['Invalid'] = true;
        }
    }
    return $errors;
}
admin_run('Extensions_DialTone_Modify', 'Admin.tpl');
                $PK_Rule = explode('_', $PK_Rule);
                $PK = $PK_Rule[1];
                //disk
                $query = "SELECT\n\t\t\t\t\t\t\t\t`FK_Group`, `Order`, `Fileext`\n\t\t\t\t\t\t  FROM\n\t\t\t\t\t\t\t\t`Moh_Files`\n\t\t\t\t\t\t  WHERE `PK_File` = {$PK}";
                $result = $mysqli->query($query) or die($mysqli->error);
                $File_src = $result->fetch_assoc();
                $PK_Group = $File_src['FK_Group'];
                $old_order = $File_src['Order'];
                $extension = $File_src['Fileext'];
                $src = $path;
                $src .= "/group_" . str_pad($PK_Group, 10, "0", STR_PAD_LEFT);
                $src .= "/file_" . str_pad($old_order, 6, "0", STR_PAD_LEFT);
                $src .= "_" . str_pad($PK, 9, "0", STR_PAD_LEFT) . "." . $extension;
                $dest = $path;
                $dest .= "/group_" . str_pad($PK_Group, 10, "0", STR_PAD_LEFT);
                $dest .= "/file_" . str_pad($order, 6, "0", STR_PAD_LEFT);
                $dest .= "_" . str_pad($PK, 9, "0", STR_PAD_LEFT) . "." . $extension;
                rename($src, $dest);
                //db
                $query = "UPDATE `Moh_Files` SET `Order` = '" . intval($order) . "' WHERE `PK_File` = '" . intval($PK) . "'";
                $mysqli->query($query) or die($mysqli->error);
                $order++;
            }
            asterisk_UpdateConf('musiconhold.conf');
            asterisk_Reload();
            break;
    }
    echo json_encode($response);
}
admin_run('MOH_Files_ListGroup_Ajax');
<?php

include_once dirname(__FILE__) . '/../include/db_utils.inc.php';
include_once dirname(__FILE__) . '/../include/smarty_utils.inc.php';
include_once dirname(__FILE__) . '/../include/admin_utils.inc.php';
function NetworkSettings_Ajax()
{
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    $data = $_REQUEST;
    $response = array();
    switch ($data['Action']) {
        case 'LookupExternalIP':
            $url = "http://ipinfo.io/ip";
            $response['IP'] = get_web_page($url);
            break;
    }
    echo json_encode($response);
}
admin_run('NetworkSettings_Ajax');
Пример #24
0
<?php

include_once dirname(__FILE__) . '/../include/db_utils.inc.php';
include_once dirname(__FILE__) . '/../include/admin_utils.inc.php';
include_once dirname(__FILE__) . '/../include/moh_utils.inc.php';
function MOH_Files_Download()
{
    global $mysqli;
    $session =& $_SESSION['MOH_Files_Download'];
    $PK_File = intval($_REQUEST['PK_File']);
    $query = "SELECT * FROM Moh_Files WHERE PK_File = '{$PK_File}' LIMIT 1";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    $File = $result->fetch_assoc();
    $Filename = moh_filename($PK_File);
    if (file_exists($Filename)) {
        //header("Content-type: " . mime_content_type($Filename));
        header("Content-Disposition: attachment; filename=\"" . basename($File['Filename'] . "." . $File['Extension']) . "\"");
        $handle = fopen($Filename, 'r');
        while (!feof($handle)) {
            echo fread($handle, 8192);
        }
        fclose($handle);
    } else {
        echo "File not found.";
    }
    die;
}
admin_run('MOH_Files_Download');
Пример #25
0
        $Start = $_REQUEST['Start'];
    } else {
        $Start = 0;
    }
    // Init total entries (Total)
    $query = "SELECT COUNT(*) FROM Backups";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    $row = $result->fetch_array();
    $Total = $row[0];
    // Init table fields (Backups)
    $Backups = array();
    $query = "SELECT PK_Backup, Optionals, Size, Date FROM Backups ORDER BY {$Sort} {$Order} LIMIT {$Start}, {$PageSize}";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $Backups[] = $row;
    }
    // Init end record (End)
    $End = $Start + $PageSize;
    $smarty->assign('Errors', $Errors);
    $smarty->assign('Backups', $Backups);
    $smarty->assign('Sort', $Sort);
    $smarty->assign('Order', $Order);
    $smarty->assign('Start', $Start);
    $smarty->assign('End', $End);
    $smarty->assign('Total', $Total);
    $smarty->assign('PageSize', $PageSize);
    $smarty->assign('Message', $Message);
    return $smarty->fetch('Backup.tpl');
}
admin_run('Backup', 'Admin.tpl');
Пример #26
0
                $errors['ExtensionStart']['Invalid'] = true;
            }
            if ($data['Type'] == 'Multiple') {
                if ($data['ExtensionEnd'] == "") {
                    $errors['ExtensionEnd']['Invalid'] = true;
                } elseif (intval($data['ExtensionEnd']) . "" != $data['ExtensionEnd']) {
                    $errors['ExtensionEnd']['Invalid'] = true;
                } elseif (strlen($data['ExtensionEnd']) < 3 || strlen($data['ExtensionEnd']) > 5) {
                    $errors['ExtensionEnd']['Invalid'] = true;
                }
            } else {
                $data['ExtensionEnd'] = 0;
            }
            if (!preg_match('/^[0-9]?$/', $data['FK_OutgoingRule'])) {
                $data['FK_OutgoingRule'] = 0;
            }
            if (!preg_match('/^[0-9]?$/', $data['Add'])) {
                $data['Add'] = 0;
            }
            $query = "\n\t\t\t\tUPDATE\n\t\t\t\t\tOutgoingCIDRules\n\t\t\t\tSET\n\t\t\t\t\tType            = '" . $mysqli->real_escape_string($data['Type']) . "',\n\t\t\t\t\tExtensionStart  = '" . $mysqli->real_escape_string($data['ExtensionStart']) . "',\n\t\t\t\t\tExtensionEnd    = '" . $mysqli->real_escape_string($data['ExtensionEnd']) . "',\n\t\t\t\t\tFK_OutgoingRule = '" . $mysqli->real_escape_string($data['FK_OutgoingRule']) . "',\n\t\t\t\t\t`Add`           =  " . intval($data['Add']) . ",\n\t\t\t\t\tPrependDigits   = '" . $mysqli->real_escape_string($data['PrependDigits']) . "',\n\t\t\t\t\tName            = '" . $mysqli->real_escape_string($data['Name']) . "',\n\t\t\t\t\tNumber          = '" . $mysqli->real_escape_string($data['Number']) . "'\n\t\t\t\tWHERE\n\t\t\t\t\tPK_OutgoingCIDRule = " . intval($data['ID']) . "\n\t\t\t\tLIMIT 1\n\t\t\t";
            $mysqli->query($query) or die($mysqli->error . $query);
            $response['ID'] = $data['ID'];
            $response['Errors'] = $errors;
            break;
    }
    asterisk_UpdateConf('extensions.conf');
    asterisk_Reload();
    echo json_encode($response);
}
admin_run('OutgoingCalls_Ajax');
Пример #27
0
    $variables = array('Voicemail_From', 'Voicemail_SMTP_Server', 'Voicemail_SMTP_User', 'Voicemail_SMTP_Pass', 'Voicemail_AllowLogin', 'Voicemail_OperatorExtension', 'Voicemail_EmailTemplate', 'Voicemail_EmailTemplate_Original', 'Voicemail_UseExternal', 'Voicemail_PK_SipProvider');
    foreach ($variables as $name) {
        $data[$name] = pbx_var_get($name);
    }
    return $data;
}
function formdata_save($data, $variables)
{
    $variables = array('Voicemail_From', 'Voicemail_SMTP_Server', 'Voicemail_SMTP_User', 'Voicemail_SMTP_Pass', 'Voicemail_AllowLogin', 'Voicemail_OperatorExtension', 'Voicemail_EmailTemplate', 'Voicemail_UseExternal', 'Voicemail_PK_SipProvider');
    if (is_array($data)) {
        foreach ($data as $name => $value) {
            if (in_array($name, $variables)) {
                pbx_var_set($name, $value);
            }
        }
    }
}
function formdata_validate($data, $variables)
{
    $errors = array();
    if (in_array('Voicemail_OperatorExtension', $variables)) {
        if (!empty($data['Voicemail_OperatorExtension'])) {
            if (!preg_match('/^[0-9]{3,4}$/', $data['Voicemail_OperatorExtension'])) {
                $errors['Voicemail_OperatorExtension']['Invalid'] = true;
            }
        }
    }
    return $errors;
}
admin_run('VoicemailSettings', 'Admin.tpl');
    global $mysqli;
    if ($data['PK_Action'] == "") {
        $query = "SELECT COUNT(*) FROM IVR_Actions WHERE FK_Menu={$data['FK_Menu']}";
        $result = $mysqli->query($query) or die($mysqli->error . $query);
        $row = $result->fetch_row();
        $data['Order'] = $row[0] + 1;
        $query = "INSERT INTO IVR_Actions (FK_Menu, `Order`, Type) VALUES({$data['FK_Menu']}, {$data['Order']}, 'record_digits')";
        $mysqli->query($query) or die($mysqli->error . $query);
        $data['PK_Action'] = $mysqli->insert_id;
    }
    $query = "DELETE FROM IVR_Action_Params WHERE FK_Action = {$data['PK_Action']}";
    $mysqli->query($query) or die($mysqli->error . $query);
    if (is_array($data['Param'])) {
        foreach ($data['Param'] as $Name => $Value) {
            $query = "\n\t\t\t\tINSERT INTO\n\t\t\t\t\tIVR_Action_Params\n\t\t\t\tSET\n\t\t\t\t\t`Name`      = '" . $mysqli->real_escape_string($Name) . "',\n\t\t\t\t\t`Value`     = '" . $mysqli->real_escape_string($Value) . "',\n\t\t\t\t\t`FK_Action` = {$data['PK_Action']}\n\t\t\t";
            $mysqli->query($query) or die($mysqli->error . $query);
            if ($Name == 'Name') {
                $query = "\n\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\tIVR_Action_Params\n\t\t\t\t\tSET\n\t\t\t\t\t\t`Name`      = 'Null',\n\t\t\t\t\t\t`Variable`  = '" . $mysqli->real_escape_string($Value) . "',\n\t\t\t\t\t\t`FK_Action` = {$data['PK_Action']}\n\t\t\t\t";
                $mysqli->query($query) or die($mysqli->error . $query);
            }
        }
    }
    return $data['PK_Action'];
}
function formdata_validate($data)
{
    $errors = array();
    return $errors;
}
admin_run('Extensions_Action_Modify', 'Admin.tpl');
Пример #29
0
    if (@$_REQUEST['submit'] == 'delete_confirm') {
        //delete files from database
        $query = "DELETE FROM Moh_Files  WHERE FK_Group = {$PK_Group}";
        $mysqli->query($query) or die($mysqli->error . $query);
        //delete files from hdd
        $handle = @opendir($path . "/group_" . str_pad($PK_Group, 10, "0", STR_PAD_LEFT) . "/");
        if ($handle) {
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {
                    @unlink($path . "/group_" . str_pad($PK_Group, 10, "0", STR_PAD_LEFT) . "/" . $file);
                }
            }
            closedir($handle);
            @rmdir($path . "/group_" . str_pad($PK_Group, 10, "0", STR_PAD_LEFT));
        }
        //delete directories from database
        $query = "DELETE FROM Moh_Groups WHERE PK_Group = '{$PK_Group}'";
        $mysqli->query($query) or die($mysqli->error . $query);
        asterisk_UpdateConf('musiconhold.conf');
        asterisk_Reload();
        header('Location: MOH_Groups_List.php');
        die;
    }
    $query = "SELECT * FROM Moh_Groups WHERE PK_Group =  {$PK_Group};";
    $result = $mysqli->query($query) or die($mysqli->error);
    $Group = $result->fetch_assoc();
    $smarty->assign('Group', $Group);
    return $smarty->fetch('MOH_Groups_Delete.tpl');
}
admin_run('MOH_Groups_Delete', 'Admin.tpl');
    if (@$_REQUEST['submit'] == 'delete_confirm') {
        $query = "DELETE FROM Extensions WHERE PK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM Ext_SipPhones WHERE PK_Extension = {$PK_Extension} LIMIT 1";
        $mysqli->query($query) or die($mysqli->error);
        if ($mysqli->affected_rows != 1) {
            return;
        }
        $query = "DELETE FROM Ext_SipPhones_Codecs WHERE FK_Extension = {$PK_Extension}";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM Extension_Groups WHERE FK_Extension = {$PK_Extension}";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM Ext_SipPhones_Features WHERE FK_Extension = {$PK_Extension}";
        $mysqli->query($query) or die($mysqli->error);
        $query = "DELETE FROM Extension_Rules WHERE FK_Extension = {$PK_Extension}";
        $mysqli->query($query) or die($mysqli->error);
        asterisk_UpdateConf('sip.conf');
        asterisk_UpdateConf('voicemail.conf');
        asterisk_Reload();
        header('Location: Extensions_List.php?msg=DELETE_SIPPHONE_EXTENSION');
        die;
    }
    // Init extension info (Extension)
    $query = "\n\t\tSELECT\n\t\t\tPK_Extension,\n\t\t\tExtension\n\t\tFROM\n\t\t\tExtensions\n\t\tWHERE\n\t\t\tPK_Extension = {$PK_Extension}\n\t\tLIMIT 1\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    $Extension = $result->fetch_assoc();
    $smarty->assign('Extension', $Extension);
    return $smarty->fetch('Extensions_SipPhone_Delete.tpl');
}
admin_run('Extensions_SipPhone_Delete', 'Admin.tpl');