You are here

function _advagg_build_url in Advanced CSS/JS Aggregation 6

Same name and namespace in other branches
  1. 7 advagg.module \_advagg_build_url()

Helper function to build an URL for asynchronous requests.

Parameters

$filepath: Path to a URI excluding everything to the left and including the base path.

5 calls to _advagg_build_url()
advagg_admin_info_form in ./advagg.admin.inc
Form builder; Configure advagg settings.
advagg_check_missing_handler in ./advagg.install
Check to see if the CSS/JS generator is working.
advagg_css_js_file_builder in ./advagg.module
Aggregate CSS/JS files, putting them in the files directory.
advagg_install_test_async_stream in ./advagg.install
Test if STREAM_CLIENT_ASYNC_CONNECT can be used.
advagg_js_compress_test_compression in advagg_js_compress/advagg_js_compress.module
Run various theme functions so the cache is primed.

File

./advagg.module, line 3960
Advanced CSS/JS aggregation module

Code

function _advagg_build_url($filepath = '') {
  global $base_path;

  // Server auth.
  $auth = '';
  if (isset($_SERVER['AUTH_TYPE']) && $_SERVER['AUTH_TYPE'] == 'Basic') {
    $auth = $_SERVER['PHP_AUTH_USER'] . ':' . $_SERVER['PHP_AUTH_PW'] . '@';
  }

  // Host.
  $ip = variable_get('advagg_server_addr', FALSE);
  if ($ip == -1) {
    $ip = $_SERVER['HTTP_HOST'];
  }
  elseif (empty($ip)) {
    $ip = empty($_SERVER['SERVER_ADDR']) ? '127.0.0.1' : $_SERVER['SERVER_ADDR'];
  }

  // Port.
  $port = '';

  //   if (   isset($_SERVER['SERVER_PORT'])
  //       && is_numeric($_SERVER['SERVER_PORT'])
  //       && ($_SERVER['SERVER_PORT'] != 80 || $_SERVER['SERVER_PORT'] != 443)
  //         ) {
  //     $port = ':' . $_SERVER['SERVER_PORT'];
  //   }
  return 'http://' . $auth . $ip . $port . $base_path . $filepath;
}