Skip to content

Commit

Permalink
adding check for function.
Browse files Browse the repository at this point in the history
  • Loading branch information
padams committed Oct 8, 2013
1 parent 7f506f8 commit 9615cd2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 32 deletions.
17 changes: 10 additions & 7 deletions modules/base/installCheckEnv.php
Expand Up @@ -57,15 +57,18 @@ function action() {
// Check permissions on log directory

// check for magic_quotes
$magic_quotes = get_magic_quotes_gpc();

if ( $magic_quotes ) {
if ( function_exists( 'get_magic_quotes_gpc' ) ) {

$errors['magic_quotes_gpc']['name'] = 'magic_quotes_gpc';
$errors['magic_quotes_gpc']['value'] = $magic_quotes;
$errors['magic_quotes_gpc']['msg'] = "The magic_quotes_gpc PHP INI directive must be set to 'OFF' in order for OWA domstreams to operate correctly.";
$bad_environment = true;
$magic_quotes = get_magic_quotes_gpc();

if ( $magic_quotes ) {

$errors['magic_quotes_gpc']['name'] = 'magic_quotes_gpc';
$errors['magic_quotes_gpc']['value'] = $magic_quotes;
$errors['magic_quotes_gpc']['msg'] = "The magic_quotes_gpc PHP INI directive must be set to 'OFF' in order for OWA domstreams to operate correctly.";
$bad_environment = true;

}
}

// Check for config file and then test the db connection
Expand Down
67 changes: 42 additions & 25 deletions plugins/db/owa_db_mysql.php
Expand Up @@ -141,38 +141,52 @@ function connect() {
* @access public
*
*/
function query($sql) {
function query( $sql ) {

if ($this->connection_status == false):
owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
if ( $this->connection_status == false) {

owa_coreAPI::profile($this, __FUNCTION__, __LINE__);

$this->connect();
owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
endif;

owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
}

owa_coreAPI::profile($this, __FUNCTION__, __LINE__);

$this->e->debug(sprintf('Query: %s', $sql));

$this->result = '';

$this->new_result = '';

if (!empty($this->new_result)):
if (!empty($this->new_result)) {
mysql_free_result($this->new_result);
endif;
}

owa_coreAPI::profile($this, __FUNCTION__, __LINE__, $sql);
$result = @mysql_unbuffered_query($sql, $this->connection);

$result = @mysql_unbuffered_query( $sql, $this->connection );

owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
// Log Errors
if (mysql_errno($this->connection)):
$this->e->debug(sprintf('A MySQL error occured. Error: (%s) %s. Query: %s',
mysql_errno($this->connection),
htmlspecialchars(mysql_error($this->connection)),
$sql));
endif;

if ( mysql_errno( $this->connection ) ) {
$this->e->debug(
sprintf(
'A MySQL error ocured. Error: (%s) %s. Query: %s',
mysql_errno( $this->connection ),
htmlspecialchars( mysql_error( $this->connection ) ),
$sql
)
);
}

owa_coreAPI::profile($this, __FUNCTION__, __LINE__);

$this->new_result = $result;

return $this->new_result;

}

function close() {
Expand All @@ -189,26 +203,29 @@ function close() {
* @return array
* @access public
*/
function get_results($sql) {
function get_results( $sql ) {

if ($sql):
if ( $sql ) {

$this->query($sql);
endif;
}

$num_rows = 0;

while ( $row = @mysql_fetch_assoc($this->new_result) ) {

$this->result[$num_rows] = $row;
$num_rows++;
}

if ($this->result):
if ( $this->result ) {

return $this->result;

else:
} else {

return null;
endif;
}
}

/**
Expand All @@ -233,11 +250,11 @@ function get_row($sql) {
* @param string $string
* @return string
*/
function prepare($string) {
function prepare( $string ) {

if ($this->connection_status == false):
if ($this->connection_status == false) {
$this->connect();
endif;
}

return mysql_real_escape_string($string, $this->connection);

Expand All @@ -249,4 +266,4 @@ function getAffectedRows() {
}
}

?>
?>

0 comments on commit 9615cd2

Please sign in to comment.