2020-10-27, 12:50 PM
There was a plugin for 1.6 version of mybb. There are plenty of plugins which are working perfectly after changing the compatibility to 1.8* .
But in this case the plugin is not installing at all it's took me to page which shows me :- error 500 . i mean it's not installing at all.
The plugin's name is :- Trash can forum.
[attachment=43416]
if anyone plugin master seeing this please help me to get this. and this will be helpful to mybb too.
I know there is alternative plugin for this naming Trash Bin but it's function is not like this plugin.
Please someone help me with this.
trash.php :-
But in this case the plugin is not installing at all it's took me to page which shows me :- error 500 . i mean it's not installing at all.
The plugin's name is :- Trash can forum.
[attachment=43416]
if anyone plugin master seeing this please help me to get this. and this will be helpful to mybb too.
I know there is alternative plugin for this naming Trash Bin but it's function is not like this plugin.
Please someone help me with this.
trash.php :-
<?php
/**
* Copyright � 2006 Nick Palmer, http://e-xarx.net
* Copyright � 2006-2008 CraKteR, crakter [at] gmail [dot] com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @version $Id: trash.php 34 2008-08-14 19:12:19Z CraKteR $
* @copyright $LastChangedDate: 2008-08-14 21:12:19 +0200 (to, 14 aug 2008) $
* @author CraKteR <[email protected]>
*
* Thanks to FirefoxWiz who provided the Purge Trash button.
*/
if(!defined("IN_MYBB"))
{
die("This file cannot be accessed directly.");
}
$plugins->add_hook('editpost_deletepost', 'trash', 0);
$plugins->add_hook('moderation_do_deletethread', 'thread_trash', 0);
$plugins->add_hook('moderation_do_deleteposts', 'moderation_trash', 0);
$plugins->add_hook('moderation_start', 'inline_trash', 100000);
$plugins->add_hook('forumdisplay_start', 'trash_show_button');
function trash_info()
{
return array(
'name' => 'Trash Can Forum',
'description' => 'Deleted Threads Will Automatically be moved to this forum',
'website' => '',
'author' => 'CraKteR',
'authorsite' => 'mailto:[email protected]',
'version' => '2.0',
'guid' => '732aeadd8e2572f35884cdb76bf8a398',
'compatibility' => '16*',
);
}
function trash_activate()
{
global $db;
// Delete all settings to avoid duplicates
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN(
'enabletrash',
'trashcanfid',
'trash_closetopics'
)");
$db->delete_query("settinggroups", "name = 'trashcan'");
$query = $db->simple_select("settinggroups", "COUNT(*) as rows");
$rows = $db->fetch_field($query, "rows");
$trash_group = array(
'name' => 'trashcan',
'title' => 'Trash Can Forum',
'description' => 'Settings for the Trash Can Forum plugin.',
'disporder' => $rows+1,
'isdefault' => 'no'
);
$db->insert_query('settinggroups', $trash_group);
$gid = $db->insert_id();
$trash_setting_1 = array(
'name' => 'enabletrash',
'title' => 'Enable The Trash Can',
'description' => 'Enable The Trash Can. If not enabled, all threads are deleted as normal',
'optionscode' => 'onoff',
'value' => 1,
'disporder' => 1,
'gid' => intval($gid)
);
$trash_setting_2 = array(
'name' => 'trashcanfid',
'title' => 'Trash Can Forum Id',
'description' => 'Enter The ID Of The Forum You Wish The Trash Can To Be',
'optionscode' => 'text',
'value' => '',
'disporder' => 2,
'gid' => intval($gid)
);
$trash_setting_3 = array(
'name' => 'trash_closetopics',
'title' => 'Close The Topics?',
'description' => 'Do You Want The Topics To Become Automatically locked in the trash?',
'optionscode' => 'onoff',
'value' => 1,
'disporder' => 3,
'gid' => intval($gid)
);
$db->insert_query('settings', $trash_setting_1);
$db->insert_query('settings', $trash_setting_2);
$db->insert_query('settings', $trash_setting_3);
rebuildsettings();
$template1 = array(
"title" => "forumdisplay_deletebutton",
"template" => "<a href=\"moderation.php?action=delete_trash&fid={\$fid}\"><img src=\"{\$theme[\'imglangdir\']}/purgetrash.gif\" alt=\"Purge trash\" /></a> ",
"sid" => -1
);
$db->insert_query("templates", $template1);
$template2 = array(
"title" => "moderation_purgetrash",
"template" => "<html>
<head>
<title>{\$mybb->settings[\'bbname\']} - {\$lang->purge_trash_threads}</title>
{\$headerinclude}
</head>
<body>
{\$header}
<form action=\"moderation.php\" method=\"post\">
<table border=\"0\" cellspacing=\"{\$theme[\'borderwidth\']}\" cellpadding=\"{\$theme[\'tablespace\']}\" class=\"tborder\">
<tr>
<td class=\"thead\"><strong>{\$lang->purge_next_threads}</strong></td>
</tr>
<tr>
<td class=\"trow1\"><span style=\"font-size: 1em;\">{\$threads_left}</span></td>
</tr>
</table>
<br />
<input type=\"hidden\" name=\"action\" value=\"delete_trash\" />
<input type=\"hidden\" name=\"fid\" value=\"{\$fid}\" />
<div style=\"text-align: center\"><input type=\"submit\" class=\"button\" name=\"submit\" value=\"{\$lang->purge_next_threads}\" /></div>
</form>
{\$footer}
</body>
</html>",
"sid" => -1
);
$db->insert_query("templates", $template2);
require MYBB_ROOT.'inc/adminfunctions_templates.php';
find_replace_templatesets("forumdisplay_threadlist", '#{\$newthread}#', "{\$newthread}{\$deletebutton}");
}
function trash_deactivate()
{
global $db;
$db->delete_query("settings", "name IN('enabletrash', 'trashcanfid', 'trash_closetopics')");
$db->delete_query("settinggroups", "name = 'trashcan'");
$db->delete_query("templates", "title IN('moderation_purgetrash', 'forumdisplay_deletebutton')");
rebuildsettings();
require MYBB_ROOT.'inc/adminfunctions_templates.php';
find_replace_templatesets("forumdisplay_threadlist", '#{\$deletebutton}#', "", 0);
}
function trash()
{
global $cache, $db, $moderation, $tid, $pid, $fid, $newfid, $forumpermissions, $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $plugins, $session;
$newfid = intval($mybb->settings['trashcanfid']);
if($mybb->input['delete'] == 1 && $mybb->settings['enabletrash'] == 1 && $newfid != 0)
{
if(!isset($lang->thread_deleted))
{
$lang->load("moderation");
}
$query = $db->simple_select("posts", "pid", "tid='{$tid}'", array("limit" => 1, "order_by" => "dateline", "order_dir" => "asc"));
$firstcheck = $db->fetch_field($query, 'pid');
$firstpost = ($firstcheck == $pid) ? 1 : 0;
if($firstpost)
{
if($forumpermissions['candeletethreads'] == 1)
{
if($tid == 0)
{
$query = $db->simple_select("posts", "tid", "pid='$pid'");
$tid = $db->fetch_field($query, 'tid');
}
$query = $db->simple_select("threads", "subject, fid", "tid='$tid'");
$thread = $db->fetch_array($query);
if($newfid != $thread['fid'])
{
move_thread();
redirect("forumdisplay.php?fid=$fid", $lang->redirect_threaddeleted);
}
return false;
}
}
else
{
if($forumpermissions['candeleteposts'] == 1)
{
$query = $db->simple_select("posts", "*", "pid='$pid'");
$post = $db->fetch_array($query);
if($post['fid'] != $newfid)
{
move_post();
redirect("showthread.php?tid=$tid", $lang->redirect_postdeleted);
}
return false;
}
}
}
}
function thread_trash()
{
global $cache, $db, $moderation, $tid, $pid, $fid, $newfid, $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $plugins, $session;
$newfid = intval($mybb->settings['trashcanfid']);
if($mybb->settings['enabletrash'] == 1 && $newfid != 0)
{
if($tid == 0)
{
$query = $db->simple_select("posts", "tid", "pid='$pid'");
$tid = $db->fetch_field($query, 'tid');
}
$query = $db->simple_select("threads", "subject, fid", "tid='$tid'");
$thread = $db->fetch_array($query);
if($newfid != $thread['fid'])
{
move_thread();
redirect("forumdisplay.php?fid=$fid", $lang->redirect_threaddeleted);
}
}
}
function inline_trash()
{
global $db, $cache, $fid, $newfid, $tid, $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $groupscache, $forum_cache, $fpermcache, $usercache, $fpermissionscache, $plugins, $session, $moderation;
$newfid = intval($mybb->settings['trashcanfid']);
if($mybb->settings['enabletrash'] == 1 && $newfid != 0 && (($mybb->input['action'] == "do_multideletethreads" || $mybb->input['action'] == "do_multideleteposts") && $mybb->request_method == "post") || $mybb->input['action'] == 'delete_trash')
{
$tid = intval($mybb->input['tid']);
$fid = intval($mybb->input['fid']);
if($tid)
{
$thread = get_thread($tid);
$fid = $thread['fid'];
if(!$thread['tid'])
{
error($lang->error_invalidthread);
}
$modlogdata['tid'] = $tid;
}
if($fid)
{
$modlogdata['fid'] = $fid;
$forum = get_forum($fid);
if($newfid == $fid && $mybb->input['action'] != 'delete_trash')
{
return;
}
else if($newfid != $fid && $mybb->input['action'] == 'delete_trash')
{
return;
}
}
$permissions = forum_permissions($fid);
if($fid)
{
check_forum_password($fid, $forum['password']);
}
switch($mybb->input['action'])
{
case "do_multideletethreads":
if(is_moderator($fid, "candeleteposts") != true)
{
if($permissions['candeletethreads'] != 1 || $mybb->user['uid'] != $thread['uid'])
{
error_no_permission();
}
}
$threadlist = explode("|", $mybb->input['threads']);
$done = false;
if(is_array($threadlist))
{
foreach($threadlist as $tid)
{
$query = $db->simple_select("threads", "subject, fid, tid", "tid='$tid'");
$thread = $db->fetch_array($query);
if($newfid != $thread['fid'])
{
$tid = $thread['tid'];
move_thread();
$done = true;
$fid = $thread['fid'];
}
}
if($done)
{
redirect("forumdisplay.php?fid=$fid", $lang->redirect_inline_threadsdeleted);
}
}
break;
case "do_multideleteposts":
if(is_moderator($fid, "candeleteposts") != true)
{
error_no_permission();
}
$movethread = true;
$postlist = explode("|", $mybb->input['posts']);
$done = false;
$query = $db->simple_select("posts", "*", "tid='$tid'");
$plist = array();
while($post = $db->fetch_array($query))
{
if(in_array($post['pid'], $postlist))
{
$plist[] = $post;
}
else
{
$movethread = false;
}
}
$fid = $plist[0]['fid'];
if($movethread)
{
$query = $db->simple_select("threads", "subject, fid", "tid='$tid'");
$thread = $db->fetch_array($query);
if($newfid != $thread['fid'])
{
move_thread();
redirect("forumdisplay.php?fid=".$thread['fid'], $lang->redirect_inline_threadsdeleted);
}
}
else
{
if($newfid != $fid)
{
$insert_array = array(
'dateline' => intval($plist[0]['dateline']),
'lastpost' => intval($plist[0]['dateline']),
'fid' => intval($newfid),
'subject' => $db->escape_string($plist[0]['subject']),
'uid' => intval($plist[0]['uid']),
'username' => $db->escape_string($plist[0]['username']),
'visible' => 1,
'closed' => (($mybb->settings['trash_closetopics'] == 1) ? 'yes' : '')
);
$db->insert_query("threads", $insert_array);
$newtid = $db->insert_id();
foreach($plist as $post)
{
$update_array = array(
'tid' => $newtid,
'fid' => $newfid
);
$db->update_query("posts", $update_array, "pid=".$post['pid']);
}
update_thread_counters($tid, array('posts' => '-'.count($plist)));
update_thread_counters($newtid, array('posts' => '+'.count($plist)));
update_forum_counters($fid, array('posts' => '-'.count($plist)));
update_forum_counters($newfid, array('posts' => '+'.count($plist)));
update_first_post($tid);
$cache->update_stats();
redirect("showthread.php?tid=$tid", $lang->redirect_postsdeleted);
}
}
break;
case 'delete_trash':
if(is_moderator($fid, "candeleteposts") != true)
{
if($permissions['candeletethreads'] != 1)
{
error_no_permission();
}
}
$query = $db->simple_select("threads", "tid", "fid='$fid'", array("limit" => 100));
$query2 = $db->simple_select("threads", "COUNT(*) AS threads", "fid='$fid'");
$count = $db->fetch_field($query2, 'threads');
$lang->load("trash");
if($mybb->request_method != "post")
{
if($count == 1)
{
$threads_left = $lang->you_really_want_to_purge_the_thread;
}
else
{
$threads_left = str_replace('[1]', $count, $lang->you_really_want_to_purge_the_threads);
}
}
else
{
if($count > 0)
{
while($thread = $db->fetch_array($query))
{
$moderation->delete_thread($thread['tid']);
$count--;
}
}
if($count == 1)
{
$threads_left = $lang->purge_thread_left;
}
else
{
$threads_left = str_replace('[1]', $count, $lang->purge_threads_left);
}
}
if($count < 100)
{
$num = $count;
}
else
{
$num = 100;
}
if($num == 1)
{
$lang->purge_next_threads = $lang->purge_next_thread;
$lang->purge_trash_threads = $lang->purge_trash_thread;
}
else
{
$lang->purge_next_threads = str_replace('[1]', $num, $lang->purge_next_threads);
}
add_breadcrumb($lang->purge_trash_threads);
if($count > 0)
{
eval("\$moderate = \"".$templates->get("moderation_purgetrash")."\";");
output_page($moderate);
exit();
}
else
{
redirect("forumdisplay.php?fid=".$fid, $lang->redirect_inline_threadsdeleted);
}
break;
}
}
}
function moderation_trash()
{
global $cache, $db, $mybb, $tid, $fid, $newfid, $lang, $thread, $moderation;
$newfid = intval($mybb->settings['trashcanfid']);
if($mybb->settings['enabletrash'] == 1 && $newfid != 0)
{
$movethread = true;
$deletepost = $mybb->input['deletepost'];
$query = $db->simple_select("posts", "*", "tid='$tid'");
$plist = array();
while($post = $db->fetch_array($query))
{
if($deletepost[$post['pid']] == 1)
{
$plist[] = $post;
}
else
{
$movethread = false;
}
}
$fid = $plist[0]['fid'];
if($movethread)
{
$query = $db->simple_select("threads", "subject, fid", "tid='$tid'");
$thread = $db->fetch_array($query);
if($newfid != $thread['fid'])
{
move_thread();
redirect("forumdisplay.php?fid=".$thread['fid'], $lang->redirect_inline_threadsdeleted);
}
}
else
{
if($newfid != $fid)
{
$insert_array = array(
'dateline' => intval($plist[0]['dateline']),
'lastpost' => intval($plist[0]['dateline']),
'fid' => intval($newfid),
'subject' => $db->escape_string($plist[0]['subject']),
'uid' => intval($plist[0]['uid']),
'username' => $db->escape_string($plist[0]['username']),
'visible' => 1,
'closed' => (($mybb->settings['trash_closetopics'] == 1) ? 'yes' : '')
);
$db->insert_query("threads", $insert_array);
$newtid = $db->insert_id();
foreach($plist as $post)
{
$update_array = array(
'tid' => $newtid,
'fid' => $newfid
);
$db->update_query("posts", $update_array, "pid=".$post['pid']);
}
update_thread_counters($tid, array('posts' => '-'.count($plist)));
update_thread_counters($newtid, array('posts' => '+'.count($plist)));
update_forum_counters($fid, array('posts' => '-'.count($plist)));
update_forum_counters($newfid, array('posts' => '+'.count($plist)));
update_first_post($tid);
$cache->update_stats();
redirect("showthread.php?tid=$tid", $lang->redirect_postsdeleted);
}
}
}
}
function move_thread()
{
global $cache, $db, $mybb, $tid, $fid, $newfid, $lang, $thread, $moderation;
if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation();
}
$moderation->move_thread($tid, $newfid, '');
if($mybb->settings['trash_closetopics'] == 1)
{
$moderation->close_threads($tid);
}
$modlogdata['thread_subject'] = $thread['subject'];
log_moderator_action($modlogdata, sprintf($lang->thread_deleted, $thread['subject']));
$cache->update_stats();
}
function move_post()
{
global $db, $cache, $post, $fid, $newfid, $mybb, $pid, $tid;
if(!empty($post['subject']))
{
$post['subject'] .= " - ";
}
$post['subject'] .= "From #{$tid}";
$insert_array = array(
'dateline' => intval($post['dateline']),
'lastpost' => intval($post['dateline']),
'fid' => intval($newfid),
'subject' => $db->escape_string($post['subject']),
'uid' => intval($post['uid']),
'username' => $db->escape_string($post['username']),
'visible' => 1,
'closed' => (($mybb->settings['trash_closetopics'] == 1) ? 'yes' : ''),
'notes' => ''
);
$db->insert_query("threads", $insert_array);
$newtid = $db->insert_id();
$update_array = array(
'tid' => $newtid,
'fid' => $newfid
);
$db->update_query("posts", $update_array, "pid='$pid'");
$affected = $db->affected_rows();
$cache->update_stats();
update_thread_counters($tid, array('posts' => '-'.$affected));
update_thread_counters($newtid, array('posts' => '+'.$affected));
update_forum_counters($newfid, array('posts' => '+'.$affected, 'threads' => '+1'));
update_forum_counters($fid, array('posts' => '-'.$affected, 'threads' => '-1'));
}
function trash_show_button()
{
global $deletebutton, $templates, $mybb, $theme;
$delete = '';
$fid = intval($mybb->input['fid']);
if($fid == intval($mybb->settings['trashcanfid']) && is_moderator($fid, "candeleteposts") == true)
{
eval("\$deletebutton = \"".$templates->get("forumdisplay_deletebutton")."\";");
}
}
?>