示例#1
0
function saveConfigs($smarty, $module_name, $local_templates_dir, $pDB, $arrCredentials)
{
    $val = new PaloValidar();
    $bGuardar = TRUE;
    // Validar toda la lista de IPs
    $_POST['lista_hosts'] = trim($_POST['lista_hosts']);
    $arrHostsFinal = empty($_POST['lista_hosts']) ? array() : explode("\n", $_POST['lista_hosts']);
    if (count($arrHostsFinal) <= 0) {
        $bGuardar = FALSE;
        $smarty->assign(array('mb_title' => _tr('Error'), 'mb_message' => _tr('No IP entered, you must keep at least the IP 127.0.0.1')));
    } else {
        foreach (array_keys($arrHostsFinal) as $k) {
            $arrHostsFinal[$k] = trim($arrHostsFinal[$k]);
            $bGuardar = $bGuardar && ($arrHostsFinal[$k] == 'localhost' || $val->validar(_tr('IP') . ' ' . $arrHostsFinal[$k], $arrHostsFinal[$k], 'ip'));
        }
    }
    // Formato de errores de validación
    if ($val->existenErroresPrevios()) {
        $msgErrorVal = _tr('Validation Error') . '<br/><br/>';
        foreach ($val->arrErrores as $nombreVar => $arrVar) {
            $msgErrorVal .= "<b>{$nombreVar}</b>: {$arrVar['mensaje']}<br/>";
        }
        $smarty->assign(array('mb_title' => _tr('Error'), 'mb_message' => $msgErrorVal));
        $bGuardar = FALSE;
    }
    if ($bGuardar) {
        // Si no hay errores de validacion entonces ingreso las redes al archivo de host
        $output = NULL;
        $retval = NULL;
        exec('/usr/bin/elastix-helper faxconfig setfaxhosts ' . implode(' ', $arrHostsFinal) . ' 2>&1', $output, $retval);
        if ($retval == 0) {
            $smarty->assign(array('mb_title' => _tr('Message'), 'mb_message' => _tr('Configuration updated successfully')));
        } else {
            $smarty->assign(array('mb_title' => _tr('Error'), 'mb_message' => _tr('Write error when writing the new configuration.') . ' ' . implode(' ', $output)));
        }
    }
    return showConfigs($smarty, $module_name, $local_templates_dir, $pDB, $arrCredentials);
}
示例#2
0
function saveConfigs($smarty, $module_name, $local_templates_dir, $pDB, $arrCredentials)
{
    $fMaster = new paloFaxMaster($pDB);
    $email_account = getParameter('fax_master');
    $email_account = trim($email_account);
    if (!preg_match("/^[a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*@[a-z0-9]+([\\._\\-]?[a-z0-9]+)*(\\.[a-z0-9]{2,6})+\$/", $email_account)) {
        $smarty->assign("mb_title", "ERROR");
        $smarty->assign("mb_message", _tr('Invalid Email Address'));
        return showConfigs($smarty, $module_name, $local_templates_dir, $pDB, $arrCredentials);
    }
    if ($fMaster->setFaxMaster($email_account)) {
        $smarty->assign("mb_title", "Message");
        $smarty->assign("mb_message", _tr('Changes were applied successfully'));
    } else {
        $smarty->assign("mb_title", "ERROR");
        $smarty->assign("mb_message", _tr('Changes could not be applied.') . " " . $fMaster->getErrorMsg());
    }
    return showConfigs($smarty, $module_name, $local_templates_dir, $pDB, $arrCredentials);
}