示例#1
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);
        }
    }
 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;
     }
 }
示例#3
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);
            }
        }
    }
示例#4
0
文件: index.php 项目: hardikk/HNH
    private function _leerRegistrosEventos($idUser)
    {
        global $arrConf;
        $db = new paloDB("sqlite3:///{$arrConf['elastix_dbdir']}/calendar.db");
        $sql = <<<SQL_EVENTOS
SELECT id, subject, asterisk_call, startdate, enddate, starttime, endtime, eventtype
FROM events
WHERE uid = ? AND enddate >= ?
ORDER BY id desc        
SQL_EVENTOS;
        $recordset = $db->fetchTable($sql, TRUE, array($idUser, date('Y-m-d')));
        if (!is_array($recordset)) {
            return array();
        }
        return $recordset;
    }
 function get_hint()
 {
     // We should always check the EXTUSER in case they logged into a device
     // but we will fall back to the old methond if $astman not open although
     // I'm pretty sure everything else will puke anyhow if not running
     //
     $error = "";
     $pDB = new paloDB(generarDSNSistema("asteriskuser", "elxpbx"));
     $astman = AsteriskManagerConnect($error);
     if ($astman != false) {
         //se obtine los dispositivos a los cuales la extension esta asociada
         $deviceDB = $astman->database_get("EXTUSER", $this->code . "/" . $this->exten . "/device");
         $device_arr = explode('&', $deviceDB);
         //se obtine como se marca a dichos dispositivos
         foreach ($device_arr as $device) {
             $tmp_dial = $astman->database_get("DEVICE", $this->code . "/" . $device . "/dial");
             if ($tmp_dial !== "ERROR") {
                 $dial[] = $tmp_dial;
             }
         }
     } else {
         $query = "SELECT dial from extension where exten=? and organization_domain=?";
         $arrayParam = array($this->exten, $this->domain);
         $results = $pDB->fetchTable($query, false, $arrayParam);
         //create an array of strings
         if (is_array($results)) {
             foreach ($results as $result) {
                 $dial[] = str_replace('ZAP', 'DAHDI', $result[0]);
             }
         }
     }
     //create a string with & delimiter
     if (isset($dial) && is_array($dial)) {
         $hint = implode($dial, "&");
     } else {
         $query = "SELECT dial from extension where exten=? and organization_domain=?";
         $results = $pDB->getFirstRowQuery($query, false, array($this->exten, $this->domain));
         if (isset($results[0])) {
             $hint = $results[0];
         } else {
             $hint = "";
         }
     }
     return $hint;
 }
