[2.0.7] Disable Censors Per Forum

The cleanup is complete. This forum is now read only.

Rating:

Excellent!
5
63%
Very Good
0
No votes
Good
0
No votes
Fair
1
13%
Poor
2
25%
 
Total votes: 8

Ozzie Gal
Registered User
Posts: 28
Joined: Tue Mar 06, 2007 2:55 pm
Location: NSW. AUSTRALIA
Name: Ros
Contact:

Re: [2.0.7] Disable Censors Per Forum

Post by Ozzie Gal » Sat Aug 25, 2007 11:30 am

For the people who are experiencing the problem of the left pane not showing in the admin panel and who have waited patiently for a solution, as I did, I will post it below. Thanks to Seria and myself comparing our files for this mod I realised that the admin_forum_censors.php file that I had downloaded was not the same and therefore it caused the issue of no left pane. I suggest, of course, that you backup your own files and then replace the admin_forum_censors.php with the one in the code below, go to your forums admin panel to see if it has worked wwithout any dramas.

Mine is now working as it should, so hopefully this will fix it for others that experienced the same problem after installing this mod.

Many thanks to Seria for taking the time to help me out! :mrgreen:

Code: Select all

<?php
// admin_forum_censors.php
// Part of the Forum Censor MOD for phpBB
// version 1.0.0

define('IN_PHPBB', 1);

if( !empty($setmodules) )
{
   $file = basename(__FILE__);
   $module['Forums']['Forum_Censor_Control'] = $file;
   return;
}

//
// Load default header
//

$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);

//
// Mode setting
//
if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
{
   $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
}
else
{
   $mode = "";
}

//Functions

function get_info_censors($mode, $id)
{
   global $db;

   switch($mode)
   {
      case 'category':
         $table = CATEGORIES_TABLE;
         $idfield = 'cat_id';
         $namefield = 'cat_title';
         break;

      case 'forum':
         $table = FORUMS_TABLE;
         $idfield = 'forum_id';
         $namefield = 'forum_name';
         $censorstatus = 'forum_disablecensors';
         break;

      default:
         message_die(GENERAL_ERROR, "Wrong mode for generating select list", "", __LINE__, __FILE__);
         break;
   }
   $sql = "SELECT count(*) as total
      FROM $table";
   if( !$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, "Couldn't get Forum/Category information", "", __LINE__, __FILE__, $sql);
   }
   $count = $db->sql_fetchrow($result);
   $count = $count['total'];

   $sql = "SELECT *
      FROM $table
      WHERE $idfield = $id";

   if( !$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, "Couldn't get Forum/Category information", "", __LINE__, __FILE__, $sql);
   }

   if( $db->sql_numrows($result) != 1 )
   {
      message_die(GENERAL_ERROR, "Forum/Category doesn't exist or multiple forums/categories with ID $id", "", __LINE__, __FILE__);
   }

   $return = $db->sql_fetchrow($result);
   $return['number'] = $count;
   return $return;
}

if( !empty($mode) )
{
   switch($mode)
   {
      case 'censorenable':
         $forum_id = intval($HTTP_GET_VARS[POST_FORUM_URL]);
         $sql = "UPDATE " . FORUMS_TABLE . "
            SET forum_disablecensors = 0
            WHERE forum_id = $forum_id";
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql);
         }
         $show_index = TRUE;
      break;

      case 'censordisable':
         $forum_id = intval($HTTP_GET_VARS[POST_FORUM_URL]);
         $sql = "UPDATE " . FORUMS_TABLE . "
            SET forum_disablecensors = 1
            WHERE forum_id = $forum_id";
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql);
         }
         $show_index = TRUE;
      break;
   }
   if ($show_index != TRUE)
   {
      include('./page_footer_admin.'.$phpEx);
      exit;
   }
}


//
// Generate page
//

$template->set_filenames(array(
   'body' => 'admin/forum_censors.tpl')
);

$template->assign_vars(array(
   'L_TITLE' => $lang['forumcensors_title'],
   'L_DESCRIPTION' => $lang['forumcensors_decription'],
   'L_FILTER_STATUS' => $lang['forumcensors_filter_status'],
   'L_CHANGE' => $lang['forumcensors_change_status'],
   'L_ENABLE' => $lang['forumcensors_change_enable'],
   'L_DISABLE' => $lang['forumcensors_change_disable']

) );


