[BETA] MOD Logbook

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
clawed
Registered User
Posts: 32
Joined: Tue Jun 14, 2005 3:04 am

Post by clawed »

I had to edit the mod file a lot to get it to work with easymod, here is the file I used If you use this file also check the differences between it and the original file. Sorry for the long post.

Code: Select all

############################################################## 

## MOD Title:          Logbook MOD

## MOD Author:         Merlin Sythove < Merlin@XXXXXX > (N/A) N/A

## MOD Description:    This MOD will keep a logbook of all posting.php

##                     andmodcp.php action

##                     [BETA] MOD Logbook

##                     http://www.phpbb.com/phpBB/viewtopic.php?t=350367			

## MOD Version:        1.0.0

## Compatibility:      2.0.18

##

## Installation Level: Medium

## Installation Time:  20 Minutes (1mn by EasyMOD of Nuttzy)

## Files To Edit:

##     	modcp.php

##    	posting.php

##    	includes/constants.php

##    	includes/page_header.php	

##    	language/lang_english/lang_main.php		

##    	language/lang_english/lang_admin.php		

##    	templates/subSilver/subSilver.cfg

##    	templates/subSilver/overall_header.tpl

## Included Files:     

##    	logbook.php

##    	admin/admin_logbook.php	

##    	admin/admin_logbook_config.php	

##    	includes/functions_logbook.php 

##    	templates/subSilver/images/icon_mini_logbook.gif 

##    	templates/subSilver/admin/logbook_config_body.tpl 

##    	templates/subSilver/logbook_body.tpl
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2  

############################################################## 

## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 

## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 

## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 

## in our MOD-Database, located at: http://www.phpbb.com/mods/ 

############################################################## 

## Author Notes:
## 

## 18-12-2005 -	Version 1.0.0

##							
## mymods removed language, css style, #403

############################################################## 

## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 

############################################################## 

#

#-----[ COPY ]-------------------------------------------------

#

	copy logbook.php to logbook.php



	copy admin/admin_logbook.php	to admin/admin_logbook.php

	copy admin/admin_logbook_config.php	to admin/admin_logbook_config.php

	

	copy includes/functions_logbook.php to includes/functions_logbook.php

	

	copy templates/subSilver/images/icon_mini_logbook.gif to templates/subSilver/images/icon_mini_logbook.gif

	copy templates/subSilver/admin/logbook_config_body.tpl to templates/subSilver/admin/logbook_config_body.tpl

	copy templates/subSilver/logbook_body.tpl to templates/subSilver/logbook_body.tpl 

	

	copy templates/subRed/images/icon_mini_logbook.gif to templates/subRed/images/icon_mini_logbook.gif

	copy templates/subRed/admin/logbook_config_body.tpl to templates/subRed/admin/logbook_config_body.tpl

	copy templates/subRed/logbook_body.tpl to templates/subRed/logbook_body.tpl 

	

#

#-----[ SQL ]-------------------------------------------------

# NOTE: Create table, make sure you change phpbb_ to your own table prefix!



CREATE TABLE `phpbb_logbook` (

  `log_id` mediumint(10) NOT NULL auto_increment,

  `action` varchar(50) default NULL,

  `user_id` mediumint(8) default '0',

  `username` varchar(25) default NULL,

  `user_ip` varchar(8) default '0',

  `time` int(11) default '0',

  `old_forum_id` mediumint(9) default NULL,

  `old_topic_id` mediumint(9) default NULL,

  `old_topic_title` varchar(60) default NULL,

  `old_post_id` mediumint(9) default NULL,

  `old_post_time` int(11) default '0',

  `old_title` varchar(60) default NULL,

  `old_text` text,

  `new_forum_id` mediumint(9) default NULL,

  `new_topic_id` mediumint(9) default NULL,

  `new_topic_title` varchar(60) default NULL,

  `new_post_id` mediumint(9) default NULL,

  `new_title` varchar(60) default NULL,

  `new_text` text,

  PRIMARY KEY  (`log_id`)

) TYPE=MyISAM  ;	

ALTER TABLE `phpbb_users` ADD `user_view_log` TINYINT( 4 ) DEFAULT '0' NOT NULL; 	

	

#

#-----[ OPEN ]-------------------------------------------------

#

templates/subSilver/subSilver.cfg



#

#-----[ FIND ]-------------------------------------------------

