PDA

View Full Version : How do i call dooutput() from files within admin directory?


matthew tucker
03-27-2003, 09:24 PM
I'm writing a hack based on a modified /admin/user.php that tracks an association's financial members details in a separate table of the vb database.

I am trying to call

eval("dooutput(\"".gettemplate("members_expiresoon")."\");");

to be able to print "reminder" letters from a browser using a vb template "members_expiresoon".

If I put that code in another php file in /forums and call that file, it works well, but if I just include the above code in my main program (in forums/admin/) I get a blank screen. grrr

This seems like an "include" or a path issue but I can work it out. Any suggestions?

(I have the following code at the start of my program)
require("./global.php");
require("./functions.php");

filburt1
03-27-2003, 09:52 PM
The admin CP is not designed to use templates. You might have to use an iframe.

matthew tucker
03-27-2003, 10:15 PM
what's an iframe?

can't I just define doutput() somewhere else? Or is using templates in the admin area a security risk?

filburt1
03-27-2003, 10:34 PM
PHP doesn't let you override functions, so you can't redefine it.

An iframe is a frame not bound to any sides of a window. Search around.

Xenon
03-27-2003, 11:20 PM
dooutput works in adminfiles as well, but as filburt said the gettemplate function makes problems, because it doesn't know which styleid to use and so on..

matthew tucker
03-28-2003, 12:18 AM
Hi Stefan

So, could I just define a modified gettemplate() function maybe (using another function name in my program file!) that would work?

I had a close look at gettemplate() in functions.php but it doesn't seem to reference anything like styleid - maybe I don't understand how that works?

Is there any security risk in calling templates from within the admin area?

Brad
03-28-2003, 12:55 AM
No there is no risk im aware of, but it will be alot of stuff to work around to use them. If i where you i would just use echo and some html to display the message in the admin cp.

matthew tucker
03-28-2003, 01:09 AM
Well I think I did it with the following hacked function. I used a sculptor's technique ... removed bits of code until it worked.

// ###################### Start gettemplate #######################
function getmytemplate($templatename,$escape=1,$gethtmlcomm ents=1) {
// gets a template from the db or from the local cache
global $DB_site,$templatesetid,$addtemplatename;

$gettemp=$DB_site->query_first("SELECT template FROM template WHERE title='".addslashes($templatename)."' ");
$template=$gettemp[template];

if ($escape==1) {
$template=addslashes($template);
$template=str_replace("\\'","'",$template);
}

if ($gethtmlcomments) {
return "<!-- BEGIN MYTEMPLATE: $templatename -->\n$template\n<!-- END TEMPLATE: $templatename -->";
}

return $template;
}

I'm not too clear how the template cache works, or what the $templatesetid and $addtemplatename variables are for - and maybe this will bugger up some other code - but so far so good, I'm happy. Thanks for your responses.

Brad
03-28-2003, 01:50 AM
I'm not too clear how the template cache works

Check out any file in the /forums folder, you'll most likely see a line that starts with $templatesused with a bunch of template names seprated by commas.

Basicly any template called in the file that is not in this line will add a query. however sometimes its better not to add a template here if it wont be used 90% of the time because it adds a bit of overhead.

Xenon
03-28-2003, 11:03 AM
the templatecache is irrelevant on adminfiles, because no templates are called normally.

just the templatesetid has to be specified, or you'd always get the original templates and not your modified ones.