<?php
/*************************************************************************
 * 文件说明：
 *    功能说明：配置文件
 *        1、多语言版本设置
 *        2、系统配置参数设定
 *        3、访问控制
 *
 *    调用关系：调用:各语种的包含文件
 *              被调用:lib.inc
 *
 *
 *    作者：
 *
 *修改注释：
 *NO.1
 *姓名：
 *时间：
 *修改说明： 删除一些不必要的设置/按新的要求配置
 *************************************************************************/
//==============================各OMC的类型定义============================
$omcTypeArr = array(
    array('typeNo' => '0', 'name' => 'WXC2 OMC', 'path' => 'wxc2_omc'),
    array('typeNo' => '1', 'name' => 'GMSC OMC', 'path' => 'gmsc_omc'),
    array('typeNo' => '2', 'name' => 'MSC OMC', 'path' => 'msc_omc'),
    array('typeNo' => '3', 'name' => 'HLR OMC', 'path' => 'hlr_omc'),
    array('typeNo' => '4', 'name' => 'AUC OMC', 'path' => 'auc_omc'),
    array('typeNo' => '5', 'name' => 'PPS OMC', 'path' => 'pps_omc'),
    array('typeNo' => '6', 'name' => 'SMSC OMC', 'path' => 'smsc_omc'),
    array('typeNo' => '7', 'name' => 'BSS OMC', 'path' => 'bss_omc'),
    array('typeNo' => '8', 'name' => 'EIR OMC', 'path' => 'eir_omc'),
    array('typeNo' => '9', 'name' => 'HBSC OMC', 'path' => 'hbsc_omc'),
    array('typeNo' => '10', 'name' => 'SN OMC', 'path' => 'sn_omc'),
);
//echo "cofnig $PHP_SELF";
$PHP_SELF = $_SERVER['PHP_SELF'];
$DEBUG=0;

if(isset($selectedOmcPath) && strlen($selectedOmcPath) > 0){
    $thisOmcPath=$selectedOmcPath;
}else{
    $PHP_SELF = $_SERVER['PHP_SELF'];
    $pathArr=explode('/',$PHP_SELF);
    $thisOmcPath=$pathArr[1];
}


for ($ii = 0; $ii < sizeof($omcTypeArr); $ii++) {
    //echo "<br>if($thisOmcPath == {$omcTypeArr[$ii][path]})";
    if ($thisOmcPath == $omcTypeArr[$ii]['path']) {
        $thisOmcType = $omcTypeArr[$ii]['typeNo'];
        break;
    }
}


//===============================OMC说明变量==============================================================
$COMPANY_NAME = "InterWave";
$COMPANY_WEBSITE = "www.iwv.com";
$COMPANY_E_MAIL = "Help@iwv.com";

$SYSTEM_VERSION = $omcTypeArr[$thisOmcType]['name'] . "<br>R3V3_09";
$SYSTEM_VERSION_ISSUE_DATE = "2002-11-19";

$OMC_NAME = $omcTypeArr[$thisOmcType]['name'];
$OMC_VERSION = "R6V5_10";
$OMC_VERSION_ISSUE_DATE = "2002-10-21";

$WELCOME_WORDS = "WELCOME TO $OMC_NAME";
$COPY_RIGHT_WORDS = "Copyright 2001-2002 iwv.com All rights reserved.";


//==============================各OMC的URL=================================================================
$host_ip = getenv("HTTP_HOST");
//echo "<br>host_ip=$host_ip";

global $userInfo;

//用户选择的语言类型
if ($userInfo['language'] == 'chn') {
    require("../../inc/chinese_gb.inc");
    $USER_GUIDE_DIR = "../../../guide/index_cn.htm";
    $language = 'chn';
    $language_type = 1;
//}elseif ($language == 'eng'){
} else {
    require("../../inc/english.inc");
    $USER_GUIDE_DIR = "../../../guide/index_en.htm";
    $language = 'eng';
    $language_type = 0;
}

//=============================数据下载设置==============================================================
$load_sys_type = 0;//与HLR有关的CSV数据模版类型(msc-->0/hlr-->1/pps-->2);

//=============================数据库设置=================================================================
//---------------服务器设置-----------------
//OMC-0

$handle = fopen("../../inc/mysqlpw.inc", "r");
$mysqluser = str_rot13(trim(fgets($handle)));
$mysqlpw = str_rot13(trim(fgets($handle)));
fclose($handle);


