Skip to content
Snippets Groups Projects
Select Git revision
  • issue-752
  • develop
  • master default
  • issue-677
  • issue-677-original-with-migrate
  • issue-716
  • issue-654
  • issue-732
  • issue-737
  • issue-735
  • issue-707
  • issue-706
  • issue-705
  • issue-703
  • issue-696
  • issue-690
  • issue-675
  • issue-670
  • issue-635
  • issue-404
  • 7.19
  • 2012-04-18
  • 2012-04-03
  • 2012-04-02
  • 2012-03-01
  • 2012-02-07
  • 20120207
  • 2012-01-13
  • 2012-01-12
  • 2011-12-16
  • 2011-12-05
  • 2011-11-17
  • 2011-11-14
  • 2011-11-08.2
  • 2011-11-08
  • 2011-11-01
  • 2011-10-27
  • 2011-10-06
  • 2011-10-03
  • 2011-09-19
40 results

rewrite_miss.php

Blame
  • Forked from UNL Information Services / UNL-CMS
    325 commits behind the upstream repository.
    rewrite_miss.php 1.19 KiB
    <?php
    
    if (!isset($argv, $argv[1])) {
      echo 'NULL';
      exit(1);
    }
    
    $line = $argv[1];
    
    set_time_limit(5);
    
    define('DRUPAL_ROOT', __DIR__);
    
    require_once DRUPAL_ROOT . '/includes/unl_bootstrap.inc';
    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    
    // Parse the 3 fields.
    list($host, $uri, $path) = explode(';delim;', $line);
    
    // Get the base path of the drupal install
    $base_path = substr($uri, 0, strlen($uri) - strlen($path));
    
    // Set up some _SERVER variables as if this was a HTTP request.
    $_SERVER['SCRIPT_NAME'] = $base_path . 'index.php';
    $_SERVER['SCRIPT_FILENAME'] = DRUPAL_ROOT . '/index.php';
    $_SERVER['REQUEST_URI'] = $uri;
    $_SERVER['HTTP_HOST'] = $host;
    
    // Call the UNL bootstrap to fix conf_path and SCRIPT_NAME
    unl_bootstrap();
    $site_dir = conf_path();
    $base_path = substr($_SERVER['SCRIPT_NAME'], 0, -9);
    // Now we fix the drupal path.
    $drupal_path = substr($uri, strlen($base_path));
    
    // Finally, generate the path to the file we might be accessing
    $file_path = $site_dir . '/files/' . $drupal_path;
    
    // If that file exists, return the correct path to it, otherwise, return what we were given. 
    if (is_file($file_path)) {
      $output = $file_path;
    }
    else {
      $output = 'NULL';
    }
    
    echo $output;