22, November 2008

problems with modifying phpbb forum - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: problems with modifying phpbb forum
« previous next »
Pages: [1] Print

Author Topic: problems with modifying phpbb forum  (Read 701 times)
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« on: Apr 08, 2006, 11:38:18 PM »

i am installing a mod for phpbb, if you are familiar with it, it comes from phpbbhacks.com. when trying to create a new forum after making the necessary changes, it disallows me from creating the forum due to a mysql error. here is the error mysql gives us:

Quote
General Error
Couldn't insert row in forums table

DEBUG MODE

SQL Error : 1136 Column count doesn't match value count at row 1

INSERT INTO phpbb_forums (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, show_quickreply, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate) VALUES ('22', 'test', 2, 'a', 50, 0, 0, 0, 0, 0, 0, 1, 1, 3, 3, 1, 1)

Line : 410
File : admin_forums.php


Powered by phpBB 2.0.19 and Ad Infinitum v1.06


here is the text that tells us what changes to make to the stock file (see below for stick and modified files)

Quote
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_forums.php

#
#-----[ FIND ]------------------------------------------
#
            $forumstatus = $row['forum_status'];

#
#-----[ AFTER, ADD ]------------------------------------
#
            if( $row['show_quickreply'] == 1)
            {
               $quickreply_enabled = "checked=\"checked\"";
            }
            else
            {
               $quickreply_enabled = '';
            }

#
#-----[ FIND ]------------------------------------------
#
            $forum_id = '';
            $prune_enabled = '';

#
#-----[ AFTER, ADD ]------------------------------------
#
            $quickreply_enabled = "checked=\"checked\"";

#
#-----[ FIND ]------------------------------------------
#
            'S_STATUS_LIST' => $statuslist,

#
#-----[ AFTER, ADD ]------------------------------------
#
            'S_QUICKREPLY_ENABLED' => $quickreply_enabled,

#
#-----[ FIND ]------------------------------------------
#
            'L_FORUM_STATUS' => $lang['Forum_status'],

#
#-----[ AFTER, ADD ]------------------------------------
#
            'L_SHOW_QUICKREPLY' => $lang['Show_Quickreply'],

#
#-----[ FIND ]------------------------------------------
#
         $sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, prune_enable" . $field_sql . ")

#
#-----[ IN-LINE, FIND ]---------------------------------
#
forum_status,

#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
 show_quickreply,

#
#-----[ FIND ]------------------------------------------
#
            VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")";

#
#-----[ IN-LINE, FIND ]---------------------------------
#
" . intval($HTTP_POST_VARS['forumstatus']) . ",

#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
 " . intval($HTTP_POST_VARS['show_quickreply']) . ",

#
#-----[ FIND ]------------------------------------------
#
            SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "
            SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ",

#
#-----[ IN-LINE, FIND ]---------------------------------
#
forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ",

#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
 show_quickreply = " . intval($HTTP_POST_VARS['show_quickreply']) . ",

here is the modified version of "admin_forums.php":

