Skip to content

Commit

Permalink
* Spacinazi + I think we should allow for bigger random numbers, even…
Browse files Browse the repository at this point in the history
… if it's unlikely we'll get a collision. But hey it's free. (Subs-CachePHP.php)

- I guess we don't need that ugly debug code anymore then. I was considering keeping the index fallback, but then I figured webmasters wouldn't even be able to determine one of their files is screwed up. (index.php)
  • Loading branch information
Nao committed Feb 6, 2017
1 parent 57f28d6 commit d47934c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/app/Subs-CachePHP.php
Expand Up @@ -15,7 +15,7 @@
// Build the cached version of our source file
function cache_source_file($source, $dest)
{
$dest_locked = substr($dest, 0, -4).'-'.mt_rand(10000, 99999).'.php';
$dest_locked = substr($dest, 0, -4) . '-' . mt_rand(999, 999999999) . '.php';
apply_plugin_mods($source, $dest_locked);
minify_php($dest_locked);
rename($dest_locked, $dest);
Expand Down
12 changes: 3 additions & 9 deletions index.php
Expand Up @@ -181,10 +181,10 @@ function loadSource($source_name)
else
{
$cache = ROOT_DIR . '/gz/app/' . str_replace(array('/', '..'), array('_', 'UP'), $file) . '.php';
if (!file_exists($cache) || filemtime($cache) < filemtime(APP_DIR . '/' . $file . '.php'))
if (!file_exists($cache) || filemtime($cache) < filemtime($dest = APP_DIR . '/' . $file . '.php'))
{
loadSource('Subs-CachePHP');
cache_source_file(APP_DIR . '/' . $file . '.php', $cache);
cache_source_file($dest, $cache);
}
}
require_once($cache);
Expand Down Expand Up @@ -256,13 +256,7 @@ function determine_action($action)
loadSource($target[0]);

// Remember, if the function is the same as the filename, you may declare it just once.
$func_name = isset($target[1]) ? $target[1] : $target[0];

if (is_callable($func_name))
return $func_name;

log_error('An error occurred while loading a file. ' . print_r($target, true) . ' -- filesize: ' . filesize(APP_DIR . '/' . $target[0] . '.php'));
return index_action('fallback_action');
return isset($target[1]) ? $target[1] : $target[0];
}

function index_action($hook_action = 'default_action')
Expand Down

0 comments on commit d47934c

Please sign in to comment.