Changeset 2138 for trunk/bb-includes/functions.bb-core.php
- Timestamp:
- 06/10/2009 06:57:41 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/bb-includes/functions.bb-core.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bb-includes/functions.bb-core.php
r2124 r2138 157 157 return true; 158 158 } 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.0168 */169 function bb_cache_javascript_headers() {170 $expiresOffset = 864000; // 10 days171 header( "Content-Type: text/javascript; charset=utf-8" );172 header( "Vary: Accept-Encoding" ); // Handle proxies173 header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" );174 }175 176 159 177 160 … … 414 397 415 398 function 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 ); 425 400 } 426 401 … … 538 513 // Use https? 539 514 if ( 540 ( ( $context & BB_URI_CONTEXT_BB_USER_FORMS ) && bb_force_ssl_user_forms() ) // Force https when required on user forms515 ( ( $context & BB_URI_CONTEXT_BB_USER_FORMS ) && force_ssl_login() ) // Force https when required on user forms 541 516 || 542 ( ( $context & BB_URI_CONTEXT_BB_ADMIN ) && bb_force_ssl_admin() ) // Force https when required in admin517 ( ( $context & BB_URI_CONTEXT_BB_ADMIN ) && force_ssl_admin() ) // Force https when required in admin 543 518 ) { 544 519 static $_uri_ssl; … … 559 534 560 535 /** 561 * Whether SSL should be forced when sensitive user data is being submitted.562 *563 * @since 1.0564 *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.0585 *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 /**603 536 * Forces redirection to an SSL page when required 604 537 * … … 614 547 615 548 if ( BB_IS_ADMIN ) { 616 if ( ! bb_force_ssl_admin() ) {549 if ( !force_ssl_admin() ) { 617 550 return; 618 551 } … … 621 554 case 'login-page': 622 555 case 'register-page': 623 if ( ! bb_force_ssl_user_forms() ) {556 if ( !force_ssl_login() ) { 624 557 return; 625 558 } … … 628 561 global $self; 629 562 if ( $self == 'profile-edit.php' ) { 630 if ( ! bb_force_ssl_user_forms() ) {563 if ( !force_ssl_login() ) { 631 564 return; 632 565 } … … 641 574 } 642 575 643 if ( bb_is_ssl() ) {576 if ( is_ssl() ) { 644 577 return; 645 578 } … … 649 582 bb_safe_redirect( $uri ); 650 583 exit; 651 }652 653 /**654 * Determine if SSL is used.655 *656 * @since 1.0657 *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;681 584 } 682 585 … … 1093 996 /* Nonce */ 1094 997 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 ) { 998 function bb_nonce_url( $actionurl, $action = -1 ) 999 { 1000 return wp_nonce_url( $actionurl, $action ); 1001 } 1002 1003 function bb_nonce_field( $action = -1, $name = "_wpnonce", $referer = true, $echo = true ) 1004 { 1005 return wp_nonce_field( $action, $name, $referer, $echo ); 1006 } 1007 1008 function bb_nonce_ays( $action ) 1009 { 1113 1010 $title = __( 'bbPress Failure Notice' ); 1114 1011 $html .= "\t<div id='message' class='updated fade'>\n\t<p>" . wp_specialchars( bb_explain_nonce( $action ) ) . "</p>\n\t<p>"; … … 1120 1017 } 1121 1018 1122 function bb_install_header( $title = '', $header = false, $logo = false ) { 1019 function bb_install_header( $title = '', $header = false, $logo = false ) 1020 { 1123 1021 if ( empty($title) ) 1124 1022 if ( function_exists('__') )
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)