#

?>



#

#-----[ BEFORE, ADD ]-------------------------------------------------

#

//MOD Logbook

$images['icon_mini_logbook'] = "$current_template_images/icon_mini_logbook.gif";



#

#-----[ OPEN ]-------------------------------------------------

#

includes/page_header.php



#

#-----[ FIND ]-------------------------------------------------

#
	'U_PROFILE' => append_sid('profile.'.$phpEx.'?mode=editprofile'),



#

#-----[ AFTER, ADD ]-------------------------------------------------

#	

//START MOD Logbook

'U_LOGBOOK' => append_sid($phpbb_root_path . 'logbook.'.$phpEx),

'L_LOGBOOK' => $lang['Log_title'], 

//END MOD Logbook



#

#-----[ FIND ]-------------------------------------------------

#

	if ( !empty($userdata['user_popup_pm']) )

	{

		$template->assign_block_vars('switch_enable_pm_popup', array());

	}

#

#-----[ AFTER, ADD ]-------------------------------------------------

#	

	//START MOD Logbook

	if (($board_config['log_allow_all'] && $userdata['user_view_log']) || $userdata['user_id'] == 2)

	{

		$template->assign_block_vars('switch_view_log', array());

	}

	//END MOD Logbook

	
#

#-----[ OPEN ]-------------------------------------------------

#

	templates/subSilver/overall_header.tpl

	

#

#-----[ FIND ]-------------------------------------------------

#

# Note: this is a partial line!

# Note: Change 'subSilver' to the correct template folder in this line, for other templates

	<a href="{U_LOGIN_LOGOUT}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_login.gif" width="12" height="13" border="0" alt="{L_LOGIN_LOGOUT}" hspace="3" />{L_LOGIN_LOGOUT}</a>&nbsp;



#

#-----[ AFTER, ADD ]-------------------------------------------------

#	Note: this is inserted within the line!

# Note: Change 'subSilver' to the correct template folder in this liconstne, for other templates

	<!-- BEGIN switch_view_log -->

	<a href="{U_LOGBOOK}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_logbook.gif" width="12" height="13" border="0" alt="{L_LOGBOOK}" hspace="3" />{L_LOGBOOK}</a>&nbsp;

	<!-- END switch_view_log -->				



#

#-----[ OPEN ]-------------------------------------------------

# Note: Remember to do other languages too. No Dutch version available.

language/lang_english/lang_admin.php	



#

#-----[ FIND ]-------------------------------------------------

#

?>



#

#-----[ BEFORE, ADD ]-------------------------------------------------

#	

//START MOD Logbook

$lang['Log_not_authorized'] = 'Sorry, you\'re not allowed to view this page.';



//Messages

$lang['Log_delete'] = 'Log deleted successfully.';

$lang['Click_return_admin_log'] = 'Click %shere%s to return to the logbook.';

$lang['Log_config_updated'] = 'Logbook configuration successfull.';

$lang['Click_return_admin_log_config'] = 'Click %shere%s to return to the logbook configuration.';



//Config titles

$lang['Log_config'] = 'Logbook configuration';

$lang['Log_config_explain'] = 'Here you will be able to configure some options of the logbook.';

$lang['Log_general_config'] = 'Logbook general configuration';



//Radio button

$lang['Log_allow_all'] = 'Logbook available to the whole list?';

$lang['Log_allow_all_explain'] = 'Make the logbook available to just the main administrator, or to all people on the list below?';



//Authorisation list 

$lang['Add_username_admin_explain'] = 'Select another person who will be allowed to see the logbook.';

$lang['Delete_username_admin_explain'] = 'Select the people you don\'t want to see the logbook anymore.';

$lang['No_other_admins'] = 'No more people to select';

$lang['No_admins_authorized'] = 'No more people authorised';

$lang['Add_Admin_Username'] = 'Add a moderator or administrator';

$lang['Delete_Admin_Username'] = 'Delete one or more moderators or administrators';

$lang['No_admins_allow'] = 'There are no people to allow to view the logbook.';

$lang['No_admins_disallow'] = 'There are no people to remove from viewing the logbook.';

$lang['Admins_add_success'] = 'People have been added to the list successfully.';

$lang['Admins_del_success'] = 'People have been deleted from the list successfully.';

//Logbookpruning

$lang['Log_prune_success'] = 'Logbook pruning completed.';