$OMC_server[0]['host'] = 'localhost';    // MySQL hostname，如果该主机名无法被解释，将出现无法打开页面的情况！！
$OMC_server[0]['user']		= $mysqluser;		// MySQL user (only needed with basic auth)
$OMC_server[0]['password']	= $mysqlpw;		// MySQL password (only needed with basic auth)
//$OMC_server[0]['user'] = 'root';        // MySQL user (only needed with basic auth)
//$OMC_server[0]['password'] = 'root';        // MySQL password (only needed with basic auth)
$OMC_server[0]['port'] = '';            // MySQL port - leave blank for default port
$OMC_server[0]['adv_auth'] = false;        // Use advanced authentication?
$OMC_server[0]['adv_user'] = '';            // MySQL standard user (only needed with advanced auth)
$OMC_server[0]['adv_pass'] = '';            // MySQL standard password (only needed with advanced auth)
$OMC_server[0]['only_db'] = '';            // If set to a db-name, only this db is accessible
$OMC_server[0]['verbose'] = 'master server';    // Verbose name for this host - leave blank to show the hostname

//OMC-1
$OMC_server[1]['host'] = 'omc-1';
$OMC_server[1]['user'] = $mysqluser;
$OMC_server[1]['password'] = $mysqlpw;
$OMC_server[1]['port'] = '';
$OMC_server[1]['adv_auth'] = false;
$OMC_server[1]['adv_user'] = '';
$OMC_server[1]['adv_pass'] = '';
$OMC_server[1]['only_db'] = '';
$OMC_server[1]['verbose'] = 'second server';

//数据库连接
//$link[0] = mysql_pconnect($OMC_server[0]['host'], $OMC_server[0]['user'], $OMC_server[0]['password']);
//if (!$link[0]) {//可惜在该主机名无法被解释的条件下，这段程序无法执行
//    echo "<font color=ff0000 size=4>Connect databese error!! please check the server name or the user_id and password</font>";
//    exit();
//}
$pubConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], "OMC_PUB");
//$bssDbConn=mysqli_connect($$OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], "BssOmcDb");
@mysqli_query($pubConn, "set names 'gb2312'");
@mysqli_query($pubConn, "set character_set_client=gb2312");
@mysqli_query($pubConn, "set character_set_results=gb2312");
//$link[1]=mysql_pconnect($OMC_server[1]['host'],$OMC_server[1]['user'],$OMC_server[1]['password']);

//-----------数据库数据表设置-------------------
//数据库列表
$omc_db = 'OMC_PUB';        //omc公用数据库
$cdr_db = 'CDR_DB';        //存放各种话单资料
$csta_db = 'CSTA_DB';        //存放话务统计数据
$auc_para = 'AUC_Para';        //存放AUC数据
$eir_para = 'EIR_Para';        //存放EIR数据
$account_db = 'account_db';
$bill_db = 'tariff_db';
$hlr_db = 'hlr_db';
$bss_db = 'BssOmcDb';
$refresh_card_db = 'refresh_card';
$parameter_db = 'parameter_db';
$sysconf_table = 'sysConf';        //设备定义表，是设备信息的基础
$paramConf_table = 'paramConf';        //参数定义表
$alarmconf_table = 'sysAlarmConf';    //告警定义
$sysStat_table = 'sysStat';        //状态信息表
$sysoperlog_table = 'sysOperLog';        //日志表
$sysoperconf_table = 'sysOperConf';    //日志类型定义表
$syscsvconf_table = 'sysCsvConf';        //CSV模板定义
$cstadefine_table = 'cstaDefine';        //csta配置
$cdrdefine_table = 'cdrSource';        //cdr配置

