コード例 #1
0
ファイル: index.php プロジェクト: hardikk/HNH
 protected function _formatReportForExtension($smarty, $module_name, $extension, &$respuesta)
 {
     $voicePath = "/var/spool/asterisk/voicemail/default/{$extension}/INBOX";
     $result = is_dir($voicePath) ? glob("{$voicePath}/*.txt") : array();
     if (count($result) <= 0) {
         $respuesta['status'] = 'error';
         $respuesta['message'] = _tr("You don't recibed voicemails");
     } else {
         $clavesVM = array();
         foreach ($result as $archivo) {
             /* El archivo es formato ini, pero no estoy seguro de que 
              * sea completamente parseable por parse_ini_file() */
             $content = array();
             foreach (file($archivo) as $s) {
                 $regs = NULL;
                 if (preg_match('/^(\\w+)\\s*=\\s*(.*)/', trim($s), $regs)) {
                     $content[$regs[1]] = $regs[2];
                 }
             }
             $clavesVM[$content['origtime']] = $content;
         }
         krsort($clavesVM, SORT_STRING);
         $estadoVM = array();
         foreach (array_slice($clavesVM, 0, MAX_VM_RECORDS) as $content) {
             $estadoVM[] = str_replace(array('{source}', '{date}', '{duration}'), array($content['callerid'] == 'Unknown' ? _tr('unknow') : $content['callerid'], date('Y/m/d H:i:s', $content['origtime']), $content['duration']), _tr('voicemail recived'));
         }
         $respuesta['html'] = implode(".<br/>\n", $estadoVM) . ".<br/>\n";
     }
 }
コード例 #2
0
ファイル: index.php プロジェクト: hardikk/HNH
    protected function _formatReportForExtension($smarty, $module_name, $extension, &$respuesta)
    {
        $dsnAsteriskCDR = generarDSNSistema("asteriskuser", "asteriskcdrdb");
        $pDB = new paloDB($dsnAsteriskCDR);
        if (!empty($pDB->errMsg)) {
            $respuesta['status'] = 'error';
            $respuesta['message'] = _tr('Error at read yours calls.') . $pDB->errMsg;
        } else {
            $sql = <<<SQL_LLAMADAS_RECIBIDAS
SELECT calldate, src, duration, disposition FROM cdr
WHERE dst = ? OR SUBSTRING_INDEX(SUBSTRING_INDEX(dstchannel,'-',1),'/',-1) = ?
ORDER BY calldate DESC LIMIT ?
SQL_LLAMADAS_RECIBIDAS;
            $recordset = $pDB->fetchTable($sql, TRUE, array($extension, $extension, MAX_CALL_RECORDS));
            if (!is_array($recordset)) {
                $respuesta['status'] = 'error';
                $respuesta['message'] = _tr('Error at read yours calls.') . $pDB->errMsg;
            } elseif (count($recordset) <= 0) {
                $respuesta['html'] = _tr("You don't recibed calls");
            } else {
                $estadoLlamadas = array();
                foreach ($recordset as $tupla) {
                    $answ = $tupla['disposition'] == 'ANSWERED';
                    $estadoLlamadas[] = str_replace(array('{status}', '{date}', '{source}'), array($answ ? _tr('answered') : _tr('missed'), $tupla['calldate'], empty($tupla['src']) ? _tr('unknow') : $tupla['src']), _tr('call record')) . ($answ ? str_replace('{time}', $tupla['duration'], _tr('call duration')) : '.');
                }
                $respuesta['html'] = implode('<br/>', $estadoLlamadas);
            }
        }
    }