示例#6
0
function putMenuAsBookmark($menu)
{
    include_once "libs/paloSantoACL.class.php";
    $arrResult['status'] = FALSE;
    $arrResult['data'] = array("action" => "none", "menu" => "{$menu}");
    $arrResult['msg'] = _tr("Please your session id does not exist. Refresh the browser and try again.");
    if ($menu != "") {
        $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
        global $arrConf;
        $pdbACL = new paloDB("sqlite3:///{$arrConf['elastix_dbdir']}/acl.db");
        $pACL = new paloACL($pdbACL);
        $uid = $pACL->getIdUser($user);
        if ($uid !== FALSE) {
            $id_resource = $pACL->getResourceId($menu);
            $resource = $pACL->getResources($id_resource);
            $exist = false;
            $bookmarks = "SELECT aus.id AS id, ar.id AS id_menu, ar.name AS name, ar.description AS description FROM acl_user_shortcut aus, acl_resource ar WHERE id_user = ? AND type = 'bookmark' AND ar.id = aus.id_resource ORDER BY aus.id DESC";
            $arr_result1 = $pdbACL->fetchTable($bookmarks, TRUE, array($uid));
            if ($arr_result1 !== FALSE) {
                $i = 0;
                $arrIDS = array();
                foreach ($arr_result1 as $key => $value) {
                    if ($value['id_menu'] == $id_resource) {
                        $exist = true;
                    }
                }
                if ($exist) {
                    $pdbACL->beginTransaction();
                    $query = "DELETE FROM acl_user_shortcut WHERE id_user = ? AND id_resource = ? AND type = ?";
                    $r = $pdbACL->genQuery($query, array($uid, $id_resource, "bookmark"));
                    if (!$r) {
                        $pdbACL->rollBack();
                        $arrResult['status'] = FALSE;
                        $arrResult['data'] = array("action" => "delete", "menu" => _tr($resource[0][2]), "idmenu" => $id_resource, "menu_session" => $menu);
                        $arrResult['msg'] = _tr("Bookmark cannot be removed. Please try again or contact with your elastix administrator and notify the next error: ") . $pdbACL->errMsg;
                        return $arrResult;
                    } else {
                        $pdbACL->commit();
                        $arrResult['status'] = TRUE;
                        $arrResult['data'] = array("action" => "delete", "menu" => _tr($resource[0][2]), "idmenu" => $id_resource, "menu_session" => $menu);
                        $arrResult['msg'] = _tr("Bookmark has been removed.");
                        return $arrResult;
                    }
                }
                if (count($arr_result1) > 4) {
                    $arrResult['msg'] = _tr("The bookmark maximum is 5. Please uncheck one in order to add this bookmark");
                } else {
                    $pdbACL->beginTransaction();
                    $query = "INSERT INTO acl_user_shortcut(id_user, id_resource, type) VALUES(?, ?, ?)";
                    $r = $pdbACL->genQuery($query, array($uid, $id_resource, "bookmark"));
                    if (!$r) {
                        $pdbACL->rollBack();
                        $arrResult['status'] = FALSE;
                        $arrResult['data'] = array("action" => "add", "menu" => _tr($resource[0][2]), "idmenu" => $id_resource, "menu_session" => $menu);
                        $arrResult['msg'] = _tr("Bookmark cannot be added. Please try again or contact with your elastix administrator and notify the next error: ") . $pdbACL->errMsg;
                    } else {
                        $pdbACL->commit();
                        $arrResult['status'] = TRUE;
                        $arrResult['data'] = array("action" => "add", "menu" => _tr($resource[0][2]), "idmenu" => $id_resource, "menu_session" => $menu);
                        $arrResult['msg'] = _tr("Bookmark has been added.");
                        return $arrResult;
                    }
                }
            }
        }
    }
    return $arrResult;
}
示例#7
0
 function getEventsCalendar($idUser, $numRegs)
 {
     global $arrConf;
     global $arrLang;
     $db = new paloDB("sqlite3:///{$arrConf['elastix_dbdir']}/calendar.db");
     $actual_date = date("Y-m-d");
     $actual_date_hour = date("Y-m-d H:i:s");
     $query = "SELECT id, subject, asterisk_call, startdate, enddate, starttime, eventtype " . "FROM events " . "WHERE uid={$idUser} and enddate>='{$actual_date}' " . "ORDER BY id desc;";
     $result = $db->fetchTable($query, TRUE);
     if (!$result) {
         return $arrLang["You don't have events"];
     }
     $data = "";
     $arrEventos = array();
     foreach ($result as $value) {
         $iStartTimestamp = strtotime($value['starttime']);
         $endstamp = strtotime($value['enddate']);
         $startstamp = strtotime($value['startdate']);
         if ($value['eventtype'] == 1 || $value['eventtype'] == 5) {
             if ($value['eventtype'] == 1) {
                 $segundos = 86400;
                 $num_dias = ($endstamp - $startstamp) / $segundos + 1;
                 //Sumo 1 para incluir el ultimo dia
             } else {
                 if ($value['eventtype'] == 5) {
                     $segundos = 604800;
                     $num_dias = ($endstamp - $startstamp) / $segundos + 1;
                     //Sumo 1 para incluir la ultima semana
                     $num_dias = (int) $num_dias;
                 }
             }
             for ($i = 0; $i < $num_dias; $i++) {
                 $sFechaEvento = date('Y-m-d H:i:s', $iStartTimestamp);
                 $iStartTimestamp += $segundos;
                 if ($sFechaEvento >= $actual_date_hour) {
                     $arrEventos[] = array("date" => $sFechaEvento, "subject" => $value['subject'], "call" => $value['asterisk_call'], "id" => $value['id']);
                 }
             }
         } else {
             if ($value['eventtype'] == 6) {
                 $i = 0;
                 while ($iStartTimestamp <= $endstamp) {
                     $sFechaEvento = date('Y-m-d H:i:s', $iStartTimestamp);
                     $iStartTimestamp = strtotime("+1 months", $iStartTimestamp);
                     if ($sFechaEvento >= $actual_date_hour) {
                         $arrEventos[] = array("date" => $sFechaEvento, "subject" => $value['subject'], "call" => $value['asterisk_call'], "id" => $value['id']);
                     }
                     $i++;
                 }
             }
         }
     }
     if (count($arrEventos) < 1) {
         return $arrLang["You don't have events"];
     }
     //Ordenamiento por fechas en orden descendente (antiguos primero)
     $fechas = array();
     //$horas  = array();
     foreach ($arrEventos as $llave => $valor) {
         $fechas[$llave] = $valor['date'];
     }
     array_multisort($fechas, SORT_ASC, $arrEventos);
     $i = 0;
     while ($i < count($arrEventos) && $i < $numRegs) {
         $temp = "<a href='?menu=calendar&action=display&id=" . $arrEventos[$i]["id"] . "&event_date=" . date("Y-m-d", strtotime($arrEventos[$i]["date"])) . "'>" . $arrEventos[$i]["subject"] . "</a>";
         $temp .= "&nbsp;&nbsp;&nbsp;";
         $temp .= "Date: ";
         $temp .= $arrEventos[$i]['date'];
         $temp .= " - Call: ";
         $temp .= $arrEventos[$i]['call'];
         $temp .= "<br>";
         $data .= $temp;
         $i++;
     }
     return $data;
 }
