无法通过代码将主题发布到 phpbb 论坛



我想知道为什么这段代码不会向论坛提交新的主题。

<?php
define('IN_PHPBB', true);
$phpbb_root_path = '../PHPBB3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
include '/phpBB3/includes/functions_posting.php';
function unhtmlentities($string)
{
// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr("\1")', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
/*   //debug - uncomment for testing
$_POST["username"] = "username";
$_POST["password"] = "password";
$_POST["title"] = "thread title";
$_POST["text"] = "thread comment";
$_POST["forumid"] = 24; //this is the forum id you wanna post to (required for a reply too)
$_POST["topicid"] = ''; //if you wanna submit a reply to a thread add topic id here
*/
$title = htmlspecialchars($_POST['title']);
$name = htmlspecialchars($_POST['name']);
$text = htmlspecialchars($_POST['description']);
$Prioritet = $_POST['priority'];
$Typ = $_POST['type'];
$text = utf8_normalize_nfc($text);
$poll = $uid = $bitfield = $options = '';
generate_text_for_storage($text, $uid, $bitfield, $bbcode_options, false, false, false);
$subject = utf8_normalize_nfc($title);
$username = utf8_normalize_nfc($name);
$data = array( 
// General Posting Settings
'forum_id'            => 2,    // The forum ID in which the post will be placed. (int)
'topic_id'            => 0,    // Post a new topic or in an existing one? Set to 0 to create a new one, if not, specify your topic ID here instead.
'icon_id'            => false,    // The Icon ID in which the post will be displayed with on the viewforum, set to false for icon_id. (int)
// Defining Post Options
'enable_bbcode'    => true,    // Enable BBcode in this post. (bool)
'enable_smilies'    => false,    // Enabe smilies in this post. (bool)
'enable_urls'        => true,    // Enable self-parsing URL links in this post. (bool)
'enable_sig'        => true,    // Enable the signature of the poster to be displayed in the post. (bool)
// Message Body
'message'            => $text,        // Your text you wish to have submitted. It should pass through generate_text_for_storage() before this. (string)
'message_md5'    => md5($text),// The md5 hash of your message
// Values from generate_text_for_storage()
'bbcode_bitfield'    => $bitfield,    // Value created from the generate_text_for_storage() function.
'bbcode_uid'        => $uid,        // Value created from the generate_text_for_storage() function.
// Other Options
'post_edit_locked'    => 1,        // Disallow post editing? 1 = Yes, 0 = No
'topic_title'        => $subject,    // Subject/Title of the topic. (string)
// Email Notification Settings
'notify_set'        => false,        // (bool)
'notify'            => false,        // (bool)
'post_time'         => 0,        // Set a specific time, use 0 to let submit_post() take care of getting the proper time (int)
'forum_name'        => '',        // For identifying the name of the forum in a notification email. (string)
// Indexing
'enable_indexing'    => true,        // Allow indexing the post? (bool)
// 3.0.6
'force_approved_state'    => true, // Allow the post to be submitted without going into unapproved queue
// 3.1-dev, overwrites force_approve_state
'force_visibility'            => true, // Allow the post to be submitted without going into unapproved queue, or make it be deleted
);
submit_post('post', $subject, $username, POST_NORMAL, $poll, $data, [$update_message = true]);
?>

现在,它只显示了一个白色页面,而不是我上面的html代码,论坛上也没有新的帖子。认为它一定是php代码中的某个内容,但似乎找不到错误。我很感激我能得到的所有答案!

EDIT:问题出在submit_post函数中。可能是链接不正确或缺少变量?

编辑2:已编辑代码。现在唯一的问题是,文本不会发布在论坛上!

编辑3:这是错误日志:警告:include(../PHPBB3/common.php):无法打开流:第15行的/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/PHPBB3/formhandled.php中没有这样的文件或目录

警告:include():无法打开".."/PHPBB3/common.php,用于在第15行上的/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/PHPBB3/formhandled.php中包含(include_path='.:/usr/local/share/pear')

警告:include(../PHPBB3/includes/functions_posting.php):无法打开流:在第16行的/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/PHPBB3/formhandled.php中没有这样的文件或目录

警告:include():无法打开".."/在第16行上的/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/PHPBB3/formhandled.php中包含PHPBB3/inclutes/functions_posting.php(include_path='.:/usr/local/share/pear')

警告:include(../PHPBB3/includes/message_parser.php):无法打开流:在第17行的/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/PHPBB3/formhandled.php中没有这样的文件或目录

警告:include():无法打开".."/在第17行的/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/PHPBB3/formhandled.php中包含PHPBB3/included/message_parser.php(include_path='.:/usr/local/share/pear')

警告:include(/baw.se/public_html/phpBB3/includes/functions_posting.php):无法打开流:第18行的/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php中没有这样的文件或目录

警告:include():无法在/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/includes/functions_posting.php中打开'/baw.se/ppublic_html/phpBB3/formhandled.php'进行包含(include_path='.:/usr/local/share/pear')第18行

致命错误:调用第45行/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php中未定义的函数utf8_normalize_nfc()

似乎有一些问题。。。

第4版:修正了错误,现在我有了一个新错误。一般错误SQL错误〔mysqli〕

列"topic_first_poster_color"不能为null[1048]

获取此页面时发生sql错误。如果此问题仍然存在,请与管理员联系。

$message = = generate_text_for_storage($meddelande, $new_uid, $new_bitfield, $bbcode_options, false, false, false);

应该是

$message = generate_text_for_storage($meddelande, $new_uid, $new_bitfield, $bbcode_options, false, false, false);

你有一个额外的=登录我还认为:

$mode = post;

应该是

$mode = 'post';

我认为$mode需要一个字符串(来自内存,自从我玩submit_post以来已经有一段时间了)edit是,第一个参数是字符串。"可以发布、编辑、回复或删除。"-取自维基

最新更新