2014-12-05, 09:54 PM
Hello,
I'm developing a plugin , but I get an error that I sincerely do not understand .
This:
' Parse error : syntax error , unexpected $ end in /membri/yugiohspirits/inc/plugins/thread_restriction.php on line 642 '
But is impossible , because the line 635 to 642 is this:
I just do not understand .... help me!
Anyway here's to you the COMPLETE CODE of plugin:
I'm developing a plugin , but I get an error that I sincerely do not understand .
This:
' Parse error : syntax error , unexpected $ end in /membri/yugiohspirits/inc/plugins/thread_restriction.php on line 642 '
But is impossible , because the line 635 to 642 is this:
$db->query("UPDATE ".TABLE_PREFIX."threads SET submit_thread_restriction=1, thread_restriction_user='".$db->escape_string($emptyfield)."' WHERE tid='".$post['tid']."'");
}
if($mybb->input['submit_thread_restriction'] == 0)
{
$db->query("UPDATE ".TABLE_PREFIX."threads SET submit_thread_restriction=0, thread_restriction_user='".$db->escape_string($emptyfield)."' WHERE tid='".$post['tid']."'");
}
?>
I just do not understand .... help me!
Anyway here's to you the COMPLETE CODE of plugin:
<?php
/**
* Thread Restriction plugin
* Copyright = © 2014 The_Dark
* Author = The_Dark
* Codding = The_Dark & murder
* Version = 3.5
* 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 .= 'thread_restriction_user';
}
// add infinty hooks xD
$plugins->add_hook("showthread_start", "thread_restriction_showthread_start");
$plugins->add_hook("newthread_start", "thread_restriction_newthread_start");
$plugins->add_hook('datahandler_post_validate_thread', 'thread_restriction_newthread_validate');
$plugins->add_hook("datahandler_post_insert_thread", 'thread_restriction_action_newthread');
$plugins->add_hook("editpost_action_start", "thread_restriction_editpost_action_start");
$plugins->add_hook("editpost_do_editpost_start", "thread_restriction_editpost_action_send");
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_info()
{
global $mybb, $db, $lang;
$lang->load("thread_restriction_user", 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.5",
"guid" => "",
"compatibility" => "18*"
);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_install()
{
//add templates
global $db, $mybb, $templates, $lang;
$lang->load("thread_restriction_user");
$db->query("ALTER TABLE ".TABLE_PREFIX."threads ADD submit_thread_restriction INT(1) NOT NULL");
$db->query("ALTER TABLE ".TABLE_PREFIX."threads ADD thread_restriction_user TEXT NOT NULL");
$template1 = array(
'title' => 'thread_restriction_user',
'template' => $db->escape_string('<tr>
<td class="trow2"><strong>{$lang->thread_restriction_user}</strong></td>
<td class="trow2"><input type="text" class="textbox" name="thread_restriction_user" size="40" maxlength="240" value="{$thread_restriction_user}" tabindex="2" /></td>
</tr><tr>
<td class="trow2">
<input id="submit_thread_restriction" type="submit" class="button" name="submit_thread_restriction" value="{$submit_thread_restriction}" tabindex="3">
<span id="spinner_span"></span>
</td>
</tr>'),
'sid' => '-1',
'version' => '',
'dateline' => TIME_NOW
);
$db->insert_query("templates", $template1);
$template2 = array(
'title' => 'youdonthavepermission',
'template' => $db->escape_string('<tr>
<td class="trow2"><strong>{$lang->thread_restriction_error_permission}</strong></td>
<td class="trow2"><input type="text" class="textbox" name="youdonthavepermission" size="40" maxlength="240" value="{$youdonthavepermission}" tabindex="2" /></td>
</tr>'),
'sid' => '-1',
'version' => '',
'dateline' => TIME_NOW
);
$db->insert_query("templates", $template2);
$template3 = array(
'title' => 'youdonthavepermissionforedit',
'template' => $db->escape_string('<tr>
<td class="trow2"><strong>{$lang->thread_restriction_you_do_not_edit_restriction_in_this_thread}</strong></td>
<td class="trow2"><input type="text" class="textbox" name="youdonthavepermissionforedit" size="40" maxlength="240" value="{$youdonthavepermissionforedit}" tabindex="2" /></td>
</tr>'),
'sid' => '-1',
'version' => '',
'dateline' => TIME_NOW
);
$db->insert_query("templates", $template3);
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("newthread", "#" . preg_quote('{$posticons}') . "#i", '{$thread_restriction_user}{$posticons}');
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_is_installed()
{
global $db, $mybb, $templates, $thread, $tid, $forums, $fid, $uid, $thread_restriction_user, $submit_thread_restriction;
if($db->field_exists("submit_thread_restriction", "threads") && $db->field_exists("thread_restriction_user", "threads"))
{
return true;
}
return false;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_uninstall()
{
global $db, $mybb, $templates;
$db->query("ALTER TABLE ".TABLE_PREFIX."threads DROP `submit_thread_restriction`");
$db->query("ALTER TABLE ".TABLE_PREFIX."threads DROP `thread_restriction_user`");
$db->delete_query("templates", "title IN('thread_restriction_user','youdonthavepermission','youdonthavepermissionforedit')");
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_activate()
{
global $db, $mybb, $templates, $lang;
$lang->load("thread_restriction_user");
// 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_usergroup",
"title" => $lang->threadrestriction_settings_usergroup,
"description" => $lang->threadrestriction_settings_usergroup_desc,
"optionscode" => "text",
"value" => "",
"disporder" => "4",
"gid" => intval($gid),
);
$db->insert_query("settings", $setting3);
rebuild_settings();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_deactivate()
{
global $db, $mybb, $templates, $lang;
$db->delete_query("settinggroups", "name = 'threadrestriction'");
$db->delete_query('settings', 'name IN ( \'threadrestriction_threads\',\'threadrestriction_banuser\',\'threadrestriction_bangroups\',\'threadrestriction_usergroup\')');
rebuild_settings();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_newthread_start()
{
global $db, $lang, $mybb, $templates, $post_errors, $thread, $tid, $forums, $fid, $uid, $threadrestriction, $youdonthavepermission, $thread_restriction_user, $submit_thread_restriction;
$lang->load("thread_restriction_user");
require_once MYBB_ROOT."/newthread.php";
$ugroup = $mybb->settings['threadrestriction_usergroup'];
$uidss = $mybb->settings['threadrestriction_user'];
$youdonthavepermission = $lang->thread_restriction_error_permission;
$submit_thread_restriction = $lang->submit_thread_restriction;
if (in_array($mybb->user['uid'], explode(',', $uidss)))
{
eval("\$thread_restriction_user = \"".$templates->get("thread_restriction_user")."\";");
}
if(!in_array($mybb->user['uid'], explode(',', $uidss))) {
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("newthread", "#" . preg_quote('{$thread_restriction_user}') . "#i", '{$youdonthavepermission}');
eval("\$youdonthavepermission = \"".$templates->get("youdonthavepermission")."\";");
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_newthread_validate(&$dh)
{
global $mybb;
if($mybb->input['submit_thread_restriction'])
{
$dh->data['submit_thread_restriction'] = $mybb->input['submit_thread_restriction_user'];
$dh->data['thread_restriction_user'] = $mybb->input['thread_restriction_user'];
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_action_newthread(&$dh)
{
global $mybb, $lang, $db, $templates, $thread_restriction_user, $submit_thread_restriction;
if($mybb->input['submit_thread_restriction'] == 1)
{
$thread_restriction_user = $mybb->input['thread_restriction_user'];
$lang->load("thread_restriction_user");
$submit_thread_restriction = $lang->submit_thread_restriction;
if($thread_restriction_user = $mybb->user['uid'])
{
success($lang->thread_restriction_valide_send);
}
if($thread_restriction_user != $mybb->user['uid'])
{
error($lang->thread_restriction_invalide_uids);
}
if($thread_restriction_user = "")
{
error($lang->thread_restriction_invalide);
}
if($thread_restriction_user = $mybb->usergroup['cancp'])
{
error($lang->thread_restriction_permission_admin);
}
else{$db->query("UPDATE ".TABLE_PREFIX."threads SET submit_thread_restriction=1 AND thread_restriction_user='".$db->escape_string(intval($mybb->input['thread_restriction_user']))."' WHERE tid='".$posthandler->tid."'");}
if($dh->action == 'thread' && $dh->method == 'insert')
{
$dh->thread_insert_data['submit_thread_restriction'] = $db->escape_string($dh->data['submit_thread_restriction']);
$dh->thread_insert_data['thread_restriction_user'] = $db->escape_string($dh->data['thread_restriction_user']);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_showthread_start()
{
global $db, $lang, $mybb, $templates, $submit_thread_restriction, $post_errors, $thread, $tid, $forums, $fid, $uid, $threadrestriction, $thread_restriction_user, $submit_thread_restriction;
$lang->load("thread_restriction_user");
$ugroup = $mybb->settings['threadrestriction_usergroup'];
$tids = $mybb->settings['threadrestriction_threads'];
$uids = $mybb->settings['threadrestriction_banuser'];
$uidss = $mybb->input['thread_restriction_user'];
$ugroups = $mybb->settings['threadrestriction_bangroups'];
$submit_thread_restriction = $mybb->input['submit_thread_restriction'];
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();
}
if(in_array($mybb->user['usergroup'], explode(',', $ugroup)) && in_array($submit_thread_restriction, explode(',', $uidss)))
{
error_no_permission();
}
eval("\$thread_restriction_user = \"".$templates->get("thread_restriction_user")."\";");
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Admin can edit the choice of the users about thread restriction, users and other groups not:
function thread_restriction_editpost_action_start()
{
global $db, $lang, $mybb, $templates, $post, $editpost, $youdonthavepermissionforedit, $thread, $uid, $pid,
$submit_thread_restriction, $thread_restriction_user;
require_once MYBB_ROOT."/editpost.php";
$lang->load("thread_restriction_user");
$submit_thread_restriction = $lang->submit_thread_restriction;
$youdonthavepermissionforedit = $lang->thread_restriction_you_do_not_edit_restriction_in_this_thread;
if($mybb->usergroup['cancp'] == 1)
{
eval("\$thread_restriction_user = \"".$templates->get("thread_restriction_user")."\";");
}
if($mybb->usergroup['cancp'] != 1)
{
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("newthread", "#" . preg_quote('{$thread_restriction_user}') . "#i", '{$youdonthavepermissionforedit}');
eval("\$youdonthavepermissionforedit = \"".$templates->get("youdonthavepermissionforedit")."\";");
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function thread_restriction_editpost_action_send()
{
global $mybb, $lang, $thread, $db, $post, $thread_restriction_user, $submit_thread_restriction, $templates;
$emptyfield = $mybb->input['thread_restriction_user'];
$tid = $thread['tid'];
if($mybb->input['submit_thread_restriction'] == 1)
{
$lang->load("thread_restriction_user");
if($mybb->usergroup['cancp'] == 1)
{
eval("\$thread_restriction_user = \"".$templates->get("thread_restriction_user")."\";");
}
if($mybb->usergroup['cancp'] != 1)
{
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("newthread", "#" . preg_quote('{$thread_restriction_user}') . "#i", '{$youdonthavepermissionforedit}');
eval("\$youdonthavepermissionforedit = \"".$templates->get("youdonthavepermissionforedit")."\";");
}
if($emptyfield != $mybb->user['uid'])
{
error($lang->thread_restriction_invalide_uids);
}
if($emptyfield = "")
{
error($lang->thread_restriction_invalide);
}
if($emptyfield = $mybb->usergroup['cancp'])
{
error($lang->thread_restriction_permission_admin);
}
$db->query("UPDATE ".TABLE_PREFIX."threads SET submit_thread_restriction=1, thread_restriction_user='".$db->escape_string($emptyfield)."' WHERE tid='".$post['tid']."'");
}
if($mybb->input['submit_thread_restriction'] == 0)
{
$db->query("UPDATE ".TABLE_PREFIX."threads SET submit_thread_restriction=0, thread_restriction_user='".$db->escape_string($emptyfield)."' WHERE tid='".$post['tid']."'");
}
?>