$lang['Log_prune_nothing'] = 'Sorry, no records to prune.';

$lang['Log_prune_title'] = 'Logbook pruning';

$lang['Log_prune_logbook'] = 'Prune logbook';

$lang['Log_prune'] = 'Prune the logbook';

$lang['Log_prune_submit'] = 'Prune';

$lang['Log_prune_explain'] = 'Enter the number of days prior to which you want to delete all log records. 0 = delete everything.';

$lang['Log_set_prune'] = 'Please fill in a number of days to prune the logbook!';



$lang['File_not_deleted'] = 'You have not yet deleted the file install_tables.php: do it before trying to see this page.';

//END MOD Logbook




#

#-----[ OPEN ]-------------------------------------------------

#

language/lang_english/lang_main.php	

#

#-----[ FIND ]-------------------------------------------------

#

?>



#

#-----[ BEFORE, ADD ]-------------------------------------------------

#	

//START MOD Logbook

$lang['Log_title'] = 'Logbook';

$lang['Logs_restricted'] = 'Sorry, you are not allowed to view the logbook.';

//Table

$lang['Log_action_title'] = 'Logbook';

$lang['Log_action_explain'] = 'Here you can see your moderators and administrators actions.';



$lang['Return_to_logbook'] = 'Click %shere%s to return to the logbook.';

$lang['Log_deleted'] = 'Logbook records deleted successfully.';



$lang['Confirm_delete_log'] = 'Are you sure you want to delete this logbook record?';

$lang['Confirm_delete_logs'] = 'Are you sure you want to delete these logbook records?';



$lang['Log_details']= 'Details';

$lang['Log number'] = "Logbook record";

$lang['Logbook_record_not_exist'] = 'The logbook record does not exist (any longer).';



//Actions

$lang['log_delete'] = 'Deleted'; 		

$lang['log_move'] = 'Moved';				

$lang['log_lock'] = 'Locked'; 			

$lang['log_unlock'] = 'Unlocked'; 			

$lang['log_merge'] = 'Merged';

$lang['log_split'] = 'Split';

$lang['log_move_post'] = 'Moved post';   

$lang['log_edit_title'] = 'Edited title';

$lang['log_edit_post'] = 'Edited post';

$lang['log_delete_post'] = 'Deleted post';

$lang['log_delete_poll'] = 'Deleted poll';



$lang['Action'] = 'Action';

$lang['View_ip'] = 'ip';

//END MOD Logbook

#

#-----[ OPEN ]-------------------------------------------------

#

includes/constants.php

#

#-----[ FIND ]-------------------------------------------------

#

?>

#

#-----[ BEFORE, ADD ]-------------------------------------------------

#	

//MOD Logbook

define('LOGBOOK_TABLE', $table_prefix.'logbook');




#

#-----[ OPEN ]-------------------------------------------------

#

posting.php



#

#-----[ FIND ]-------------------------------------------------

#

include($phpbb_root_path . 'includes/functions_post.'.$phpEx);



#

#-----[ AFTER, ADD ]-------------------------------------------------

#	

//START MOD Logbook

include($phpbb_root_path . 'includes/functions_logbook.'.$phpEx);

//END MOD Logbook



#

#-----[ FIND ]-------------------------------------------------

#



		$select_sql = (!$submit) ? ', t.topic_title, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, pt.bbcode_uid, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid' : '';

		$from_sql = ( !$submit ) ? ", " . POSTS_TEXT_TABLE . " pt, " . USERS_TABLE . " u" : '';

		$where_sql = ( !$submit ) ? "AND pt.post_id = p.post_id AND u.user_id = p.poster_id" : '';



		$sql = "SELECT f.*, t.topic_id, t.topic_status, t.topic_type, t.topic_first_post_id, t.topic_last_post_id, t.topic_vote, p.post_id, p.poster_id" . $select_sql . " 

			FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $from_sql . " 

			WHERE p.post_id = $post_id 

				AND t.topic_id = p.topic_id 

				AND f.forum_id = p.forum_id

				$where_sql";

#

#-----[ REPLACE WITH ]-------------------------------------------------

