function endpointConfiguratedShow($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf) { $arrData = array(); if (!isset($_SESSION['elastix_endpoints']) || !is_array($_SESSION['elastix_endpoints']) || empty($_SESSION['elastix_endpoints'])) { $paloFileEndPoint = new PaloSantoFileEndPoint($arrConf["tftpboot_path"], $_SESSION["endpoint_mask"]); $paloEndPoint = new paloSantoEndPoint($dsnAsterisk, $dsnSqlite); $arrEndpointsConf = $paloEndPoint->listEndpointConf(); $arrVendor = $paloEndPoint->listVendor(); $arrDeviceFreePBX = $paloEndPoint->getDeviceFreePBX(); $arrDeviceFreePBXAll = $paloEndPoint->getDeviceFreePBX(true); $endpoint_mask = isset($_POST['endpoint_mask']) ? $_POST['endpoint_mask'] : network(); $_SESSION["endpoint_mask"] = $endpoint_mask; $pValidator = new PaloValidar(); if (!$pValidator->validar('endpoint_mask', $endpoint_mask, 'ip/mask')) { $smarty->assign("mb_title", _tr('ERROR') . ":"); $strErrorMsg = ""; if (is_array($pValidator->arrErrores) && count($pValidator->arrErrores) > 0) { foreach ($pValidator->arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } } $smarty->assign("mb_message", _tr('Invalid Format in Parameter') . ": " . $strErrorMsg); } else { $pattonDevices = $paloEndPoint->getPattonDevices(); $arrEndpointsMap = $paloEndPoint->endpointMap($endpoint_mask, $arrVendor, $arrEndpointsConf, $pattonDevices); if ($arrEndpointsMap == false) { $smarty->assign("mb_title", _tr('ERROR') . ":"); $smarty->assign("mb_message", $paloEndPoint->errMsg); } if (is_array($arrEndpointsMap) && count($arrEndpointsMap) > 0) { $cont = 0; foreach ($arrEndpointsMap as $key => $endspoint) { $flag = 0; $cont++; if (isset($endspoint['model_no']) && $endspoint['model_no'] != "") { if ($paloEndPoint->modelSupportIAX($endspoint['model_no'])) { $comboDevices = combo($arrDeviceFreePBXAll, $endspoint['account']); } else { $comboDevices = combo($arrDeviceFreePBX, $endspoint['account']); } } else { $comboDevices = combo(array("Unselected" => _tr("Unselected")), ""); } if ($endspoint['configurated']) { $unset = "<input type='checkbox' name='epmac_{$endspoint['mac_adress']}' />"; $report = $paloEndPoint->compareDevicesAsteriskSqlite($endspoint['account']); } else { $unset = ""; } if ($endspoint['desc_vendor'] == "Unknown") { $endspoint['desc_vendor'] = $paloEndPoint->getDescription($endspoint['name_vendor']); } $macWithout2Points = str_replace(":", "", $endspoint['mac_adress']); $currentExtension = $paloEndPoint->getExtension($endspoint['ip_adress']); if ($endspoint["name_vendor"] == "Patton") { $arrTmp[0] = ""; $arrTmp[1] = ""; $arrTmp[5] = $endspoint["model_no"]; $arrTmp[6] = "<a href='?menu={$module_name}&action=patton_data&mac={$endspoint['mac_adress']}'>" . _tr("Data Configuration") . "</a>"; $configured = false; foreach ($arrEndpointsConf as $arrConf) { if (in_array($endspoint["mac_adress"], $arrConf)) { $configured = true; break; } } if ($configured) { $arrTmp[7] = "<font color = 'green'>" . _tr("Configured") . "</font>"; } else { $arrTmp[7] = _tr("Not Configured"); } $_SESSION['endpoint_model'][$endspoint['mac_adress']] = $endspoint["model_no"]; } elseif ($endspoint["name_vendor"] == "Sangoma") { $arrTmp[0] = ""; $arrTmp[1] = ""; // $arrTmp[5] = $endspoint["model_no"]; // $arrTmp[5] = "<select name='id_model_device_{$endspoint['mac_adress']}' onchange='getDevices(this,\"$macWithout2Points\");'>".combo($paloEndPoint->getAllModelsVendor($endspoint['name_vendor']),$endspoint['model_no'])."</select>"; $arrPorts = $paloFileEndPoint->getSangomaPorts($endspoint['ip_adress'], $endspoint["mac_adress"], $dsnAsterisk, $dsnSqlite, 2); if ($arrPorts == null) { $arrPorts['fxo'] = "?"; $arrPorts['fxs'] = "?"; } $arrTmp[5] = $paloFileEndPoint->getSangomaModel($endspoint['ip_adress'], $endspoint["mac_adress"], $dsnAsterisk, $dsnSqlite, 1) . "FXO: " . $arrPorts['fxo'] . " FXS: " . $arrPorts['fxs']; $arrTmp[6] = "<a href='?menu={$module_name}&action=vega_data&mac={$endspoint['mac_adress']}'>" . _tr("Data Configuration") . "</a>"; $configured = false; foreach ($arrEndpointsConf as $arrConf) { if (in_array($endspoint["mac_adress"], $arrConf)) { $configured = true; break; } } if ($configured) { $arrTmp[7] = "<font color = 'green'>" . _tr("Configured") . "</font>"; } else { $arrTmp[7] = _tr("Not Configured"); } $_SESSION['endpoint_model'][$endspoint['mac_adress']] = $endspoint["model_no"]; } else { if ($endspoint["name_vendor"] == "Grandstream") { $arr = $paloFileEndPoint->getModelElastix("admin", "admin", $endspoint['ip_adress'], 2); if ($arr) { $flag = 1; $endpointElastix = $paloEndPoint->getVendorByName("Elastix"); $endspoint['name_vendor'] = $endpointElastix["name"]; $endspoint['desc_vendor'] = $endpointElastix["description"]; $endspoint['id_vendor'] = $endpointElastix["id"]; } } $arrTmp[0] = "<input type='checkbox' name='epmac_{$endspoint['mac_adress']}' />"; $arrTmp[1] = $unset; $arrTmp[5] = "<select name='id_model_device_{$endspoint['mac_adress']}' onchange='getDevices(this,\"{$macWithout2Points}\");'>" . combo($paloEndPoint->getAllModelsVendor($endspoint['name_vendor']), $endspoint['model_no']) . "</select>"; $arrTmp[6] = "<select name='id_device_{$endspoint['mac_adress']}' id='id_device_{$macWithout2Points}' >{$comboDevices}</select>"; if ($currentExtension != "Not Registered") { $arrTmp[7] = "<font color = 'green'>{$currentExtension}</font>"; } else { $arrTmp[7] = $currentExtension; } } $arrTmp[2] = $endspoint['mac_adress']; //$arrTmp[3] = "<div class='chkbox' id=".$cont." style='width:135px;'><div class='resp_".$cont."'><a href='http://{$endspoint['ip_adress']}/' target='_blank' id='a_".$cont."' style='float:left;'>{$endspoint['ip_adress']}</a><input type='hidden' name='ip_adress_endpoint_{$endspoint['mac_adress']}' id='hid_".$cont."' value='{$endspoint['ip_adress']}' />"."<input type='checkbox' id='chk_".$cont."' name='{$endspoint['mac_adress']}' style='margin-top:1px;' /></div></div>"; $arrTmp[3] = "<a href='http://{$endspoint['ip_adress']}/' target='_blank'>{$endspoint['ip_adress']}</a><input type='hidden' name='ip_adress_endpoint_{$endspoint['mac_adress']}' value='{$endspoint['ip_adress']}' />"; $arrTmp[4] = $endspoint['name_vendor'] . " / " . $endspoint['desc_vendor'] . " <input type='hidden' name='id_vendor_device_{$endspoint['mac_adress']}' value='{$endspoint['id_vendor']}' /> <input type='hidden' name='name_vendor_device_{$endspoint['mac_adress']}' value='{$endspoint['name_vendor']}' />"; $arrData[] = $arrTmp; $_SESSION["endpoint_ip"][$endspoint['mac_adress']] = $endspoint['ip_adress']; } $_SESSION['elastix_endpoints'] = $arrData; $_SESSION['grid'] = $arrData; //Lo guardo en la session para hacer mucho mas rapido el proceso //de configuracion de los endpoint. Solo la primera vez corre el //comado nmap y cuando quiera el usuario correrlo de nuevo lo debe //hacer por medio del boton Discover Endpoints in this Network, ahi de nuevo vuelve a //construir el arreglo $arrData. } } } else { $arrData = $_SESSION['elastix_endpoints']; } if (!isset($endpoint_mask)) { $endpoint_mask = network(); } return buildReport($arrData, $smarty, $module_name, $endpoint_mask); }