From 8ecfdce09f4b15f934c0c06f9bc0cc02468235ea Mon Sep 17 00:00:00 2001 From: Bruce Bannon Date: Mon, 9 Oct 2023 13:33:15 -0600 Subject: [PATCH] Replace some functions deprecated in PHP 5.4 --- includes/dbi4php.php | 14 +++++++------- includes/xcal.php | 11 ++++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/includes/dbi4php.php b/includes/dbi4php.php index 3716d9672..8cede22c7 100644 --- a/includes/dbi4php.php +++ b/includes/dbi4php.php @@ -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 ) @@ -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
\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 ); @@ -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 ) @@ -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 } @@ -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 ) diff --git a/includes/xcal.php b/includes/xcal.php index b805801f8..ae2570425 100644 --- a/includes/xcal.php +++ b/includes/xcal.php @@ -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; @@ -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++; @@ -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";