Problem med Topic Categories MOD

Frågor kring MODdar (modifikationer) för phpBB 2.0.x.

Moderatorer: Supportgrupp, Moderatorgrupp

Användarens profilbild
Holger
Support - Ledare
Support - Ledare
Inlägg: 6561
Blev medlem: 2004-06-09 09:32
Svar: 1

Problem med Topic Categories MOD

Inlägg av Holger »

Hej, efter uppdatering till 2.0.10 får jag följande fel när jag försöker ÄNDRA ett skrivet inlägg:
Error in posting

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax near 'WHERE topic_id = 14' at line 1

UPDATE phpbb_topics SET topic_title = 'Namn- och adresslista', topic_type = 0 , k_id= WHERE topic_id = 14

Line : 266
File : /customers/gremminger.se/gremminger.se/httpd.www/service/forum/includes/functions_post.php
Variablen k_id kommer ifrån Topic Categories MODden.

Vad kan det bero på?

/Holger

Kod: Markera allt

#################################################################
## Mod Title: Title Categorie
## Mod Version: 1.0.5
## Author: Ta Lun <ta_lun@hotmail.com> - http://www.talun.de for Updates
## Description: 	Add Titel categories to you Forums. You can see it in the viewforums.php
##              		and viewtopic.php. You can edit it for each post.  
##		For each forum you can select you own categories with a CP in the Mod CP 
##
## Installation Level: Medium
## Installation Time: 20 Minutes
## Files To Edit: 	PHP = viewtopic,viewforum,modcp,posting,constans,lang_main,functions_post
##                	tpl = viewtopic,viewforum,modcp,posting_body
##                
##                
##                
##                
##                
##
##
#################################################################
## Security Disclaimer: This MOD Cannot Be Posted To Or Added At Any Non-Official phpBB Sites
#################################################################
##
##
#################################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
#################################################################
##
##  Revision History:
##
## v1.0.5 (2003/07/31
##  Run under Phpbb 2.0.5 small bug fixes (Preview, Change the Categorie to Null in Polls etc.)
##  v1.0.3 (2003/03/07)
##  Add Categories in List of Modcp (thanks to dookie for the idea)
##  Works under phpbb Version 2.0.4
##  v1.0.2 (2002/05/10) 
##  Some Bugfixes like 
##  - If No Categorie you cant Post
##  - You can choose no Kategories
##  v1.0.0
##  - First Release and Final.
##
#################################################################

--------Add Table in your Mysql DB----------

CREATE TABLE `phpbb_topic_cat` (
`k_id` INT(11) AUTO_INCREMENT PRIMARY KEY, 
`forum_id` INT(11), 
`kategorie` TEXT
); 

ALTER TABLE `phpbb_topics` ADD `k_id` INT(10) DEFAULT '0';

(Change the name if you want. Then you must change the entries in the constans.php)

---------------------------

##########################################################################################
open your lang_main.php (Change it for every Language you have. German and Englisch included)

###----Find----

//
// That's all Folks!

##---Add before German----

//KATEGORIEN
$lang['akt_kat']="Kategorie(n) erfolgreich Aktualisiert.";
$lang['new_kat']="Neue Kategorie hinzufügen:";
$lang['kat']="Kategorien Controlpanel";

##---Add before Englisch----

//KATEGORIEN
$lang['akt_kat']="Categorie(s) Updated";
$lang['new_kat']="Add New Categorie:";
$lang['kat']="Categories Controlpanel";

##------------------------------------------
Save and Close lang_main.php
##########################################################################################

Open includes/constants.php

##----Find----
define('VOTE_DESC_TABLE', $table_prefix.'vote_desc');
define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results');
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
##-----After Add-----

//kategorien
define('TOPIC_KAT', $table_prefix.'topic_cat');
//kategorien

##---------------------------

Save and close the constans.php
##########################################################################################

open includes/function_post.php

##------Find----
function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length)

##----Change the end of row-----
&$poll_options, &$poll_length, &$k_id)

##-----------------------------


##----FIND in function submit_post------
		$sql  = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type " . (($post_data['edit_vote'] || !empty($poll_title)) ? ", topic_vote = " . $topic_vote : "") . " WHERE topic_id = $topic_id";

##----Replace with----

$sql  = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote,k_id) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote, $k_id)" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type " . (($post_data['edit_vote'] || !empty($poll_title)) ? ", topic_vote = " . $topic_vote : "") . ", k_id=$k_id WHERE topic_id = $topic_id";

##--------------------

Save an close the function_post.php
##########################################################################################

Open viewtopic.php

##----Find----
else
	{
		$l_edited_by = '';
	}

##---Add After----
//kategorien
	if ( $postrow[$i]['k_id'] != 0 ) {
	$sql="select kategorie FROM " . TOPIC_KAT . " where k_id=" .$postrow[$i]['k_id'];
	if ( $result = $db->sql_query($sql) ){
	$kat2 = $db->sql_fetchrow($result);
	$topic_kat="[" .$kat2['kategorie'] . "]";
	
	$template->assign_vars(array(
	'TOPIC_CAT' => $topic_kat,
	));	
	}
	}
//kategorien

##-------------

##----FInd-----
//
// Go ahead and pull all data for this topic
//
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid
	FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
	WHERE p.topic_id = $topic_id
		$limit_posts_time
		AND pt.post_id = p.post_id
		AND u.user_id = p.poster_id
	ORDER BY p.post_time $post_time_order
	LIMIT $start, ".$board_config['posts_per_page'];

##----Replace with---
//
// Go ahead and pull all data for this topic
//
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile,u.user_active, u.user_allow_viewonline, u.user_session_time, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid, t.k_id
	FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt, " . TOPICS_TABLE. " t
	WHERE p.topic_id = $topic_id
		$limit_posts_time
		AND pt.post_id = p.post_id
		AND u.user_id = p.poster_id
		AND t.topic_id = $topic_id
	ORDER BY p.post_time $post_time_order
	LIMIT $start, ".$board_config['posts_per_page'];
	

##-----------------

Save an Close viewtopic.php
##########################################################################################

Open viewforum.php

##---Find----
if( ( $replies + 1 ) > $board_config['posts_per_page'] )
		{

##----Add Before-----
//kategorien
		if($topic_rowset[$i]['k_id'] !=0)
		{
			$sql="select kategorie FROM " . TOPIC_KAT ." where k_id=" . $topic_rowset[$i]['k_id'];
			
			if ( $result = $db->sql_query($sql) )
			{
			$kat = $db->sql_fetchrow($result);
			$topic_kat="[" .$kat['kategorie'] . "]";
			}
		}else{
			$topic_kat="";
		}
		//kategorien

##------------

##----Find----
$template->assign_block_vars('topicrow', array(
'ROW_COLOR' => $row_color,

##---Replace with-----
$template->assign_block_vars('topicrow', array(
			'TOPIC_KAT' => $topic_kat,
			'ROW_COLOR' => $row_color,
##--------------------


Save and Close viewforum.php

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

Open modcp.php

##----Find----
else if ( $unlock )
	{
		$mode = 'unlock';
	}
##---Add after---

//kategorien EDIT
	else if ( $edit )
	{
		$mode = 'edit';
	}
	//Kategorien EDIT

##---------



##---Find----
//
// Obtain relevant data
//
if ( !empty($topic_id) )
{
	$sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
		FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
		WHERE t.topic_id = " . $topic_id . "
			AND f.forum_id = t.forum_id";
##---Replace with----
//
// Obtain relevant data
//
if ( !empty($topic_id) )
{
	$sql = "SELECT f.forum_id, f.forum_name, f.forum_topics,t.k_id
		FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
		WHERE t.topic_id = " . $topic_id . "
			AND f.forum_id = t.forum_id";
##-------------------


##----Find---

	$template->assign_vars(array(
			'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
		);

		message_die(GENERAL_MESSAGE, $lang['Topics_Locked'] . '<br /><br />' . $message);

		break;
##---Add After------

//kategorien
	case 'edit':
		$page_title = $lang['Mod_CP'];
		include($phpbb_root_path . 'includes/page_header.'.$phpEx);
		$total_kat= count($kategorie);
		$j=0;
		$i=0;
		while($j < $total_kat){
		$kategorie[$i]=addslashes($kategorie[$i]);
		$sql="Update " . TOPIC_KAT ." set kategorie='$kategorie[$i]' WHERE  k_id=" .$kat_old[$i];
		$j++;
		$i++;
		if ( !($result = $db->sql_query($sql)) )
		{
			
			
			message_die(GENERAL_ERROR, 'Could not update Category table', '', __LINE__, __FILE__, $sql);
		}
			
		}
		if(!empty($add_cat))	{
		$add_cat= addslashes($add_cat);
		$sql_k_u="INSERT INTO " . TOPIC_KAT ." (k_id, forum_id, kategorie) VALUES  ('', $forum_id, '$add_cat')";
		if ( !($result = $db->sql_query($sql_k_u)) )
		{
		echo $add_cat;
		echo $sql_k_u;
		message_die(GENERAL_ERROR, 'Could not Insert Category table', '', __LINE__, __FILE__, $sql);
		}
		}
		
		$c_del_k= count($kat_del);
		if($c_del_k){
		 
		 $j=0;
		$i=0;
		while($j < $c_del_k){
		 
		    $sql_del="Delete  From " . TOPIC_KAT ." where k_id=" .$kat_del[$i];
		$j++;
		$i++;
		if ( !($result = $db->sql_query($sql_del)) )
		{
			
			message_die(GENERAL_ERROR, 'Could not Del Category ', '', __LINE__, __FILE__, $sql);
		}
		}
		}
		
		
			$redirect_page = "$PHP_SELF?f=$forum_id&sid=$sid";
			$message= $lang['akt_kat'];
			$message.="<br>";
			$message.="<a href=\"$redirect_page\">" . $lang['Previous']  . "</a>";
			message_die(GENERAL_MESSAGE, $message);
		
		
		
	break;	
	//kategorien	

##--------------


##---Find-----

'L_REPLIES' => $lang['Replies'], 
			'L_LASTPOST' => $lang['Last_Post'], 
			'L_SELECT' => $lang['Select'], 
##----Add after-----
//kategorien
			'L_ADD_KAT' =>$lang['new_kat'],
			'L_KAT' => $lang['Category'],
			'L_KATE' =>$lang['kat'],
			'L_DEL_KATE' => $lang['Delete'],
			//kategorien


##--------


##----Find----
$topic_title = '';

			if ( $row['topic_status'] == TOPIC_LOCKED )
			{
##---Add before (i mean before $topic_title="; ok friends? ;-)-----

//kategorien
			if($row['k_id'] !=0){
			$sql2="select kategorie FROM " . TOPIC_KAT ." where k_id=".$row['k_id'];
			if ( $result2 = $db->sql_query($sql2) )
				{
					$kat = $db->sql_fetchrow($result2);
					$topic_kat="[" .$kat['kategorie'] . "]";
				}
			}else{
			$topic_kat="";
			}
			//kategorien

##--------------

##----Find-----
	'TOPIC_ID' => $topic_id,
					
				'L_TOPIC_FOLDER_ALT' => $folder_alt)
			);
						
		}
##----Bevore ADD-----


	'TOPIC_KAT' => $topic_kat,


##----Find the same again-----
	'TOPIC_ID' => $topic_id,
					
				'L_TOPIC_FOLDER_ALT' => $folder_alt)
			);
						
		}
##----Add After----

//kategorien
		$sql_forum_k="select kategorie,k_id FROM " . TOPIC_KAT ." where forum_id=".$forum_id;
			if ( $result_f = $db->sql_query($sql_forum_k) )
			{
			while($kat2 = $db->sql_fetchrow($result_f))
			{
			
			$template->assign_block_vars('forum_katrow', array(
				'FORUM_KAT' => $kat2['kategorie'],
				'K_ID' => $kat2['k_id'])
			);
			}
	}

//kategorien

##---------------

Save and close modcp.php


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

open posting.php

##-----Find----
case 'newtopic':
		if ( empty($forum_id) )
		{
			message_die(GENERAL_MESSAGE, $lang['Forum_not_exist']);
		}

		$sql = "SELECT * 
			FROM " . FORUMS_TABLE . " 
			WHERE forum_id = $forum_id";
			
##----Add after----

//kategorien
		$sql_kat="select * FROM " . TOPIC_KAT . " where forum_id=" .$forum_id. " ORDER BY kategorie" ;
        		if ( $result = $db->sql_query($sql_kat) ){
			$result2 = $db->sql_query($sql_kat);
			$kat33 = $db->sql_fetchrow($result2);
			$to_result=count($kat33);
			if($to_result >=2){
			$first= "<select size=\"1\" name=\"k_id\">";
			$first.="<option value=\"0\">$kat[kategorie]</option>";
			while($kat = $db->sql_fetchrow($result)){
			$first.="<option value=\"" . $kat[k_id] . "\">$kat[kategorie]</option>";
			}
			$first.="</select>";
			$kat=$first;
			}else{
			$kat="<input type=\"hidden\" name=\"k_id\" value=\"0\">";
			}
			$template->assign_vars(array(
			'TOPIC_CAT' => $kat,
			));
			
		}
		//kategorien	
##---------

##----find----
$message = $post_info['post_text'];

if ( $mode == 'editpost' )
		{

##----Add After----
		//kategorien
		if($post_id ==$post_info['topic_first_post_id'])
		{		
		
		$sql_kat2="select * FROM " . TOPIC_KAT . " where forum_id=" .$forum_id. " ORDER BY kategorie" ;
        		
        		if ($result = $db->sql_query($sql_kat2)){
		$result2 = $db->sql_query($sql_kat2);
		$kat33 = $db->sql_fetchrow($result2);		
		$to_cat=count($kat33);
		if($to_cat >1){
			$first= "<select size=\"1\" name=\"k_id\">";
			$first.="<option value=\"0\" $s>$kat[kategorie]</option>";
			while($kat = $db->sql_fetchrow($result)){
			if(($post_info['k_id'])==$kat['k_id'])
			{
			$s="selected";
			}else
			{
			$s="";
			}
			$first.="<option value=\"" . $kat[k_id] . "\" $s>$kat[kategorie]</option>";
			}
			$first.="</select>";
			$kat=$first;
		}else{
		$kat="<input type=\"hidden\" name=\"k_id\" value=\"0\">";
		}			
			$template->assign_vars(array(
			'TOPIC_CAT' => $kat,
			));
			
		}
		}
		//kategorien	

##--------

##------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);

##---Replace with----
	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, $k_id);

##----

##----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" : '';

##---Replace with----
	$select_sql = ( !$submit ) ? ", t.topic_title,t.k_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" : '';

##--------

##----Find---
	$preview_subject = $subject;
	$preview_username = $username;

##----Add After----
	//kategorien
	$previews_k_id= $k_id;
	//kategorien

##--------

##----Find---

	else if( $error_msg != '' )
	{
		$template->set_filenames(array(
			'reg_header' => 'error_body.tpl')
		);
		$template->assign_vars(array(
			'ERROR_MESSAGE' => $error_msg)
		);
		$template->assign_var_from_handle('ERROR_BOX', 'reg_header');
	}

##----Add After----

//kategorien
	if($k_id>=0)
		{		
		
		$sql_kat2="select * FROM " . TOPIC_KAT . " where forum_id=" .$forum_id. " ORDER BY kategorie" ;
        		
        		if ($result = $db->sql_query($sql_kat2)){
		$result2 = $db->sql_query($sql_kat2);
		$kat33 = $db->sql_fetchrow($result2);		
		$to_cat=count($kat33);
		if($to_cat >1){
			$first= "<select size=\"1\" name=\"k_id\">";
			$first.="<option value=\"0\" $s></option>";
			while($kat = $db->sql_fetchrow($result)){
			if(($k_id)==$kat['k_id'])
			{
			$s="selected";
			}else
			{
			$s="";
			}
			$first.="<option value=\"" . $kat[k_id] . "\" $s>$kat[kategorie]</option>";
			}
			$first.="</select>";
			$kat=$first;
		}else{
		$kat="<input type=\"hidden\" name=\"k_id\" value=\"0\">";
		}			
			$template->assign_vars(array(
			'TOPIC_CAT' => $kat,
			));
			
		}
		}
		//kategorien	

##--------

Save and Close Posting.php


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

open posting_body.tpl

##----find---
<input type="text" name="subject" size="45" maxlength="60" style="width:450px" tabindex="2" class="post" value="{SUBJECT}" />

##----Add Before----
{TOPIC_CAT}&nbsp;&nbsp;

##-------

Save and Close posting_body.tpl
##########################################################################################

Open modcp_body.tpl

##----Find----
<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>

##----Add before----

<b>{topicrow.TOPIC_KAT}</b>


##----Find----
<input type="submit" name="lock" class="liteoption" value="{L_LOCK}" />
		&nbsp; 
		<input type="submit" name="unlock" class="liteoption" value="{L_UNLOCK}" />
	  </td>
	</tr>
  </table>
##----Add After----

   <table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline">
  <tr>
  <td colspan="2" class="row1" align="center" valign="middle"><span class="postdetails"><b>{L_KATE}</b></span> </td>
  <td class="row1" align="center" valign="middle"><span class="postdetails"><b>{L_DEL_KATE}</b></span> </td>	
  </tr>
   
  <!-- BEGIN forum_katrow -->
  <tr> 
  	<td class="row1" align="center" valign="middle"><span class="postdetails">{L_KAT}:</span> </td>	
	  <td class="row1" align="center" valign="middle"><span class="postdetails"><input type="text" name="kategorie[]" class="post" size="20" value="{forum_katrow.FORUM_KAT}"></span>
	    <td class="row1" align="center" valign="middle"><span class="postdetails"><input type="checkbox" name="kat_del[]" value="{forum_katrow.K_ID}"></span> </td>
	    <input type="hidden" name="kat_old[]" value="{forum_katrow.K_ID}">
	  </td>
	  </tr>
  <!-- END forum_katrow -->
 <tr> 
 	<td class="row1" align="center" valign="middle"><span class="postdetails">{L_ADD_KAT}</span> </td>
	  <td class="row1" align="center" valign="middle"><span class="postdetails"><input type="text" name="add_cat" class="post" size="20" value=""></span>
	    </td>
	  <td class="row1" align="center" valign="middle"><span class="postdetails"></span> </td>
	  </tr>
  <tr align="right"> 
	  <td class="catBottom" colspan="5" height="29"> {S_HIDDEN_FIELDS} 
		<input type="submit" name="edit" class="liteoption" value="Edit" />
		
		
	  </td>
	</tr>
  </table>

##-----------------------------------

Save and Close modcp_body.tpl


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

open viewtopic_body.tpl

##---Find---
<td align="left" valign="bottom" colspan="2"><a class="maintitle" href="{U_VIEW_TOPIC}">{TOPIC_TITLE}</a><br />

##----Replace with-----
<td align="left" valign="bottom" colspan="2"><a class="maintitle" href="{U_VIEW_TOPIC}">{TOPIC_CAT} {TOPIC_TITLE}</a><br />
##------------

Save and close viewtopic_body.tpl

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

Open viewforum_body.tpl

##----Find in the topicrow----

<td class="row1" width="100%"><span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a></span><span class="gensmall"><br />


##---Replace with----
<td class="row1" width="100%"><span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.TOPIC_TYPE} {topicrow.TOPIC_KAT} <a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a></span><span class="gensmall"><br />

##------------
Save and close viewforum_body.tpl


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

Done have Fun
EOF
Holger Gremminger
Ingen support via PM!

Vilka är online

Användare som besöker denna kategori: 1 och 0 gäst