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
Got a custom php file, it's being included, here's the code
Code:
<?
function paginateRecords($dataFile,$page,$numRecs=10){
$output='';
// validate data file
(file_exists($dataFile))?$data=(file
($dataFile)):die('Data file not valid.');
// validate number of records per page
(is_int($numRecs)&&$numRecs>0)?$numRecs=$numRecs:die
('Invalid number of records '.$numRecs);
// calculate total of records
$numPages=ceil(count($data)/$numRecs);
// validate page pointer
if(!preg_match("/^\d{1,2}$/",$page)
||$page<1||$page>$numPages){
$page=1;
}
// retrieve records from flat file
$data=array_slice($data,($page-1)*$numRecs,$numRecs);
// append records to output
foreach($data as $row){
$columns=explode('_',$row);
foreach($columns as $column){
$output.=$column.' ';
}
$output.='<br />';
}
// create previous link
$output.='<div class="cheatpagenation">';
if($page>1){
$output.='<a href="'.$_SERVER['PHP_SELF'].'?page='.
($page-1).'"><< Previous</a> ';
}
// create intermediate links
for($i=1;$i<=$numPages;$i++){
($i!=$page)?$output.='<a href="'.$_SERVER
['PHP_SELF'].'?page='.$i.'">'.$i.'</a> ':$output.=$i.' ';
}
// create next link
if($page<$numPages){
$output.=' <a href="'.$_SERVER['PHP_SELF'].'?page='.
($page+1).'">Next >></a></div>';
}
// return final output
return $output;
}
?>
So in my custom template I have this line:
Code:
// // require_once('top10pagenation.php');
// $page=$_GET['page'];
// echo paginateRecords('top10.txt',$page);
It's all commented out at the moment as I can't save it without that error
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;
if (!is_array($safe_functions))
{
$safe_functions = array(
// logical stuff
0 => 'and', // logical and
1 => 'or', // logical or
2 => 'xor', // logical xor
// built-in variable checking functions
'in_array', // used for checking
'is_array', // used for checking
'is_numeric', // used for checking
'isset', // used for checking
'empty', // used for checking
'defined', // used for checking
'array', // used for checking
// vBulletin-defined functions
'can_moderate', // obvious one
'can_moderate_calendar', // another obvious one
'exec_switch_bg', // harmless function that we use sometimes
'is_browser', // function to detect browser and versions
'is_member_of', // function to check if $user is member of $usergroupid
'paginateRecords', // test
);
just to add my function at the end, still can't save my template.. same error