function _moduleContent(&$smarty, $module_name) { //global variables global $arrConf; //folder path for custom templates $local_templates_dir = getWebDirModule($module_name); //conexion resource //$str_conn = "sqlite3:////var/www/db/iptables.db"; $pDB = new paloDB($arrConf['dsn_conn_database']); //actions $accion = getAction(); switch ($accion) { case "new": $content = newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, array()); break; case "desactivate": $content = desactivateFirewall($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "save": $content = saveRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "getPorts": $content = getPorts($pDB); break; case "change": $content = change($pDB); break; case "changeOtherPage": $content = changeOtherPage($pDB, $module_name); break; case "exec": $content = execRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "delete": $content = deleteFilter($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; default: $content = reportRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; } return $content; }
function determine_PortLinker() { global $localSplit, $remoteSplit, $portLinkerObjectTypes; $errorText = ""; assertUIntArg('object_id', __FUNCTION__); $object = spotEntity('object', $_REQUEST['object_id']); $linkok = localpretrigger_PortLinker(); if ($linkok == 2) { if (in_array($object['objtype_id'], $portLinkerObjectTypes)) { $localPortCount = countPorts($object['id']); $remotePortCount = array(); $remoteObject = array(); $remoteSplit = array(); $localSplit = determinePortSplit($object['label'], $localPortCount); $current = 1; foreach ($localSplit as $aKey => $aValue) { if (strlen($errorText) == 0) { $q = "SELECT id FROM RackObject WHERE name='{$aKey}' "; $result = usePreparedSelectBlade($q); if ($result == NULL) { print_r($dbxlink->errorInfo()); die; } if ($row = $result->fetch(PDO::FETCH_NUM)) { $remotePortCount[$aKey] = countPorts($row[0]); $remoteObject[$aKey] = spotEntity('object', $row[0]); $remoteSplit[$aKey] = determinePortSplit($remoteObject[$aKey]['label'], $remotePortCount[$aKey]); } else { $errorText = "Could not find object <b>{$aKey}</b>"; } } } if (strlen($errorText) == 0) { foreach ($localSplit as $aKey => $aValue) { if (strlen($errorText) == 0 && !isset($remoteSplit[$aKey][$object['name']]['count'])) { $errorText = "Object <b>{$aKey}</b> does not list this object in the label field as a remote panel"; } if (strlen($errorText) == 0 && $remoteSplit[$aKey][$object['name']]['count'] != $aValue['count']) { $errorText = "Port count does not match for object <b>{$aKey}</b>"; } } if (strlen($errorText) == 0) { foreach ($localSplit as $aKey => $aValue) { if (strlen($errorText) == 0) { $localSplit[$aKey]['ports'] = getPorts($object['id'], $aValue['count'], $aValue['start']); if (count($localSplit[$aKey]['ports']) != $aValue['count']) { $errorText = "Not all ports available on this object"; } } if (strlen($errorText) == 0) { $localSplit[$aKey]['remote_ports'] = getPorts($remoteObject[$aKey]['id'], $remoteSplit[$aKey][$object['name']]['count'], $remoteSplit[$aKey][$object['name']]['start']); if (count($localSplit[$aKey]['ports']) != $remoteSplit[$aKey][$object['name']]['count']) { $errorText = "Not all ports available on this object"; } } } } } } else { $errorText = "Object type should be PatchPanel or ODFPanel"; } } else { switch ($linkok) { case "-1": $errorText = "There are no ports configured yet, so nothing to link to."; break; case "0": $errorText = "Some link ports are already linked to another port."; break; case "1": $errorText = "No ports found that end in link."; break; default: $errorText = "Unknown error."; } } return $errorText; }
function _moduleContent(&$smarty, $module_name) { //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoRules.class.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']; //conexion resource //$str_conn = "sqlite3:////var/www/db/iptables.db"; $pDB = new paloDB($arrConf['dsn_conn_database']); //actions $accion = getAction(); switch ($accion) { case "new": $content = newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, array()); break; case "desactivate": $content = desactivateFirewall($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "save": $content = saveRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "getPorts": $content = getPorts($pDB); break; case "change": $content = change($pDB); break; case "changeOtherPage": $content = changeOtherPage($pDB, $module_name); break; case "exec": $content = execRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "delete": $content = deleteFilter($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; default: $content = reportRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; } return $content; }