示例#8
0
文件: index.php 项目: hardikk/HNH
function _moduleContent(&$smarty, $module_name)
{
    include_once "libs/paloSantoDB.class.php";
    include_once "libs/paloSantoConfig.class.php";
    include_once "libs/paloSantoGrid.class.php";
    include_once "libs/paloSantoACL.class.php";
    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);
    //conexion acl.db
    $pDB = new paloDB($arrConf['elastix_dsn']['acl']);
    //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'];
    $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
    $arrConfig = $pConfig->leer_configuracion(false);
    $dsn = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asterisk";
    $pDBa = new paloDB($dsn);
    ////////////////////
    if (!empty($pDB->errMsg)) {
        echo "ERROR DE DB: {$pDB->errMsg} <br>";
    }
    $arrData = array();
    $arrData[""] = $arrLang["no extension"];
    $pACL = new paloACL($pDB);
    if (!empty($pACL->errMsg)) {
        echo "ERROR DE ACL: {$pACL->errMsg} <br>";
    }
    /*******/
    $typeUser = "";
    $userLevel1 = "";
    $extOther = "";
    $userAccount = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    $idUserAccount = $pACL->isUserAdministratorGroup($userAccount);
    $idUserInt = $pACL->getIdUser($userAccount);
    if ($idUserAccount) {
        $userLevel1 = "admin";
    } else {
        $userLevel1 = "other";
    }
    $smarty->assign("userLevel1", $userLevel1);
    /*******/
    $sQuery = "select extension from users order by extension;";
    $arrayResult = $pDBa->fetchTable($sQuery, true);
    if (!$arrayResult) {
        $error = $pDBa->errMsg;
    } else {
        if (is_array($arrayResult) && count($arrayResult) > 0) {
            //$arrData[$item["null"]] = "No extension";
            if ($idUserAccount) {
                foreach ($arrayResult as $item) {
                    $arrData[$item["extension"]] = $item["extension"];
                }
            } else {
                $idOther = $pACL->getIdUser($userAccount);
                $arrUserOther = $pACL->getUsers($idOther);
                $extOther = $arrUserOther[0][3];
                $arrData[$extOther] = $extOther;
            }
        }
    }
    $arrGruposACL = $pACL->getGroups();
    for ($i = 0; $i < count($arrGruposACL); $i++) {
        if ($arrGruposACL[$i][1] == 'administrator') {
            $arrGruposACL[$i][1] = $arrLang['administrator'];
        } else {
            if ($arrGruposACL[$i][1] == 'operator') {
                $arrGruposACL[$i][1] = $arrLang['operator'];
            } else {
                if ($arrGruposACL[$i][1] == 'extension') {
                    $arrGruposACL[$i][1] = $arrLang['extension'];
                }
            }
        }
        if ($idUserAccount) {
            $arrGrupos[$arrGruposACL[$i][0]] = $arrGruposACL[$i][1];
        } else {
            $arrUserPer = $pACL->getMembership($idUserInt);
            foreach ($arrUserPer as $key => $value) {
                if ($arrGruposACL[$i][1] == $key) {
                    $arrGrupos[$arrGruposACL[$i][0]] = $arrGruposACL[$i][1];
                }
            }
        }
    }
    $arrFormElements = array("description" => array("LABEL" => "{$arrLang['Name']} {$arrLang['(Ex. John Doe)']}", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "name" => array("LABEL" => $arrLang["Login"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "EDITABLE" => "no"), "password1" => array("LABEL" => $arrLang["Password"], "REQUIRED" => "yes", "INPUT_TYPE" => "PASSWORD", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "password2" => array("LABEL" => $arrLang["Retype password"], "REQUIRED" => "yes", "INPUT_TYPE" => "PASSWORD", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "group" => array("LABEL" => $arrLang["Group"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrGrupos, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "extension" => array("LABEL" => $arrLang["Extension"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrData, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "webmailpassword1" => array("LABEL" => $arrLang["Webmail Password"], "REQUIRED" => "no", "INPUT_TYPE" => "PASSWORD", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "webmailuser" => array("LABEL" => $arrLang["Webmail User"], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "webmaildomain" => array("LABEL" => $arrLang["Webmail Domain"], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""));
    $contenidoModulo = "";
    $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]);
    $smarty->assign("CANCEL", $arrLang["Cancel"]);
    $smarty->assign("APPLY_CHANGES", $arrLang["Apply changes"]);
    $smarty->assign("SAVE", $arrLang["Save"]);
    $smarty->assign("EDIT", $arrLang["Edit"]);
    $smarty->assign("DELETE", $arrLang["Delete"]);
    $smarty->assign("CONFIRM_CONTINUE", $arrLang["Are you sure you wish to continue?"]);
    $smarty->assign("icon", "images/user.png");
    $smarty->assign("title_webmail", $arrLang["Mail Profile"]);
    if (isset($_POST['submit_create_user'])) {
        // Implementar
        include_once "libs/paloSantoForm.class.php";
        $arrFillUser['description'] = '';
        $arrFillUser['name'] = '';
        $arrFillUser['group'] = '';
        $arrFillUser['extension'] = '';
        $arrFillUser['password1'] = '';
        $arrFillUser['password2'] = '';
        $oForm = new paloForm($smarty, $arrFormElements);
        $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New User"], $arrFillUser);
    } else {
        if (!is_null(getParameter("edit"))) {
            $contenidoModulo = editUser($userAccount, $pACL, $pDB, $arrFormElements, $smarty, $local_templates_dir, $arrLang, $idUserAccount, $userLevel1);
        } else {
            if (isset($_POST['submit_save_user'])) {
                include_once "libs/paloSantoForm.class.php";
                $oForm = new paloForm($smarty, $arrFormElements);
                if ($oForm->validateForm($_POST)) {
                    // Exito, puedo procesar los datos ahora.
                    $pACL = new paloACL($pDB);
                    if (empty($_POST['password1']) or $_POST['password1'] != $_POST['password2']) {
                        // Error claves
                        $smarty->assign("mb_message", $arrLang["The passwords are empty or don't match"]);
                        $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New User"], $_POST);
                    } else {
                        if ($userLevel1 == "admin") {
                            // Creo al usuario
                            $md5_password = md5($_POST['password1']);
                            $pACL->createUser($_POST['name'], $_POST['description'], $md5_password, $_POST['extension']);
                            $idUser = $pACL->getIdUser($_POST['name']);
                            // Versiones viejas del archivo acl.db tienen una fila con una
                            // tupla que asocia al usuario inexistente con ID 2, con el
                            // grupo 2 (Operadores). Se limpia cualquier membresía extraña.
                            $listaMembresia = $pACL->getMembership($idUser);
                            if (is_array($listaMembresia) && count($listaMembresia) > 0) {
                                foreach ($listaMembresia as $idGrupo) {
                                    $pACL->delFromGroup($idUser, $idGrupo);
                                }
                            }
                            // Creo la membresia
                            $pACL->addToGroup($idUser, $_POST['group']);
                            $bExito = TRUE;
                            if (empty($pACL->errMsg)) {
                                $nuevasPropiedades = array();
                                if (!empty($_POST['webmailuser'])) {
                                    $nuevasPropiedades['login'] = $_POST['webmailuser'];
                                }
                                if (!empty($_POST['webmailpassword1'])) {
                                    $nuevasPropiedades['password'] = $_POST['webmailpassword1'];
                                }
                                if (!empty($_POST['webmaildomain'])) {
                                    $nuevasPropiedades['domain'] = $_POST['webmaildomain'];
                                }
                                $bExito = actualizarPropiedades($pDB, $smarty, $idUser, 'webmail', 'default', $nuevasPropiedades);
                            }
                            if (!empty($pACL->errMsg)) {
                                // Ocurrio algun error aqui
                                $smarty->assign("mb_message", "ERROR: {$pACL->errMsg}");
                                $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New User"], $_POST);
                            } else {
                                if ($bExito) {
                                    header("Location: ?menu=userlist");
                                }
                            }
                        } else {
                            $smarty->assign("mb_message", $arrLang["userNoAllowed"]);
                        }
                    }
                } else {
                    // Error
                    $smarty->assign("mb_title", $arrLang["Validation Error"]);
                    $arrErrores = $oForm->arrErroresValidacion;
                    $strErrorMsg = "<b>{$arrLang['The following fields contain errors']}:</b><br>";
                    foreach ($arrErrores as $k => $v) {
                        $strErrorMsg .= "{$k}, ";
                    }
                    $strErrorMsg .= "";
                    $smarty->assign("mb_message", $strErrorMsg);
                    $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New User"], $_POST);
                }
            } else {
                if (isset($_POST['submit_apply_changes'])) {
                    $arrayContent = applyChanges($userAccount, $pACL, $smarty, $arrLang, $idUserAccount, $userLevel1, $arrFormElements, $pDB, $local_templates_dir, $idUserInt, $extOther);
                    if (isset($arrayContent["mb_title"]) && isset($arrayContent["mb_message"])) {
                        $smarty->assign("mb_title", $arrayContent["mb_title"]);
                        $smarty->assign("mb_message", $arrayContent["mb_message"]);
                    }
                    if ($arrayContent["success"]) {
                        header("Location: ?menu=userlist");
                    } else {
                        if (isset($arrayContent["id_user"])) {
                            $smarty->assign("id_user", $_POST['id_user']);
                        }
                        if (isset($arrayContent["fill_user"])) {
                            $contenidoModulo = $arrayContent["form"]->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["Edit User"], $arrayContent["fill_user"]);
                        } else {
                            $contenidoModulo = $arrayContent["content"];
                        }
                    }
                } else {
                    if (isset($_GET['action']) && $_GET['action'] == "view") {
                        if (!$pACL->isUserAdministratorGroup($userAccount)) {
                            if ($pACL->getIdUser($userAccount) != $_GET['id']) {
                                $smarty->assign("mb_title", $arrLang["ERROR"]);
                                $smarty->assign("mb_message", $arrLang["You are not authorized to access to information of that user"]);
                                return reportUserList($arrLang, $pACL, $idUserAccount, $smarty, $userLevel1, $userAccount);
                            }
                        }
                        include_once "libs/paloSantoForm.class.php";
                        $oForm = new paloForm($smarty, $arrFormElements);
                        //- TODO: Tengo que validar que el id sea valido, si no es valido muestro un mensaje de error
                        $oForm->setViewMode();
                        // Esto es para activar el modo "preview"
                        $arrUser = $pACL->getUsers($_GET['id']);
                        // Conversion de formato
                        $arrTmp['name'] = $arrUser[0][1];
                        $arrTmp['description'] = $arrUser[0][2];
                        $arrTmp['password1'] = "****";
                        $arrTmp['password2'] = "****";
                        $arrTmp['extension'] = $arrUser[0][3];
                        //- TODO: Falta llenar el grupo
                        $arrMembership = $pACL->getMembership($_GET['id']);
                        $id_group = "";
                        if (is_array($arrMembership)) {
                            foreach ($arrMembership as $groupName => $groupId) {
                                $id_group = $groupId;
                                // Asumo que cada usuario solo puede pertenecer a un grupo
                                break;
                            }
                        }
                        $arrTmp['group'] = $id_group;
                        $listaPropiedades = leerPropiedadesWebmail($pDB, $smarty, $_GET['id']);
                        if (isset($listaPropiedades['login'])) {
                            $arrTmp['webmailuser'] = $listaPropiedades['login'];
                        }
                        if (isset($listaPropiedades['domain'])) {
                            $arrTmp['webmaildomain'] = $listaPropiedades['domain'];
                        }
                        if (isset($listaPropiedades['password'])) {
                            $arrTmp['webmailpassword1'] = '****';
                        }
                        //if (isset($listaPropiedades['imapsvr'])) $arrTmp['webmailimapsvr'] = $listaPropiedades['imapsvr'];
                        $smarty->assign("id_user", $_GET['id']);
                        $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["View User"], $arrTmp);
                        // hay que pasar el arreglo
                    } else {
                        if (getParameter('action') == "edit_userExtension") {
                            $smarty->assign("editUserExtension", "yes");
                            $html = editUser($userAccount, $pACL, $pDB, $arrFormElements, $smarty, $local_templates_dir, $arrLang, $idUserAccount, $userLevel1);
                            $smarty->assign("CONTENT", $html);
                            $smarty->assign("THEMENAME", $arrConf['mainTheme']);
                            $smarty->assign("MODULE_NAME", $module_name);
                            $smarty->assign("path", "");
                            $contenidoModulo = $smarty->display("{$local_templates_dir}/edit_userExtension.tpl");
                        } else {
                            if (getParameter('action') == "apply_changes_UserExtension") {
                                include_once "libs/paloSantoJSON.class.php";
                                $jsonObject = new PaloSantoJSON();
                                $result = applyChanges($userAccount, $pACL, $smarty, $arrLang, $idUserAccount, $userLevel1, $arrFormElements, $pDB, $local_templates_dir, $idUserInt, $extOther);
                                $arrMessage["mb_title"] = isset($result["mb_title"]) ? $result["mb_title"] : null;
                                $arrMessage["mb_message"] = isset($result["mb_message"]) ? $result["mb_message"] : null;
                                $arrMessage["success"] = $result["success"];
                                $jsonObject->set_message($arrMessage);
                                $contenidoModulo = $jsonObject->createJSON();
                            } else {
                                $contenidoModulo = reportUserList($arrLang, $pACL, $idUserAccount, $smarty, $userLevel1, $userAccount);
                            }
                        }
                    }
                }
            }
        }
    }
    return $contenidoModulo;
}
示例#9
0
 function getAppletsActivated($user)
 {
     global $arrConf;
     $dsn = "sqlite3:///{$arrConf['elastix_dbdir']}/dashboard.db";
     $pDB = new paloDB($dsn);
     $arrApplets = array();
     $pDB2 = new paloDB($arrConf['elastix_dsn']['acl']);
     $pACL = new paloACL($pDB2);
     if ($pACL->isUserAdministratorGroup($user)) {
         $typeUser = "******";
     } else {
         $typeUser = "******";
     }
     $query = "select\n                    a.code, a.icon, a.name, aau.id aau_id\n                  from \n                    activated_applet_by_user aau \n                        inner join \n                    default_applet_by_user dau on aau.id_dabu=dau.id \n                        inner join \n                    applet a on dau.id_applet=a.id \n                  where \n                    dau.username=? and aau.username=?\n                  order \n                    by aau.order_no asc";
     $result = $pDB->fetchTable($query, true, array($typeUser, $user));
     if ($result == FALSE) {
         $this->errMsg = $pDB->errMsg;
         return array();
     }
     return $result;
 }
示例#10
0
function putMenuAsBookmark($menu)
{
    global $arrConf;
    include_once "libs/paloSantoACL.class.php";
    $arrResult['status'] = FALSE;
    $arrResult['data'] = array("action" => "none", "menu" => "{$menu}");
    $arrResult['msg'] = _tr("Please your session id does not exist. Refresh the browser and try again.");
    if ($menu != "") {
        $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
        $pdbACL = new paloDB($arrConf['elastix_dsn']['elastix']);
        $pACL = new paloACL($pdbACL);
        $uid = $pACL->getIdUser($user);
        if ($uid !== FALSE) {
            //antes de obtener el listado de los modulos debemos determinar
            //si la interfaz desde la cual se esta llamando a los metodos es administrativa o
            //es de usuario final.
            $tmpPath = explode("/", $arrConf['basePath']);
            if ($tmpPath[count($tmpPath) - 1] == 'admin') {
                $administrative = "yes";
            } else {
                $administrative = "no";
            }
            //si el que realiza la accion no es el superadmin incluir en la busqueda la restriccion
            //de que el modulo puede ser accedido por la organizacion
            $org_access = !$pACL->isUserSuperAdmin($_SESSION['elastix_user']) ? 'yes' : NULL;
            //OBTENEMOS EL RECURSO
            $resource = $pACL->getResources($menu, $org_access, $administrative);
            $exist = false;
            $bookmarks = "SELECT aus.id AS id, ar.id AS id_menu,  ar.description AS description FROM user_shortcut aus, acl_resource ar WHERE id_user = ? AND aus.type = 'bookmark' AND ar.id = aus.id_resource ORDER BY aus.id DESC";
            $arr_result1 = $pdbACL->fetchTable($bookmarks, TRUE, array($uid));
            if ($arr_result1 !== FALSE) {
                $i = 0;
                $arrIDS = array();
                foreach ($arr_result1 as $key => $value) {
                    if ($value['id_menu'] == $menu) {
                        $exist = true;
                    }
                }
                //existia anteriormente se procede a eliminarlo del bookmark
                if ($exist) {
                    $pdbACL->beginTransaction();
                    $query = "DELETE FROM user_shortcut WHERE id_user = ? AND id_resource = ? AND type = ?";
                    $r = $pdbACL->genQuery($query, array($uid, $menu, "bookmark"));
                    if (!$r) {
                        $pdbACL->rollBack();
                        $arrResult['status'] = FALSE;
                        $arrResult['data'] = array("action" => "delete", "menu" => _tr($resource[0][1]), "idmenu" => $menu, "menu_session" => $menu);
                        $arrResult['msg'] = _tr("Bookmark cannot be removed. Please try again or contact with your elastix administrator and notify the next error: ") . $pdbACL->errMsg;
                        return $arrResult;
                    } else {
                        $pdbACL->commit();
                        $arrResult['status'] = TRUE;
                        $arrResult['data'] = array("action" => "delete", "menu" => _tr($resource[0][1]), "idmenu" => $menu, "menu_session" => $menu);
                        $arrResult['msg'] = _tr("Bookmark has been removed.");
                        return $arrResult;
                    }
                }
                //no existia anteriormente se lo agrega
                if (count($arr_result1) > 4) {
                    $arrResult['msg'] = _tr("The bookmark maximum is 5. Please uncheck one in order to add this bookmark");
                } else {
                    $pdbACL->beginTransaction();
                    $query = "INSERT INTO user_shortcut(id_user, id_resource, type) VALUES(?, ?, ?)";
                    $r = $pdbACL->genQuery($query, array($uid, $menu, "bookmark"));
                    if (!$r) {
                        $pdbACL->rollBack();
                        $arrResult['status'] = FALSE;
                        $arrResult['data'] = array("action" => "add", "menu" => _tr($resource[0][1]), "idmenu" => $menu, "menu_session" => $menu);
                        $arrResult['msg'] = _tr("Bookmark cannot be added. Please try again or contact with your elastix administrator and notify the next error: ") . $pdbACL->errMsg;
                    } else {
                        $pdbACL->commit();
                        $arrResult['status'] = TRUE;
                        $arrResult['data'] = array("action" => "add", "menu" => _tr($resource[0][1]), "idmenu" => $menu, "menu_session" => $menu);
                        $arrResult['msg'] = _tr("Bookmark has been added.");
                        return $arrResult;
                    }
                }
            }
        }
    }
    return $arrResult;
}
示例#11
0
 function getDeviceFreePBX($dsn, $limit = NULL, $offset = NULL, $field_name = NULL, $field_pattern = NULL, $count = FALSE)
 {
     //Defining the fields to get. If the param $count is true, then we will get the result of the sql function count(), else, we will get all fields in the table.
     $fields = $count ? "count(id) as total" : "*";
     //Begin to build the query.
     $query = "SELECT {$fields} FROM devices ";
     $strWhere = "";
     $arrParam = array();
     if (!is_null($field_name) and !is_null($field_pattern)) {
         if ($field_name == 'name') {
             $strWhere .= " description like ? ";
             $arrParam[] = $field_pattern;
         } else {
             if ($field_name == 'telefono') {
                 $strWhere .= " id like ? ";
                 $arrParam[] = $field_pattern;
             }
         }
     }
     // Clausula WHERE aqui
     if (!empty($strWhere)) {
         $query .= "WHERE {$strWhere} ";
     }
     //ORDER BY
     $query .= " ORDER BY  description";
     // Limit
     if (!is_null($limit)) {
         $limit = (int) $limit;
         $query .= " LIMIT {$limit} ";
     }
     if (!is_null($offset) and $offset > 0) {
         $offset = (int) $offset;
         $query .= " OFFSET {$offset}";
     }
     $pDB = new paloDB($dsn);
     if ($pDB->connStatus) {
         return false;
     }
     $result = $pDB->fetchTable($query, true, $arrParam);
     //se consulta a la base asterisk
     return $result;
 }
示例#12
0
 function getDeviceFreePBX($dsn)
 {
     global $arrLang;
     $pDB = new paloDB($dsn);
     if ($pDB->connStatus) {
         return false;
     }
     $sqlPeticion = "select id, concat(description,' <',user,'>') label FROM devices WHERE tech = 'sip' ORDER BY id ASC;";
     $result = $pDB->fetchTable($sqlPeticion, true);
     //se consulta a la base asterisk
     $pDB->disconnect();
     $arrDevices = array();
     if (is_array($result) && count($result) > 0) {
         $arrDevices['unselected'] = "-- {$arrLang['Unselected']} --";
         foreach ($result as $key => $device) {
             $arrDevices[$device['id']] = $device['label'];
         }
     } else {
         $arrDevices['no_device'] = "-- {$arrLang['No Extensions']} --";
     }
     return $arrDevices;
 }
 function getListExternalContacts()
 {
     global $arrCredentials, $arrConf;
     $pDB = new paloDB($arrConf['elastix_dsn']['elastix']);
     $data = array($arrCredentials['idUser'], $arrCredentials['id_organization'], $arrCredentials['idUser']);
     $query = "(select concat (name,' ',last_name) as name, " . "email as username from contacts where iduser=? AND email!='' AND email IS NOT NULL) " . "UNION (select concat (c.name,' ',c.last_name) as name, " . "c.email as username from contacts c where c.iduser IN " . "(select acu.id from acl_user acu " . "join acl_group acg on acu.id_group = acg.id " . "WHERE acg.id_organization = ? AND acu.id!=?) " . " AND c.email!='' AND c.email IS NOT NULL AND c.status='isPublic') ORDER BY name ASC";
     $result = $pDB->fetchTable($query, true, $data);
     if ($result === FALSE) {
         $this->errMsg = $pDB->errMsg;
         return false;
     } else {
         return $result;
     }
 }
 private function _recogerPaquetesTransaccion($sContenido)
 {
     $lineas = explode("\n", $sContenido);
     $this->_estadoPaquete['progreso'] = array();
     $bReporte = FALSE;
     $sOperacion = NULL;
     $sLineaPrevia = '';
     foreach ($lineas as $sLinea) {
         $regs = NULL;
         if (!$bReporte && preg_match('/^\\s+Package\\s+Arch\\s+Version\\s+Repository\\s+Size/', $sLinea)) {
             $bReporte = TRUE;
         } elseif (strpos($sLinea, "Transaction Summary") !== FALSE) {
             $bReporte = FALSE;
         } elseif ($bReporte) {
             /* Si el nombre de paquete es muy largo, puede que el resto de la 
                información haya sido desplazada a la línea siguiente. Sin
                embargo, no se espera que hayan más de dos líneas. */
             $regs = NULL;
             $sLineaCompleta = ' ' . $sLineaPrevia . $sLinea;
             if (preg_match('/^\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+([0-9\\.\\,]+)\\s+[kM]?/', $sLineaCompleta, $regs)) {
                 $this->_estadoPaquete['progreso'][] = array('pkgaction' => $sOperacion, 'nombre' => $regs[1], 'arch' => $regs[2], 'version' => $regs[3], 'repo' => $regs[4], 'longitud' => $regs[5], 'rpmfile' => NULL, 'descargado' => '-', 'currstatus' => $sOperacion == 'remove' ? 'installed' : 'waiting', 'provides' => NULL, 'requires' => NULL);
                 $sLineaPrevia = '';
             } elseif (strpos($sLinea, 'Installing') === 0) {
                 $sOperacion = 'install';
                 $sLineaPrevia = '';
             } elseif (strpos($sLinea, 'Updating') === 0) {
                 $sOperacion = 'update';
                 $sLineaPrevia = '';
             } elseif (strpos($sLinea, 'Removing') === 0) {
                 $sOperacion = 'remove';
                 $sLineaPrevia = '';
             } else {
                 if (preg_match('/^\\s+(\\S+)\\s*$/', $sLinea)) {
                     $sLineaPrevia = $sLinea;
                 } else {
                     $sLineaPrevia = '';
                 }
             }
         }
         if (preg_match('/No package (\\S+) available/', $sLinea, $regs)) {
             $this->_estadoPaquete['status'] = 'error';
             $this->_estadoPaquete['errores'][] = "The following package is not available: " . $regs[1];
         }
     }
     if ($this->_estadoPaquete['status'] != 'error' && count($this->_estadoPaquete['progreso']) <= 0) {
         $this->_estadoPaquete['action'] = 'none';
         $this->_estadoPaquete['warning'][] = 'No packages to install or update';
     }
     /* La información de tamaño que proporciona yum es demasiado poco detallada
          para poder seguir la pista de la descarga con precisión de bytes. Por lo
          tanto, hay que abrir las bases SQLITE3 de yum y leer los datos de allí.
        */
     // Validar las rutas base de los repos
     $infoRepo = array();
     if ($this->_estadoPaquete['status'] != 'error') {
         $sRutaCache = $this->_cachedir;
         foreach ($this->_estadoPaquete['progreso'] as $paquete) {
             if (!isset($infoRepo[$paquete['repo']])) {
                 $sNombreRepo = $paquete['repo'];
                 if ($sNombreRepo == 'installed') {
                     continue;
                 }
                 if ($sNombreRepo[0] == '@') {
                     continue;
                 }
                 $sRutaRepo = $sRutaCache . '/' . $paquete['repo'] . '/';
                 $infoRepo[$sNombreRepo] = array('ruta' => $sRutaRepo);
                 if (!is_dir($sRutaRepo)) {
                     $this->_estadoPaquete['status'] = 'error';
                     $this->_estadoPaquete['errores'][] = "Unable to figure out cache directory for repo: {$sNombreRepo}";
                 } elseif (!is_readable($sRutaRepo . 'repomd.xml')) {
                     $this->_estadoPaquete['status'] = 'error';
                     $this->_estadoPaquete['errores'][] = "Unable to read file repomd.xml from repo: {$sNombreRepo}";
                 } else {
                     // El siguiente código require el módulo php-xml
                     $repomd = new SimpleXMLElement(file_get_contents($sRutaRepo . 'repomd.xml'));
                     foreach ($repomd->data as $dataObj) {
                         if ($dataObj['type'] == 'primary_db') {
                             $sRutaPrimary = $dataObj->location['href'];
                             $regs = NULL;
                             if (preg_match('|^(.*)/(\\S+)(\\.bz2)|', $sRutaPrimary, $regs)) {
                                 $sRutaPrimary = $regs[2];
                             }
                             $infoRepo[$sNombreRepo]['primary_db'] = $sRutaPrimary;
                         } elseif (!isset($infoRepo[$sNombreRepo]['primary_db']) && $dataObj['type'] == 'primary') {
                             $sRutaPrimary = $dataObj->location['href'];
                             $regs = NULL;
                             if (preg_match('|^(.*)/(\\S+)|', $sRutaPrimary, $regs)) {
                                 $sRutaPrimary = $regs[2];
                             }
                             // CentOS 5 usa $sRutaRepo/primary.xml.gz.sqlite
                             // Fedora 17 usa $sRutaRepo/gen/primary.xml.sqlite
                             if (file_exists($sRutaRepo . 'gen/' . basename($sRutaPrimary, '.gz') . '.sqlite')) {
                                 $infoRepo[$sNombreRepo]['primary_db'] = 'gen/' . basename($sRutaPrimary, '.gz') . '.sqlite';
                             } else {
                                 $infoRepo[$sNombreRepo]['primary_db'] = $sRutaPrimary . '.sqlite';
                             }
                         }
                     }
                     if (!isset($infoRepo[$sNombreRepo]['primary_db'])) {
                         $this->_estadoPaquete['status'] = 'error';
                         $this->_estadoPaquete['errores'][] = "Unable to locate primary_db from repo: {$sNombreRepo}";
                     } elseif (!is_readable($sRutaRepo . $infoRepo[$sNombreRepo]['primary_db'])) {
                         $this->_estadoPaquete['status'] = 'error';
                         $this->_estadoPaquete['errores'][] = "Unable to read primary_db from repo: {$sNombreRepo}";
                         unset($infoRepo[$sNombreRepo]['primary_db']);
                     }
                 }
             }
         }
     }
     // Para cada paquete, se abre el archivo primary_db de su correspondiente
     // repo y se consulta vía SQL el tamaño del paquete.
     if ($this->_estadoPaquete['status'] != 'error') {
         foreach ($this->_estadoPaquete['progreso'] as &$infoPaquete) {
             if ($infoPaquete['repo'] == 'installed') {
                 continue;
             }
             if ($infoPaquete['repo'][0] == '@') {
                 continue;
             }
             $repo =& $infoRepo[$infoPaquete['repo']];
             $regs = NULL;
             if (!preg_match('/^((\\S+):)?(\\S+)-(\\S+)$/', $infoPaquete['version'], $regs)) {
                 $this->_estadoPaquete['status'] = 'error';
                 $this->_estadoPaquete['errores'][] = "Unable to parse version string for package: " . $infoPaquete['nombre'];
             } else {
                 $sEpoch = $regs[2] == "" ? 0 : $regs[2];
                 $sVersion = $regs[3];
                 $sRelease = $regs[4];
                 // Abrir la conexión a la base de datos
                 $dsn = "sqlite3:///" . $repo['ruta'] . $repo['primary_db'];
                 $oDB = new paloDB($dsn);
                 if ($oDB->connStatus) {
                     $this->_estadoPaquete['status'] = 'error';
                     $this->_estadoPaquete['errores'][] = "Unable to open primary_db for package: " . $infoPaquete['nombre'];
                 } else {
                     $pkgKey = NULL;
                     // select size_package from packages where name = "pidgin" and arch = "x86_64" and epoch = "0" and version = "2.6.6" and release = "1.el5"
                     $sql = 'SELECT size_package, location_href, pkgKey FROM packages ' . 'WHERE name = ? AND arch = ? AND epoch = ? AND version = ? AND release = ?';
                     $recordset = $oDB->fetchTable($sql, FALSE, array($infoPaquete['nombre'], $infoPaquete['arch'], $sEpoch, $sVersion, $sRelease));
                     if (!is_array($recordset)) {
                         $this->_estadoPaquete['status'] = 'error';
                         $this->_estadoPaquete['errores'][] = "Unable to query primary_db for package: " . $infoPaquete['nombre'];
                     } elseif (count($recordset) <= 0) {
                         $this->_estadoPaquete['status'] = 'error';
                         $this->_estadoPaquete['errores'][] = "Unable to locate package in primary_db for package: " . $infoPaquete['nombre'] . " {$infoPaquete['arch']} {$sEpoch} {$sVersion} {$sRelease}";
                     } elseif (count($recordset) > 1) {
                         $this->_estadoPaquete['status'] = 'error';
                         $this->_estadoPaquete['errores'][] = "Duplicate package information in primary_db for package: " . $infoPaquete['nombre'];
                     } else {
                         $pkgKey = $recordset[0][2];
                         $infoPaquete['longitud'] = $recordset[0][0];
                         if ($infoPaquete['pkgaction'] != 'remove') {
                             $infoPaquete['descargado'] = 0;
                         }
                         $regs = NULL;
                         if (preg_match('|^((.*)/)?(\\S+\\.rpm)$|', $recordset[0][1], $regs)) {
                             $infoPaquete['rpmfile'] = $repo['ruta'] . 'packages/' . $regs[3];
                         } else {
                             $this->_estadoPaquete['status'] = 'error';
                             $this->_estadoPaquete['errores'][] = "Unable to discover RPM filename for package: " . $infoPaquete['nombre'];
                         }
                     }
                     // Leer los datos de lo que provee y lo que requiere
                     if (!is_null($pkgKey)) {
                         $infoPaquete['provides'] = $oDB->fetchTable('SELECT * FROM provides WHERE pkgKey = ?', TRUE, array($pkgKey));
                         $infoPaquete['requires'] = $oDB->fetchTable('SELECT * FROM requires WHERE pkgKey = ?', TRUE, array($pkgKey));
                     }
                     $oDB->disconnect();
                 }
             }
         }
     }
 }
 function getChannels($type)
 {
     $param = array();
     $where = "";
     global $arrConf;
     $pDB = new paloDB("sqlite3:///{$arrConf['elastix_dbdir']}/hardware_detector.db");
     //los canales disponibles se los obtine de la tabla echo_canceller que pertenece a la base hardware_detector
     if (!is_null($type)) {
         if (preg_match("/^(analog|digital)\$/", $type)) {
             if ($type == "analog") {
                 $where = " where name_port=? or name_port=?";
             } else {
                 $where = " where name_port!=? && name_port!=?";
             }
             $param[] = "FXO";
             $param[] = "FXS";
         }
     }
     $query = "SELECT num_port,name_port,id_card FROM echo_canceller {$where}";
     $result = $pDB->fetchTable($query, true, $param);
     if ($result === false) {
         $this->errMsg = $pDB->errMsg;
         return false;
     } else {
         return $result;
     }
 }
示例#16
0
文件: index.php 项目: hardikk/HNH
 $webmail_password = NULL;
 $webmail_imapsvr = 'localhost';
 $path_root = $_SERVER["DOCUMENT_ROOT"];
 include_once "{$path_root}/libs/misc.lib.php";
 include_once "{$path_root}/configs/default.conf.php";
 include_once "{$path_root}/libs/paloSantoDB.class.php";
 include_once "{$path_root}/libs/paloSantoACL.class.php";
 global $arrConf;
 $pDB = new paloDB($arrConf["elastix_dsn"]["acl"]);
 if (!empty($pDB->errMsg)) {
     echo "ERROR DE DB: {$pDB->errMsg} <br/>";
 } else {
     $pACL = new paloACL($pDB);
     $idUser = $pACL->getIdUser($_SESSION['elastix_user']);
     $sPeticionPropiedades = 'SELECT pp.property, pp.value ' . 'FROM acl_profile_properties pp, acl_user_profile up, acl_resource r ' . 'WHERE up.id_user = ? ' . 'AND up.profile = "default" ' . 'AND up.id_profile = pp.id_profile ' . 'AND up.id_resource = r.id ' . 'AND r.name = "webmail"';
     $tabla = $pDB->fetchTable($sPeticionPropiedades, FALSE, array($idUser));
     if ($tabla === FALSE) {
         print "ERROR DE DB: " . $pDB->errMsg;
     } else {
         foreach ($tabla as $tupla) {
             switch ($tupla[0]) {
                 case 'login':
                     $webmail_login = $tupla[1];
                     break;
                 case 'domain':
                     $webmail_domain = $tupla[1];
                     break;
                 case 'password':
                     $webmail_password = $tupla[1];
                     break;
                 case 'imapsvr':
示例#17
0
 /**
   Retorna un array de extensiones de la PBX no utilizadas como callback extensions.
 */
 public function getUnusedExtensions()
 {
     // Consultar todas las extensiones disponibles
     $sPwdFreepbx = obtenerClaveConocidaMySQL('asteriskuser');
     if (is_null($sPwdFreepbx)) {
         $this->errMsg = 'No se puede leer clave DB para FreePBX';
         return NULL;
     }
     // BUG del framework: para asteriskuser se devuelve un array
     if (is_array($sPwdFreepbx)) {
         $sPwdFreepbx = $sPwdFreepbx['valor'];
     }
     $dsn = "mysql://*****:*****@localhost/asterisk";
     $dbFreepbx = new paloDB($dsn);
     if ($dbFreepbx->connStatus) {
         $this->errMsg = 'No se puede conectar a DB para FreePBX';
         return NULL;
     }
     $extensiones = array();
     $recordset = $dbFreepbx->fetchTable('SELECT data FROM sip WHERE keyword = "Dial" UNION ' . 'SELECT data FROM iax WHERE keyword = "Dial"', TRUE);
     if (!is_array($recordset)) {
         $this->errMsg = 'No se pueden consultar extensiones en FreePBX - ' . $dbFreepbx->errMsg;
         return NULL;
     }
     foreach ($recordset as $tupla) {
         $extensiones[$tupla['data']] = $tupla['data'];
     }
     $dbFreepbx = NULL;
     // Quitar de la lista las extensiones ya registradas
     $listaAgentes = $this->getAgents();
     if (!is_array($listaAgentes)) {
         return NULL;
     }
     foreach ($listaAgentes as $agente) {
         $k = $agente['type'] . '/' . $agente['number'];
         if (isset($extensiones[$k])) {
             unset($extensiones[$k]);
         }
     }
     return $extensiones;
 }