Невозможно опубликовать тему на phpbb-forum по коду
Интересно, почему этот код не будет представлять новую тему на форумах.
<?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-коде, но, похоже, не могу найти ошибку. Я ценю все ответы, которые я могу получить!
РЕДАКТИРОВАТЬ: проблема в функции submit_post. Возможно плохая ссылка или отсутствующая переменная?
РЕДАКТИРОВАТЬ 2: отредактированный код. Единственная проблема сейчас заключается в том, что текст не будет размещен на форумах!
РЕДАКТИРОВАТЬ 3: Это журнал ошибок: Предупреждение: include(../PHPBB3/common.php): не удалось открыть поток: нет такого файла или каталога в /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php в строке 15
Предупреждение: include(): Не удалось открыть "../PHPBB3/common.php" для включения (include_path='.:/ Usr/local/share/pear') в /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/ public_html / phpBB3 / formhandled.php в строке 15
Предупреждение: include(../PHPBB3/includes/functions_posting.php): не удалось открыть поток: нет такого файла или каталога в /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php в строке 16
Предупреждение: include(): не удалось открыть "../PHPBB3/includes/functions_posting.php" для включения (include_path='.:/ Usr/local/share/pear') в / www / webvol11 / jc / 87yqo3f2oz6gicm / baaw. se / public_html / phpBB3 / formhandled.php в строке 16
Предупреждение: include(../PHPBB3/includes/message_parser.php): не удалось открыть поток: нет такого файла или каталога в /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php в строке 17
Предупреждение: include(): Не удалось открыть "../PHPBB3/includes/message_parser.php" для включения (include_path='.:/ Usr/local/share/pear') в / www / webvol11 / jc / 87yqo3f2oz6gicm / baaw. se / public_html / phpBB3 / formhandled.php в строке 17
Предупреждение: include(/baaw.se/public_html/phpBB3/includes/functions_posting.php): не удалось открыть поток: нет такого файла или каталога в /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled. PHP на линии 18
Предупреждение: include(): не удалось открыть '/baaw.se/public_html/phpBB3/includes/functions_posting.php' для включения (include_path='.:/ Usr/local/share/pear') в / www / webvol11 / jc / 87yqo3f2oz6gicm / baaw.se / public_html / phpBB3 / formhandled.php в строке 18
Неустранимая ошибка: вызов неопределенной функции utf8_normalize_nfc() в /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php в строке 45
Кажется, есть некоторые проблемы...
РЕДАКТИРОВАТЬ 4: Исправлены ошибки, теперь я получил новый. Общая ошибка SQL ОШИБКА [ mysqli ]
Столбец topic_first_poster_colour не может быть пустым [1048]
Произошла ошибка SQL при получении этой страницы. Пожалуйста, свяжитесь с администратором, если проблема не устранена.
1 ответ
$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 Да, 1-й параметр - это строка. Msgstr "Можно публиковать, редактировать, отвечать или удалять." - взяты из вики