#	



		//START MOD Logbook

		//$select_sql = (!$submit) ? ', t.topic_title, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, pt.bbcode_uid, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid' : '';

		//$from_sql = ( !$submit ) ? ", " . POSTS_TEXT_TABLE . " pt, " . USERS_TABLE . " u" : '';

		//$where_sql = ( !$submit ) ? "AND pt.post_id = p.post_id AND u.user_id = p.poster_id" : '';

		//

		//$sql = "SELECT f.*, t.topic_id, t.topic_status, t.topic_type, t.topic_first_post_id, t.topic_last_post_id, t.topic_vote, p.post_id, p.poster_id" . $select_sql . " 

		//	FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $from_sql . " 

		//	WHERE p.post_id = $post_id 

		//		AND t.topic_id = p.topic_id 

		//		AND f.forum_id = p.forum_id

		//		$where_sql";

if ($submit)

    {

			$sql = "SELECT f.*, t.topic_id, t.topic_status, t.topic_type, t.topic_title, t.topic_first_post_id, 

				t.topic_last_post_id, t.topic_vote, p.post_id, p.post_time, p.poster_id, 

				pt.post_subject, pt.post_text, pt.bbcode_uid

  			FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f , " . POSTS_TEXT_TABLE . " pt 

  			WHERE p.post_id = $post_id

  				AND t.topic_id = p.topic_id

  				AND f.forum_id = p.forum_id 

					AND pt.post_id = p.post_id ";    

    }

    else

    {

  		$sql = "SELECT f.*, t.topic_id, t.topic_status, t.topic_type, t.topic_first_post_id, t.topic_last_post_id, 

				t.topic_vote, t.topic_title, p.post_id, p.post_time, p.poster_id , p.enable_bbcode, 

				p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, 

				pt.bbcode_uid, u.username, u.user_id, u.user_sig

  			FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f, " . POSTS_TEXT_TABLE . " pt, " . USERS_TABLE . " u 

  			WHERE p.post_id = $post_id

  				AND t.topic_id = p.topic_id

  				AND f.forum_id = p.forum_id

  				AND pt.post_id = p.post_id AND u.user_id = p.poster_id";

		}



#

#-----[ FIND ]-------------------------------------------------

#

		$post_data['poster_id'] = $post_info['poster_id'];		



#

#-----[ AFTER, ADD ]-------------------------------------------------

#	



		//START MOD Logbook: Remember old post details

		$post_data['topic_title'] = $post_info['topic_title'];

		$post_data['forum_id'] = $post_info['forum_id']; //old values

		$post_data['topic_id'] = $post_info['topic_id'];

		$post_data['old_title'] = ($post_info['post_subject'] ? $post_info['post_subject'] : $post_info['topic_title'] );

		$post_data['old_text'] = $post_info['post_text']; 

		if ( $post_info['bbcode_uid'] != '' )

		{

			$post_data['old_title'] = preg_replace('/\:(([a-z0-9]:)?)' . $post_info['bbcode_uid'] . '/s', '', $post_data['old_title']);

			$post_data['old_text'] = preg_replace('/\:(([a-z0-9]:)?)' . $post_info['bbcode_uid'] . '/s', '', $post_data['old_text']);

		}

		//END MOD Logbook

#

#-----[ FIND ]-------------------------------------------------

#

      

      prepare_post($mode, $post_data, $bbcode_on, $html_on, $smilies_on, $error_msg, $username, $bbcode_uid, $subject, $message, $poll_title, $poll_options, $poll_length);



#

#-----[ BEFORE, ADD ]-------------------------------------------------

#	



			//MOD Logbook: Message with bbcode but no bbcode_uid

      $post_text = stripslashes($message);

      $post_title = stripslashes($subject);

#

#-----[ FIND ]-------------------------------------------------

#

        submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\'", "''", $username), str_replace("\'", "''", $subject), str_replace("\'", "''", $message), str_replace("\'", "''", $poll_title), $poll_options, $poll_length);



#

#-----[ BEFORE, ADD ]-------------------------------------------------

#	

				//START MOD Logbook 

        if ($mode == 'editpost')  

				{

					$new_topic_title = ($post_data['first_post'] ? $post_title : $post_data['topic_title']);

					if ($post_data['old_text'] == $post_text)

					{						

						log_action('edit_title', $forum_id, $topic_id, $post_data['topic_title'], $post_id, $post_data['post_time'], $post_data['old_title'], '', $forum_id, $topic_id, $new_topic_title, $post_id, $post_title );

					}

					else

					{

						$post_title = ($post_title ? $post_title : $post_info['topic_title'] );

						log_action('edit_post', $forum_id, $topic_id, $post_data['topic_title'], $post_id, $post_data['post_time'], $post_data['old_title'], $post_data['old_text'], $forum_id, $topic_id, $new_topic_title, $post_id, $post_title, $post_text);

					}

				}

      	//END MOD Logbook        



