# 07. Navicat 数据库代理
URL: /%E6%96%87%E6%A1%A3/04.%E5%BC%80%E5%8F%91%E6%96%87%E6%A1%A3/03.%20%E8%BF%90%E7%BB%B4%E6%89%8B%E5%86%8C/02.%20K8S%E8%BF%90%E7%BB%B4/10.%20K8S%20%E5%B8%B8%E7%94%A8%E7%BB%84%E4%BB%B6/07.%20Navicat%20%E6%95%B0%E6%8D%AE%E5%BA%93%E4%BB%A3%E7%90%86


替换：`scrm-dev-v3`

# 07. Navicat 数据库代理

```yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    k8s.kuboard.cn/displayName: widiazine-navicat-数据库代理
    k8s.kuboard.cn/workload: widiazine-navicat
  labels:
    k8s.kuboard.cn/layer: cloud
    k8s.kuboard.cn/name: widiazine-navicat
  name: widiazine-navicat
  namespace: scrm-dev-v3
  resourceVersion: '1499615539'
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      k8s.kuboard.cn/layer: cloud
      k8s.kuboard.cn/name: widiazine-navicat
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/restartedAt: '2023-10-24T12:18:08+08:00'
        kubesphere.io/creator: admin
      creationTimestamp: null
      labels:
        k8s.kuboard.cn/layer: cloud
        k8s.kuboard.cn/name: widiazine-navicat
    spec:
      containers:
        - image: 'registry-vpc.cn-shanghai.aliyuncs.com/base-widiazine/php-fpm:8.0'
          imagePullPolicy: Always
          name: php-8
          ports:
            - containerPort: 9000
              name: tcp-php8
              protocol: TCP
          resources:
            limits:
              cpu: '1'
              memory: 512Mi
            requests:
              cpu: 100m
              memory: 64Mi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /etc/localtime
              name: host-time
              readOnly: true
            - mountPath: /var/www/html/ntunnel_mysql.php
              name: volume-nwaj6
              subPath: ntunnel_mysql
            - mountPath: /var/www/html/ntunnel_pgsql.php
              name: volume-nwaj6
              subPath: ntunnel_pgsql
        - image: 'registry-vpc.cn-shanghai.aliyuncs.com/base-widiazine/nginx:1.25.1_br'
          imagePullPolicy: Always
          name: nginx
          ports:
            - containerPort: 8080
              name: tcp
              protocol: TCP
          resources: {}
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            runAsNonRoot: true
            runAsUser: 65530
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /var/www/html/ntunnel_mysql.php
              name: volume-nwaj6
              subPath: ntunnel_mysql
            - mountPath: /var/www/html/ntunnel_pgsql.php
              name: volume-nwaj6
              subPath: ntunnel_pgsql
            - mountPath: /etc/nginx/conf.d/default.conf
              name: volume-84xny
              subPath: php.conf
            - mountPath: /etc/nginx/nginx.conf
              name: volume-84xny
              subPath: nginx.conf
            - mountPath: /etc/localtime
              name: host-time
            - mountPath: /var/cache/nginx/
              name: volume-sspzj
            - mountPath: /var/run/
              name: volume-sspzj
        - image: 'registry-vpc.cn-shanghai.aliyuncs.com/base-widiazine/php-fpm:7.0-fpm'
          imagePullPolicy: Always
          name: php-7
          ports:
            - containerPort: 9001
              name: tcp-php7
              protocol: TCP
          resources:
            limits:
              cpu: '1'
              memory: 512Mi
            requests:
              cpu: 100m
              memory: 64Mi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /etc/localtime
              name: host-time
            - mountPath: /var/www/html/ntunnel_mysql.php
              name: volume-nwaj6
              subPath: ntunnel_mysql
            - mountPath: /var/www/html/ntunnel_pgsql.php
              name: volume-nwaj6
              subPath: ntunnel_pgsql
            - mountPath: /usr/local/etc/php-fpm.d/zz-docker.conf
              name: volume-nwaj6
              subPath: php7
      dnsPolicy: ClusterFirst
      imagePullSecrets:
        - name: aliyun
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
        - hostPath:
            path: /etc/localtime
            type: ''
          name: host-time
        - configMap:
            defaultMode: 420
            name: php
          name: volume-nwaj6
        - configMap:
            defaultMode: 420
            name: nginx-config
          name: volume-84xny
        - emptyDir: {}
          name: volume-sspzj

---
apiVersion: v1
kind: Service
metadata:
  annotations:
    k8s.kuboard.cn/workload: widiazine-navicat
  labels:
    k8s.kuboard.cn/layer: cloud
    k8s.kuboard.cn/name: widiazine-navicat
  name: widiazine-navicat
  namespace: scrm-dev-v3
  resourceVersion: '922115346'
spec:
  internalTrafficPolicy: Cluster
  ipFamilies:
    - IPv4
  ipFamilyPolicy: SingleStack
  ports:
    - name: syckys
      port: 9000
      protocol: TCP
      targetPort: tcp-php8
    - name: 3m66p2
      port: 80
      protocol: TCP
      targetPort: tcp
    - name: y32x8n
      port: 9001
      protocol: TCP
      targetPort: tcp-php7
  selector:
    k8s.kuboard.cn/layer: cloud
    k8s.kuboard.cn/name: widiazine-navicat
  sessionAffinity: None
  type: ClusterIP
---
apiVersion: v1
data:
  ntunnel_mysql: "<?php\t//version my202\n\n//set allowTestMenu to false to disable System/Server test page\n$allowTestMenu = true;\n\n$use_mysqli = function_exists(\"mysqli_connect\");\n\nheader(\"Content-Type: text/plain; charset=x-user-defined\");\nerror_reporting(0);\nset_time_limit(0);\n\nfunction phpversion_int()\n{\n\tlist($maVer, $miVer, $edVer) = preg_split(\"(/|\\.|-)\", phpversion());\n\treturn $maVer*10000 + $miVer*100 + $edVer;\n}\n\nif (phpversion_int() < 50300)\n{\n\tset_magic_quotes_runtime(0);\n}\n\nfunction GetLongBinary($num)\n{\n\treturn pack(\"N\",$num);\n}\n\nfunction GetShortBinary($num)\n{\n\treturn pack(\"n\",$num);\n}\n\nfunction GetDummy($count)\n{\n\t$str = \"\";\n\tfor($i=0;$i<$count;$i++)\n\t\t$str .= \"\\x00\";\n\treturn $str;\n}\n\nfunction GetBlock($val)\n{\n\t$len = strlen($val);\n\tif( $len < 254 )\n\t\treturn chr($len).$val;\n\telse\n\t\treturn \"\\xFE\".GetLongBinary($len).$val;\n}\n\nfunction EchoHeader($errno)\n{\n\t$str = GetLongBinary(1111);\n\t$str .= GetShortBinary(202);\n\t$str .= GetLongBinary($errno);\n\t$str .= GetDummy(6);\n\techo $str;\n}\n\nfunction EchoConnInfo($conn)\n{\n\tif ($GLOBALS['use_mysqli']) {\n\t\t$str = GetBlock(mysqli_get_host_info($conn));\n\t\t$str .= GetBlock(mysqli_get_proto_info($conn));\n\t\t$str .= GetBlock(mysqli_get_server_info($conn));\n\t\techo $str;\n\t} else {\n\t\t$str = GetBlock(mysql_get_host_info($conn));\n\t\t$str .= GetBlock(mysql_get_proto_info($conn));\n\t\t$str .= GetBlock(mysql_get_server_info($conn));\n\t\techo $str;\n\t}\n}\n\nfunction EchoResultSetHeader($errno, $affectrows, $insertid, $numfields, $numrows)\n{\n\t$str = GetLongBinary($errno);\n\t$str .= GetLongBinary($affectrows);\n\t$str .= GetLongBinary($insertid);\n\t$str .= GetLongBinary($numfields);\n\t$str .= GetLongBinary($numrows);\n\t$str .= GetDummy(12);\n\techo $str;\n}\n\nfunction EchoFieldsHeader($res, $numfields)\n{\n\t$str = \"\";\n\tfor( $i = 0; $i < $numfields; $i++ ) {\n\t\tif ($GLOBALS['use_mysqli']) {\n\t\t\t$finfo = mysqli_fetch_field_direct($res, $i);\n\t\t\t$str .= GetBlock($finfo->name);\n\t\t\t$str .= GetBlock($finfo->table);\n\t\t\t\n\t\t\t$type = $finfo->type;\n\t\t\t$length = $finfo->length;\n\t\t\n\t\t\t$str .= GetLongBinary($type);\n\t\n\t\t\t$intflag = $finfo->flags;\n\t\t\t$str .= GetLongBinary($intflag);\n\t\n\t\t\t$str .= GetLongBinary($length);\n\t\t} else {\n\t\t\t$str .= GetBlock(mysql_field_name($res, $i));\n\t\t\t$str .= GetBlock(mysql_field_table($res, $i));\n\t\n\t\t\t$type = mysql_field_type($res, $i);\n\t\t\t$length = mysql_field_len($res, $i);\n\t\t\tswitch ($type) {\n\t\t\t\tcase \"int\":\n\t\t\t\t\tif( $length > 11 ) $type = 8;\n\t\t\t\t\telse $type = 3;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"real\":\n\t\t\t\t\tif( $length == 12 ) $type = 4;\n\t\t\t\t\telseif( $length == 22 ) $type = 5;\n\t\t\t\t\telse $type = 0;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"null\":\n\t\t\t\t\t$type = 6;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"timestamp\":\n\t\t\t\t\t$type = 7;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"date\":\n\t\t\t\t\t$type = 10;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"time\":\n\t\t\t\t\t$type = 11;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"datetime\":\n\t\t\t\t\t$type = 12;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"year\":\n\t\t\t\t\t$type = 13;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"blob\":\n\t\t\t\t\tif( $length > 16777215 ) $type = 251;\n\t\t\t\t\telseif( $length > 65535 ) $type = 250;\n\t\t\t\t\telseif( $length > 255 ) $type = 252;\n\t\t\t\t\telse $type = 249;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t$type = 253;\n\t\t\t}\n\t\t\t$str .= GetLongBinary($type);\n\t\n\t\t\t$flags = explode( \" \", mysql_field_flags ( $res, $i ) );\n\t\t\t$intflag = 0;\n\t\t\tif(in_array( \"not_null\", $flags )) $intflag += 1;\n\t\t\tif(in_array( \"primary_key\", $flags )) $intflag += 2;\n\t\t\tif(in_array( \"unique_key\", $flags )) $intflag += 4;\n\t\t\tif(in_array( \"multiple_key\", $flags )) $intflag += 8;\n\t\t\tif(in_array( \"blob\", $flags )) $intflag += 16;\n\t\t\tif(in_array( \"unsigned\", $flags )) $intflag += 32;\n\t\t\tif(in_array( \"zerofill\", $flags )) $intflag += 64;\n\t\t\tif(in_array( \"binary\", $flags)) $intflag += 128;\n\t\t\tif(in_array( \"enum\", $flags )) $intflag += 256;\n\t\t\tif(in_array( \"auto_increment\", $flags )) $intflag += 512;\n\t\t\tif(in_array( \"timestamp\", $flags )) $intflag += 1024;\n\t\t\tif(in_array( \"set\", $flags )) $intflag += 2048;\n\t\t\t$str .= GetLongBinary($intflag);\n\t\n\t\t\t$str .= GetLongBinary($length);\n\t\t}\n\t}\n\techo $str;\n}\n\nfunction EchoData($res, $numfields, $numrows)\n{\n\tfor( $i = 0; $i < $numrows; $i++ ) {\n\t\t$str = \"\";\n\t\t$row = null;\n\t\tif ($GLOBALS['use_mysqli'])\n\t\t\t$row = mysqli_fetch_row( $res );\n\t\telse\n\t\t\t$row = mysql_fetch_row( $res );\n\t\tfor( $j = 0; $j < $numfields; $j++ ){\n\t\t\tif( is_null($row[$j]) )\n\t\t\t\t$str .= \"\\xFF\";\n\t\t\telse\n\t\t\t\t$str .= GetBlock($row[$j]);\n\t\t}\n\t\techo $str;\n\t}\n}\n\n\nfunction doSystemTest()\n{\n\tfunction output($description, $succ, $resStr) {\n\t\techo \"<tr><td class=\\\"TestDesc\\\">$description</td><td \";\n\t\techo ($succ)? \"class=\\\"TestSucc\\\">$resStr[0]</td></tr>\" : \"class=\\\"TestFail\\\">$resStr[1]</td></tr>\";\n\t}\n\toutput(\"PHP version >= 4.0.5\", phpversion_int() >= 40005, array(\"Yes\", \"No\"));\n\toutput(\"mysql_connect() available\", function_exists(\"mysql_connect\"), array(\"Yes\", \"No\"));\n\toutput(\"mysqli_connect() available\", function_exists(\"mysqli_connect\"), array(\"Yes\", \"No\"));\n\tif (phpversion_int() >= 40302 && substr($_SERVER[\"SERVER_SOFTWARE\"], 0, 6) == \"Apache\" && function_exists(\"apache_get_modules\")){\n\t\tif (in_array(\"mod_security2\", apache_get_modules()))\n\t\t\toutput(\"Mod Security 2 installed\", false, array(\"No\", \"Yes\"));\n\t}\n}\n\n/////////////////////////////////////////////////////////////////////////////\n////\n\n\tif (phpversion_int() < 40005) {\n\t\tEchoHeader(201);\n\t\techo GetBlock(\"unsupported php version\");\n\t\texit();\n\t}\n\n\tif (phpversion_int() < 40010) {\n\t\tglobal $HTTP_POST_VARS;\n\t\t$_POST = &$HTTP_POST_VARS;\t\n\t}\n\n\tif (!isset($_POST[\"actn\"]) || !isset($_POST[\"host\"]) || !isset($_POST[\"port\"]) || !isset($_POST[\"login\"])) {\n\t\t$testMenu = $allowTestMenu;\n\t\tif (!$testMenu){\n\t\t\tEchoHeader(202);\n\t\t\techo GetBlock(\"invalid parameters\");\n\t\t\texit();\n\t\t}\n\t}\n\n\tif (!$testMenu){\n\t\tif ($_POST[\"encodeBase64\"] == '1') {\n\t\t\tfor($i=0;$i<count($_POST[\"q\"]);$i++)\n\t\t\t\t$_POST[\"q\"][$i] = base64_decode($_POST[\"q\"][$i]);\n\t\t}\n\t\t\n\t\tif (!function_exists(\"mysql_connect\") && !function_exists(\"mysqli_connect\")) {\n\t\t\tEchoHeader(203);\n\t\t\techo GetBlock(\"MySQL not supported on the server\");\n\t\t\texit();\n\t\t}\n\t\t\n\t\t$errno_c = 0;\n\t\t$hs = $_POST[\"host\"];\n\t\tif ($use_mysqli) {\n\t\t\tif( $_POST[\"port\"] ) \n\t\t\t\t$conn = mysqli_connect($hs, $_POST[\"login\"], $_POST[\"password\"], '', $_POST[\"port\"]);\n\t\t\telse\n\t\t\t\t$conn = mysqli_connect($hs, $_POST[\"login\"], $_POST[\"password\"]);\n\t\t\t$errno_c = mysqli_connect_errno($conn);\n\t\t\tif (phpversion_int() >= 50005){  // for unicode database name\n\t\t\t\tmysqli_set_charset($conn, 'UTF8');\n\t\t\t}\n\t\t\tif($errno_c > 0) {\n\t\t\t\tEchoHeader($errno_c);\n\t\t\t\techo GetBlock(mysqli_connect_error($conn));\n\t\t\t\texit;\n\t\t\t}\n\n\t\t\tif(($errno_c <= 0) && ( $_POST[\"db\"] != \"\" )) {\n\t\t\t\t$res = mysqli_select_db($conn, $_POST[\"db\"] );\n\t\t\t\t$errno_c = mysqli_errno($conn);\n\t\t\t}\n\n\t\t\tEchoHeader($errno_c);\n\t\t\tif($errno_c > 0) {\n\t\t\t\techo GetBlock(mysqli_error($conn));\n\t\t\t} elseif($_POST[\"actn\"] == \"C\") {\n\t\t\t\tEchoConnInfo($conn);\n\t\t\t} elseif($_POST[\"actn\"] == \"Q\") {\n\t\t\t\tfor($i=0;$i<count($_POST[\"q\"]);$i++) {\n\t\t\t\t\t$query = $_POST[\"q\"][$i];\n\t\t\t\t\tif($query == \"\") continue;\n\t\t\t\t\tif (phpversion_int() < 50400){  \n\t\t\t\t\t\tif(get_magic_quotes_gpc())\n\t\t\t\t\t\t\t$query = stripslashes($query);\n\t\t\t\t\t}\n\t\t\t\t\t$res = mysqli_query($conn, $query);\n\t\t\t\t\t$errno = mysqli_errno($conn);\n\t\t\t\t\t$affectedrows = mysqli_affected_rows($conn);\n\t\t\t\t\t$insertid = mysqli_insert_id($conn);\t\t\t\t\n\t\t\t\t\tif (false !== $res) {\n\t\t\t\t\t\t$numfields = mysqli_field_count($conn);\n\t\t\t\t\t\t$numrows = mysqli_num_rows($res);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t$numfields = 0;\n\t\t\t\t\t\t$numrows = 0;\n\t\t\t\t\t}\n\t\t\t\t\tEchoResultSetHeader($errno, $affectedrows, $insertid, $numfields, $numrows);\n\t\t\t\t\tif($errno > 0)\n\t\t\t\t\t\techo GetBlock(mysqli_error($conn));\n\t\t\t\t\telse {\n\t\t\t\t\t\tif($numfields > 0) {\n\t\t\t\t\t\t\tEchoFieldsHeader($res, $numfields);\n\t\t\t\t\t\t\tEchoData($res, $numfields, $numrows);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(phpversion_int() >= 40300)\n\t\t\t\t\t\t\t\techo GetBlock(mysqli_info($conn));\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\techo GetBlock(\"\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif($i<(count($_POST[\"q\"])-1))\n\t\t\t\t\t\techo \"\\x01\";\n\t\t\t\t\telse\n\t\t\t\t\t\techo \"\\x00\";\n\t\t\t\t\tif (false !== $res)\n\t\t\t\t\t\tmysqli_free_result($res);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif( $_POST[\"port\"] ) $hs .= \":\".$_POST[\"port\"];\n\t\t\t$conn = mysql_connect($hs, $_POST[\"login\"], $_POST[\"password\"]);\n\t\t\t$errno_c = mysql_errno();\n\t\t\tif (phpversion_int() >= 50203){  // for unicode database name\n\t\t\t\tmysql_set_charset('UTF8', $conn);\n\t\t\t}\n\t\t\tif(($errno_c <= 0) && ( $_POST[\"db\"] != \"\" )) {\n\t\t\t\t$res = mysql_select_db( $_POST[\"db\"], $conn);\n\t\t\t\t$errno_c = mysql_errno();\n\t\t\t}\n\t\t\t\n\t\t\tEchoHeader($errno_c);\n\t\t\tif($errno_c > 0) {\n\t\t\t\techo GetBlock(mysql_error());\n\t\t\t} elseif($_POST[\"actn\"] == \"C\") {\n\t\t\t\tEchoConnInfo($conn);\n\t\t\t} elseif($_POST[\"actn\"] == \"Q\") {\n\t\t\t\tfor($i=0;$i<count($_POST[\"q\"]);$i++) {\n\t\t\t\t\t$query = $_POST[\"q\"][$i];\n\t\t\t\t\tif($query == \"\") continue;\n\t\t\t\t\tif (phpversion_int() < 50400){  \n\t\t\t\t\t\tif(get_magic_quotes_gpc())\n\t\t\t\t\t\t\t$query = stripslashes($query);\n\t\t\t\t\t}\n\t\t\t\t\t$res = mysql_query($query, $conn);\n\t\t\t\t\t$errno = mysql_errno();\n\t\t\t\t\t$affectedrows = mysql_affected_rows($conn);\n\t\t\t\t\t$insertid = mysql_insert_id($conn);\n\t\t\t\t\t$numfields = mysql_num_fields($res);\n\t\t\t\t\t$numrows = mysql_num_rows($res);\n\t\t\t\t\tEchoResultSetHeader($errno, $affectedrows, $insertid, $numfields, $numrows);\n\t\t\t\t\tif($errno > 0)\n\t\t\t\t\t\techo GetBlock(mysql_error());\n\t\t\t\t\telse {\n\t\t\t\t\t\tif($numfields > 0) {\n\t\t\t\t\t\t\tEchoFieldsHeader($res, $numfields);\n\t\t\t\t\t\t\tEchoData($res, $numfields, $numrows);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(phpversion_int() >= 40300)\n\t\t\t\t\t\t\t\techo GetBlock(mysql_info($conn));\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\techo GetBlock(\"\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif($i<(count($_POST[\"q\"])-1))\n\t\t\t\t\t\techo \"\\x01\";\n\t\t\t\t\telse\n\t\t\t\t\t\techo \"\\x00\";\n\t\t\t\t\tmysql_free_result($res);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\texit();\n\t}\n\n\theader(\"Content-Type: text/html\");\n////\n/////////////////////////////////////////////////////////////////////////////\n?>\n\n<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n\t<title>Navicat HTTP Tunnel Tester</title>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n\t<style type=\"text/css\">\n\t\tbody{\n\t\t\tmargin: 30px;\n\t\t\tfont-family: Tahoma;\n\t\t\tfont-weight: normal;\n\t\t\tfont-size: 14px;\n\t\t\tcolor: #222222;\n\t\t}\n\t\ttable{\n\t\t\twidth: 100%;\n\t\t\tborder: 0px;\n\t\t}\n\t\tinput{\n\t\t\tfont-family:Tahoma,sans-serif;\n\t\t\tborder-style:solid;\n\t\t\tborder-color:#666666;\n\t\t\tborder-width:1px;\n\t\t}\n\t\tfieldset{\n\t\t\tborder-style:solid;\n\t\t\tborder-color:#666666;\n\t\t\tborder-width:1px;\n\t\t}\n\t\t.Title1{\n\t\t\tfont-size: 30px;\n\t\t\tcolor: #003366;\n\t\t}\n\t\t.Title2{\n\t\t\tfont-size: 10px;\n\t\t\tcolor: #999966;\n\t\t}\n\t\t.TestDesc{\n\t\t\twidth:70%\n\t\t}\n\t\t.TestSucc{\n\t\t\tcolor: #00BB00;\n\t\t}\n\t\t.TestFail{\n\t\t\tcolor: #DD0000;\n\t\t}\n\t\t.mysql{\n\t\t}\n\t\t.pgsql{\n\t\t\tdisplay:none;\n\t\t}\n\t\t.sqlite{\n\t\t\tdisplay:none;\n\t\t}\n\t\t#page{\n\t\t\tmax-width: 42em;\n\t\t\tmin-width: 36em;\n\t\t\tborder-width: 0px;\n\t\t\tmargin: auto auto;\n\t\t}\n\t\t#host, #dbfile{\n\t\t\twidth: 300px;\n\t\t}\n\t\t#port{\n\t\t\twidth: 75px;\n\t\t}\n\t\t#login, #password, #db{\n\t\t\twidth: 150px;\n\t\t}\n\t\t#Copyright{\n\t\t\ttext-align: right;\n\t\t\tfont-size: 10px;\n\t\t\tcolor: #888888;\n\t\t}\n\t</style>\n\t<script type=\"text/javascript\">\n\tfunction getInternetExplorerVersion(){\n\t\tvar ver = -1;\n\t\tif (navigator.appName == \"Microsoft Internet Explorer\"){\n\t\t\tvar regex = new RegExp(\"MSIE ([0-9]{1,}[\\.0-9]{0,})\");\n\t\t\tif (regex.exec(navigator.userAgent))\n\t\t\t\tver = parseFloat(RegExp.$1);\n\t\t}\n\t\treturn ver;\n\t}\n\tfunction setText(element, text, succ){\n\t\telement.className = (succ)?\"TestSucc\":\"TestFail\";\n\t\telement.innerHTML = text;\n\t}\n\tfunction getByteAt(str, offset){\n\t\treturn str.charCodeAt(offset) & 0xff;\n\t}\n\tfunction getIntAt(binStr, offset){\n\t\treturn (getByteAt(binStr, offset) << 24)+\n\t\t\t(getByteAt(binStr, offset+1) << 16)+\n\t\t\t(getByteAt(binStr, offset+2) << 8)+\n\t\t\t(getByteAt(binStr, offset+3) >>> 0);\n\t}\n\tfunction getBlockStr(binStr, offset){\n\t\tif (getByteAt(binStr, offset) < 254)\n\t\t\treturn binStr.substring(offset+1, offset+1+binStr.charCodeAt(offset));\n\t\telse\n\t\t\treturn binStr.substring(offset+5, offset+5+getIntAt(binStr, offset+1));\n\t}\n\tfunction doServerTest(){\n\t\tvar version = getInternetExplorerVersion();\n\t\tif (version==-1 || version>=9.0){\n\t\t\tvar xmlhttp = (window.XMLHttpRequest)? new XMLHttpRequest() : xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n\t\t\t\n\t\t\txmlhttp.onreadystatechange=function(){\n\t\t\t\tvar outputDiv = document.getElementById(\"ServerTest\");\n\t\t\t\tif (xmlhttp.readyState == 4){\n\t\t\t\t\tif (xmlhttp.status == 200){\n\t\t\t\t\t\tvar errno = getIntAt(xmlhttp.responseText, 6);\n\t\t\t\t\t\tif (errno == 0)\n\t\t\t\t\t\t\tsetText(outputDiv, \"Connection Success!\", true);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tsetText(outputDiv, parseInt(errno)+\" - \"+getBlockStr(xmlhttp.responseText, 16), false);\n\t\t\t\t\t}else\n\t\t\t\t\t\tsetText(outputDiv, \"HTTP Error - \"+xmlhttp.status, false);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tvar params = \"\";\n\t\t\tvar form = document.getElementById(\"TestServerForm\");\n\t\t\tfor (var i=0; i<form.elements.length; i++){\n\t\t\t\tif (i>0) params += \"&\";\n\t\t\t\tparams += form.elements[i].id+\"=\"+form.elements[i].value.replace(\"&\", \"%26\");\n\t\t\t}\n\t\t\t\n\t\t\tdocument.getElementById(\"ServerTest\").className = \"\";\n\t\t\tdocument.getElementById(\"ServerTest\").innerHTML = \"Connecting...\";\n\t\t\txmlhttp.open(\"POST\", \"\", true);\n\t\t\txmlhttp.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\");\n\t\t\txmlhttp.setRequestHeader(\"Content-length\", params.length);\n\t\t\txmlhttp.setRequestHeader(\"Connection\", \"close\");\n\t\t\txmlhttp.send(params);\n\t\t}else{\n\t\t\tdocument.getElementById(\"ServerTest\").className = \"\";\n\t\t\tdocument.getElementById(\"ServerTest\").innerHTML = \"Internet Explorer \"+version+\" is not supported, please use Internet explorer 9.0 or above, firefox, chrome or safari\";\n\t\t}\n\t}\n\t</script>\n</head>\n\n<body>\n<div id=\"page\">\n<p>\n\t<font class=\"Title1\">Navicat&trade;</font><br>\n\t<font class=\"Title2\">The gateway to your database!</font>\n</p>\n<fieldset>\n\t<legend>System Environment Test</legend>\n\t<table>\n\t\t<tr style=\"<?php echo \"display:none\"; ?>\"><td width=70%>PHP installed properly</td><td class=\"TestFail\">No</td></tr>\n\t\t<?php echo doSystemTest();?>\n\t</table>\n</fieldset>\n<br>\n<fieldset>\n\t<legend>Server Test</legend>\n\t<form id=\"TestServerForm\" action=\"#\" onSubmit=\"return false;\">\n\t<input type=hidden id=\"actn\" value=\"C\">\n\t<table>\n\t\t<tr class=\"mysql\"><td width=\"35%\">Hostname/IP Address:</td><td><input type=text id=\"host\" placeholder=\"localhost\"></td></tr>\n\t\t<tr class=\"mysql\"><td>Port:</td><td><input type=text id=\"port\" placeholder=\"3306\"></td></tr>\n\t\t<tr class=\"pgsql\"><td>Initial Database:</td><td><input type=text id=\"db\" placeholder=\"template1\"></td></tr>\n\t\t<tr class=\"mysql\"><td>Username:</td><td><input type=text id=\"login\" placeholder=\"root\"></td></tr>\n\t\t<tr class=\"mysql\"><td>Password:</td><td><input type=password id=\"password\" placeholder=\"\"></td></tr>\n\t\t<tr class=\"sqlite\"><td>Database File:</td><td><input type=text id=\"dbfile\" placeholder=\"sqlite.db\"></td></tr>\n\t\t<tr><td></td><td><br><input id=\"TestButton\" type=\"submit\" value=\"Test Connection\" onClick=\"doServerTest()\"></td></tr>\n\t</table>\n\t</form>\n\t<div id=\"ServerTest\"><br></div>\n</fieldset>\n<p id=\"Copyright\">Copyright &copy; PremiumSoft &trade; CyberTech Ltd. All Rights Reserved.</p>\n</div>\n</body>\n</html>"
  ntunnel_pgsql: "<?php\n$versionNum = 203; // remark: require update CC_HTTP_TUNNEL_SCRIPT_LATEST_VERSION_PGSQL\n\n//set allowTestMenu to false to disable System/Server test page\n$allowTestMenu = true;\n\nheader(\"Content-Type: text/plain; charset=x-user-defined\");\nerror_reporting(0);\nset_time_limit(0);\n\nfunction phpversion_int()\n{\n\tlist($maVer, $miVer, $edVer) = preg_split(\"(/|\\.|-)\", phpversion());\n\treturn $maVer*10000 + $miVer*100 + $edVer;\n}\n\nif (phpversion_int() < 50300)\n{\n\tset_magic_quotes_runtime(0);\n}\n\nfunction GetLongBinary($num)\n{\n\treturn pack(\"N\",$num);\n}\n\nfunction GetShortBinary($num)\n{\n\treturn pack(\"n\",$num);\n}\n\nfunction GetDummy($count)\n{\n\t$str = \"\";\n\tfor($i=0;$i<$count;$i++)\n\t\t$str .= \"\\x00\";\n\treturn $str;\n}\n\nfunction GetBlock($val)\n{\n\t$len = strlen($val);\n\tif( $len < 254 )\n\t\treturn chr($len).$val;\n\telse\n\t\treturn \"\\xFE\".GetLongBinary($len).$val;\n}\n\nfunction EchoHeader($errno)\n{\n    global $versionNum;\n\n\t$str = GetLongBinary(1111);\n\t$str .= GetShortBinary($versionNum);\n\t$str .= GetLongBinary($errno);\n\t$str .= GetDummy(6);\n\techo $str;\n}\n\nfunction EchoConnInfo($conn)\n{\n\t$str = GetBlock(pg_host($conn));\n\t$protocol = \"3\";\n\t$version = \"\";\n\t$is_set = false;\n\tif(function_exists(\"pg_version\")) {\n\t\t$v = pg_version($conn);\n\t\tif(array_key_exists('protocol', $v)) {\n\t\t\t$protocol = $v['protocol'];\n\t\t}\n\t\tif(array_key_exists('server', $v)) {\n\t\t\t$version = $v['server'];\n\t\t\t$is_set = true;\n\t\t}\n\t}\n\tif(!$is_set) {\n\t\t$res = pg_query($conn,\"select substring(version(), '[0-9]{1,2}\\\\.[0-9]{1,2}[\\\\.|0-9|a-z|A-Z]+')\");\n\t\tif($res) {\n\t\t\t$numfields = pg_num_fields($res);\n\t\t\tif($numfields == 1) {\n\t\t\t\t$row = pg_fetch_row($res);\n\t\t\t\tif($row) {\n\t\t\t\t\t$version = $row[0];\n\t\t\t\t}\n\t\t\t}\n\t\t\tpg_free_result($res);\n\t\t}\n\t}\n\t$str .= GetBlock($protocol);\n\t\n\t$major = 0;\n\t$minor = 0;\n\t$patch_level = 0;\n\t$version_int = 0;\n\tif(sscanf($version, \"%d.%d.%d\", $major, $minor, $patch_level) >= 3) {\n\t\t$version_int = $major*10000+$minor*100+$patch_level;\n\t} else if(sscanf($version, \"%d.%d%s\", $major, $minor, $patch_level) >= 3) {\n\t\t$version_int = $major*10000+$minor*100;\n\t} else {\n\t\t$version_int = 0; // returns 0 such that navicat able to handle the server version\n\t}\n\t$str .= GetBlock($version_int);\n\techo $str;\n}\n\nfunction EchoResultSetHeader($errno, $affectrows, $insertid, $numfields, $numrows)\n{\n\t$str = GetLongBinary($errno);\n\t$str .= GetLongBinary($affectrows);\n\t$str .= GetLongBinary($insertid);\n\t$str .= GetLongBinary($numfields);\n\t$str .= GetLongBinary($numrows);\n\t$str .= GetDummy(12);\n\techo $str;\n}\n\nfunction EchoFieldsHeader($res, $numfields)\n{\n\t$str = \"\";\n\tfor( $i = 0; $i < $numfields; $i++ ) {\n\t\t$str .= GetBlock(pg_field_name($res, $i));\n\t\t$str .= GetBlock(\"\");\n\n\t\t$type = pg_field_type($res, $i);\n\t\t$length = pg_field_size($res, $i);\n\t\tswitch ($type){\n\t\t\tcase \"boolean\":\t\t\t$type=16;\t\tbreak;\n\t\t\tcase \"bytea\":\t\t\t$type=17;\t\tbreak;\n\t\t\tcase \"bit\":\t\t\t\t$type=1560;\t\tbreak;\n\t\t\tcase \"varbit\":\t\t\t$type=1562;\t\tbreak;\n\t\t\tcase \"char\":\t\t\t$type=18;\t\tbreak;\n\t\t\tcase \"name\":\t\t\t$type=19;\t\tbreak;\n\t\t\tcase \"int2vector\":\t\t$type=22;\t\tbreak;\n\t\t\tcase \"oidvector\":\t\t$type=30;\t\tbreak;\n\t\t\tcase \"int8\":\t\t\t$type=20;\t\tbreak;\n\t\t\tcase \"tid\":\t\t\t\t$type=27;\t\tbreak;\n\t\t\tcase \"int2\":\t\t\t$type=21;\t\tbreak;\n\t\t\tcase \"int4\":\t\t\t$type=23;\t\tbreak;\n\t\t\tcase \"oid\":\t\t\t\t$type=26;\t\tbreak;\n\t\t\tcase \"xid\":\t\t\t\t$type=28;\t\tbreak;\n\t\t\tcase \"cid\":\t\t\t\t$type=29;\t\tbreak;\n\t\t\tcase \"text\":\t\t\t$type=25;\t\tbreak;\n\t\t\tcase \"money\":\t\t\t$type=790;\t\tbreak;\n\t\t\tcase \"numeric\":\t\t\t$type=1700;\t\tbreak;\n\t\t\tcase \"point\":\t\t\t$type=600;\t\tbreak;\n\t\t\tcase \"lseg\":\t\t\t$type=601;\t\tbreak;\n\t\t\tcase \"path\":\t\t\t$type=602;\t\tbreak;\n\t\t\tcase \"box\":\t\t\t\t$type=603;\t\tbreak;\n\t\t\tcase \"polygon\":\t\t\t$type=604;\t\tbreak;\n\t\t\tcase \"line\":\t\t\t$type=628;\t\tbreak;\n\t\t\tcase \"circle\":\t\t\t$type=718;\t\tbreak;\n\t\t\tcase \"float4\":\t\t\t$type=700;\t\tbreak;\n\t\t\tcase \"float8\":\t\t\t$type=701;\t\tbreak;\n\t\t\tcase \"abstime\":\t\t\t$type=702;\t\tbreak;\n\t\t\tcase \"tinterval\":\t\t$type=704;\t\tbreak;\n\t\t\tcase \"timestamp\":\t\t$type=1114;\t\tbreak;\n\t\t\tcase \"timestamptz\":\t\t$type=1184;\t\tbreak;\n\t\t\tcase \"interval\":\t\t$type=1186;\t\tbreak;\n\t\t\tcase \"timetz\":\t\t\t$type=1266;\t\tbreak;\n\t\t\tcase \"unknown\":\t\t\t$type=705;\t\tbreak;\n\t\t\tcase \"macaddr\":\t\t\t$type=829;\t\tbreak;\n\t\t\tcase \"inet\":\t\t\t$type=869;\t\tbreak;\n\t\t\tcase \"cidr\":\t\t\t$type=650;\t\tbreak;\n\t\t\tcase \"bpchar\":\t\t\t$type=1042;\t\tbreak;\n\t\t\tcase \"varchar\":\t\t\t$type=1043;\t\tbreak;\n\t\t\tcase \"date\":\t\t\t$type=1082;\t\tbreak;\n\t\t\tcase \"time\":\t\t\t$type=1083;\t\tbreak;\n\t\t\tcase \"regproc\":\t\t\t$type=24;\t\tbreak;\n\t\t\tcase \"refcursor\":\t\t$type=1790;\t\tbreak;\n\t\t\tcase \"regprocedure\":\t$type=2202;\t\tbreak;\n\t\t\tcase \"regoper\":\t\t\t$type=2203;\t\tbreak;\n\t\t\tcase \"regoperator\":\t\t$type=2204;\t\tbreak;\n\t\t\tcase \"regclass\":\t\t$type=2205;\t\tbreak;\n\t\t\tcase \"regtype\":\t\t\t$type=2206;\t\tbreak;\n\t\t\tdefault: 0;\n\t\t}\n\n\t\t$str .= GetLongBinary($type);\n\t\t$str .= GetLongBinary(0);\n\t\t$str .= GetLongBinary($length);\n\t}\n\techo $str;\n}\n\nfunction EchoData($res, $numfields, $numrows)\n{\n\tfor ($i=0; $i < $numrows; $i++ ) {\n\t\t$str = \"\";\n\t\t$row = pg_fetch_row( $res );\n\t\tfor ($j=0; $j < $numfields; $j++ ){\n\t\t\tif( is_null($row[$j]) )\n\t\t\t\t$str .= \"\\xFF\";\n\t\t\telse\n\t\t\t\t$str .= GetBlock($row[$j]);\n\t\t}\n\t\techo $str;\n\t}\n}\n\n\tif (phpversion_int() < 40005) {\n\t\tEchoHeader(201);\n\t\techo GetBlock(\"unsupported php version\");\n\t\texit();\n\t}\n\t\n\tif (phpversion_int() < 40010) {\n\t\tglobal $HTTP_POST_VARS;\n\t\t$_POST = &$HTTP_POST_VARS;\t\n\t}\n\t\n\tif (!isset($_POST[\"actn\"]) || !isset($_POST[\"host\"]) || !isset($_POST[\"port\"]) || !isset($_POST[\"login\"])) {\n\t\t$testMenu = $allowTestMenu;\n\t\tif (!$testMenu){\n\t\t\tEchoHeader(202);\n\t\t\techo GetBlock(\"invalid parameters\");\n\t\t\texit();\n\t\t}\n\t}\n\t\n\tif (!$testMenu){\n\t\tif ($_POST[\"encodeBase64\"] == '1') {\n\t\t\tfor($i=0;$i<count($_POST[\"q\"]);$i++)\n\t\t\t\t$_POST[\"q\"][$i] = base64_decode($_POST[\"q\"][$i]);\n\t\t}\n\t\t\n\t\tif (!function_exists(\"pg_connect\")) {\n\t\t\tEchoHeader(203);\n\t\t\techo GetBlock(\"PostgresSQL not supported on the server\");\n\t\t\texit();\n\t\t}\n\n\t\t$errno_c = 0;\n\t\tif ($_POST[\"host\"] != \"\")\n\t\t\t$connstr = \"host=\".$_POST[\"host\"];\n\t\t$connstr .= \" port=\".$_POST[\"port\"];\n\t\tif ($_POST[\"db\"] != \"\")\n\t\t\t$connstr .= \" dbname='\".$_POST[\"db\"].\"'\";\n\t\telse\n\t\t\t$connstr .= \" dbname='template1'\";\n\t\t$connstr .= \" user=\".$_POST[\"login\"].\" password=\".$_POST[\"password\"];\n\t\t$conn = pg_connect($connstr);\n\t\tif (!$conn) {\n\t\t\t$errno_c = 202;\n\t\t\t$error_c = \"Could not allocate new connection\";\n\t\t}\n\t\n\t\tEchoHeader($errno_c);\n\t\tif ($errno_c > 0) {\n\t\t\techo GetBlock($error_c);\n\t\t} elseif ($_POST[\"actn\"] == \"C\") {\n\t\t\tEchoConnInfo($conn);\n\t\t} elseif ($_POST[\"actn\"] == \"Q\") {\n\t\t\tfor ($i=0; $i < count($_POST[\"q\"]); $i++) {\n\t\t\t\t$query = $_POST[\"q\"][$i];\n\t\t\t\tif ($query == \"\") continue;\n\t\t\t\tif (phpversion_int() < 50400){  \n\t\t\t\t\tif(get_magic_quotes_gpc())\n\t\t\t\t\t\t$query = stripslashes($query);\n\t\t\t\t}\n\t\t\t\t$res = pg_query($conn,$query);\n\t\t\t\t$error = pg_last_error($conn);\n\t\t\t\tif ($error <> \"\")\n\t\t\t\t\t$errno = 1;\n\t\t\t\telse\n\t\t\t\t\t$errno = 0;\n\t\t\t\t$affectedrows = pg_affected_rows($res);\n\t\t\t\t$insertid = 0;\n\t\t\t\t$numfields = pg_num_fields($res);\n\t\t\t\t$numrows = pg_num_rows($res);\n\t\t\t\tEchoResultSetHeader($errno, $affectedrows, $insertid, $numfields, $numrows);\n\t\t\t\tif($errno > 0)\n\t\t\t\t\techo GetBlock($error);\n\t\t\t\telse {\n\t\t\t\t\tif ($numfields > 0) {\n\t\t\t\t\t\tEchoFieldsHeader($res, $numfields);\n\t\t\t\t\t\tEchoData($res, $numfields, $numrows);\n\t\t\t\t\t} else\n\t\t\t\t\t\techo GetBlock(\"\");\n\t\t\t\t}\n\t\t\t\tif ($i < (count($_POST[\"q\"])-1))\n\t\t\t\t\techo \"\\x01\";\n\t\t\t\telse\n\t\t\t\t\techo \"\\x00\";\n\t\t\t\tpg_free_result($res);\n\t\t\t}\n\t\t}\n\t\texit();\n\t}\n\n\n\nfunction doSystemTest()\n{\n    global $versionNum;\n\n\tfunction output($description, $succ, $resStr) {\n\t\techo \"<tr><td class=\\\"TestDesc\\\">$description</td><td \";\n\t\techo ($succ)? \"class=\\\"TestSucc\\\">$resStr[0]</td></tr>\" : \"class=\\\"TestFail\\\">$resStr[1]</td></tr>\";\n\t}\n\toutput(\"PHP version >= 4.0.5\", phpversion_int() >= 40005, array(\"Yes (\".phpversion().\")\", \"No (\".phpversion().\")\"));\n\toutput(\"pg_connect() available\", function_exists(\"pg_connect\"), array(\"Yes\", \"No\"));\n\tif (phpversion_int() >= 40302 && substr($_SERVER[\"SERVER_SOFTWARE\"], 0, 6) == \"Apache\" && function_exists(\"apache_get_modules\")){\n\t\tif (in_array(\"mod_security2\", apache_get_modules()))\n\t\t\toutput(\"Mod Security 2 installed\", false, array(\"No\", \"Yes\"));\n\t}\n    output(\"Current tunnel file version\", true, array((int)($versionNum / 100) .\".\". ($versionNum % 100), \"\"));\n}\n\nheader(\"Content-Type: text/html\");\n?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n\t<title>Navicat HTTP Tunnel Tester</title>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n\t<style type=\"text/css\">\n\t\tbody{\n\t\t\tmargin: 30px;\n\t\t\tfont-family: Tahoma;\n\t\t\tfont-weight: normal;\n\t\t\tfont-size: 14px;\n\t\t\tcolor: #222222;\n\t\t}\n\t\ttable{\n\t\t\twidth: 100%;\n\t\t\tborder: 0px;\n\t\t}\n\t\tinput{\n\t\t\tfont-family:Tahoma,sans-serif;\n\t\t\tborder-style:solid;\n\t\t\tborder-color:#666666;\n\t\t\tborder-width:1px;\n\t\t}\n\t\tfieldset{\n\t\t\tborder-style:solid;\n\t\t\tborder-color:#666666;\n\t\t\tborder-width:1px;\n\t\t}\n\t\t.Title1{\n\t\t\tfont-size: 30px;\n\t\t\tcolor: #003366;\n\t\t}\n\t\t.Title2{\n\t\t\tfont-size: 10px;\n\t\t\tcolor: #999966;\n\t\t}\n\t\t.TestDesc{\n\t\t\twidth:70%\n\t\t}\n\t\t.TestSucc{\n\t\t\tcolor: #00BB00;\n\t\t}\n\t\t.TestFail{\n\t\t\tcolor: #DD0000;\n\t\t}\n\t\t.mysql{\n\t\t}\n\t\t.pgsql{\n\t\t}\n\t\t.sqlite{\n\t\t\tdisplay:none;\n\t\t}\n\t\t#page{\n\t\t\tmax-width: 42em;\n\t\t\tmin-width: 36em;\n\t\t\tborder-width: 0px;\n\t\t\tmargin: auto auto;\n\t\t}\n\t\t#host, #dbfile{\n\t\t\twidth: 300px;\n\t\t}\n\t\t#port{\n\t\t\twidth: 75px;\n\t\t}\n\t\t#login, #password, #db{\n\t\t\twidth: 150px;\n\t\t}\n\t\t#Copyright{\n\t\t\ttext-align: right;\n\t\t\tfont-size: 10px;\n\t\t\tcolor: #888888;\n\t\t}\n\t</style>\n\t<script type=\"text/javascript\">\n\tfunction getInternetExplorerVersion(){\n\t\tvar ver = -1;\n\t\tif (navigator.appName == \"Microsoft Internet Explorer\"){\n\t\t\tvar regex = new RegExp(\"MSIE ([0-9]{1,}[\\.0-9]{0,})\");\n\t\t\tif (regex.exec(navigator.userAgent))\n\t\t\t\tver = parseFloat(RegExp.$1);\n\t\t}\n\t\treturn ver;\n\t}\n\tfunction setText(element, text, succ){\n\t\telement.className = (succ)?\"TestSucc\":\"TestFail\";\n\t\telement.innerHTML = text;\n\t}\n\tfunction getByteAt(str, offset){\n\t\treturn str.charCodeAt(offset) & 0xff;\n\t}\n\tfunction getIntAt(binStr, offset){\n\t\treturn (getByteAt(binStr, offset) << 24)+\n\t\t\t(getByteAt(binStr, offset+1) << 16)+\n\t\t\t(getByteAt(binStr, offset+2) << 8)+\n\t\t\t(getByteAt(binStr, offset+3) >>> 0);\n\t}\n\tfunction getBlockStr(binStr, offset){\n\t\tif (getByteAt(binStr, offset) < 254)\n\t\t\treturn binStr.substring(offset+1, offset+1+binStr.charCodeAt(offset));\n\t\telse\n\t\t\treturn binStr.substring(offset+5, offset+5+getIntAt(binStr, offset+1));\n\t}\n\tfunction doServerTest(){\n\t\tvar version = getInternetExplorerVersion();\n\t\tif (version==-1 || version>=9.0){\n\t\t\tvar xmlhttp = (window.XMLHttpRequest)? new XMLHttpRequest() : xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n\t\t\t\n\t\t\txmlhttp.onreadystatechange=function(){\n\t\t\t\tvar outputDiv = document.getElementById(\"ServerTest\");\n\t\t\t\tif (xmlhttp.readyState == 4){\n\t\t\t\t\tif (xmlhttp.status == 200){\n\t\t\t\t\t\tvar errno = getIntAt(xmlhttp.responseText, 6);\n\t\t\t\t\t\tif (errno == 0)\n\t\t\t\t\t\t\tsetText(outputDiv, \"Connection Success!\", true);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tsetText(outputDiv, parseInt(errno)+\" - \"+getBlockStr(xmlhttp.responseText, 16), false);\n\t\t\t\t\t}else\n\t\t\t\t\t\tsetText(outputDiv, \"HTTP Error - \"+xmlhttp.status, false);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tvar params = \"\";\n\t\t\tvar form = document.getElementById(\"TestServerForm\");\n\t\t\tfor (var i=0; i<form.elements.length; i++){\n\t\t\t\tif (i>0) params += \"&\";\n\t\t\t\tparams += form.elements[i].id+\"=\"+form.elements[i].value.replace(\"&\", \"%26\");\n\t\t\t}\n\t\t\t\n\t\t\tdocument.getElementById(\"ServerTest\").className = \"\";\n\t\t\tdocument.getElementById(\"ServerTest\").innerHTML = \"Connecting...\";\n\t\t\txmlhttp.open(\"POST\", \"\", true);\n\t\t\txmlhttp.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\");\n\t\t\txmlhttp.setRequestHeader(\"Content-length\", params.length);\n\t\t\txmlhttp.setRequestHeader(\"Connection\", \"close\");\n\t\t\txmlhttp.send(params);\n\t\t}else{\n\t\t\tdocument.getElementById(\"ServerTest\").className = \"\";\n\t\t\tdocument.getElementById(\"ServerTest\").innerHTML = \"Internet Explorer \"+version+\" is not supported, please use Internet explorer 9.0 or above, firefox, chrome or safari\";\n\t\t}\n\t}\n\t</script>\n</head>\n\n<body>\n<div id=\"page\">\n<p>\n\t<font class=\"Title1\">Navicat&trade;</font><br>\n\t<font class=\"Title2\">The gateway to your database!</font>\n</p>\n<fieldset>\n\t<legend>System Environment Test</legend>\n\t<table>\n\t\t<tr style=\"<?php echo \"display:none\"; ?>\"><td width=70%>PHP installed properly</td><td class=\"TestFail\">No</td></tr>\n\t\t<?php echo doSystemTest();?>\n\t</table>\n</fieldset>\n<br>\n<fieldset>\n\t<legend>Server Test</legend>\n\t<form id=\"TestServerForm\" action=\"#\" onSubmit=\"return false;\">\n\t<input type=hidden id=\"actn\" value=\"C\">\n\t<table>\n\t\t<tr class=\"mysql\"><td width=\"35%\">Hostname/IP Address:</td><td><input type=text id=\"host\" placeholder=\"localhost\"></td></tr>\n\t\t<tr class=\"mysql\"><td>Port:</td><td><input type=text id=\"port\" placeholder=\"5432\"></td></tr>\n\t\t<tr class=\"pgsql\"><td>Initial Database:</td><td><input type=text id=\"db\" placeholder=\"template1\"></td></tr>\n\t\t<tr class=\"mysql\"><td>Username:</td><td><input type=text id=\"login\" placeholder=\"postgres\"></td></tr>\n\t\t<tr class=\"mysql\"><td>Password:</td><td><input type=password id=\"password\" placeholder=\"\"></td></tr>\n\t\t<tr class=\"sqlite\"><td>Database File:</td><td><input type=text id=\"dbfile\" placeholder=\"sqlite.db\"></td></tr>\n\t\t<tr><td></td><td><br><input id=\"TestButton\" type=\"submit\" value=\"Test Connection\" onClick=\"doServerTest()\"></td></tr>\n\t</table>\n\t</form>\n\t<div id=\"ServerTest\"><br></div>\n</fieldset>\n<p id=\"Copyright\">Copyright &copy; PremiumSoft &trade; CyberTech Ltd. All Rights Reserved.</p>\n</div>\n</body>\n</html>"
  php7: |
    [global]
    daemonize = no

    [www]
    listen = 9001
kind: ConfigMap
metadata:
  name: php
  namespace: scrm-dev-v3
  resourceVersion: '922227875'



```