コード例 #3
0
ファイル: index.php プロジェクト: hardikk/HNH
function showApplets_Admin($module_name)
{
    global $smarty;
    global $arrLang;
    global $arrConf;
    $pAppletAdmin = new paloSantoAppletAdmin();
    $oForm = new paloForm($smarty, array());
    $arrApplets = $pAppletAdmin->getApplets_User($_SESSION["elastix_user"]);
    //Codigo para tomar en cuenta el nombre de applets para los archivos de idioma
    foreach ($arrApplets as &$applet) {
        $applet['name'] = _tr($applet['name']);
    }
    unset($applet);
    //
    $smarty->assign("applets", $arrApplets);
    $smarty->assign("SAVE", $arrLang["Save"]);
    $smarty->assign("CANCEL", $arrLang["Cancel"]);
    $smarty->assign("Applet", $arrLang["Applet"]);
    $smarty->assign("Activated", $arrLang["Activated"]);
    $smarty->assign("checkall", $arrLang["Check All"]);
    $smarty->assign("icon", "modules/{$module_name}/images/system_dashboard_applet_admin.png");
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/applet_admin.tpl", $arrLang["Dashboard Applet Admin"], $_POST);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}
コード例 #4
0
ファイル: index.php プロジェクト: hardikk/HNH
function listFax($smarty, $module_name, $local_templates_dir)
{
    $limit = 30;
    $oFax = new paloFax();
    $total = $oFax->getTotalFax();
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $oGrid->pagingShow(true);
    $oGrid->setURL("?menu=faxlist");
    $oGrid->setTitle(_tr("Virtual Fax List"));
    $oGrid->setIcon("/modules/{$module_name}/images/fax_virtual_fax_list.png");
    $arrColumns = array(_tr("Virtual Fax Name"), _tr("Fax Extension"), _tr("Secret"), _tr("Destination Email"), _tr("Caller ID Name"), _tr("Caller ID Number"), _tr("Status"));
    $oGrid->setColumns($arrColumns);
    $offset = $oGrid->calculateOffset();
    $arrFax = $oFax->getFaxList($offset, $limit);
    $arrFaxStatus = $oFax->getFaxStatus();
    $arrData = array();
    foreach ($arrFax as $fax) {
        $arrTmp = array();
        $arrTmp[0] = "&nbsp;<a href='?menu=faxnew&action=view&id=" . $fax['id'] . "'>" . $fax['name'] . "</a>";
        $arrTmp[1] = $fax['extension'];
        $arrTmp[2] = $fax['secret'];
        $arrTmp[3] = $fax['email'];
        $arrTmp[4] = $fax['clid_name'] . "&nbsp;";
        $arrTmp[5] = $fax['clid_number'] . "&nbsp;";
        $arrTmp[6] = $arrFaxStatus['modems']['ttyIAX' . $fax['dev_id']] . ' on ttyIAX' . $fax['dev_id'];
        $arrData[] = $arrTmp;
    }
    $session = getSession();
    $session['faxlist']['faxListStatus'] = $arrData;
    putSession($session);
    $oGrid->setData($arrData);
    return $oGrid->fetchGrid();
}
コード例 #5
0
 function setFaxMaster($email_account)
 {
     if (!preg_match("/^[a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*@[a-z0-9]+([\\._\\-]?[a-z0-9]+)*(\\.[a-z0-9]{2,6})+\$/", $email_account)) {
         $this->errMsg = _tr("Invalid Email Address");
         return false;
     }
     $this->_DB->beginTransaction();
     $query = "DELETE from settings WHERE property='fax_master'";
     if (!$this->_DB->genQuery($query)) {
         $this->_DB->rollBack();
         $this->_tr("DATABASE ERROR");
         return false;
     }
     $query = "INSERT INTO settings(property,value) VALUES(?,?)";
     if (!$this->_DB->genQuery($query, array('fax_master', $email_account))) {
         $this->_DB->rollBack();
         $this->_tr("DATABASE ERROR");
         return false;
     }
     //realizamos el cambios en los archivos del email
     if (!$this->modificar_archivos_mail($email_account)) {
         $this->_DB->rollBack();
         $this->errMsg = 'Error in mail configuration. ' . $this->errMsg;
         return false;
     } else {
         $this->_DB->commit();
         return true;
     }
 }
コード例 #6
0
ファイル: index.php プロジェクト: hardikk/HNH
 function handleJSON_dirspacereport($smarty, $module_name, $appletlist)
 {
     $respuesta = array('status' => 'success', 'message' => '(no message)');
     // Lista de directorios a buscar
     $listaReporteDir = array('logs' => array('dir' => '/var/log', 'tag' => _tr('Logs'), 'use' => 'N/A'), 'backups' => array('dir' => '/var/www/backup', 'tag' => _tr('Local Backups'), 'use' => 'N/A'), 'emails' => array('dir' => '/var/spool/imap', 'tag' => _tr('Emails'), 'use' => 'N/A'), 'config' => array('dir' => '/etc', 'tag' => _tr('Configuration'), 'use' => 'N/A'), 'voicemails' => array('dir' => '/var/spool/asterisk/voicemail', 'tag' => _tr('Voicemails'), 'use' => 'N/A'), 'recordings' => array('dir' => '/var/spool/asterisk/monitor', 'tag' => _tr('Recordings'), 'use' => 'N/A'));
     /* Se cierra la sesión para quitar el candado sobre la sesión y permitir
      * que otras operaciones ajax puedan funcionar mientras se espera el 
      * reporte de espacio por directorio. */
     session_commit();
     $pipe_dirspace = popen('/usr/bin/elastix-helper dirspacereport', 'r');
     while ($s = fgets($pipe_dirspace)) {
         $s = trim($s);
         $l = explode(' ', $s);
         if (count($l) > 1 && isset($listaReporteDir[$l[0]])) {
             $listaReporteDir[$l[0]]['use'] = $l[1];
         }
     }
     pclose($pipe_dirspace);
     @session_start();
     $smarty->assign('listaReporteDir', $listaReporteDir);
     $local_templates_dir = dirname($_SERVER['SCRIPT_FILENAME']) . "/modules/{$module_name}/applets/HardDrives/tpl";
     $respuesta['html'] = $smarty->fetch("{$local_templates_dir}/dirspacereport.tpl");
     $json = new Services_JSON();
     Header('Content-Type: application/json');
     return $json->encode($respuesta);
 }
コード例 #7
0
 function getApplets_User($user)
 {
     global $arrConf;
     $dsn = "sqlite3:///{$arrConf['elastix_dbdir']}/dashboard.db";
     $pDB = new paloDB($dsn);
     $pDB2 = new paloDB($arrConf['elastix_dsn']['elastix']);
     $pACL = new paloACL($pDB2);
     if ($pACL->isUserSuperAdmin($user)) {
         $typeUser = "******";
     } else {
         $typeUser = "******";
     }
     $query = "\n                select\n                    t1.id id,\n                    t1.name name,\n                    ifnull(t2.activated,0) activated,\n                    ifnull(t2.order_no,0) order_no\n                from\n                    (select\n                        dau.id id,\n                        a.name name\n                     from\n                        applet a\n                            inner join\n                        default_applet_by_user dau on a.id=dau.id_applet\n                    where\n                        dau.username=?) t1\n                left join\n                    (select\n                        aau.id_dabu id_dabu,\n                        aau.id activated,\n                        aau.order_no order_no\n                     from\n                        activated_applet_by_user aau\n                     where\n                        aau.username=?) t2\n                on\n                    t1.id=t2.id_dabu\n                order by\n                    t1.id asc;";
     $result = $pDB->fetchTable($query, true, array($typeUser, $user));
     if ($result == FALSE) {
         $this->errMsg = $pDB->errMsg;
         return array();
     } else {
         $applets = array();
         foreach ($result as $value) {
             $value['name'] = _tr($value['name']);
             $applets[] = $value;
         }
         return $applets;
     }
 }
コード例 #8
0
ファイル: index.php プロジェクト: hardikk/HNH
    protected function _formatReportForExtension($smarty, $module_name, $extension, &$respuesta)
    {
        global $arrConf;
        $dbFax = new paloDB("sqlite3:///{$arrConf['elastix_dbdir']}/fax.db");
        $sql = <<<SQL_FAXES_EXTENSION
SELECT a.pdf_file, a.company_name, a.date, a.id
FROM info_fax_recvq a, fax b
WHERE b.extension = ? AND b.id = a.fax_destiny_id AND type='in'
ORDER BY a.id desc LIMIT ?
SQL_FAXES_EXTENSION;
        $recordset = $dbFax->fetchTable($sql, TRUE, array($extension, MAX_FAX_RECORDS));
        if (!is_array($recordset)) {
            $recordset = array();
        }
        if (count($recordset) <= 0) {
            $respuesta['status'] = 'error';
            $respuesta['message'] = _tr("You don't recibed faxes");
        } else {
            $estadoFaxes = array();
            foreach ($recordset as $tupla) {
                $estadoFaxes[] = str_replace(array('{file}', '{source}', '{date}'), array("<a href='?menu=faxviewer&action=download&rawmode=yes&id={$tupla['id']}'>{$tupla['pdf_file']}</a>", $tupla['company_name'] == 'XXXXXXX' ? _tr('unknow') : $tupla['company_name'], $tupla['date']), _tr('fax recived'));
            }
            $respuesta['html'] = implode("<br/>\n", $estadoFaxes);
        }
    }
コード例 #9
0
ファイル: index.php プロジェクト: hardikk/HNH
function _moduleContent(&$smarty, $module_name)
{
    require_once "modules/{$module_name}/libs/contentFreePBX.php";
    $smarty->assign("title", _tr("PBX Configuration"));
    $smarty->assign("icon", "/modules/{$module_name}/images/pbx_configuration.png");
    $salida = getContent($smarty, $module_name, true);
    return $salida;
}
コード例 #10
0
function viewFormInstant_Messaging($smarty, $module_name, $local_templates_dir, $arrConf)
{
    $smarty->assign("icon", "modules/{$module_name}/images/instant_messaging.png");
    $smarty->assign("imess1_img", "modules/{$module_name}/images/spark.jpg");
    $smarty->assign("tag_manuf_description", _tr("Manufacturer Description"));
    $smarty->assign("download_link", _tr("Download Link"));
    $smarty->assign("tag_manufacturer", _tr("Manufacturer"));
    $smarty->assign("imess1_software_description", _tr("spark_software_description"));
    $smarty->assign("imess1_manufacturer_description", _tr("spark_manufacturer_description"));
    $oForm = new paloForm($smarty, array());
    $content = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Instant Messaging"));
    return $content;
}
コード例 #11
0
 function getFaxExtensionUser($idUser)
 {
     $query = "SELECT fax_extension FROM acl_user WHERE id=?";
     $result = $this->_DB->getFirstRowQuery($query, false, array($idUser));
     if ($result === false) {
         $this->errMsg = _tr("DATABASE ERROR");
         return false;
     } elseif (count($result) == 0) {
         $this->errMsg = _tr("User does not exist");
         return false;
     }
     return $result[0];
 }
コード例 #12
0
function viewFormSoftphones($smarty, $module_name, $local_templates_dir, $arrConf)
{
    $smarty->assign("icon", "modules/{$module_name}/images/softphones.png");
    $smarty->assign("xlite_img", "modules/{$module_name}/images/x-lite-4-lrg.png");
    $smarty->assign("zoiper_img", "modules/{$module_name}/images/zoiper.png");
    $smarty->assign("tag_manuf_description", _tr("Manufacturer Description"));
    $smarty->assign("download_link", _tr("Download Link"));
    $smarty->assign("tag_manufacturer", _tr("Manufacturer"));
    $smarty->assign("xlite_software_description", _tr("xlite_software_description"));
    $smarty->assign("xlite_manufacturer_description", _tr("xlite_manufacturer_description"));
    $smarty->assign("zoiper_software_description", _tr("zoiper_software_description"));
    $smarty->assign("zoiper_manufacturer_description", _tr("zoiper_manufacturer_description"));
    $oForm = new paloForm($smarty, array());
    $content = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Softphones"), array());
    return $content;
}
コード例 #13
0
function viewFormFax_Utilities($smarty, $module_name, $local_templates_dir, $arrConf)
{
    $smarty->assign("icon", "modules/{$module_name}/images/fax_utilities.png");
    $smarty->assign("fax1_img", "modules/{$module_name}/images/jhylafax.jpg");
    $smarty->assign("fax2_img", "modules/{$module_name}/images/winprinthylafax.jpg");
    $smarty->assign("tag_manuf_description", _tr("Manufacturer Description"));
    $smarty->assign("download_link", _tr("Download Link"));
    $smarty->assign("tag_manufacturer", _tr("Manufacturer"));
    $smarty->assign("fax1_software_description", _tr("jhylafax_software_description"));
    $smarty->assign("fax1_manufacturer_description", _tr("jhylafax_manufacturer_description"));
    $smarty->assign("fax2_software_description", _tr("winprint_software_description"));
    $smarty->assign("fax2_manufacturer_description", _tr("winprint_manufacturer_description"));
    $oForm = new paloForm($smarty, array());
    $content = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Fax Utilities"), array());
    return $content;
}
コード例 #14
0
ファイル: index.php プロジェクト: hardikk/HNH
 function handleJSON_getContent($smarty, $module_name, $appletlist)
 {
     $respuesta = array('status' => 'success', 'message' => '(no message)');
     // Leer credenciales a partir del usuario y el perfil asociado
     global $arrConf;
     $dbAcl = new paloDB($arrConf["elastix_dsn"]["acl"]);
     $pACL = new paloACL($dbAcl);
     $userId = $pACL->getIdUser($_SESSION['elastix_user']);
     $listaEventos = $this->_leerRegistrosEventos($userId);
     $listaEventosDias = $this->_expandirRegistrosEventos($listaEventos);
     $smarty->assign(array('NO_EVENTOS' => _tr("You don't have events"), 'EVENTOS_DIAS' => $listaEventosDias, 'tag_date' => _tr("Date"), 'tag_call' => _tr("Call")));
     $local_templates_dir = dirname($_SERVER['SCRIPT_FILENAME']) . "/modules/{$module_name}/applets/Calendar/tpl";
     $respuesta['html'] = $smarty->fetch("{$local_templates_dir}/calendar_events.tpl");
     $json = new Services_JSON();
     Header('Content-Type: application/json');
     return $json->encode($respuesta);
 }
コード例 #15
0
ファイル: themesetup.php プロジェクト: lordbasex/elastix-gui
function themeSetup(&$smarty, $selectedMenu, $pdbACL, $pACL, $idUser)
{
    /* El tema elastixneo muestra hasta 7 items de menú de primer nivel, y 
     * coloca el resto en una lista desplegable a la derecha del último item. 
     * Se debe de garantizar que el item actualmente seleccionado aparezca en 
     * un menú de primer nivel que esté entre los 7 primeros, reordenando los 
     * items si es necesario. */
    $lang = get_language();
    $arrMainMenu = $smarty->get_template_vars('arrMainMenu');
    foreach ($arrMainMenu as $idMenu => $arrMenuItem) {
        $arrMainMenu[$idMenu]['icon'] = setIcon($idMenu);
    }
    $idMainMenuSelected = $smarty->get_template_vars('idMainMenuSelected');
    $MAX_ITEMS_VISIBLES = 7;
    if (count($arrMainMenu) > $MAX_ITEMS_VISIBLES) {
        // Se transfiere a arreglo numérico para manipular orden de enumeración
        $tempMenulist = array();
        $idxMainMenu = NULL;
        foreach ($arrMainMenu as $key => $value) {
            if ($key == $idMainMenuSelected) {
                $idxMainMenu = count($tempMenulist);
            }
            $tempMenulist[] = array($key, $value);
        }
        if (!is_null($idxMainMenu) && $idxMainMenu >= $MAX_ITEMS_VISIBLES) {
            $menuitem = array_splice($tempMenulist, $idxMainMenu, 1);
            array_splice($tempMenulist, $MAX_ITEMS_VISIBLES - 1, 0, $menuitem);
            $arrMainMenu = array();
            foreach ($tempMenulist as $menuitem) {
                $arrMainMenu[$menuitem[0]] = $menuitem[1];
            }
        }
        unset($tempMenulist);
    }
    $smarty->assign('arrMainMenu', $arrMainMenu);
    $smarty->assign("LANG", $lang);
    $smarty->assign(array("ABOUT_ELASTIX2" => _tr('About Elastix2'), "HELP" => _tr('HELP'), "USER_LOGIN" => $_SESSION['elastix_user'], "USER_ID" => $idUser, "CURRENT_PASSWORD_ALERT" => _tr("Please write your current password."), "NEW_RETYPE_PASSWORD_ALERT" => _tr("Please write the new password and confirm the new password."), "PASSWORDS_NOT_MATCH" => _tr("The new password doesn't match with retype password."), "CHANGE_PASSWORD" => _tr("Change Elastix Password"), "CURRENT_PASSWORD" => _tr("Current Password"), "NEW_PASSWORD" => _tr("New Password"), "RETYPE_PASSWORD" => _tr("Retype New Password"), "CHANGE_PASSWORD_BTN" => _tr("Change"), "MODULES_SEARCH" => _tr("Search modules"), "ADD_BOOKMARK" => _tr("Add Bookmark"), "REMOVE_BOOKMARK" => _tr("Remove Bookmark"), "ADDING_BOOKMARK" => _tr("Adding Bookmark"), "REMOVING_BOOKMARK" => _tr("Removing Bookmark"), "HIDING_IZQTAB" => _tr("Hiding left panel"), "SHOWING_IZQTAB" => _tr("Loading left panel"), "HIDE_IZQTAB" => _tr("Hide left panel"), "SHOW_IZQTAB" => _tr("Load left panel"), 'viewMenuTab' => getStatusNeoTabToggle($pdbACL, $idUser), 'MENU_COLOR' => getMenuColorByMenu($pdbACL, $idUser), 'IMG_BOOKMARKS' => menuIsBookmark($pdbACL, $idUser, $selectedMenu) ? 'bookmarkon.png' : 'bookmark.png', 'SHORTCUT' => loadShortcut($pdbACL, $idUser, $smarty), 'STATUS_STICKY_NOTE' => 'false', 'BREADCRUMB' => setBreadcrumb($arrMainMenu, $selectedMenu)));
    // se obtiene si ese menu tiene una nota agregada
    $statusStickyNote = getStickyNote($pdbACL, $idUser, $selectedMenu);
    if ($statusStickyNote['status'] && $statusStickyNote['data'] != "") {
        $smarty->assign('STATUS_STICKY_NOTE', 'true');
        if ($statusStickyNote['popup'] == 1) {
            $smarty->assign('AUTO_POPUP', '1');
        }
    }
}
コード例 #16
0
ファイル: index.php プロジェクト: hardikk/HNH
 function handleJSON_getContent($smarty, $module_name, $appletlist)
 {
     $respuesta = array('status' => 'success', 'message' => '(no message)');
     $smarty->assign(array('LABEL_CPU' => _tr('CPU'), 'LABEL_RAM' => _tr('RAM'), 'LABEL_SWAP' => _tr('SWAP'), 'LABEL_CPUINFO' => _tr('CPU Info'), 'LABEL_UPTIME' => _tr('Uptime'), 'LABEL_CPUSPEED' => _tr('CPU Speed'), 'LABEL_MEMORYUSE' => _tr('Memory usage')));
     $cpu_a = $this->obtener_muestra_actividad_cpu();
     $fastgauge = $this->_getFastGraphics();
     $cpuinfo = $this->getCPUInfo();
     $speed = number_format($cpuinfo['CpuMHz'], 2) . " MHz";
     $cpu_info = $cpuinfo['CpuModel'];
     $meminfo = $this->getMemInfo();
     //MEMORY USAGE
     $fraction_mem_used = ($meminfo['MemTotal'] - $meminfo['MemFree'] - $meminfo['Cached'] - $meminfo['MemBuffers']) / $meminfo['MemTotal'];
     $inf2 = number_format($meminfo['MemTotal'] / 1024, 2) . " Mb";
     //SWAP USAGE
     $fraction_swap_used = ($meminfo['SwapTotal'] - $meminfo['SwapFree']) / $meminfo['SwapTotal'];
     $inf3 = number_format($meminfo['SwapTotal'] / 1024, 2) . " Mb";
     //UPTIME
     $upfields = array();
     $up = $this->getUptime();
     // Segundos de actividad desde arranque
     $upfields[] = $up % 60;
     $up = ($up - $upfields[0]) / 60;
     $upfields[] = $up % 60;
     $up = ($up - $upfields[1]) / 60;
     $upfields[] = $up % 24;
     $up = ($up - $upfields[2]) / 24;
     $upfields[] = $up;
     $uptime = $upfields[1] . ' ' . _tr('minute(s)');
     if ($upfields[2] > 0) {
         $uptime = $upfields[2] . ' ' . _tr('hour(s)') . ' ' . $uptime;
     }
     if ($upfields[3] > 0) {
         $uptime = $upfields[3] . ' ' . _tr('day(s)') . ' ' . $uptime;
     }
     usleep(200000);
     $cpu_b = $this->obtener_muestra_actividad_cpu();
     $fraction_cpu_used = $this->calcular_carga_cpu_intervalo($cpu_a, $cpu_b);
     $_SESSION[$module_name]['cpusample'] = $cpu_b;
     $smarty->assign(array('fastgauge' => $fastgauge, 'cpu_info' => $cpu_info, 'uptime' => $uptime, 'speed' => $speed, 'memtotal' => $inf2, 'swaptotal' => $inf3));
     $smarty->assign($this->_formatGauges($fraction_cpu_used, $fraction_mem_used, $fraction_swap_used));
     $local_templates_dir = dirname($_SERVER['SCRIPT_FILENAME']) . "/modules/{$module_name}/applets/SystemResources/tpl";
     $respuesta['html'] = $smarty->fetch("{$local_templates_dir}/system_resources.tpl");
     $json = new Services_JSON();
     Header('Content-Type: application/json');
     return $json->encode($respuesta);
 }
コード例 #17
0
ファイル: index.php プロジェクト: lordbasex/elastix-gui
 private function _sampler_CallsMemoryCPU()
 {
     $arrayResult = array();
     $oSampler = new paloSampler();
     //retorna
     //Array ( [0] => Array ( [id] => 1 [name] => Sim. calls [color] => #00cc00 [line_type] => 1 )
     $arrLines = $oSampler->getGraphLinesById(1);
     //retorna
     //Array ( [name] => Simultaneous calls, memory and CPU )
     $arrGraph = $oSampler->getGraphById(1);
     $endtime = time();
     $starttime = $endtime - 26 * 60 * 60;
     $oSampler->deleteDataBeforeThisTimestamp($starttime);
     $arrayResult['ATTRIBUTES'] = array('TITLE' => utf8_decode(_tr($arrGraph['name'])), 'TYPE' => 'lineplot_multiaxis', 'LABEL_X' => 'Etiqueta X', 'LABEL_Y' => 'Etiqueta Y', 'SHADOW' => false, 'SIZE' => "450,260", 'MARGIN' => "50,110,30,120", 'COLOR' => "#fafafa", 'POS_LEYEND' => "0.35,0.85");
     $arrayResult['MESSAGES'] = array('ERROR' => 'Error', 'NOTHING_SHOW' => _tr('Nothing to show yet'));
     //$oSampler->getSamplesByLineId(1)
     //retorna
     //Array ( [0] => Array ( [timestamp] => 1230562202 [value] => 2 ), .......
     $i = 1;
     $arrData = array();
     foreach ($arrLines as $num => $line) {
         $arraySample = $oSampler->getSamplesByLineId($line['id']);
         $arrDat_N = array();
         $arrValues = array();
         foreach ($arraySample as $num => $time_value) {
             $arrValues[$time_value['timestamp']] = (int) $time_value['value'];
         }
         $arrStyle = array();
         $arrStyle['COLOR'] = $line['color'];
         $arrStyle['LEYEND'] = utf8_decode(_tr($line['name']));
         $arrStyle['STYLE_STEP'] = true;
         $arrStyle['FILL_COLOR'] = $i == 1 ? true : false;
         $arrDat_N["VALUES"] = $arrValues;
         $arrDat_N["STYLE"] = $arrStyle;
         if (count($arrValues) > 1) {
             $arrData["DAT_{$i}"] = $arrDat_N;
         } else {
             $arrData["DAT_{$i}"] = array();
         }
         $i++;
     }
     $arrayResult['DATA'] = $arrData;
     $arrayResult['FORMAT_CALLBACK'] = array($this, 'functionCallback');
     return $arrayResult;
 }
コード例 #18
0
function _moduleContent(&$smarty, $module_name)
{
    //folder path for custom templates
    $local_templates_dir = getWebDirModule($module_name);
    $smarty->assign("title", _tr("Channels Usage Report"));
    $smarty->assign("icon", "web/apps/{$module_name}/images/reports_channel_usage.png");
    if (isset($_GET['image'])) {
        $_GET['image'] = (int) $_GET['image'];
        displayGraph($module_name, "paloSantoChannelUsage", "channelsUsage", array($_GET['image']), "functionCallback");
    } else {
        $listaGraficos = array('img_1' => 2, 'img_2' => 3, 'img_3' => 4, 'img_4' => 5, 'img_5' => 6, 'img_6' => 7);
        foreach (array_keys($listaGraficos) as $k) {
            $listaGraficos[$k] = "<img alt=\"{$listaGraficos[$k]}\" src=\"?menu={$module_name}&amp;image={$listaGraficos[$k]}&rawmode=yes\" />";
        }
        $smarty->assign($listaGraficos);
        return $smarty->fetch("{$local_templates_dir}/channelusage.tpl");
    }
}
コード例 #19
0
ファイル: index.php プロジェクト: hardikk/HNH
 protected function leerInformacionImap($smarty, $module_name, $imap, &$respuesta)
 {
     $smarty->assign(array('NO_EMAILS' => _tr("You don't recibed emails")));
     $mails = array();
     $tmp = imap_check($imap);
     if ($tmp->Nmsgs > 0) {
         $result = imap_fetch_overview($imap, "1:{$tmp->Nmsgs}", 0);
         foreach ($result as $overview) {
             if (!($overview->seen || $overview->answered)) {
                 $mails[] = array('seen' => $overview->seen, 'recent' => $overview->recent, 'answered' => $overview->answered, 'date' => $overview->date, 'from' => $overview->from, 'subject' => $overview->subject);
             }
         }
         $mails = array_reverse(array_slice($mails, -1 * MAX_EMAIL_RECORDS, MAX_EMAIL_RECORDS));
     }
     $smarty->assign('mails', $mails);
     $local_templates_dir = dirname($_SERVER['SCRIPT_FILENAME']) . "/modules/{$module_name}/applets/Emails/tpl";
     $respuesta['html'] = $smarty->fetch("{$local_templates_dir}/emails.tpl");
 }
コード例 #20
0
 function channelsUsage($id)
 {
     $arrayResult = array();
     $oSampler = new paloSampler();
     //retorna
     //Array ( [0] => Array ( [id] => 1 [name] => Sim. calls [color] => #00cc00 [line_type] => 1 )
     $arrLines = $oSampler->getGraphLinesById($id);
     //retorna
     //Array ( [name] => Simultaneous calls, memory and CPU )
     $arrGraph = $oSampler->getGraphById($id);
     $endtime = time();
     $starttime = $endtime - 26 * 60 * 60;
     $oSampler->deleteDataBeforeThisTimestamp($starttime);
     $arrayResult['ATTRIBUTES'] = array('TITLE' => str_ireplace('zap', 'DAHDI', $arrGraph['name']), 'TYPE' => 'lineplot', 'LABEL_X' => "", 'LABEL_Y' => '', 'SHADOW' => false, 'SIZE' => "570,170", 'MARGIN' => "50,140,30,50", 'COLOR' => "#fafafa", 'POS_LEYEND' => "0.02,0.5");
     $arrayResult['MESSAGES'] = array('ERROR' => 'Error', 'NOTHING_SHOW' => _tr('Nothing to show yet'));
     //$oSampler->getSamplesByLineId(1)
     //retorna
     //Array ( [0] => Array ( [timestamp] => 1230562202 [value] => 2 ), .......
     $i = 1;
     $arrData = array();
     foreach ($arrLines as $num => $line) {
         $arraySample = $oSampler->getSamplesByLineId($line['id']);
         $arrDat_N = array();
         $arrValues = array();
         foreach ($arraySample as $num => $time_value) {
             $arrValues[$time_value['timestamp']] = (int) $time_value['value'];
         }
         $arrStyle = array();
         $arrStyle['COLOR'] = $line['color'];
         $arrStyle['LEYEND'] = str_ireplace('zap', 'DAHDI', $line['name']);
         $arrStyle['STYLE_STEP'] = true;
         $arrStyle['FILL_COLOR'] = false;
         $arrDat_N["VALUES"] = $arrValues;
         $arrDat_N["STYLE"] = $arrStyle;
         if (count($arrValues) > 1) {
             $arrData["DAT_{$i}"] = $arrDat_N;
         } else {
             $arrData["DAT_{$i}"] = array();
         }
         $i++;
     }
     $arrayResult['DATA'] = $arrData;
     return $arrayResult;
 }
コード例 #21
0
ファイル: index.php プロジェクト: hardikk/HNH
function _moduleContent(&$smarty, $module_name)
{
    $lang = get_language();
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $lang_file = "modules/{$module_name}/lang/{$lang}.lang";
    if (file_exists("{$base_dir}/{$lang_file}")) {
        include_once "{$lang_file}";
    } else {
        include_once "modules/{$module_name}/lang/en.lang";
    }
    //global variables
    global $arrLang;
    global $arrLangModule;
    $arrLang = array_merge($arrLang, $arrLangModule);
    $smarty->assign("title", _tr("VoIP Provider"));
    $smarty->assign("icon", "images/list.png");
    $smarty->assign("mb_title", _tr("Message"));
    $smarty->assign("mb_message", _tr("This module was removed from the package elastix-pbx and it was created as an Addon. This menu will be completely removed in the future. If you want it back please go to the Addons module and install it or click here."));
    return "";
}
コード例 #22
0
function _moduleContent(&$smarty, $module_name)
{
    global $arrConf;
    //folder path for custom templates
    $local_templates_dir = getWebDirModule($module_name);
    $txtCommand = isset($_POST['txtCommand']) ? trim($_POST['txtCommand']) : '';
    $oForm = new paloForm($smarty, array());
    $smarty->assign(array('asterisk' => _tr('Asterisk CLI'), 'command' => _tr('Command'), 'txtCommand' => htmlspecialchars($txtCommand), 'execute' => _tr('Execute'), 'icon' => "web/apps/{$module_name}/images/pbx_tools_asterisk_cli.png"));
    $result = "";
    if (!empty($txtCommand)) {
        $output = $retval = NULL;
        exec("/usr/sbin/asterisk -rnx " . escapeshellarg($txtCommand), $output, $retval);
        $result = '<pre>' . implode("\n", array_map('htmlspecialchars', $output)) . '</pre>';
    }
    if ($result == "") {
        $result = "&nbsp;";
    }
    $smarty->assign("RESPUESTA_SHELL", $result);
    return $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr('Asterisk-Cli'), $_POST);
}
コード例 #23
0
ファイル: index.php プロジェクト: lordbasex/elastix-gui
function shutdown($smarty, $module_name, $local_templates_dir, $arrPermission, $arrCredentiasls)
{
    $smarty->assign("SHUTDOWN_PROGRESS", _tr("Shutdown in progress"));
    $smarty->assign("MSG_LINK", _tr("Continue"));
    if ($_POST['shutdown_mode'] == '1') {
        $smarty->assign("SHUTDOWN_MSG", _tr("Your system in shutting down now. Please, try again later."));
        exec("sudo -u root /sbin/shutdown -h now", $salida, $retorno);
        $salida = $smarty->fetch("file:{$local_templates_dir}/shutdown_in_progress.tpl");
    } else {
        if ($_POST['shutdown_mode'] == '2') {
            $smarty->assign("SHUTDOWN_MSG", _tr("The reboot signal has been sent correctly."));
            exec("sudo -u root /sbin/shutdown -r now", $salida, $retorno);
            $salida = $smarty->fetch("file:{$local_templates_dir}/shutdown_in_progress.tpl");
        } else {
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", _tr("Invalid Mode"));
            return showModule($smarty, $module_name, $local_templates_dir, $arrPermission, $arrCredentiasls);
        }
    }
}
コード例 #24
0
function _moduleContent(&$smarty, $module_name)
{
    //global variables
    global $arrConf;
    //folder path for custom templates
    $local_templates_dir = getWebDirModule($module_name);
    $smarty->assign("title", _tr("Incoming Email"));
    $smarty->assign("icon", "../web/_common/images/bardoc.png");
    if (isset($_GET['image'])) {
        $_GET['image'] = (int) $_GET['image'];
        displayGraph($module_name, "paloSantoPostfixStats", "postfixStats", array($_GET['image']), "functionCallback");
    } else {
        $listaGraficos = array('img_1' => 0, 'img_2' => 1, 'img_3' => 2);
        foreach (array_keys($listaGraficos) as $k) {
            $listaGraficos[$k] = "<img alt=\"{$listaGraficos[$k]}\" src=\"?menu={$module_name}&amp;image={$listaGraficos[$k]}&rawmode=yes\" />";
        }
        $smarty->assign($listaGraficos);
        return $smarty->fetch("{$local_templates_dir}/form.tpl");
    }
}
コード例 #25
0
 function handleJSON_getContent($smarty, $module_name, $appletlist)
 {
     $respuesta = array('status' => 'success', 'message' => '(no message)');
     // Obtener extensión del usuario logoneado
     global $arrConf;
     $dbAcl = new paloDB($arrConf["elastix_dsn"]["acl"]);
     $pACL = new paloACL($dbAcl);
     $extension = $pACL->getUserExtension($_SESSION["elastix_user"]);
     if (empty($extension) || !ctype_digit($extension)) {
         $respuesta['status'] = 'error';
         $respuesta['message'] = _tr("You haven't extension");
         if (!empty($pACL->errMsg)) {
             $respuesta['message'] = $pACL->errMsg;
         }
     } else {
         $this->_formatReportForExtension($smarty, $module_name, $extension, $respuesta);
     }
     $json = new Services_JSON();
     Header('Content-Type: application/json');
     return $json->encode($respuesta);
 }