$sql = "SELECT cat_id, cat_title, cat_order
   FROM " . CATEGORIES_TABLE . "
   ORDER BY cat_order";
if( !$q_categories = $db->sql_query($sql) )
{
   message_die(GENERAL_ERROR, "Could not query categories list", "", __LINE__, __FILE__, $sql);
}

if( $total_categories = $db->sql_numrows($q_categories) )
{
   $category_rows = $db->sql_fetchrowset($q_categories);

   $sql = "SELECT *
      FROM " . FORUMS_TABLE . "
      ORDER BY cat_id, forum_order";
   if(!$q_forums = $db->sql_query($sql))
   {
      message_die(GENERAL_ERROR, "Could not query forums information", "", __LINE__, __FILE__, $sql);
   }

   if( $total_forums = $db->sql_numrows($q_forums) )
   {
      $forum_rows = $db->sql_fetchrowset($q_forums);
   }

   //
   // Okay, let's build the index
   //
   $gen_cat = array();

   for($i = 0; $i < $total_categories; $i++)
   {
      $cat_id = $category_rows[$i]['cat_id'];

      $template->assign_block_vars("catrow", array(
         'S_ADD_FORUM_SUBMIT' => "addforum[$cat_id]",
         'S_ADD_FORUM_NAME' => "forumname[$cat_id]",

         'CAT_ID' => $cat_id,
         'CAT_DESC' => $category_rows[$i]['cat_title'],

         'U_VIEWCAT' => append_sid($phpbb_root_path."index.$phpEx?" . POST_CAT_URL . "=$cat_id"))
      );

      for($j = 0; $j < $total_forums; $j++)
      {
         $forum_id = $forum_rows[$j]['forum_id'];
         
         if ($forum_rows[$j]['cat_id'] == $cat_id)
         {

            if ($forum_rows[$j]['forum_disablecensors']==0){
               $status = $lang['forumcensors_status_enabled'];
            }else{
               $status = $lang['forumcensors_status_disabled'];
            }
            $template->assign_block_vars("catrow.forumrow",   array(
               'FORUM_NAME' => $forum_rows[$j]['forum_name'],
               'FORUM_DESC' => $forum_rows[$j]['forum_desc'],
               'ROW_COLOR' => $row_color,
               'I_STATUS' => $status,

               'U_VIEWFORUM' => append_sid($phpbb_root_path."viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"),
               'U_ENABLE' => append_sid("admin_forum_censors.$phpEx?mode=censorenable&" . POST_FORUM_URL . "=$forum_id"),
               'U_DISABLE' => append_sid("admin_forum_censors.$phpEx?mode=censordisable&" . POST_FORUM_URL . "=$forum_id"))
            );

         }// if ... forumid == catid
         
      } // for ... forums

   } // for ... categories

}// if ... total_categories

$template->pparse('body');

include('./page_footer_admin.'.$phpEx);

?>

Cheers
Ros :D
Communication is the key to success in all things that life endeavours...

numnutz
Registered User
Posts: 16
Joined: Thu Aug 09, 2007 12:47 am

Re:

Post by numnutz » Sat Apr 26, 2008 5:45 pm

Excellent mod. And, thanks to Cerus98 for the following:
Cerus98 wrote:I've just installed this mod on 2.0.21 and it works great. But like everyone else, I was dissapointed to find that the censors were still activated in quotes. So I added a couple lines so that quotes are no longer censored.

Here's what to do...

In posting.php Find:

Code: Select all

		if ( $mode == 'quote' )
		{
Add After:

Code: Select all

		if ($forum_disablecensors==0){
Find: (there are two of these, find the second one)

Code: Select all

			$orig_word = array();
			$replacement_word = array();
			obtain_word_list($orig_word, $replace_word);
Add After:

Code: Select all

		}
And that's all there is to it :)
Perfectly solves the quoting of words on the word censor. Thanks you!!

Post Reply

Return to “[2.0.x] MOD Database Cleanup”

Who is online

Users browsing this forum: Cama and 2 guests