//==============================平台类型定义================================================
$PlatTypeDefArr=array(
    array('num'=> '0', 'remark' => 'EMS',  'sysTypeNo' => '0',   'maxSysNum' => '2', 'platAgent' => '0'),
    array('num'=> '1', 'remark' => 'GMSC', 'sysTypeNo' => '310', 'maxSysNum' => '2', 'platAgent' => '1'),
    array('num'=> '2', 'remark' => 'MSC',  'sysTypeNo' => '320', 'maxSysNum' => '2', 'platAgent' => '2'),
    array('num'=> '3', 'remark' => 'HSS',  'sysTypeNo' => '330', 'maxSysNum' => '2', 'platAgent' => '2'),
    array('num'=> '4', 'remark' => 'AUC',  'sysTypeNo' => '340', 'maxSysNum' => '2', 'platAgent' => '4'),
    array('num'=> '5', 'remark' => 'PPS',  'sysTypeNo' => '360', 'maxSysNum' => '2', 'platAgent' => '5'),
    array('num'=> '6', 'remark' => 'SMSC', 'sysTypeNo' => '350', 'maxSysNum' => '2', 'platAgent' => '6'),
    array('num'=> '7', 'remark' => 'EIR',  'sysTypeNo' => '380', 'maxSysNum' => '2', 'platAgent' => '4'),
    array('num'=> '8', 'remark' => 'VSS',  'sysTypeNo' => '390', 'maxSysNum' => '10', 'platAgent' => '4'),
    array('num'=> '9', 'remark' => 'MSS',  'sysTypeNo' => '388', 'maxSysNum' => '2', 'platAgent' => '4'),
    array('num'=> '10', 'remark' => 'MNP',  'sysTypeNo' => '370', 'maxSysNum' => '2', 'platAgent' => '4'),
    array('num'=> '11', 'remark' => 'AAS',  'sysTypeNo' => '311', 'maxSysNum' => '2', 'platAgent' => '2'),
    array('num'=> '12', 'remark' => 'SMEG',  'sysTypeNo' => '355', 'maxSysNum' => '2', 'platAgent' => '1'),
    array('num'=> '13', 'remark' => 'OPPS',  'sysTypeNo' => '375', 'maxSysNum' => '2', 'platAgent' => '2'),
    array('num'=> '14', 'remark' => 'MRFC',  'sysTypeNo' => '385', 'maxSysNum' => '2', 'platAgent' => '2'),
    array('num'=> '15', 'remark' => 'iPALIM', 'sysTypeNo' => '378', 'maxSysNum' => '2', 'platAgent' => '2'),
    array('num'=> '16', 'remark' => 'iRLS', 'sysTypeNo' => '379', 'maxSysNum' => '2', 'platAgent' => '2'),
    array('num'=> '17', 'remark' => 'MHC',  'sysTypeNo' => '386', 'maxSysNum' => '2', 'platAgent' => '2'),
    array('num'=> '18', 'remark' => 'RCM',  'sysTypeNo' => '395', 'maxSysNum' => '2', 'platAgent' => '2'),
);
//==============================告警等级设定================================================
$alarmLevelDefArr=array(
    array('value' => '0',	'remark' => $strClearedAlarm,	'color' => '#0000FF'),
    array('value' => '1',	'remark' => $strCriticalAlarm,	'color' => '#FF0000'),
    array('value' => '2',	'remark' => $strMajorAlarm,		'color' => '#980030'),
    array('value' => '3',	'remark' => $strMinorAlarm,		'color' => '#980030'),
    array('value' => '4',	'remark' => $strWarningAlarm,		'color' => '#980030'),
    //array(value => '5',	remark => $strClearedAlarm,		color => '#0000FF'),

);

//=============================系统配置参数==================================

$separator = ',';    //csv数据的字段分割符
$heatbeat_overtime = 48;      //heartbeat的超时设置。单位为秒。

/*被注释掉的变量定义将删除

$def_sys_param_sign  = 99;	//系统参数在参数表中用一个特殊的子系统编号，该编号不等于其他的子系统编号。
                             
$total_subsys_num    = 8;	//每个系统中子系统数，每个系统的子系统数相等
                             
$len_of_sys_num      = 2;       //sys_id编号方式中系统编号的长度
                        
$len_of_subsys_num   = 2;       //sys_id编号方式中子系统编号的长度
                                                        
$def_len_of_record   = 32;	// 参数表中每条记录默认所含的Byte个数
*/


//服务器工作状态定义，这个需要放在子模块中
$server_work_status = array(
    array('num' => '0', 'remark' => $strRestart, 'color' => '#FF0000'),
    array('num' => '1', 'remark' => $strInitialize, 'color' => '#FF0000'),
    array('num' => '2', 'remark' => $strNormal, 'color' => '#0000FF'),
    array('num' => '3', 'remark' => $strPause, 'color' => '#FF0000'),
    array('num' => '4', 'remark' => $strStop, 'color' => '#FF0000')
);

//================================操作权限设定======================================
//---------------------操作种类权限定义------------------------------
/*
$privilegeDefArr=array(
		array('permit' => '0',  'remark' => 'any one',						'show'=>0),
		array('permit' => '1',  'remark' => $strOprationRestriction,		'show'=>1),
		array('permit' => '2',  'remark' => $strConfigurationRestriction,	'show'=>1),
		array('permit' => '3',  'remark' => $strManagementRestriction,		'show'=>1),
		array('permit' => '4',  'remark' => 'System management',						'show'=>1),
		array('permit' => '5',  'remark' => 'Development',						'show'=>0)
);
*/
$privilegeDefArr = array(
    array('permit' => '0', 'remark' => 'any one', 'show' => 0),
    array('permit' => '1', 'remark' => $strOprationRestriction, 'show' => 1),
    array('permit' => '2', 'remark' => 'Technician', 'show' => 1),
    array('permit' => '3', 'remark' => 'Engineer', 'show' => 1),
    array('permit' => '4', 'remark' => $strManagementRestriction, 'show' => 1),
    array('permit' => '5', 'remark' => 'Development', 'show' => 0)
);

