Пример #1
0
include_once dirname(__FILE__) . '/../include/user_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') {
        // See if user is alowed to update this timeframe
        $query = "\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tTimeframes\n\t\t\tWHERE\n\t\t\t\tPK_Timeframe  = {$PK_Timeframe}\n\t\t\t\tAND\n\t\t\t\tFK_Extension = '" . $mysqli->real_escape_string($_SESSION['_USER']['PK_Extension']) . "'\n\t\t";
        $result = $mysqli->query($query) or die($mysqli->error . $query);
        if ($result->num_rows != 1) {
            header('Location: TimeFrames.php?msg=DELETE_TIMEFRAME');
            die;
        }
        $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');
}
user_run('TimeFrames_Delete', 'User.tpl');
Пример #2
0
        }
        if (count($errors) == 0) {
            $query = "INSERT INTO Timeframes(Name, FK_Extension) VALUES('" . $mysqli->real_escape_string($_POST['Name']) . "','" . $mysqli->real_escape_string($_SESSION['_USER']['PK_Extension']) . "')";
            $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 = '" . $mysqli->real_escape_string($_SESSION['_USER']['PK_Extension']) . "'\n\t\tORDER BY Name\n\t";
    $result = $mysqli->query($query) or die($mysqli->error);
    while ($row = $result->fetch_assoc()) {
        $Timeframes[] = $row;
    }
    // Init table fields (Timeframes_Admin)
    $Timeframes_Admin = 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_Admin[] = $row;
    }
    $smarty->assign('Timeframes', $Timeframes);
    $smarty->assign('Timeframes_Admin', $Timeframes_Admin);
    $smarty->assign('Errors', $errors);
    $smarty->assign('Message', $Message);
    return $smarty->fetch('TimeFrames.tpl');
}
user_run('TimeFrames', 'User.tpl');
Пример #3
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/user_utils.inc.php';
function Extensions_Popup()
{
    global $mysqli;
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    // Set 'Extensions'
    $query = "\n\t\tSELECT\n\t\t\tExtension,\n\t\t\tLPAD(Extension,5,' ') AS Extension_Pad,\n\t\t\tType,\n\t\t\tCONCAT(\n\t\t\t\tIFNULL(Extensions.Name,''),\n\t\t\t\tIFNULL(IVR_Menus.Name,'')\n\t\t\t) AS Name\n\t\tFROM\n\t\t\tExtensions\n\t\t\tLEFT JOIN Ext_IVR       ON Ext_IVR.PK_Extension       = Extensions.PK_Extension\n\t\t\t\tLEFT JOIN IVR_Menus ON Ext_IVR.FK_Menu = IVR_Menus.PK_Menu\n\t\tWHERE\n\t\t\t( NOT Type  LIKE '%Reserved%' )\n\t\tORDER BY\n\t\t\tExtension_Pad ASC\n\t";
    $result = $mysqli->query($query) or die($mysqli->error);
    $Extensions = array();
    while ($row = $result->fetch_assoc()) {
        $Extensions[] = $row;
    }
    $smarty->assign('FillID', $_REQUEST['FillID']);
    $smarty->assign('Extensions', $Extensions);
    return $smarty->fetch('Extensions_Popup.tpl');
}
user_run('Extensions_Popup', 'UserPopup.tpl');
Пример #4
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/user_utils.inc.php';
include_once dirname(__FILE__) . '/../include/asterisk_utils.inc.php';
include_once dirname(__FILE__) . '/../include/voicemail_utils.inc.php';
function Voicemail_GetFile()
{
    $Folder = $_REQUEST['Folder'];
    $File = $_REQUEST['File'];
    vm_getfile($_SESSION['_USER']['Extension'], $Folder, $File);
    return "ERROR";
}
user_run('Voicemail_GetFile', 'User.tpl');
Пример #5
0
    if ($data['StartDay'] != "" && $data['EndDay'] == "") {
        $errors['EndDay']['Missing'] = true;
    }
    if ($data['StartDay'] == "" && $data['EndDay'] != "") {
        $errors['StartDay']['Missing'] = true;
    }
    if ($data['StartDate'] != "" && $data['EndDate'] == "") {
        $errors['EndDate']['Missing'] = true;
    }
    if ($data['StartDate'] == "" && $data['EndDate'] != "") {
        $errors['StartDate']['Missing'] = true;
    }
    return $errors;
}
function formdata_save($data)
{
    global $mysqli;
    // See if user is alowed to update this timeframe
    $query = "\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\tTimeframes\n\t\tWHERE\n\t\t\tPK_Timeframe  = {$data['FK_Timeframe']}\n\t\t\tAND\n\t\t\tFK_Extension = '" . $mysqli->real_escape_string($_SESSION['_USER']['PK_Extension']) . "'\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    if ($result->num_rows != 1) {
        return;
    }
    $query = "INSERT INTO Timeframe_Intervals() VALUES()";
    $mysqli->query($query) or die($mysqli->error . $query);
    $data['PK_Interval'] = $mysqli->insert_id;
    $query = "\n\t\tUPDATE\n\t\t\tTimeframe_Intervals\n\t\tSET\n\t\t\tFK_Timeframe  = " . intval($data['FK_Timeframe']) . ",\n\t\t\tStartDate     = '" . $mysqli->real_escape_string($data['StartDate']) . "',\n\t\t\tEndDate       = '" . $mysqli->real_escape_string($data['EndDate']) . "',\n\t\t\tStartDay      = " . intval($data['StartDay']) . ",\n\t\t\tEndDay        = " . intval($data['EndDay']) . ",\n\t\t\tStartTime     = '" . $mysqli->real_escape_string($data['StartTime']) . "',\n\t\t\tEndTime       = '" . $mysqli->real_escape_string($data['EndTime']) . "',\n\t\t\tStartTimeMode = '" . $mysqli->real_escape_string($data['StartTimeMode']) . "',\n\t\t\tEndTimeMode   = '" . $mysqli->real_escape_string($data['EndTimeMode']) . "'\n\t\tWHERE\n\t\t\tPK_Interval  = {$data['PK_Interval']}\n\t";
    $mysqli->query($query) or die($mysqli->error . $query);
}
user_run('TimeFrames_Modify', 'User.tpl');
Пример #6
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/user_utils.inc.php';
function CallLog_Details()
{
    global $mysqli;
    $session =& $_SESSION['CallLog_Details'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    $PK_CallLog = $_REQUEST['PK_CallLog'];
    $Details = array();
    $query = "\n\t\tSELECT\n\t\t\t*,\n\t\t\tDATE_FORMAT(Date,'%h:%i:%s %p') AS Date_Formated\n\t\tFROM\n\t\t\tCallLog_Details\n\t\tWHERE\n\t\t\tFK_CallLog = '" . $mysqli->real_escape_string($PK_CallLog) . "'\n\t\tORDER BY\n\t\t\tDate\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $row['Data_CSV'] = $row['Data'];
        $row['Data'] = explode(',', $row['Data_CSV']);
        $Details[] = $row;
    }
    $smarty->assign('Details', $Details);
    return $smarty->fetch('CallLog_Details.tpl');
}
user_run('CallLog_Details', '');
Пример #7
0
    $smarty->assign('Order', $Order);
    $smarty->assign('Start', $Start);
    $smarty->assign('End', $End);
    $smarty->assign('Total', $Total);
    $smarty->assign('PageSize', $PageSize);
    return $smarty->fetch('CallLog.tpl');
}
function init_filter()
{
    $filter = array();
    $session =& $_SESSION['CallLog'];
    if (isset($_GET['StartDate'])) {
        $filter['StartDate'] = $_GET['StartDate'];
    } elseif (isset($session['StartDate'])) {
        $filter['StartDate'] = $session['StartDate'];
    } else {
        $filter['StartDate'] = date('m/d/Y', time());
    }
    $session['StartDate'] = $filter['StartDate'];
    if (isset($_GET['EndDate'])) {
        $filter['EndDate'] = $_GET['EndDate'];
    } elseif (isset($session['EndDate'])) {
        $filter['EndDate'] = $session['EndDate'];
    } else {
        $filter['EndDate'] = date('m/d/Y', time());
    }
    $session['EndDate'] = $filter['EndDate'];
    return $filter;
}
user_run('CallLog', 'User.tpl');
Пример #8
0
    $smarty->assign('Messages', $Messages);
    $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);
    $smarty->assign('Hilight', isset($_REQUEST['hilight']) ? $_REQUEST['hilight'] : "");
    $smarty->assign('Path', $Path);
    return $smarty->fetch('Voicemail.tpl');
}
function array_order(&$array, $field, $order)
{
    if (!is_array($array)) {
        return;
    }
    foreach ($array as $key => $row) {
        $aux[$key] = $row[$field];
    }
    if (!is_array($aux)) {
        return;
    }
    if (strtolower($order) == 'desc') {
        array_multisort($aux, SORT_DESC, $array);
    } else {
        array_multisort($aux, SORT_ASC, $array);
    }
}
user_run('Voicemail', 'User.tpl');
Пример #9
0
    // Update Password if requested
    if ($data['Password'] != '') {
        $query = "\n\t\t\tUPDATE\n\t\t\t\t" . ($_SESSION['_USER']['Type'] == 'SipPhone' ? "Ext_SipPhones" : "") . "\n\t\t\t\t" . ($_SESSION['_USER']['Type'] == 'Virtual' ? "Ext_Virtual  " : "") . "\n\t\t\t\t" . ($_SESSION['_USER']['Type'] == 'Agent' ? "Ext_Agent    " : "") . "\n\t\t\tSET\n\t\t\t\tPassword     = '******'Password']) . "'\n\t\t\tWHERE\n\t\t\t\tPK_Extension = " . $mysqli->real_escape_string($_SESSION['_USER']['PK_Extension']) . "\n\t\t\t\tAND\n\t\t\t\tPassword_Editable = 1\n\t\t\tLIMIT 1\n\t\t";
        $mysqli->query($query) or die($mysqli->error . $query);
    }
    return $_SESSION['_USER']['PK_Extension'];
}
function formdata_validate($data)
{
    $errors = array();
    // Check if password is empty
    if ($data['Password'] == "") {
        // Nothing to do
        // Check if password is numeric
    } elseif (intval($data['Password']) . "" != $data['Password']) {
        $errors['Password']['Invalid'] = true;
        // Check if password is proper lenght
    } elseif (strlen($data['Password']) < 3 || strlen($data['Password']) > 10) {
        $errors['Password']['Invalid'] = true;
        // Check if passwords match it's retype
    } elseif ($data['Password'] != $data['Password_Retype']) {
        $errors['Password']['Match'] = true;
    }
    // Check if first name is proper length
    if (strlen($data['Name']) < 1 || strlen($data['Name']) > 32) {
        $errors['Name']['Invalid'] = true;
    }
    return $errors;
}
user_run('Account_Modify', 'User.tpl');
Пример #10
0
                $query = "SELECT Password FROM Ext_Agents    WHERE PK_Extension={$Extension['PK_Extension']} LIMIT 1";
                break;
        }
        $result = $mysqli->query($query) or die($mysqli->error . $query);
        $row = $result->fetch_row();
        if ($data['Password'] != $row[0]) {
            $errors['Wrong'] = true;
        }
    }
    // Check if the user is allowed to access the webtool
    if (count($errors) == 0) {
        switch ($Extension['Type']) {
            case 'SipPhone':
                $query = "SELECT * FROM Ext_SipPhones_Features WHERE FK_Extension={$Extension['PK_Extension']} AND FK_Feature = 5 LIMIT 1";
                break;
            case 'Virtual':
                $query = "SELECT * FROM Ext_Virtual_Features   WHERE FK_Extension={$Extension['PK_Extension']} AND FK_Feature = 5 LIMIT 1";
                break;
            case 'Agent':
                $query = "SELECT * FROM Agents WHERE PK_Extension={$Extension['PK_Extension']} AND WebAccess = 1 LIMIT 1";
                break;
        }
        $result = $mysqli->query($query) or die($mysqli->error . $query);
        if ($result->num_rows != "1") {
            $errors['Wrong'] = true;
        }
    }
    return $errors;
}
user_run('Login', 'UserLogin.tpl', false);
Пример #11
0
    $query = "SELECT PK_Room FROM Ext_ConfCenter_Rooms WHERE FK_Extension_Owner = '{$_SESSION['_USER']['PK_Extension']}' LIMIT 1";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    $row = $result->fetch_assoc();
    $PK_Room = $row['PK_Room'];
    $query = "DELETE FROM Ext_ConfCenter_Admins WHERE FK_Room = {$PK_Room}";
    $mysqli->query($query) or die($mysqli->error . $query);
    if (is_array($data['Admins'])) {
        foreach ($data['Admins'] as $FK_Extension) {
            $FK_Extension = intval($FK_Extension);
            $query = "INSERT INTO Ext_ConfCenter_Admins (FK_Room, FK_Extension) VALUES('{$PK_Room}','{$FK_Extension}')";
            $mysqli->query($query) or die($mysqli->error . $query);
        }
    }
}
function formdata_validate($data)
{
    $errors = array();
    if ($data['Number'] != '') {
        if (!preg_match('/^[0-9]{5}$/', $data['Number'])) {
            $errors['Number']['Format'] = true;
        }
    }
    if ($data['Operator'] != '') {
        if (!preg_match('/^[0-9]{3,5}$/', $data['Operator'])) {
            $errors['Operator']['Format'] = true;
        }
    }
    return $errors;
}
user_run('ConferenceSetup', 'User.tpl');