Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 07-25-2014, 09:59 PM
b6gm6n's Avatar
b6gm6n b6gm6n is offline
 
Join Date: Aug 2002
Location: UK
Posts: 691
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.'&nbsp;';

    }

    $output.='<br />';

    }

    // create previous link

    $output.='<div class="cheatpagenation">';

    if($page>1){

    $output.='<a href="'.$_SERVER['PHP_SELF'].'?page='.

    ($page-1).'">&lt;&lt; Previous</a>&nbsp;';

    }

    // create intermediate links

    for($i=1;$i<=$numPages;$i++){

    ($i!=$page)?$output.='<a href="'.$_SERVER

    ['PHP_SELF'].'?page='.$i.'">'.$i.'</a>&nbsp;':$output.=$i.'&nbsp;';

    }

    // create next link

    if($page<$numPages){

    $output.='&nbsp;<a href="'.$_SERVER['PHP_SELF'].'?page='.

    ($page+1).'">Next &gt;&gt;</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
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:38 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.06554 seconds
  • Memory Usage 2,963KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (16)bbcode_code
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (20)post_thanks_box
  • (2)post_thanks_box_bit
  • (20)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (20)post_thanks_postbit_info
  • (20)postbit
  • (2)postbit_attachment
  • (20)postbit_onlinestatus
  • (20)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete