Version: 1.00, by filburt1
Developer Last Online: May 2007
Version: 2.3.x
Rating:
Released: 05-10-2003
Last Update: Never
Installs: 16
No support by the author.
This hack lets you embed PHP code in templates. Simply add your code between a <? (not a <?php) and ?> tag and it will be eval'ed. All variables will be referenced in the global scope.
If you're using my Usergroup Tags in Templates hack then you're going to have an extraordinarily difficult time installing this hack. However the clever hacker can tell what has changed in this version.
You can somewhat use this to do conditionals in templates. Theoretically, this will work:
Just make sure that the variable to the left of the = and the variable right after the ?> match. Note that the entire <? and ?> tag itself will be stripped from the final template.
This hack also enhances the comments delimiting templates (if that option is turned on) to include the character count and PHP block count of the specified template.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
I'm very interested to see how this develops as IMO i think we'll see a lot of PHP errors popping up now on vBulletin.org due to poor PHP coding in the templates
1. Find every occurance of <? and ?> (and what's inbetween them)
2. For each occurance, make every variable within in the global scope, and then eval what's in the occurance
3. Remove the original occurances from the template.
And so, no need to modify PHP files to create new hack (even if I'll continue to modify the php files for my new hack, but this can be usefull for some modifications )
[high]* grog6 cliks install too
[/high]
Thx for it Filburt
nice hack, I fixed it slightly though to suit my needs:
PHP Code:
if (substr_count($template,'?'.'>')>=1 or substr_count($template,'php?'.'>')>=1 or substr_count($template,'</php>')>=1) {
while (preg_match("/(\<\?php|\<\?|\<php\>)(\r\n)*(.*)(\r\n)*(php\?"."\>|\?"."\>|\<\/php\>)/siU", $template, $matches)) {
if ($parse_phpcode) {
preg_match_all("/\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/", $matches[3], $varnames);
$varnames = implode(", ", $varnames[0]);
if (!empty($varnames)) {
@eval("global $varnames;");
}
$eval_result = @eval(stripslashes($matches[3]));
} else $eval_result = "";
$template = str_replace($matches[0], $eval_result, $template);
}
}
You can now use:
<? ?>
<?php php?>
<php></php>
and any combinations of them, such as:
<?php ?>
and so on.
Also now if you use return(stuff here); in the php script, it returns the data straight to the template itself. Like:
<?
$stuff = "stuff";
return $stuff;
?>
would return the $stuff varible right into the template for you.