vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   How do i call dooutput() from files within admin directory? (https://vborg.vbsupport.ru/showthread.php?t=50890)

matthew tucker 03-27-2003 09:24 PM

How do i call dooutput() from files within admin directory?
 
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

PHP Code:

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)
PHP Code:

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.

PHP Code:

// ###################### Start gettemplate #######################
function getmytemplate($templatename,$escape=1,$gethtmlcomments=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

Quote:

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.


All times are GMT. The time now is 07:59 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01508 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete