/ Published in: PHP

Expand |
Embed | Plain Text
<?php function _phptemplate_variables($hook, $vars) { switch ($hook) { case 'page': // this is a hack to suggest template files based on request uri // to suplement standard arg-based suggestions. this allows for // aliases to be taken into account $request_uri = $_SERVER['REQUEST_URI']; $suggestion = 'page'; //ignore the first match, since the URI is of the form /path/to/uri for ($i=1;$i<$num_matches;$i++) { $suggestion .= '-'. $matches[$i]; $suggestions[] = $suggestion; } $vars['template_files'] = $suggestions; // array($section_template); break; // any additional code here } return $vars; } ?>
Comments

You need to login to post a comment.
woa! This is seriously unsafe. It allows me to include and/or run an aribtrary file on your server. Please anyone looking at this: don't use this code. $request_uri, $suggestions and so forth must be sanitised at the VERY least. But even then, they should best be checked against a whitelist of template files allowed to be included.