Code:
<?php
/***************************************************************************
 *                             admin_forums.php
 *                            -------------------
 *   begin                : Thursday, Jul 12, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: admin_forums.php,v 1.40.2.12 2005/05/07 22:18:10 acydburn Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   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 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB'1);

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

//
// Load default header
//
$phpbb_root_path "./../";
require(
$phpbb_root_path 'extension.inc');
require(
'./pagestart.' $phpEx);
include(
$phpbb_root_path 'includes/functions_admin.'.$phpEx);

$forum_auth_ary = array(
"auth_view" => AUTH_ALL
"auth_read" => AUTH_ALL
"auth_post" => AUTH_ALL
"auth_reply" => AUTH_ALL
"auth_edit" => AUTH_REG
"auth_delete" => AUTH_REG
"auth_sticky" => AUTH_MOD
"auth_announce" => AUTH_MOD
"auth_vote" => AUTH_REG
"auth_pollcreate" => AUTH_REG
);

//
// 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'];
$mode htmlspecialchars($mode);
}
else
{
$mode "";
}

// ------------------
// Begin function block
//
function get_info($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';
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) != )
{
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;
}

function 
get_list($mode$id$select)
{
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';
break;

default:
message_die(GENERAL_ERROR"Wrong mode for generating select list"""__LINE____FILE__);
break;
}

$sql "SELECT *
FROM $table"
;
if( $select == )
{
$sql .= " WHERE $idfield <> $id";
}

if( !$result $db->sql_query($sql) )
{
message_die(GENERAL_ERROR"Couldn't get list of Categories/Forums"""__LINE____FILE__$sql);
}

$cat_list "";

while( $row $db->sql_fetchrow($result) )
{
$s "";
if ($row[$idfield] == $id)
{
$s " selected=\"selected\"";
}
$catlist .= "<option value=\"$row[$idfield]\"$s>" $row[$namefield] . "</option>\n";
}

return($catlist);
}

function 
renumber_order($mode$cat 0)
{
global $db;

switch($mode)
{
case 'category':
$table CATEGORIES_TABLE;
$idfield 'cat_id';
$orderfield 'cat_order';
$cat 0;
break;

case 'forum':
$table FORUMS_TABLE;
$idfield 'forum_id';
$orderfield 'forum_order';
$catfield 'cat_id';
break;

default:
message_die(GENERAL_ERROR"Wrong mode for generating select list"""__LINE____FILE__);
break;
}

$sql "SELECT * FROM $table";
if( $cat != 0)
{
$sql .= " WHERE $catfield = $cat";
}
$sql .= " ORDER BY $orderfield ASC";


if( !$result $db->sql_query($sql) )
{
message_die(GENERAL_ERROR"Couldn't get list of Categories"""__LINE____FILE__$sql);
}

$i 10;
$inc 10;

while( $row $db->sql_fetchrow($result) )
{
$sql "UPDATE $table
SET $orderfield = $i
WHERE $idfield = " 
$row[$idfield];
if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR"Couldn't update order fields"""__LINE____FILE__$sql);
}
$i += 10;
}

}
//
// End function block
// ------------------

//
// Begin program proper
//
if( isset($HTTP_POST_VARS['addforum']) || isset($HTTP_POST_VARS['addcategory']) )
{
$mode = ( isset($HTTP_POST_VARS['addforum']) ) ? "addforum" "addcat";

if( $mode == "addforum" )
{
list($cat_id) = each($HTTP_POST_VARS['addforum']);
$cat_id intval($cat_id);
// 
// stripslashes needs to be run on this because slashes are added when the forum name is posted
//
$forumname stripslashes($HTTP_POST_VARS['forumname'][$cat_id]);
}
}

if( !empty(
$mode) ) 
{
switch($mode)
{
case 'addforum':
case 'editforum':
//
// Show form to create/modify a forum
//
if ($mode == 'editforum')
{
// $newmode determines if we are going to INSERT or UPDATE after posting?

$l_title $lang['Edit_forum'];
$newmode 'modforum';
$buttonvalue $lang['Update'];

$forum_id intval($HTTP_GET_VARS[POST_FORUM_URL]);

$row get_info('forum'$forum_id);

$cat_id $row['cat_id'];
$forumname $row['forum_name'];
$forumdesc $row['forum_desc'];
$forumstatus $row['forum_status'];
if( $row['show_quickreply'] == 1)
{
$quickreply_enabled "checked=\"checked\"";
}
else
{
$quickreply_enabled '';
}

//
// start forum prune stuff.
//
if( $row['prune_enable'] )
{
$prune_enabled "checked=\"checked\"";
$sql "SELECT *
                FROM " 
PRUNE_TABLE "
                WHERE forum_id = $forum_id"
;
if(!$pr_result $db->sql_query($sql))
{
 message_die(GENERAL_ERROR"Auto-Prune: Couldn't read auto_prune table."__LINE____FILE__);
         }

$pr_row $db->sql_fetchrow($pr_result);
}
else
{
$prune_enabled '';
}
}
else
{
$l_title $lang['Create_forum'];
$newmode 'createforum';
$buttonvalue $lang['Create_forum'];

$forumdesc '';
$forumstatus FORUM_UNLOCKED;
$forum_id ''
$prune_enabled '';
$quickreply_enabled "checked=\"checked\"";
}

$catlist get_list('category'$cat_idTRUE);

$forumstatus == ( FORUM_LOCKED ) ? $forumlocked "selected=\"selected\"" $forumunlocked "selected=\"selected\"";

// These two options ($lang['Status_unlocked'] and $lang['Status_locked']) seem to be missing from
// the language files.
$lang['Status_unlocked'] = isset($lang['Status_unlocked']) ? $lang['Status_unlocked'] : 'Unlocked';
$lang['Status_locked'] = isset($lang['Status_locked']) ? $lang['Status_locked'] : 'Locked';

$statuslist "<option value=\"" FORUM_UNLOCKED "\" $forumunlocked>" $lang['Status_unlocked'] . "</option>\n";
$statuslist .= "<option value=\"" FORUM_LOCKED "\" $forumlocked>" $lang['Status_locked'] . "</option>\n"

$template->set_filenames(array(
"body" => "admin/forum_edit_body.tpl")
);

$s_hidden_fields '<input type="hidden" name="mode" value="' $newmode .'" /><input type="hidden" name="' POST_FORUM_URL '" value="' $forum_id '" />';

$template->assign_vars(array(
'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"),
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_SUBMIT_VALUE' => $buttonvalue
'S_CAT_LIST' => $catlist,
'S_STATUS_LIST' => $statuslist,
'S_QUICKREPLY_ENABLED' => $quickreply_enabled,
'S_PRUNE_ENABLED' => $prune_enabled,

'L_FORUM_TITLE' => $l_title
'L_FORUM_EXPLAIN' => $lang['Forum_edit_delete_explain'], 
'L_FORUM_SETTINGS' => $lang['Forum_settings'], 
'L_FORUM_NAME' => $lang['Forum_name'], 
'L_CATEGORY' => $lang['Category'], 
'L_FORUM_DESCRIPTION' => $lang['Forum_desc'],
'L_FORUM_STATUS' => $lang['Forum_status'],
'L_SHOW_QUICKREPLY' => $lang['Show_Quickreply'],
'L_AUTO_PRUNE' => $lang['Forum_pruning'],
'L_ENABLED' => $lang['Enabled'],
'L_PRUNE_DAYS' => $lang['prune_days'],
'L_PRUNE_FREQ' => $lang['prune_freq'],
'L_DAYS' => $lang['Days'],

'PRUNE_DAYS' => ( isset($pr_row['prune_days']) ) ? $pr_row['prune_days'] : 7,
'PRUNE_FREQ' => ( isset($pr_row['prune_freq']) ) ? $pr_row['prune_freq'] : 1,
'FORUM_NAME' => $forumname,
'DESCRIPTION' => $forumdesc)
);
$template->pparse("body");
break;

case 'createforum':
//
// Create a forum in the DB
//
if( trim($HTTP_POST_VARS['forumname']) == "" )
{
message_die(GENERAL_ERROR"Can't create a forum without a name");
}

$sql "SELECT MAX(forum_order) AS max_order
FROM " 
FORUMS_TABLE "
WHERE cat_id = " 
intval($HTTP_POST_VARS[POST_CAT_URL]);
if( !$result $db->sql_query($sql) )
{
message_die(GENERAL_ERROR"Couldn't get order number from forums table"""__LINE____FILE__$sql);
}
$row $db->sql_fetchrow($result);

$max_order $row['max_order'];
$next_order $max_order 10;

$sql "SELECT MAX(forum_id) AS max_id
FROM " 
FORUMS_TABLE;
if( !$result $db->sql_query($sql) )
{
message_die(GENERAL_ERROR"Couldn't get order number from forums table"""__LINE____FILE__$sql);
}
$row $db->sql_fetchrow($result);

$max_id $row['max_id'];
$next_id $max_id 1;

//
// Default permissions of public :: 
//
$field_sql "";
$value_sql "";
while( list($field$value) = each($forum_auth_ary) )
{
$field_sql .= ", $field";
$value_sql .= ", $value";

}

// There is no problem having duplicate forum names so we won't check for it.
$sql "INSERT INTO " FORUMS_TABLE " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, show_quickreply, prune_enable" $field_sql ")
VALUES ('" 
$next_id "', '" str_replace("\'""''"$HTTP_POST_VARS['forumname']) . "', " intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" str_replace("\'""''"$HTTP_POST_VARS['forumdesc']) . <