예제 #1
0
             if ($response->status == 'SUCCESS') {
                 print SUCCESSFULL . ',';
             } else {
                 print FAILED . ',' . $Server->error;
             }
         } else {
             print FAILED . ',' . $Server->error;
         }
         break;
     case 4:
         $Server->loginDbServer($user, $passwd);
         $Server->setDataBase($db_name, $port);
         if ($Server->errno == 0) {
             $response = $Server->tryConnectServer($type);
             if ($response->status == 'SUCCESS') {
                 $response = $Server->tryOpenDataBase($type);
                 if ($response->status == 'SUCCESS') {
                     print SUCCESSFULL . ',' . $Server->error;
                 } else {
                     print FAILED . ',' . $Server->error;
                 }
             } else {
                 print FAILED . ',' . $Server->error;
             }
         } else {
             print FAILED . ',' . $Server->error;
         }
         break;
     default:
         print 'finished';
 }
예제 #2
0
         default:
             echo "finished";
             break;
     }
 } else {
     $connectionType = $_POST["connectionType"];
     $tns = $_POST["tns"];
     $net = new NET();
     switch ($step) {
         case 1:
             $net->loginDbServer($user, $passwd);
             if ($net->errno == 0) {
                 $arrayServerData = array("connectionType" => $connectionType, "tns" => $tns);
                 $response = $net->tryConnectServer($type, $arrayServerData);
                 if ($response->status == "SUCCESS") {
                     $response = $net->tryOpenDataBase($type, $arrayServerData);
                     if ($response->status == "SUCCESS") {
                         echo SUCCESSFULL . "," . $net->error;
                     } else {
                         echo FAILED . "," . $net->error;
                     }
                 } else {
                     echo FAILED . "," . $net->error;
                 }
             } else {
                 echo FAILED . "," . $net->error;
             }
             break;
         default:
             echo "finished";
             break;
예제 #3
0
    /**
     * Test DataBase Connection
     * @var string $dataCon. Data for DataBase Connection
     * @var string $returnArray. Flag for url
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
     *
     * @return void
     */
    public function testConnection($dataCon, $returnArray = false)
    {
        $resp = array();
        $respTest = array();
        $resp['resp'] = false;

        $dataCon = array_change_key_case($dataCon, CASE_UPPER);

        $flagTns = ($dataCon["DBS_TYPE"] == "oracle" && $dataCon["DBS_CONNECTION_TYPE"] == "TNS")? 1 : 0;

        G::LoadClass( 'net' );

        if ($flagTns == 0) {
            $Server = new \NET($dataCon['DBS_SERVER']);

            // STEP 1 : Resolving Host Name
            $respTest['0'] = array();
            $respTest['0']['test'] = 'Resolving Host Name ' . $dataCon['DBS_SERVER'];
            if ($Server->getErrno() != 0) {
                if ($returnArray) {
                    $respTest['0']['error'] = "Error Testing Connection: Resolving Host Name FAILED : " . $Server->error;
                } else {
                    $resp['message'] = "Error Testing Connection: Resolving Host Name FAILED : " . $Server->error;
                    return $resp;
                }
            }

            // STEP 2 : Checking port
            $respTest['1'] = array();
            $respTest['1']['test'] = 'Checking port ' . $dataCon['DBS_PORT'];
            $Server->scannPort($dataCon['DBS_PORT']);
            if ($Server->getErrno() != 0) {
                if ($returnArray) {
                    $respTest['1']['error'] = "Error Testing Connection: Checking port FAILED : " . $Server->error;
                } else {
                    $resp['message'] = "Error Testing Connection: Checking port FAILED : " . $Server->error;
                    return $resp;
                }
            }

            // STEP 3 : Trying to connect to host
            $respTest['2'] = array();
            $respTest['2']['test'] = 'Connecting to host ' . $dataCon['DBS_SERVER'] . (($dataCon['DBS_PORT'] != '') ? ':'.$dataCon['DBS_PORT'] : '');
            $Server->loginDbServer($dataCon['DBS_USERNAME'], $dataCon['DBS_PASSWORD']);
            $Server->setDataBase($dataCon['DBS_DATABASE_NAME'], $dataCon['DBS_PORT']);
            if ($Server->errno == 0) {
                $response = $Server->tryConnectServer($dataCon['DBS_TYPE']);
                if ($response->status != 'SUCCESS') {
                    if ($returnArray) {
                        $respTest['2']['error'] = "Error Testing Connection: Connecting to host FAILED : " . $Server->error;
                    } else {
                        $resp['message'] = "Error Testing Connection: Connecting to host FAILED : " . $Server->error;
                        return $resp;
                    }
                }
            } else {
                if ($returnArray) {
                    $respTest['2']['error'] = "Error Testing Connection: Connecting to host FAILED : " . $Server->error;
                } else {
                    $resp['message'] = "Error Testing Connection: Connecting to host FAILED : " . $Server->error;
                    return $resp;
                }
            }

            // STEP 4 : Trying to open database
            $respTest['3'] = array();
            $respTest['3']['test'] = 'Opening database [' . $dataCon['DBS_DATABASE_NAME'] . ']';
            $Server->loginDbServer($dataCon['DBS_USERNAME'], $dataCon['DBS_PASSWORD']);
            $Server->setDataBase($dataCon['DBS_DATABASE_NAME'], $dataCon['DBS_PORT']);
            if ($Server->errno == 0) {
                $response = $Server->tryConnectServer($dataCon['DBS_TYPE']);
                if ($response->status == 'SUCCESS') {
                    $response = $Server->tryOpenDataBase($dataCon['DBS_TYPE']);
                    if ($response->status != 'SUCCESS') {
                        if ($returnArray) {
                            $respTest['3']['error'] = "Error Testing Connection: Opening database FAILED : " . $Server->error;
                        } else {
                            $resp['message'] = "Error Testing Connection: Opening database FAILED : " . $Server->error;
                            return $resp;
                        }
                    }
                } else {
                    if ($returnArray) {
                        $respTest['3']['error'] = "Error Testing Connection: Opening database FAILED : " . $Server->error;
                    } else {
                        $resp['message'] = "Error Testing Connection: Opening database FAILED : " . $Server->error;
                        return $resp;
                    }
                }
            } else {
                if ($returnArray) {
                    $respTest['3']['error'] = "Error Testing Connection: Opening database FAILED : " . $Server->error;
                } else {
                    $resp['message'] = "Error Testing Connection: Opening database FAILED : " . $Server->error;
                    return $resp;
                }
            }
        } else {
            $net = new \NET();

            //STEP 0: Trying to open database type TNS
            $respTest["0"] = array();
            $respTest["0"]["test"] = "Test TNS: " . $dataCon["DBS_TNS"];

            $net->loginDbServer($dataCon["DBS_USERNAME"], $dataCon["DBS_PASSWORD"]);

            if ($net->errno == 0) {
                $arrayServerData = array("connectionType" => $dataCon["DBS_CONNECTION_TYPE"], "tns" => $dataCon["DBS_TNS"]);

                $response = $net->tryConnectServer($dataCon["DBS_TYPE"], $arrayServerData);

                if ($response->status == "SUCCESS") {
                    $response = $net->tryOpenDataBase($dataCon["DBS_TYPE"], $arrayServerData);

                    if ($response->status != "SUCCESS") {
                        if ($returnArray) {
                            $respTest["0"]["error"] = "Error Testing Connection: Opening database type TNS FAILED, " . $net->error;
                        } else {
                            $resp["message"] = "Error Testing Connection: Opening database type TNS FAILED, " . $net->error;

                            //Return
                            return $resp;
                        }
                    }
                } else {
                    if ($returnArray) {
                        $respTest["0"]["error"] = "Error Testing Connection: Opening database type TNS FAILED, " . $net->error;
                    } else {
                        $resp["message"] = "Error Testing Connection: Opening database type TNS FAILED, " . $net->error;

                        //Return
                        return $resp;
                    }
                }
            } else {
                if ($returnArray) {
                    $respTest["0"]["error"] = "Error Testing Connection: Opening database type TNS FAILED, " . $net->error;
                } else {
                    $resp["message"] = "Error Testing Connection: Opening database type TNS FAILED, " . $net->error;

                    //Return
                    return $resp;
                }
            }
        }

        if ($returnArray) {
            return $respTest;
        } else {
            // CORRECT CONNECTION
            $resp['resp'] = true;
            return $resp;
        }
    }
예제 #4
0
 /**
  * Test DataBase Connection
  * @var string $dataCon. Data for DataBase Connection
  * @var string $returnArray. Flag for url
  *
  * @author Brayan Pereyra (Cochalo) <*****@*****.**>
  * @copyright Colosa - Bolivia
  *
  * @return void
  */
 public function testConnection($dataCon, $returnArray = false)
 {
     $resp = array();
     $respTest = array();
     $resp['resp'] = false;
     $dataCon = array_change_key_case($dataCon, CASE_UPPER);
     $flagTns = $dataCon["DBS_TYPE"] == "oracle" && $dataCon["DBS_CONNECTION_TYPE"] == "TNS" ? 1 : 0;
     G::LoadClass('net');
     if ($flagTns == 0) {
         $Server = new \NET($dataCon['DBS_SERVER']);
         // STEP 1 : Resolving Host Name
         $respTest['0'] = array();
         $respTest['0']['test'] = G::loadTranslation('RESOLVING_NAME') . ' ' . $dataCon['DBS_SERVER'];
         if ($Server->getErrno() != 0) {
             if ($returnArray) {
                 $respTest['0']['error'] = G::loadTranslation('ID_ERROR_HOST_NAME_FAILED') . ' : ' . $Server->error;
             } else {
                 $resp['message'] = G::loadTranslation('ID_ERROR_HOST_NAME_FAILED') . ' : ' . $Server->error;
                 return $resp;
             }
         }
         // STEP 2 : Checking port
         $respTest['1'] = array();
         $respTest['1']['test'] = G::loadTranslation('ID_CHECK_PORT') . ' ' . $dataCon['DBS_PORT'];
         $Server->scannPort($dataCon['DBS_PORT']);
         if ($Server->getErrno() != 0) {
             if ($returnArray) {
                 $respTest['1']['error'] = G::loadTranslation('ID_CHECK_PORT_FAILED') . ' : ' . $Server->error;
             } else {
                 $resp['message'] = G::loadTranslation('ID_CHECK_PORT_FAILED') . ' : ' . $Server->error;
                 return $resp;
             }
         }
         // STEP 3 : Trying to connect to host
         $respTest['2'] = array();
         $respTest['2']['test'] = G::loadTranslation('ID_CONNECTING_TO_HOST') . ' ' . $dataCon['DBS_SERVER'] . ($dataCon['DBS_PORT'] != '' ? ':' . $dataCon['DBS_PORT'] : '');
         $Server->loginDbServer($dataCon['DBS_USERNAME'], $dataCon['DBS_PASSWORD']);
         $Server->setDataBase($dataCon['DBS_DATABASE_NAME'], $dataCon['DBS_PORT']);
         if ($Server->errno == 0) {
             $response = $Server->tryConnectServer($dataCon['DBS_TYPE']);
             if ($response->status != 'SUCCESS') {
                 if ($returnArray) {
                     $respTest['2']['error'] = G::loadTranslation('ID_CONNECTING_TO_HOST_FAILED') . ' : ' . $Server->error;
                 } else {
                     $resp['message'] = G::loadTranslation('ID_CONNECTING_TO_HOST_FAILED') . ' : ' . $Server->error;
                     return $resp;
                 }
             }
         } else {
             if ($returnArray) {
                 $respTest['2']['error'] = G::loadTranslation('ID_CONNECTING_TO_HOST_FAILED') . ' : ' . $Server->error;
             } else {
                 $resp['message'] = G::loadTranslation('ID_CONNECTING_TO_HOST_FAILED') . ' : ' . $Server->error;
                 return $resp;
             }
         }
         // STEP 4 : Trying to open database
         $respTest['3'] = array();
         $respTest['3']['test'] = G::loadTranslation('ID_OPEN_DATABASE') . ' [' . $dataCon['DBS_DATABASE_NAME'] . ']';
         $Server->loginDbServer($dataCon['DBS_USERNAME'], $dataCon['DBS_PASSWORD']);
         $Server->setDataBase($dataCon['DBS_DATABASE_NAME'], $dataCon['DBS_PORT']);
         if ($Server->errno == 0) {
             $response = $Server->tryConnectServer($dataCon['DBS_TYPE']);
             if ($response->status == 'SUCCESS') {
                 $response = $Server->tryOpenDataBase($dataCon['DBS_TYPE']);
                 if ($response->status != 'SUCCESS') {
                     if ($returnArray) {
                         $respTest['3']['error'] = G::loadTranslation('ID_CONNECTING_TO_DATABASE_FAILED') . ' : ' . $Server->error;
                     } else {
                         $resp['message'] = G::loadTranslation('ID_CONNECTING_TO_DATABASE_FAILED') . ' : ' . $Server->error;
                         return $resp;
                     }
                 }
             } else {
                 if ($returnArray) {
                     $respTest['3']['error'] = G::loadTranslation('ID_CONNECTING_TO_DATABASE_FAILED') . ' : ' . $Server->error;
                 } else {
                     $resp['message'] = G::loadTranslation('ID_CONNECTING_TO_DATABASE_FAILED') . ' : ' . $Server->error;
                     return $resp;
                 }
             }
         } else {
             if ($returnArray) {
                 $respTest['3']['error'] = G::loadTranslation('ID_CONNECTING_TO_DATABASE_FAILED') . ' : ' . $Server->error;
             } else {
                 $resp['message'] = G::loadTranslation('ID_CONNECTING_TO_DATABASE_FAILED') . ' : ' . $Server->error;
                 return $resp;
             }
         }
     } else {
         $net = new \NET();
         //STEP 0: Trying to open database type TNS
         $respTest["0"] = array();
         $respTest["0"]["test"] = G::loadTranslation('ID_TEST_DATABASE_ORACLE_TNS') . ' ' . $dataCon["DBS_TNS"];
         $net->loginDbServer($dataCon["DBS_USERNAME"], $dataCon["DBS_PASSWORD"]);
         if ($net->errno == 0) {
             $arrayServerData = array("connectionType" => $dataCon["DBS_CONNECTION_TYPE"], "tns" => $dataCon["DBS_TNS"]);
             $response = $net->tryConnectServer($dataCon["DBS_TYPE"], $arrayServerData);
             if ($response->status == "SUCCESS") {
                 $response = $net->tryOpenDataBase($dataCon["DBS_TYPE"], $arrayServerData);
                 if ($response->status != "SUCCESS") {
                     if ($returnArray) {
                         $respTest["0"]["error"] = G::loadTranslation('ID_TEST_ERROR_ORACLE_TNS') . ', ' . $net->error;
                     } else {
                         $resp["message"] = G::loadTranslation('ID_TEST_ERROR_ORACLE_TNS') . ', ' . $net->error;
                         //Return
                         return $resp;
                     }
                 }
             } else {
                 if ($returnArray) {
                     $respTest["0"]["error"] = G::loadTranslation('ID_TEST_ERROR_ORACLE_TNS') . ', ' . $net->error;
                 } else {
                     $resp["message"] = G::loadTranslation('ID_TEST_ERROR_ORACLE_TNS') . ', ' . $net->error;
                     //Return
                     return $resp;
                 }
             }
         } else {
             if ($returnArray) {
                 $respTest["0"]["error"] = G::loadTranslation('ID_TEST_ERROR_ORACLE_TNS') . ', ' . $net->error;
             } else {
                 $resp["message"] = G::loadTranslation('ID_TEST_ERROR_ORACLE_TNS') . ', ' . $net->error;
                 //Return
                 return $resp;
             }
         }
     }
     if ($returnArray) {
         return $respTest;
     } else {
         // CORRECT CONNECTION
         $resp['resp'] = true;
         return $resp;
     }
 }
예제 #5
0
    /**
     * Test DataBase Connection
     * @var string $dataCon. Data for DataBase Connection
     * @var string $returnArray. Flag for url
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
     *
     * @return void
     */
    public function testConnection($dataCon, $returnArray = false)
    {
        $resp = array();
        $respTest = array();
        $resp['resp'] = false;

        $dataCon = array_change_key_case($dataCon, CASE_UPPER);

        G::LoadClass( 'net' );
        $Server = new \NET($dataCon['DBS_SERVER']);

        // STEP 1 : Resolving Host Name
        $respTest['0'] = array();
        $respTest['0']['test'] = 'Resolving Host Name ' . $dataCon['DBS_SERVER'];
        if ($Server->getErrno() != 0) {
            if ($returnArray) {
                $respTest['0']['error'] = "Error Testing Connection: Resolving Host Name FAILED : " . $Server->error;
            } else {
                $resp['message'] = "Error Testing Connection: Resolving Host Name FAILED : " . $Server->error;
                return $resp;
            }
        }

        // STEP 2 : Checking port
        $respTest['1'] = array();
        $respTest['1']['test'] = 'Checking port ' . $dataCon['DBS_PORT'];
        $Server->scannPort($dataCon['DBS_PORT']);
        if ($Server->getErrno() != 0) {
            if ($returnArray) {
                $respTest['1']['error'] = "Error Testing Connection: Checking port FAILED : " . $Server->error;
            } else {
                $resp['message'] = "Error Testing Connection: Checking port FAILED : " . $Server->error;
                return $resp;
            }
        }

        // STEP 3 : Trying to connect to host
        $respTest['2'] = array();
        $respTest['2']['test'] = 'Trying to connect to host ' . $dataCon['DBS_SERVER'] . (($dataCon['DBS_PORT'] != '') ? ':'.$dataCon['DBS_PORT'] : '');
        $Server->loginDbServer($dataCon['DBS_USERNAME'], $dataCon['DBS_PASSWORD']);
        $Server->setDataBase($dataCon['DBS_DATABASE_NAME'], $dataCon['DBS_PORT']);
        if ($Server->errno == 0) {
            $response = $Server->tryConnectServer($dataCon['DBS_TYPE']);
            if ($response->status != 'SUCCESS') {
                if ($returnArray) {
                    $respTest['2']['error'] = "Error Testing Connection: Trying to connect to host FAILED : " . $Server->error;
                } else {
                    $resp['message'] = "Error Testing Connection: Trying to connect to host FAILED : " . $Server->error;
                    return $resp;
                }
            }
        } else {
            if ($returnArray) {
                $respTest['2']['error'] = "Error Testing Connection: Trying to connect to host FAILED : " . $Server->error;
            } else {
                $resp['message'] = "Error Testing Connection: Trying to connect to host FAILED : " . $Server->error;
                return $resp;
            }
        }

        // STEP 4 : Trying to open database
        $respTest['3'] = array();
        $respTest['3']['test'] = 'Trying to open database [' . $dataCon['DBS_DATABASE_NAME'] . ']';
        $Server->loginDbServer($dataCon['DBS_USERNAME'], $dataCon['DBS_PASSWORD']);
        $Server->setDataBase($dataCon['DBS_DATABASE_NAME'], $dataCon['DBS_PORT']);
        if ($Server->errno == 0) {
            $response = $Server->tryConnectServer($dataCon['DBS_TYPE']);
            if ($response->status == 'SUCCESS') {
                $response = $Server->tryOpenDataBase($dataCon['DBS_TYPE']);
                if ($response->status != 'SUCCESS') {
                    if ($returnArray) {
                        $respTest['3']['error'] = "Error Testing Connection: Trying to open database FAILED : " . $Server->error;
                    } else {
                        $resp['message'] = "Error Testing Connection: Trying to open database FAILED : " . $Server->error;
                        return $resp;
                    }
                }
            } else {
                if ($returnArray) {
                    $respTest['3']['error'] = "Error Testing Connection: Trying to open database FAILED : " . $Server->error;
                } else {
                    $resp['message'] = "Error Testing Connection: Trying to open database FAILED : " . $Server->error;
                    return $resp;
                }
            }
        } else {
            if ($returnArray) {
                $respTest['3']['error'] = "Error Testing Connection: Trying to open database FAILED : " . $Server->error;
            } else {
                $resp['message'] = "Error Testing Connection: Trying to open database FAILED : " . $Server->error;
                return $resp;
            }
        }

        if ($returnArray) {
            return $respTest;
        } else {
            // CORRECT CONNECTION
            $resp['resp'] = true;
            return $resp;
        }
    }