#

#-----[ FIND ]-------------------------------------------------

#

		case 'delete':

#

#-----[ AFTER, ADD ]-------------------------------------------------

#	

      //START MOD Logbook 

			log_action('delete_post', $forum_id, $topic_id, $post_data['topic_title'], $post_id, $post_data['post_time'], $post_data['old_title'], $post_data['old_text']);

      //END MOD Logbook  

			delete_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id);

			break;

#

#-----[ FIND ]-------------------------------------------------

#

		case 'poll_delete':



#

#-----[ AFTER, ADD ]-------------------------------------------------

#	

      //START MOD Logbook //Could be 'delete' or 'poll_delete'

      log_action('delete_poll', $forum_id, $topic_id, $post_data['topic_title'], $post_id, $post_data['post_time'], $post_data['old_title']);

      //END MOD Logbook  

#

#-----[ OPEN ]-------------------------------------------------

#

modcp.php

#

#-----[ FIND ]-------------------------------------------------

#

include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);



#

#-----[ AFTER, ADD ]-------------------------------------------------

#	

//START MOD Logbook

include($phpbb_root_path . 'includes/functions_logbook.'.$phpEx);

//END MOD Logbook



#

#-----[ FIND ]-------------------------------------------------

#

			$sql = "SELECT topic_id 

#

#-----[ REPLACE WITH ]-------------------------------------------------

#	

			//MOD Logbook: case 'delete': added topic_title

			$sql = "SELECT topic_id, topic_title



#

#-----[ FIND ]-------------------------------------------------

#



			$topic_id_sql = '';

			while ($row = $db->sql_fetchrow($result))

			{

				$topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . intval($row['topic_id']);

			}

			$db->sql_freeresult($result);



#

#-----[ REPLACE WITH ]-------------------------------------------------

#	

			$topic_id_sql = '';

			//MOD Logbook

			$topic_title = array();

			while ($row = $db->sql_fetchrow($result))

			{

				$topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . intval($row['topic_id']);

				//MOD Logbook

				$topic_title[] = $row['topic_title'];

			}

			$db->sql_freeresult($result);

#

#-----[ FIND ]-------------------------------------------------

#

			$sql = "DELETE 

				FROM " . TOPICS_WATCH_TABLE . " 

				WHERE topic_id IN ($topic_id_sql)";

			if ( !$db->sql_query($sql, END_TRANSACTION) )

			{

				message_die(GENERAL_ERROR, 'Could not delete watched post list', '', __LINE__, __FILE__, $sql);

			}



#

#-----[ AFTER, ADD ]-------------------------------------------------

#	

			//START MOD Logbook

			//*** Action ***// Make logbook entries for each deleted topic: remember the forum_id and topic title 

      for ($i = 0; $i < count($topic_title); $i++)

			{

				log_action('delete', $forum_id, '', $topic_title[$i]);

      }

			//END MOD Logbook

#

#-----[ FIND ]-------------------------------------------------

#

		$sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . '



#

#-----[ REPLACE WITH ]-------------------------------------------------

#	

    //MOD Logbook: case 'move': added forum_name

    $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . '

#

#-----[ FIND ]-------------------------------------------------

#

			if (!$db->sql_fetchrow($result))

			{

				message_die(GENERAL_MESSAGE, 'New forum does not exist');

			}



#

#-----[ REPLACE WITH ]-------------------------------------------------

#	

			//MOD Logbook

			//if (!$db->sql_fetchrow($result))

			if (! $row = $db->sql_fetchrow($result) )

			{

				message_die(GENERAL_MESSAGE, 'New forum does not exist');

			}

			//MOD Logbook

			$new_forum_name = $row['forum_name'];



#

#-----[ FIND ]-------------------------------------------------

#

	$db->sql_freeresult($result);

#

#-----[ AFTER, ADD ]-------------------------------------------------