//-------------------------按操作种类划分页面-----------------------
//每个dir[$n][0]都是该类操作的操作权限等级值
//具体的值对照oper_type的定义

$omcDir = '/' . $omcTypeArr[$thisOmcType]['path'];
//$omcDir = '/omcWeb_v5';
//echo "<br> omcDir=$omcDir";
//---------------every one (包括未登录用户)可访问的目录-----------------
$dirAccessDefArr[0][0] = $omcDir . '/security/login/';
$dirAccessDefArr[0][1] = $omcDir . '/security/logout/';


//---------------class one:operator 可访问的目录-----------------
$dirAccessDefArr[1][0] = $omcDir . '/security/';
$dirAccessDefArr[1][1] = $omcDir . '/frame/';
$dirAccessDefArr[1][2] = $omcDir . '/fault/';

//---------------class two:engineer 可访问的目录-----------------
$dirAccessDefArr[2][0] = $omcDir . '/security/';
$dirAccessDefArr[2][1] = $omcDir . '/frame/';
$dirAccessDefArr[2][2] = $omcDir . '/fault/';
$dirAccessDefArr[2][3] = $omcDir . '/performance/';
$dirAccessDefArr[2][4] = $omcDir . '/account/';
$dirAccessDefArr[2][5] = $omcDir . '/element/';
$dirAccessDefArr[2][6] = $omcDir . '/configuration/';

//---------------class three:manager 可访问的目录-----------------
$dirAccessDefArr[3][0] = $omcDir . '/security/';
$dirAccessDefArr[3][1] = $omcDir . '/frame/';
$dirAccessDefArr[3][2] = $omcDir . '/fault/';
$dirAccessDefArr[3][3] = $omcDir . '/account/';
$dirAccessDefArr[3][4] = $omcDir . '/configuration/';
$dirAccessDefArr[3][5] = $omcDir . '/element/';
$dirAccessDefArr[3][6] = $omcDir . '/performance/';

//--------------class four:system manager 可访问的目录-----------------
$dirAccessDefArr[4][0] = $omcDir . '/security/';
$dirAccessDefArr[4][1] = $omcDir . '/frame/';
$dirAccessDefArr[4][2] = $omcDir . '/fault/';
$dirAccessDefArr[4][3] = $omcDir . '/account/';
$dirAccessDefArr[4][4] = $omcDir . '/configuration/';
$dirAccessDefArr[4][5] = $omcDir . '/element/';
$dirAccessDefArr[4][6] = $omcDir . '/performance/';

//--------------developer 可访问的目录-----------------
$dirAccessDefArr[5][0] = $omcDir . '/security/';
$dirAccessDefArr[5][1] = $omcDir . '/frame/';
$dirAccessDefArr[5][2] = $omcDir . '/fault/';
$dirAccessDefArr[5][3] = $omcDir . '/account/';
$dirAccessDefArr[5][4] = $omcDir . '/configuration/';
$dirAccessDefArr[5][5] = $omcDir . '/element/';
$dirAccessDefArr[5][6] = $omcDir . '/performance/';
$dirAccessDefArr[5][7] = $omcDir . '/sysDefine/';
?>
<?php
//Like VSS,TMG,PLAT they don't include the public parameter
//it must store the parameter into separate param table, not param_99
//return 1-pass
function checkIndependSystem($sysTypeNo)
{
    //PLAT
    if ($sysTypeNo[0] == '2')
        return 1;

    switch ($sysTypeNo) {
        //VSS
        case 390:
            //TMG
        case 391:
            //AMRMG
        case 392:
            //GbC
        case 393:
            return 1;
            break;
    }

    return 0;
}

//Like SMPP,MTP3,SCCP, it has subSysNo in the param table
function checkPlatWhoHaveSubSysNo($sysTypeNo, $sysNo)
{
    //MSS dual plat has the same parameter 
    //param_9的表是没有subSysNo, 由于多网元环境 所以不是所有网元都是xxx_9_xx
    if ($sysNo != 9 && $sysNo !=3 && $sysNo !=5 && $sysNo !=6 ) { // 9-MSS,3-HLR,5-OCS/PPS,6-SMSC if not Pub 
        switch ($sysTypeNo) {
            //SMPP
            case 260:
            
            //MTP3
            case 222:
            
            //SCCP
            case 223:
                return 1;
                break;
        }
    }
    return 0;
}

?>
