Hello guys, I need help.
In a plugin, in its activation function inserts the string {$string} in the template header, because the template does not allow php MyBB.
The problem is that this string there must be PHP code, but interprets it as text. How can I do?
You can find that string's function in the plugin file. For example if the variable in template is {$something}, then you should look for function like function something() . Additionally it might be evaluating inside the function, as well.
Mhhh, i post my code and you can see WHAT is the problem:
<?php
/**
@ Author: Clear
@ Created: 22/06/2012
@ Version: BETA
@ Contact: [email protected]
@ License: Is not allowed the copy, redistribution and sale of this plugin. For all problem, contact me.
*/
if(!defined('IN_MYBB'))
die('This file cannot be accessed directly.');
$plugins->add_hook('global_start', 'dedications');
function dedications_info() {
return array(
'name' => 'System Dedications',
'description' => 'Create a System Dedications for users.',
'website' => 'http://www.mybb.com/',
'author' => 'Clear',
'authorsite' => 'http://www.clearwebspacedesign.altervista.org/',
'version' => 'BETA',
);
}
function dedications_install()
{
global $db, $charset;
//Creazione della tabella "dediche" per le dediche
$db->query("CREATE TABLE IF NOT EXISTS ".TABLE_PREFIX."dediche(
`id` INT( 6 ) NOT NULL AUTO_INCREMENT ,
`nome` VARCHAR( 30 ) NOT NULL ,
`dedica` TEXT NOT NULL ,
PRIMARY KEY ( `id` ))");
//Inserimento della dedica di prova nella tabella "dediche"
$db->query("INSERT INTO ".TABLE_PREFIX."dediche (`id` ,`nome` ,`dedica`) VALUES (NULL , 'Admin' , 'Test of system dedications. If you see this dedication it work!')");
}
function dedications_is_installed()
{
global $db;
if($db->table_exists("dediche"))
{
$query = $db->query("
SELECT * FROM ".TABLE_PREFIX."dediche");
$row = $db->fetch_array($query);
if (!empty($row['id']))
return true;
else
return false;
}
return false;
}
function dedications_uninstall()
{
global $db;
if($db->table_exists("dediche"))
{
$db->query("DROP TABLE ".TABLE_PREFIX."dedications");
}
}
function dedications_activate()
{
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("header", "#".preg_quote('<div id="container">')."#i",'<div id="container"> {$dedications}');
rebuild_settings();
}
function dedications_deactivate()
{
global $db, $mybb;
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("header", "#".preg_quote('{$dedications}')."#i", '', 0);
rebuild_settings();
}
function dedications()
{
global $db, $mybb;
global $theme, $dedications;
$result = $db->query("SELECT * FROM ". TABLE_PREFIX."dediche order by id DESC");
while ($dediche= $db->fetch_array($result))
{
echo "".$dediche['nome'].": ".$dediche['dedica'].". " ;
}
}
?>
If you see, i want my function in header template, but it work on global_start.. Look where i installed the plugin (the text at the top of the forum outside the container):
http://www.cafedourado.altervista.org/