![]() |
where to place my safe custom functions?
Hi...
Possibly a new security feature of my vBulletin is stopping me from including my custom php file which has a custom-function within it and then using that function in a custom template, where should I place my 'safe' function and get my template working again? The error I'm having is: Fatal error: Call to undefined function customfunction() in /home/www/xxx/includes/adminfunctions_template.php(3950) : eval()'d code(277) : eval()'d code on line 47 please advise |
Use hook: template_safe_faunctions
Code:
$safe_functions[] = 'my_php_function_name'; |
Quote:
|
This should help. :)
http://www.vbulletin.com/docs/html/f...n_conditionals If you have a specific question and you can show your work, then I can be of more assistance. :) |
Thank you...
Yes were on the right track... I have a custom php file in my forums directory which through a template is being included, all that php file really has in it is that function, the template is not being saved telling me it's undefined... So in the php file I've included the line : $safe_functions[] = 'myFunction'; but it's a no show still... It all used to work :) using vBulletin 3.8.7 Patch Level 4 - Just need to let vB know that myFunction is a good'un and I'm golden.. the custom php file is being included, just can't save the template without an error.... Thanks for the help. \ EDIT, I'm getting it now I think.... |
Quote:
"Safe Functions" allows a PHP function or user function to be accessible via a template. It's main purpose was to limit harmful functions from being executed at presentation. "$safe_function" is an array that you can add the name of your function to, this is added to the array at template hook: "template_safe_functions". (See .. "/includes/adminfunctions_template.php" around line ~1888. I have a notion that you are trying to send information to the template through output buffering, but cannot be sure without seeing your code. My forte' lies with vb4, so you could be still doing something I am not familiar with. |
Yeah I dunno...
just want a function included simple as... so I see in my 'adminfunctions_template.php' this line: ($hook = vBulletinHook::fetch_hook('template_safe_functions ')) ? eval($hook) : false; What's a hook? do I need to create a new plugin for my function? insert some code into my custom php file to allow vB to accept it? or insert more code into my custom template? or create a new template with proper allowed custom functions? - I'm confused... I'll explain, this should be easier you know :D Got a custom php file, it's being included, here's the code Code:
<? Code:
// // require_once('top10pagenation.php'); Thanks ever so for the help, I just can't seem to understand what's what with this, cheers --------------- Added [DATE]1406330921[/DATE] at [TIME]1406330921[/TIME] --------------- I placed in the admin_functions template near those lines you mentioned '$safe_functions = array( 'paginateRecords', // test ); so it's like this now: Code:
static $safe_functions; |
Quote:
But I don't think that's what you want. It looks to me like you are trying to call your custom function to do some formatting, in which case you would want to use a plugin. Your code would then create one or more variables and you'd use them in a template. So, which hook location should you use? It depends on what you're trying to do. Hooks are just places in the vbulletin scripts where addon code can be called, so you need to find one in a location that's allows you to do what you want to do. |
Quote:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> My template (incidentally I have php plugin which allows me to use php in templates, so for the 'echo' statement I'm hoping is all ok) Code:
// require_once('top10pagenation.php'); |
Couple questions:
What modification are you using to include PHP in templates? What template are you inserting this into? You do not need "$safe_functions" for what you are doing, since you are circumventing the template system. Give me a few minutes to get my bearing on this with VB3. :) |
All times are GMT. The time now is 05:41 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|