コード例 #26
0
 function __construct()
 {
     global $arrConf;
     $this->_actionid = get_class($this) . '-' . posix_getpid();
     foreach (array('phones', 'dahdi', 'iptrunks', 'conferences', 'parkinglots', 'queues') as $k) {
         $this->_internalState[$k] = array();
     }
     $this->_internalState['dahdi'] = array('chan2span' => array(), 'spans' => array());
     $this->_db = new paloDB($arrConf['elastix_dsn']["elastix"]);
     if ($this->_db->errMsg != '') {
         $this->_errMsg = $this->_db->errMsg;
         $this->_db = NULL;
         return;
     }
     $this->_dbConfig = new paloDB($arrConf['dsn_conn_database']);
     if ($this->_dbConfig->errMsg != '') {
         $this->_errMsg = $this->_dbConfig->errMsg;
         $this->_dbConfig = NULL;
         return;
     }
     $this->_ami = new AGI_AsteriskManager2();
     if (!$this->_ami->connect('localhost', 'admin', obtenerClaveAMIAdmin())) {
         $this->_errMsg = _tr("Error when connecting to Asterisk Manager");
         $this->_ami = NULL;
         return;
     }
     // Instalar todos los manejadores según el nombre del método
     foreach (get_class_methods(get_class($this)) as $sMetodo) {
         $regs = NULL;
         if (preg_match('/^msg_(.+)$/', $sMetodo, $regs)) {
             if ($regs[1] != 'Default') {
                 $this->_ami->add_event_handler($regs[1], array($this, $sMetodo));
             }
         }
     }
     if ($this->_debug && method_exists($this, 'msg_Default')) {
         $this->_ami->add_event_handler('*', array($this, 'msg_Default'));
     }
 }
コード例 #27
0
ファイル: index.php プロジェクト: hardikk/HNH
function _moduleContent(&$smarty, $module_name)
{
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    //include file language agree to elastix configuration
    //if file language not exists, then include language by default (en)
    $lang = get_language();
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $lang_file = "modules/{$module_name}/lang/{$lang}.lang";
    if (file_exists("{$base_dir}/{$lang_file}")) {
        include_once "{$lang_file}";
    } else {
        include_once "modules/{$module_name}/lang/en.lang";
    }
    //global variables
    global $arrConf;
    global $arrConfModule;
    global $arrLang;
    global $arrLangModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    $arrLang = array_merge($arrLang, $arrLangModule);
    //folder path for custom templates
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    $smarty->assign("title", _tr("Incoming Email"));
    $smarty->assign("icon", "images/bardoc.png");
    if (isset($_GET['image'])) {
        $_GET['image'] = (int) $_GET['image'];
        displayGraph($module_name, "paloSantoPostfixStats", "postfixStats", array($_GET['image']), "functionCallback");
    } else {
        $listaGraficos = array('img_1' => 0, 'img_2' => 1, 'img_3' => 2);
        foreach (array_keys($listaGraficos) as $k) {
            $listaGraficos[$k] = "<img alt=\"{$listaGraficos[$k]}\" src=\"?menu={$module_name}&amp;image={$listaGraficos[$k]}&rawmode=yes\" />";
        }
        $smarty->assign($listaGraficos);
        return $smarty->fetch("{$local_templates_dir}/form.tpl");
    }
}
コード例 #28
0
ファイル: index.php プロジェクト: lordbasex/elastix-gui
 function handleJSON_getContent($smarty, $module_name, $appletlist)
 {
     $respuesta = array('status' => 'success', 'message' => '(no message)');
     define('MAGPIE_CACHE_DIR', '/tmp/rss-cache');
     define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
     $infoRSS = @fetch_rss('http://elastix.org/index.php?option=com_mediarss&feed_id=1&format=raw');
     $sMensaje = magpie_error();
     if (strpos($sMensaje, 'HTTP Error: connection failed') !== FALSE) {
         $respuesta['status'] = 'error';
         $respuesta['message'] = _tr('Could not get web server information. You may not have internet access or the web server is down');
     } else {
         // Formato de fecha y hora
         for ($i = 0; $i < count($infoRSS->items); $i++) {
             $infoRSS->items[$i]['date_format'] = date('Y.m.d', $infoRSS->items[$i]['date_timestamp']);
         }
         $smarty->assign(array('WEBSITE' => 'http://www.elastix.org', 'NO_NEWS' => _tr('No News to display'), 'NEWS_LIST' => array_slice($infoRSS->items, 0, 7)));
         $local_templates_dir = getWebDirModule($module_name) . "/applets/News/tpl";
         $respuesta['html'] = $smarty->fetch("{$local_templates_dir}/rssfeed.tpl");
     }
     $json = new Services_JSON();
     Header('Content-Type: application/json');
     return $json->encode($respuesta);
 }
コード例 #29
0
    /**
     * Procedimiento para contar las llamadas relacionadas a una extensión, 
     * desglosadas por dirección. 
     * 
     * @param   string  $date_ini   Fecha inicial yyyy-mm-dd
     * @param   string  $date_fin   Fecha final yyyy-mm-dd
     * @param   string  $ext        Extensión a consultar
     * 
     * @return  mixed   NULL en caso de error, o tupla (num_incoming_call, num_outgoing_call)
     */
    function countCallsByExtension($date_ini, $date_fin, $ext)
    {
        if (trim($ext) == '') {
            $this->errMsg = _tr('Invalid extension');
            return NULL;
        }
        $paramSQL = array($ext, $ext, $ext, $ext, $date_ini . ' 00:00:00', $date_fin . ' 23:59:59');
        $sql = <<<COUNT_CALLS_BY_EXTENSION
SELECT
    SUM(IF(dst = ? OR SUBSTRING_INDEX(SUBSTRING_INDEX(dstchannel,'-',1),'/',-1) = ?, 1, 0))
        AS num_incoming_call,
    SUM(IF(src = ? OR SUBSTRING_INDEX(SUBSTRING_INDEX(channel,'-',1),'/',-1) = ?, 1, 0))
        AS num_outgoing_call
FROM cdr
WHERE calldate BETWEEN ? AND ?
COUNT_CALLS_BY_EXTENSION;
        $result = $this->_DB->getFirstRowQuery($sql, TRUE, $paramSQL);
        if (!is_array($result)) {
            $this->errMsg = $this->_DB->errMsg;
            return NULL;
        }
        return $result;
    }
コード例 #30
0
ファイル: index.php プロジェクト: lordbasex/elastix-gui
function dettachFile($smarty, $module_name, $local_templates_dir, $arrConf, &$pImap)
{
    $jsonObject = new PaloSantoJSON();
    $idAttach = getParameter('idAttach');
    try {
        if (is_string($idAttach) && $idAttach != '') {
            if (!defined("PATH_UPLOAD_ATTACHS")) {
                throw new RuntimeException(_tr("Error uploading your file.") . _tr("Temporary directory does not exist"));
            }
            if (!is_dir(PATH_UPLOAD_ATTACHS)) {
                throw new RuntimeException(_tr("Error uploading your file.") . _tr("Temporary directory does not exist"));
            }
            $filename = $_SESSION['elastix_emailAttachs'][$idAttach]['filename'];
            $name = basename($filename);
            if (is_file(PATH_UPLOAD_ATTACHS . "/{$name}")) {
                unlink(PATH_UPLOAD_ATTACHS . "/{$name}");
            }
        }
    } catch (RuntimeException $e) {
        $jsonObject->set_error($e->getMessage());
    }
    return $jsonObject->createJSON();
}