#

      //START MOD Logbook: Get old forum name

      $old_forum_name = '';

			$sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . '

				WHERE forum_id = ' . $old_forum_id;

			if ( $result = $db->sql_query($sql)) 

			{

				if ($row = $db->sql_fetchrow($result) )

				{

					$old_forum_name = $row['forum_name'];

				}

			}

			$db->sql_freeresult($result);

			//END MOD Logbook * Ignore errors above

#

#-----[ FIND ]-------------------------------------------------

#

					$sql = "UPDATE " . POSTS_TABLE . " 

						SET forum_id = $new_forum_id 

						WHERE topic_id = $topic_id";

					if ( !$db->sql_query($sql) )

					{

						message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql);

					}

#

#-----[ AFTER, ADD ]-------------------------------------------------

#	

          //START MOD Logbook

          //*** Action ***// Make entry for one moved topic

          log_action('move', $old_forum_id, $topic_id, $row[$i]['topic_title'], '', '', '', '', $new_forum_id, $topic_id, $row[$i]['topic_title']);

          //END MOD Logbook



#

#-----[ FIND ]-------------------------------------------------

#

		$topic_id_sql = '';

		for($i = 0; $i < count($topics); $i++)

		{

			$topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);

		}



		$sql = "UPDATE " . TOPICS_TABLE . " 

			SET topic_status = " . TOPIC_LOCKED . " 

			WHERE topic_id IN ($topic_id_sql) 

				AND forum_id = $forum_id

				AND topic_moved_id = 0";

		if ( !($result = $db->sql_query($sql)) )

		{

			message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);

		}

				

#

#-----[ REPLACE WITH ]-------------------------------------------------

#	

		$topic_id_sql = '';

		for($i = 0; $i < count($topics); $i++)

		{

			$topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);

		}

		//START MOD Logbook: Retrieve topic data of locked topics

		$sql = "SELECT topic_id, forum_id, topic_title 

			FROM " . TOPICS_TABLE . "

			WHERE topic_id IN ($topic_id_sql)

				AND forum_id = $forum_id 

				AND topic_moved_id = 0";

		if ( !($result = $db->sql_query($sql)) )

		{

			message_die(GENERAL_ERROR, 'Could not get topics information', '', __LINE__, __FILE__, $sql);

		}

		$row = $db->sql_fetchrowset($result);

		$db->sql_freeresult($result);

		$topic_id_sql = '';

		$topics =  array();

		for($i = 0; $i < count($row); $i++)

		{

			$topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . $row[$i]['topic_id'];

			$topics[$i]['topic_title'] = $row[$i]['topic_title'];

			$topics[$i]['topic_id'] = $row[$i]['topic_id'];

		}

		//END MOD Logbook

		//MOD Logbook: rewritten this sql

		$sql = "UPDATE " . TOPICS_TABLE . "

			SET topic_status = " . TOPIC_LOCKED . "

			WHERE topic_id IN ($topic_id_sql)";



		if ( !($result = $db->sql_query($sql)) )

		{

			message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);

		}

		//START MOD Logbook

		//*** Action ***// Make logbook entries for each locked topic: remember the topic_id 

		for ($i = 0; $i < count($topics); $i++)

		{

			log_action('lock', $forum_id, $topics[$i]['topic_id'], $topics[$i]['topic_title']);

    }

		//END MOD Logbook			

#

#-----[ FIND ]-------------------------------------------------

#

		$topic_id_sql = '';

		for($i = 0; $i < count($topics); $i++)

		{

			$topic_id_sql .= ( ( $topic_id_sql != "") ? ', ' : '' ) . intval($topics[$i]);

		}



		$sql = "UPDATE " . TOPICS_TABLE . " 

			SET topic_status = " . TOPIC_UNLOCKED . " 

			WHERE topic_id IN ($topic_id_sql) 

				AND forum_id = $forum_id

				AND topic_moved_id = 0";

		if ( !($result = $db->sql_query($sql)) )

		{

			message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);

		}



#

#-----[ REPLACE WITH ]-------------------------------------------------

