Skip to content

Commit

Permalink
Replace some functions deprecated in PHP 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannon committed Oct 9, 2023
1 parent 8086c95 commit 8ecfdce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
14 changes: 7 additions & 7 deletions includes/dbi4php.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ function dbi_close( $conn ) {
elseif( strcmp( $GLOBALS['db_type'], 'odbc' ) == 0 )
return odbc_close( $GLOBALS['odbc_connection'] );
elseif( strcmp( $GLOBALS['db_type'], 'oracle' ) == 0 )
return OCILogOff( $conn );
return oci_close ( $conn );
elseif( strcmp( $GLOBALS['db_type'], 'postgresql' ) == 0 )
return pg_close( $GLOBALS['postgresql_connection'] );
elseif( strcmp( $GLOBALS['db_type'], 'sqlite' ) == 0 )
Expand Down Expand Up @@ -392,14 +392,14 @@ function dbi_query( $sql, $fatalOnError = true, $showError = true ) {
return odbc_exec( $GLOBALS['odbc_connection'], $sql );
} elseif( strcmp( $GLOBALS['db_type'], 'oracle' ) == 0 ) {
if( false === $GLOBALS['oracle_statement'] =
OCIParse( $GLOBALS['oracle_connection'], $sql ) )
oci_parse ( $GLOBALS['oracle_connection'], $sql ) )
dbi_fatal_error( translate( 'Error executing query.' )
. $phpdbiVerbose ? ( dbi_error() . "\n\n<br>\n" . $sql ) : ''
. '', $fatalOnError, $showError );
return OCIExecute( $GLOBALS['oracle_statement'], OCI_COMMIT_ON_SUCCESS );
} elseif( strcmp( $GLOBALS['db_type'], 'postgresql' ) == 0 ) {
$found_db_type = true;
$res = pg_exec( $GLOBALS['postgresql_connection'], $sql );
$res = pg_execute ( $GLOBALS['postgresql_connection'], $sql );
} elseif( strcmp( $GLOBALS['db_type'], 'sqlite' ) == 0 ) {
$found_db_type = true;
$res = sqlite_query( $GLOBALS['sqlite_c'], $sql, SQLITE_NUM );
Expand Down Expand Up @@ -490,7 +490,7 @@ function dbi_affected_rows( $conn, $res ) {
return odbc_num_rows( $res );
elseif( strcmp( $GLOBALS['db_type'], 'oracle' ) == 0 )
return ( $GLOBALS['oracle_statement'] >= 0
? OCIRowCount( $GLOBALS['oracle_statement'] ) : -1 );
? oci_num_rows ( $GLOBALS['oracle_statement'] ) : -1 );
elseif( strcmp( $GLOBALS['db_type'], 'postgresql' ) == 0 )
return pg_affected_rows( $res );
elseif( strcmp( $GLOBALS['db_type'], 'sqlite' ) == 0 )
Expand Down Expand Up @@ -633,11 +633,11 @@ function dbi_free_result( $res ) {
elseif( strcmp( $GLOBALS['db_type'], 'oracle' ) == 0 ) {
// Not supported. Ingore.
if( $GLOBALS['oracle_statement'] >= 0 ) {
OCIFreeStatement( $GLOBALS['oracle_statement'] );
oci_free_statement ( $GLOBALS['oracle_statement'] );
$GLOBALS['oracle_statement'] = -1;
}
} elseif( strcmp( $GLOBALS['db_type'], 'postgresql' ) == 0 )
return pg_freeresult( $res );
return pg_free_result ( $res );
elseif( strcmp( $GLOBALS['db_type'], 'sqlite' ) == 0 ) {
// Not supported
}
Expand Down Expand Up @@ -673,7 +673,7 @@ function dbi_error() {
// No way to get error from ODBC API.
$ret = translate( 'Unknown ODBC error.' );
elseif( strcmp( $GLOBALS['db_type'], 'oracle' ) == 0 ) {
$e = OCIError( $GLOBALS['oracle_connection']
$e = oci_error ( $GLOBALS['oracle_connection']
? $GLOBALS['oracle_connection'] : '' );
$ret = htmlentities( $e['message'] );
} elseif( strcmp( $GLOBALS['db_type'], 'postgresql' ) == 0 )
Expand Down
11 changes: 6 additions & 5 deletions includes/xcal.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function wc_export_fold_lines ( $string, $encoding = 'none', $limit = 76 ) {
if ( strcmp( $encoding, 'quotedprintable' ) == 0 )
$enc = export_quoted_printable_encode( $string[$i] );
else if ( strcmp( $encoding, 'utf8' ) == 0 )
$enc = utf8_encode ( $string[$i] );
$enc = mb_convert_encoding ( $string[$i] );
}
if ( $string[$i] == ':' )
$start_encode = 1;
Expand Down Expand Up @@ -221,9 +221,10 @@ function export_get_attendee( $id, $export ) {
$attendee[$count] .= ';CN="'
. ( empty( $user['cal_firstname'] ) && empty( $user['cal_lastname'] )
? $user['cal_login']
: utf8_encode( $user['cal_firstname'] ) . ' '
. utf8_encode( $user['cal_lastname'] ) ) . '"'
. ':MAILTO:' . ( empty( $user['cal_email'] )
: mb_convert_encoding ( $user['cal_firstname'] ) . ' '
. mb_convert_encoding ( $user['cal_lastname'] ) )
. '":MAILTO:'
. ( empty ( $user['cal_email'] )
? $EMAIL_FALLBACK_FROM : $user['cal_email'] );
}
$count++;
Expand Down Expand Up @@ -944,7 +945,7 @@ function export_ical ( $id = 'all', $attachment = false ) {
// Always output something, even if no records come back
// This prevents errors on the iCal client
$ret = "BEGIN:VCALENDAR\r\n";
$title = utf8_encode ( 'X-WR-CALNAME;VALUE=TEXT:' .
$title = mb_convert_encoding ( 'X-WR-CALNAME;VALUE=TEXT:' .
( empty ( $publish_fullname ) ? $login : translate ( $publish_fullname ) ) );
$title = str_replace ( ',', "\\,", $title );
$ret .= "$title\r\n";
Expand Down

0 comments on commit 8ecfdce

Please sign in to comment.