Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/10/2009 06:57:41 AM (17 years ago)
Author:
sambauers
Message:

Updates brought about by reorganisation of BackPress core functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-includes/functions.bb-core.php

    r2124 r2138  
    157157        return true;
    158158}
    159 
    160 
    161 
    162 /* HTTP Helpers */
    163 
    164 /**
    165  * Set the headers for caching for 10 days with JavaScript content type.
    166  *
    167  * @since 1.0
    168  */
    169 function bb_cache_javascript_headers() {
    170         $expiresOffset = 864000; // 10 days
    171         header( "Content-Type: text/javascript; charset=utf-8" );
    172         header( "Vary: Accept-Encoding" ); // Handle proxies
    173         header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" );
    174 }
    175 
    176159
    177160
    … …  
    414397
    415398function bb_current_time( $type = 'timestamp' ) {
    416         switch ($type) {
    417                 case 'mysql':
    418                         $d = gmdate('Y-m-d H:i:s');
    419                         break;
    420                 case 'timestamp':
    421                         $d = time();
    422                         break;
    423         }
    424         return $d;
     399        return current_time( $type, true );
    425400}
    426401
    … …  
    538513        // Use https?
    539514        if (
    540                 ( ( $context & BB_URI_CONTEXT_BB_USER_FORMS ) && bb_force_ssl_user_forms() ) // Force https when required on user forms
     515                ( ( $context & BB_URI_CONTEXT_BB_USER_FORMS ) && force_ssl_login() ) // Force https when required on user forms
    541516        ||
    542                 ( ( $context & BB_URI_CONTEXT_BB_ADMIN ) && bb_force_ssl_admin() ) // Force https when required in admin
     517                ( ( $context & BB_URI_CONTEXT_BB_ADMIN ) && force_ssl_admin() ) // Force https when required in admin
    543518        ) {
    544519                static $_uri_ssl;
    … …  
    559534
    560535/**
    561  * Whether SSL should be forced when sensitive user data is being submitted.
    562  *
    563  * @since 1.0
    564  *
    565  * @param string|bool $force Optional.
    566  * @return bool True if forced, false if not forced.
    567  */
    568 function bb_force_ssl_user_forms( $force = '' )
    569 {
    570         static $forced;
    571 
    572         if ( '' != $force ) {
    573                 $old_forced = $forced;
    574                 $forced = $force;
    575                 return $old_forced;
    576         }
    577 
    578         return $forced;
    579 }
    580 
    581 /**
    582  * Whether SSL should be forced when using the admin area.
    583  *
    584  * @since 1.0
    585  *
    586  * @param string|bool $force Optional.
    587  * @return bool True if forced, false if not forced.
    588  */
    589 function bb_force_ssl_admin( $force = '' )
    590 {
    591         static $forced;
    592 
    593         if ( '' != $force ) {
    594                 $old_forced = $forced;
    595                 $forced = $force;
    596                 return $old_forced;
    597         }
    598 
    599         return $forced;
    600 }
    601 
    602 /**
    603536 * Forces redirection to an SSL page when required
    604537 *
    … …  
    614547
    615548        if ( BB_IS_ADMIN ) {
    616                 if ( !bb_force_ssl_admin() ) {
     549                if ( !force_ssl_admin() ) {
    617550                        return;
    618551                }
    … …  
    621554                        case 'login-page':
    622555                        case 'register-page':
    623                                 if ( !bb_force_ssl_user_forms() ) {
     556                                if ( !force_ssl_login() ) {
    624557                                        return;
    625558                                }
    … …  
    628561                                global $self;
    629562                                if ( $self == 'profile-edit.php' ) {
    630                                         if ( !bb_force_ssl_user_forms() ) {
     563                                        if ( !force_ssl_login() ) {
    631564                                                return;
    632565                                        }
    … …  
    641574        }
    642575
    643         if ( bb_is_ssl() ) {
     576        if ( is_ssl() ) {
    644577                return;
    645578        }
    … …  
    649582        bb_safe_redirect( $uri );
    650583        exit;
    651 }
    652 
    653 /**
    654  * Determine if SSL is used.
    655  *
    656  * @since 1.0
    657  *
    658  * @return bool True if SSL, false if not used.
    659  */
    660 function bb_is_ssl()
    661 {
    662         static $is_ssl;
    663 
    664         if ( isset( $is_ssl ) ) {
    665                 return $is_ssl;
    666         }
    667 
    668         $is_ssl = false;
    669 
    670         if ( isset($_SERVER['HTTPS']) ) {
    671                 if ( 'on' == strtolower( $_SERVER['HTTPS'] ) ) {
    672                         $is_ssl = true;
    673                 } elseif ( '1' == $_SERVER['HTTPS'] ) {
    674                         $is_ssl = true;
    675                 }
    676         } elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
    677                 $is_ssl = true;
    678         }
    679 
    680         return $is_ssl;
    681584}
    682585
    … …  
    1093996/* Nonce */
    1094997
    1095 function bb_nonce_url($actionurl, $action = -1) {
    1096         $actionurl = str_replace( '&', '&', $actionurl );
    1097         return wp_specialchars( add_query_arg( '_wpnonce', bb_create_nonce( $action ), $actionurl ) );
    1098 }
    1099 
    1100 function bb_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
    1101         $name = attribute_escape( $name );
    1102         $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . bb_create_nonce( $action ) . '" />';
    1103         if ( $echo )
    1104                 echo $nonce_field;
    1105 
    1106         if ( $referer )
    1107                 wp_referer_field( $echo, 'previous' );
    1108 
    1109         return $nonce_field;
    1110 }
    1111 
    1112 function bb_nonce_ays( $action ) {
     998function bb_nonce_url( $actionurl, $action = -1 )
     999{
     1000        return wp_nonce_url( $actionurl, $action );
     1001}
     1002
     1003function bb_nonce_field( $action = -1, $name = "_wpnonce", $referer = true, $echo = true )
     1004{
     1005        return wp_nonce_field( $action, $name, $referer, $echo );
     1006}
     1007
     1008function bb_nonce_ays( $action )
     1009{
    11131010        $title = __( 'bbPress Failure Notice' );
    11141011        $html .= "\t<div id='message' class='updated fade'>\n\t<p>" . wp_specialchars( bb_explain_nonce( $action ) ) . "</p>\n\t<p>";
    … …  
    11201017}
    11211018
    1122 function bb_install_header( $title = '', $header = false, $logo = false ) {
     1019function bb_install_header( $title = '', $header = false, $logo = false )
     1020{
    11231021        if ( empty($title) )
    11241022                if ( function_exists('__') )
Note: See TracChangeset for help on using the changeset viewer.