#	



		$topic_id_sql = '';

		for($i = 0; $i < count($topics); $i++)

		{

			$topic_id_sql .= ( ( $topic_id_sql != "") ? ', ' : '' ) . intval($topics[$i]);

		}

		//START MOD Logbook: Retrieve topic data of locked topics

		$sql = "SELECT topic_id, forum_id, topic_title 

			FROM " . TOPICS_TABLE . "

			WHERE topic_id IN ($topic_id_sql)

				AND forum_id = $forum_id 

				AND topic_moved_id = 0";

		if ( !($result = $db->sql_query($sql)) )

		{

			message_die(GENERAL_ERROR, 'Could not get topics information', '', __LINE__, __FILE__, $sql);

		}

		$row = $db->sql_fetchrowset($result);

		$db->sql_freeresult($result);

		$topic_id_sql = '';

		$topics =  array();

		for($i = 0; $i < count($row); $i++)

		{

			$topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . $row[$i]['topic_id'];

			$topics[$i]['topic_title'] = $row[$i]['topic_title'];

			$topics[$i]['topic_id'] = $row[$i]['topic_id'];

		}

		//END MOD Logbook

		//MOD Logbook: rewritten this sql		

		$sql = "UPDATE " . TOPICS_TABLE . "

			SET topic_status = " . TOPIC_UNLOCKED . "

			WHERE topic_id IN ($topic_id_sql)";

		if ( !($result = $db->sql_query($sql)) )

		{

			message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);

		}

		//START MOD Logbook

		//*** Action ***// Make logbook entries for each unlocked topic: remember the topic_id 

    for ($i = 0; $i < count($topics); $i++)

		{

			log_action('unlock', $forum_id, $topics[$i]['topic_id'],  $topics[$i]['topic_title']);

    }

		//END MOD Logbook

#

#-----[ FIND ]-------------------------------------------------

#

			$sql = "SELECT post_id, poster_id, topic_id, post_time

				FROM " . POSTS_TABLE . "

				WHERE post_id IN ($post_id_sql) 

				ORDER BY post_time ASC";

#

#-----[ REPLACE WITH ]-------------------------------------------------

#	

			//MOD Logbook: Added topic title, and topic table so sql is rewritten

			$sql = "SELECT p.post_id, p.poster_id, p.topic_id, p.post_time, t.topic_title

				FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t

				WHERE p.post_id IN ($post_id_sql)

				AND p.topic_id = t.topic_id

				ORDER BY p.post_time ASC";

#

#-----[ FIND ]-------------------------------------------------

#

				$topic_id = $row['topic_id']; 



#

#-----[ AFTER, ADD ]-------------------------------------------------

#	

				//MOD Logbook:

				$old_topic_title = $row['topic_title']; 

#

#-----[ FIND ]-------------------------------------------------

#

				$post_subject = trim(htmlspecialchars($HTTP_POST_VARS['subject']));



#

#-----[ AFTER, ADD ]-------------------------------------------------

#	

				//MOD Logbook

				$new_topic_title = $post_subject;

#

#-----[ FIND ]-------------------------------------------------

#

				if (!$db->sql_query($sql, END_TRANSACTION))

				{

					message_die(GENERAL_ERROR, 'Could not update posts table', '', __LINE__, __FILE__, $sql);

				}

#

#-----[ AFTER, ADD ]-------------------------------------------------

#	

				//START MOD Logbook

        log_action('split', $forum_id, $topic_id, $old_topic_title, '', '','', '', $new_forum_id, $new_topic_id, $new_topic_title);

        //END MOD Logbook



#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
MRM4
Registered User
Posts: 83
Joined: Thu May 15, 2003 3:50 am

Post by MRM4 »

Modifying SQL is something I am new too. So forgive me for being totally ignorant with this question.

Where the note says "# NOTE: Create table, make sure you change phpbb_ to your own table prefix!", what exactly does that mean? I know it means anything starting with "phpbb_" needs to be changed, but I'm not sure what I'm supposed to change it to.
clawed
Registered User
Posts: 32
Joined: Tue Jun 14, 2005 3:04 am

Post by clawed »

MRM4 wrote: Modifying SQL is something I am new too. So forgive me for being totally ignorant with this question.

Where the note says "# NOTE: Create table, make sure you change phpbb_ to your own table prefix!", what exactly does that mean? I know it means anything starting with "phpbb_" needs to be changed, but I'm not sure what I'm supposed to change it to.


By default all the database tables have a prefix of phpbb_ so they don't conflict table names with other software using the same database. When you installed the board it would have given you a chance to change from the default, but you probably didn't so you should be able to install it without any changes. You can use phpMyAdmin to check what the table prefix is if you want to or run into problems.
MRM4
Registered User
Posts: 83
Joined: Thu May 15, 2003 3:50 am

