CODE STYLE class.net.php

This commit is contained in:
Fernando Ontiveros
2012-10-09 12:54:08 -04:00
parent 8c638de652
commit b7b062bdec

View File

@@ -1,9 +1,11 @@
<?php
/**
* LastModification 30/05/2008
*/
/**
*
* @package workflow.engine.classes
*/
@@ -25,6 +27,7 @@ class NET
/**
* This function is the constructor of the class net
*
* @param string $pHost
* @return void
*/
@@ -49,6 +52,7 @@ class NET
/**
* This function puts a host
*
* @param string $pHost
* @return void
*/
@@ -68,16 +72,14 @@ class NET
$this->errstr = "NET::Host down";
$this->error = "Destination Host Unreachable";
}
}
else {
} else {
$ip = @gethostbyname( $ipHost );
$long = ip2long( $ip );
if ($long == - 1 || $long === FALSE) {
$this->errno = 2000;
$this->errstr = "NET::Host down";
$this->error = "Destination Host Unreachable";
}
else {
} else {
$this->ip = @gethostbyname( $ipHost );
$this->hostname = $pHost;
}
@@ -86,6 +88,7 @@ class NET
/**
* This function resolves IP from Hostname returns hostname on failure
*
* @param string $pPort
* @return true
*/
@@ -97,8 +100,7 @@ class NET
if (@fsockopen( $this->ip, $pPort, $this->errno, $this->errstr, TIMEOUT )) {
return true;
@fclose( $x ); //close connection (i dont know if this is needed or not).
}
else {
} else {
$this->errno = 9999;
$this->errstr = "NET::Port Host Unreachable";
$this->error = "Destination Port Unreachable";
@@ -108,6 +110,7 @@ class NET
/**
* This function checks if it is a ip address
*
* @param string $pHost
* @return true
*/
@@ -125,8 +128,7 @@ class NET
break;
}
}
}
else {
} else {
$key = false;
}
return $key;
@@ -134,6 +136,7 @@ class NET
/**
* This function executes pin -w time IP
*
* @param string $pHost
* @return true
*/
@@ -149,6 +152,7 @@ class NET
/**
* This function logins in db
*
* @param string $pUser
* @param string $pPasswd
* @return void
@@ -161,6 +165,7 @@ class NET
/**
* This function sets db
*
* @param string $pDb
* @param string $pPort
* @return void
@@ -173,6 +178,7 @@ class NET
/**
* This function tries to connect to server
*
* @param string $pDbDriver
* @return void
*/
@@ -183,15 +189,12 @@ class NET
}
$stat = new Stat();
if(isset($this->db_user) && (isset($this->db_passwd) || ('' == $this->db_passwd)) && isset($this->db_sourcename))
{
switch($pDbDriver)
{
if (isset( $this->db_user ) && (isset( $this->db_passwd ) || ('' == $this->db_passwd)) && isset( $this->db_sourcename )) {
switch ($pDbDriver) {
case 'mysql':
if ($this->db_passwd == '') {
$link = @mysql_connect( $this->ip . (($this->db_port != '') && ($this->db_port != 0) ? ':' . $this->db_port : ''), $this->db_user );
}
else {
} else {
$link = @mysql_connect( $this->ip . (($this->db_port != '') && ($this->db_port != 0) ? ':' . $this->db_port : ''), $this->db_user, $this->db_passwd );
}
if ($link) {
@@ -199,14 +202,12 @@ class NET
$stat->status = 'SUCCESS';
$this->errstr = "";
$this->errno = 0;
}
else {
} else {
$this->error = "Lost MySql Connection";
$this->errstr = "NET::MYSQL->Lost Connection";
$this->errno = 10010;
}
}
else {
} else {
$this->error = "MySql connection refused!";
$this->errstr = "NET::MYSQL->The connection was refused";
$this->errno = 10001;
@@ -240,8 +241,7 @@ class NET
$stat->status = 'SUCCESS';
$this->errstr = "";
$this->errno = 0;
}
else {
} else {
$this->error = "MS-SQL Server connection refused";
$this->errstr = "NET::MSSQL->The connection was refused";
$this->errno = 30001;
@@ -256,14 +256,12 @@ class NET
$stat->status = 'SUCCESS';
$this->errstr = "";
$this->errno = 0;
}
else {
} else {
$this->error = "Oracle connection refused";
$this->errstr = "NET::ORACLE->The connection was refused";
$this->errno = 30001;
}
}
catch (Exception $e){
} catch (Exception $e) {
throw new Exception( "[erik] Couldn't connect to Oracle Server! - " . $e->getMessage() );
}
break;
@@ -273,8 +271,7 @@ class NET
case 'sqlite':
break;
}
}
else {
} else {
throw new Exception( "CLASS::NET::ERROR: No connections param." );
}
@@ -283,6 +280,7 @@ class NET
/**
* This function tries to open to the DB
*
* @param string $pDbDriver
* @return void
*/
@@ -295,10 +293,8 @@ class NET
set_time_limit( 0 );
$stat = new Stat();
if(isset($this->db_user) && (isset($this->db_passwd) || ('' == $this->db_passwd)) && isset($this->db_sourcename))
{
switch($pDbDriver)
{
if (isset( $this->db_user ) && (isset( $this->db_passwd ) || ('' == $this->db_passwd)) && isset( $this->db_sourcename )) {
switch ($pDbDriver) {
case 'mysql':
$link = @mysql_connect( $this->ip . (($this->db_port != '') && ($this->db_port != 0) ? ':' . $this->db_port : ''), $this->db_user, $this->db_passwd );
$db = @mysql_select_db( $this->db_sourcename );
@@ -310,20 +306,17 @@ class NET
$this->errstr = "";
$this->errno = 0;
@mysql_free_result( $result );
}
else {
} else {
$this->error = "the user $this->db_user doesn't have privileges to run queries!";
$this->errstr = "NET::MYSQL->Test query failed";
$this->errno = 10100;
}
}
else {
} else {
$this->error = "The $this->db_sourcename data base does'n exist!";
$this->errstr = "NET::MYSQL->Select data base failed";
$this->errno = 10011;
}
}
else {
} else {
$this->error = "MySql connection refused!";
$this->errstr = "NET::MYSQL->The connection was refused";
$this->errno = 10001;
@@ -338,14 +331,12 @@ class NET
$stat->status = 'SUCCESS';
$this->errstr = "";
$this->errno = 0;
}
else {
} else {
$this->error = "PostgreSql Connection to $this->ip is unreachable!";
$this->errstr = "NET::POSTGRES->Lost Connection";
$this->errno = 20010;
}
}
else {
} else {
$this->error = "PostgrSql connection refused";
$this->errstr = "NET::POSTGRES->The connection was refused";
$this->errno = 20001;
@@ -368,14 +359,12 @@ class NET
$stat->status = 'SUCCESS';
$this->errstr = "";
$this->errno = 0;
}
else {
} else {
$this->error = "The $this->db_sourcename data base does'n exist!";
$this->errstr = "NET::MSSQL->Select data base failed";
$this->errno = 30010;
}
}
else {
} else {
$this->error = "MS-SQL Server connection refused!";
$this->errstr = "NET::MSSQL->The connection was refused";
$this->errno = 30001;
@@ -393,14 +382,12 @@ class NET
$this->errstr = "";
$this->errno = 0;
@oci_close( $link );
}
else {
} else {
$this->error = "the user $this->db_user doesn't have privileges to run queries!";
$this->errstr = "NET::ORACLE->Couldn't execute any query on this server!";
$this->errno = 40010;
}
}
else {
} else {
$this->error = "Oracle connection refused!";
$this->errstr = "NET::ORACLE->The connection was refused";
$this->errno = 40001;
@@ -413,8 +400,7 @@ class NET
case 'sqlite':
break;
}
}
else {
} else {
throw new Exception( "CLASS::NET::ERROR: No connections param." );
}
return $stat;
@@ -422,6 +408,7 @@ class NET
/**
* This function gets DB-s version
*
* @param string $driver
* @return void
*/
@@ -442,36 +429,47 @@ class NET
$value = $oDataBase->getServerVersion( $driver, $this->ip, $this->db_port, $this->db_user, $this->db_passwd, $this->db_sourcename );
}
return $value;
}
catch (Exception $e){
} catch (Exception $e) {
throw new Exception( $e->getMessage() );
}
}
else{
} else {
throw new Exception( 'NET::Error->No params for Data Base Server!' );
}
}
/**
* This function reurns DB name
*
* @param string $pAdapter
* @return void
*/
function dbName ($pAdapter)
{
switch($pAdapter)
{
case 'mysql': return 'MySql'; break;
case 'pgsql': return 'PostgreSQL'; break;
case 'mssql': return 'Microsoft SQL Server'; break;
case 'oracle': return 'Oracle'; break;
case 'informix': return 'Informix'; break;
case 'sqlite': return 'SQLite'; break;
switch ($pAdapter) {
case 'mysql':
return 'MySql';
break;
case 'pgsql':
return 'PostgreSQL';
break;
case 'mssql':
return 'Microsoft SQL Server';
break;
case 'oracle':
return 'Oracle';
break;
case 'informix':
return 'Informix';
break;
case 'sqlite':
return 'SQLite';
break;
}
}
/**
* If there is an error then it shows
*
* @param string $pAdapter
* @return void
*/
@@ -496,6 +494,7 @@ class NET
/**
* This function gets an error
* param
*
* @return string
*/
function getErrno ()
@@ -506,6 +505,7 @@ class NET
/**
* This function gets an error message
* param
*
* @return string
*/
function getErrmsg ()
@@ -516,6 +516,7 @@ class NET
}
/**
*
* @package workflow.engine.classes
*/
class Stat