999 ) ) { $cache_value = $min_value; } } return $cache_value; } /** * Fetch a file (1.6) * * Use WordPress API to fetch a file and check results * RC is 0 to indicate success, -1 a failure * * @since 1.0 * * @param string $filein File name to fetch * @param string $header Only get headers? * @return string Array containing file contents and response */ function occ_get_file( $filein, $header = false ) { $rc = 0; $error = ''; if ( $header ) { $fileout = wp_remote_head( $filein ); if ( is_wp_error( $fileout ) ) { $error = 'Header: ' . $fileout -> get_error_message(); $rc = -1; } } else { $fileout = wp_remote_get( $filein ); if ( is_wp_error( $fileout ) ) { $error = 'Body: ' . $fileout -> get_error_message(); $rc = -1; } else { if ( isset( $fileout[ 'body' ] ) ) { $file_return[ 'file' ] = $fileout[ 'body' ]; } } } $file_return[ 'error' ] = $error; $file_return[ 'rc' ] = $rc; if ( !is_wp_error( $fileout ) ) { if ( isset( $fileout[ 'response' ][ 'code' ] ) ) { $file_return[ 'response' ] = $fileout[ 'response' ][ 'code' ]; } } return $file_return; } /** * Extract Parameters (1.1) * * Function to extract parameters from an input string * * @since 1.0 * * @param $input string Input string * @param $para string Parameter to find * @return string Parameter value */ function occ_get_parameters( $input, $para, $divider = '=', $seperator = '&' ) { $start = strpos( strtolower( $input ), $para . $divider); $content = ''; if ( $start !== false ) { $start = $start + strlen( $para ) + 1; $end = strpos( strtolower( $input ), $seperator, $start ); if ( $end !== false ) { $end = $end - 1; } else { $end = strlen( $input ); } $content = substr( $input, $start, $end - $start + 1 ); } return $content; } ?>