Post by MRM4 »

When I ran the SQL, I got the following error:

#1146 - Table 'mrmraci_smf1.phpbb_users' doesn't exist

What do I need to do to fix this?
MRM4
Registered User
Posts: 83
Joined: Thu May 15, 2003 3:50 am

Post by MRM4 »

Can anyone help? I need an education in SQL. :D
clawed
Registered User
Posts: 32
Joined: Tue Jun 14, 2005 3:04 am

Post by clawed »

MRM4 wrote: Can anyone help? I need an education in SQL. :D


It looks like the prefix for your database tables is not phpbb_. Use phpMyAdmin and look at the database tables and see if they all have a common prefix on all of them.
Sheepeeshaun
Registered User
Posts: 8
Joined: Thu Nov 02, 2006 11:01 am

Post by Sheepeeshaun »

I get this at the top of /logbook.php

Code: Select all

Warning: mysql_free_result(): 37 is not a valid MySQL result resource in /mounted-storage/home20a/sub001/sc17079-KKEA/www/dmc-clan/php-files/hosting/atomicwarriorz/db/mysql4.php on line 318
Any ideas?
MRM4
Registered User
Posts: 83
Joined: Thu May 15, 2003 3:50 am

Post by MRM4 »

I got past the other error, now I get this error message:

#1050 - Table 'mrmraci_logbook' already exists

Now what?
MRM4
Registered User
Posts: 83
Joined: Thu May 15, 2003 3:50 am

Post by MRM4 »

I tried to see if it would install and I got this error message:

Critical Error

Could not perform improperly formed COPY command.
logbook.php to logbook.php
MOD script line #57 :: FAQ :: Report

I got the same message regardless if I copied the new files myself or let the mod do it. I tried installing with EasyMOD.
User avatar
Roks
Registered User
Posts: 119
Joined: Thu Sep 14, 2006 1:15 am

Post by Roks »

Just a quick query, I've been looking for a MOD, that can log activites done by Staff in Admin cPanle, for e.g if Admin A log into Admin cPanle and changes Forum settings, or Ban somebody, these activites are logged. So that, the Main Admin can see, what has been done in Admin cPanel by the Staff's. It's like vBulletin and Lo-Fi.
MRM4
Registered User
Posts: 83
Joined: Thu May 15, 2003 3:50 am

Post by MRM4 »

I figured out the other problem and tried it again. Now, I get this error message:

FIND FAILED: In file [includes/page_header.php] could not find:

'U_PROFILE' => append_sid($phpbb_root_path . 'profile.'.$phpEx.'?mode=editprofile'),

MOD script line #79

When looking on that page, that line actually says:

'U_PROFILE' => append_sid('profile.'.$phpEx.'?mode=editprofile'),

Should I change the page to match the MOD or change the MOD to match my page?
MRM4
Registered User
Posts: 83
Joined: Thu May 15, 2003 3:50 am

Post by MRM4 »

Anyone?
Sheepeeshaun
Registered User
Posts: 8
Joined: Thu Nov 02, 2006 11:01 am

Post by Sheepeeshaun »

Sheepeeshaun wrote: I get this at the top of /logbook.php

Code: Select all

Warning: mysql_free_result(): 37 is not a valid MySQL result resource in /mounted-storage/home20a/sub001/sc17079-KKEA/www/dmc-clan/php-files/hosting/atomicwarriorz/db/mysql4.php on line 318
Any ideas?


No help so I just got rid. :(
MRM4
Registered User
Posts: 83
Joined: Thu May 15, 2003 3:50 am

Post by MRM4 »

Still need help with this:

FIND FAILED: In file [includes/page_header.php] could not find:

'U_PROFILE' => append_sid($phpbb_root_path . 'profile.'.$phpEx.'?mode=editprofile'),

MOD script line #79

When looking on that page, that line actually says:

'U_PROFILE' => append_sid('profile.'.$phpEx.'?mode=editprofile'),

Should I change the page to match the MOD or change the MOD to match my page?
MRM4
Registered User
Posts: 83
Joined: Thu May 15, 2003 3:50 am

Post by MRM4 »

EDITED
Last edited by MRM4 on Tue Dec 19, 2006 8:02 pm, edited 1 time in total.
Post Reply

Return to “[2.0.x] MODs in Development”