2014-12-03, 09:47 PM
When I clicked on install & active near the title of this plugin in ACP -> Plugins, the system said:
Fatal error: Call to a member function escape_string() on a non-object in /membri/yugiohspirits/inc/plugins/thread_restriction.php on line 233
And:
Parse error: syntax error, unexpected $end, expecting T_VARIABLE or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN in /membri/yugiohspirits/inc/plugins/thread_restriction.php on line 41
What is the problem?
Complete code of plugin:
How fix this problem
Fatal error: Call to a member function escape_string() on a non-object in /membri/yugiohspirits/inc/plugins/thread_restriction.php on line 233
And:
Parse error: syntax error, unexpected $end, expecting T_VARIABLE or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN in /membri/yugiohspirits/inc/plugins/thread_restriction.php on line 41
What is the problem?
Complete code of plugin:
<?php
/**
* Thread Restriction plugin
* Copyright = © 2014 The_Dark
* Author = The_Dark
* Codding = The_Dark & murder
* Version = 3.2
* Special thanks to murder
* Website: http://yugiohspirits.altervista.org/
* License: http://www.mybb.com/about/license
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
if(my_strpos($_SERVER['PHP_SELF'], 'newthread.php'))
{
global $templatelist;
if(isset($templatelist))
{
$templatelist .= ',';
}
$templatelist .= 'threadrestrictionuser';
}
// add hook
$plugins->add_hook("showthread_start", "thread_restriction_showthread_start");
$plugins->add_hook("newthread_start", "thread_restriction_newthread_start");
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_info()
{
global $mybb, $db, $lang;
$lang->load("thread_restriction", true);
return array(
"name" => $lang->threadrestriction_info_name,
"description" => $lang->threadrestriction_info_desc,
"website" => "http://yugiohspirits.altervista.org/",
"author" => "The_Dark",
"authorsite" => "http://yugiohspirits.altervista.org/",
"version" => "3.2",
"guid" => "",
"compatibility" => "18*"
);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_install()
{
//add templates
global $db, $mybb, $templates, $lang;
$lang->load("thread_restriction");
// create settings
$insertarray = array(
'name' => 'threadrestriction',
'title' => $lang->threadrestriction_settinggroups_title,
'description' => $lang->threadrestriction_settinggroups_desc,
'disporder' => "5",
);
$gid = $db->insert_query("settinggroups", $insertarray);
// add settings
$setting0 = array(
"name" => "threadrestriction_threads",
"title" => $lang->threadrestriction_settings_threads,
"description" => $lang->threadrestriction_settings_threads_desc,
"optionscode" => "text",
"value" => "",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $setting0);
$setting1 = array(
"name" => "threadrestriction_banuser",
"title" => $lang->threadrestriction_settings_banuser,
"description" => $lang->threadrestriction_settings_banuser_desc,
"optionscode" => "text",
"value" => "",
"disporder" => "2",
"gid" => intval($gid),
);
$db->insert_query("settings", $setting1);
$setting2 = array(
"name" => "threadrestriction_bangroups",
"title" => $lang->threadrestriction_settings_bangroups,
"description" => $lang->threadrestriction_settings_bangroups_desc,
"optionscode" => "text",
"value" => "",
"disporder" => "3",
"gid" => intval($gid),
);
$db->insert_query("settings", $setting2);
$setting3= array(
"name" => "threadrestriction_user",
"title" => $lang->threadrestriction_settings_user,
"description" => $lang->threadrestriction_settings_user_desc,
"optionscode" => "textarea",
"value" => "",
"disporder" => "4",
"gid" => intval($gid),
);
$db->insert_query("settings", $setting3);
rebuild_settings();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_is_installed()
{
global $db, $lang, $mybb;
$lang->load("thread_restriction");
$query = $db->simple_select("settinggroups", "*", "name='threadrestriction'");
$result = $db->fetch_array($query);
if(is_null($result)) {
return false;
}
return true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_uninstall()
{
global $db;
$db->delete_query("settinggroups", "name = 'threadrestriction'");
$db->delete_query('settings', 'name IN ( \'threadrestriction_threads\',\'threadrestriction_banuser\',\'threadrestriction_bangroups\',\'threadrestriction_user\')');
rebuild_settings();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_activate()
{
$insert_array = array(
'title' => 'threadrestrictionuser',
'template' => $db->escape_string('<tr>
<td class="trow2"><strong>{$lang->treadrestriction_user}</strong></td>
<td class="trow2"><input type="text" class="textbox" name="threadrestrictionuser" size="40" maxlength="240" value="{$threadrestrictionuser}" tabindex="2" /></td>
</tr>'),
'sid' => '-1',
'version' => '',
'dateline' => TIME_NOW
);
$db->insert_query("templates", $insert_array);
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("newthread", "#" . preg_quote('{$description}') . "#i", '{$description}{$threadrestrictionuser}');
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_deactivate()
{
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("newthread", "#" . preg_quote('{$threadrestrictionuser}') . "#i", '');
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_showthread_start()
{
global $db, $lang, $mybb, $templates, $post_errors, $thread, $tid, $forums, $fid, $uid, $threadrestriction, $threadrestrictionuser;
$lang->load("thread_restriction");
$tids = $mybb->settings['threadrestriction_threads'];
$uids = $mybb->settings['threadrestriction_banuser'];
$ugroups = $mybb->settings['threadrestriction_bangroups'];
if(in_array($tid, explode(',', $tids)) && in_array($mybb->user['uid'], explode(',', $uids))) {
error_no_permission();
}
if(in_array($tid, explode(',', $tids)) && in_array($mybb->user['usergroup'], explode(',', $ugroups))) {
error_no_permission();
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// News from version v3.1/v3.2 ban set by users in threads if are author of them
function thread_restriction_newthread_start()
{
global $db, $lang, $mybb, $templates, $post_errors, $thread, $tid, $forums, $fid, $uid, $threadrestriction, $threadrestrictionuser;
$lang->load("thread_restriction");
$uidss = $mybb->settings['threadrestriction_user'];
if(($mybb->input['previewpost'] || $post_errors) && in_array($mybb->user['uid'], explode(',', $uidss)))
{
$threadrestrictionuser = htmlspecialchars_uni($mybb->input['threadrestrictionuser']);
}
else
{
$threadrestrictionuser = htmlspecialchars_uni($thread['threadrestrictionuser']);
}
eval("\$threadrestrictionuser = \"".$templates->get("threadrestrictionuser")."\";");
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
?>
How fix this problem