I wonder why this code won't submit a new topic to the forums.
<?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]);
?>
Right now, it only shows a white page instead of the html code I have above and there is no new post on the forums. Figured it have to be something in the php-code, but can't seem to find the fault. I appreciate all answers I can get!
EDIT: The problem is in the submit_post function. Perhaps bad-linking or missing variable?
EDIT 2: Edited code. Only problem right now is that the text won't be posted on the forums!
EDIT 3: This is the error log: Warning: include(../PHPBB3/common.php): failed to open stream: No such file or directory in /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php on line 15
Warning: include(): Failed opening '../PHPBB3/common.php' for inclusion (include_path='.:/usr/local/share/pear') in /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php on line 15
Warning: include(../PHPBB3/includes/functions_posting.php): failed to open stream: No such file or directory in /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php on line 16
Warning: include(): Failed opening '../PHPBB3/includes/functions_posting.php' for inclusion (include_path='.:/usr/local/share/pear') in /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php on line 16
Warning: include(../PHPBB3/includes/message_parser.php): failed to open stream: No such file or directory in /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php on line 17
Warning: include(): Failed opening '../PHPBB3/includes/message_parser.php' for inclusion (include_path='.:/usr/local/share/pear') in /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php on line 17
Warning: include(/baaw.se/public_html/phpBB3/includes/functions_posting.php): failed to open stream: No such file or directory in /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php on line 18
Warning: include(): Failed opening '/baaw.se/public_html/phpBB3/includes/functions_posting.php' for inclusion (include_path='.:/usr/local/share/pear') in /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php on line 18
Fatal error: Call to undefined function utf8_normalize_nfc() in /www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php on line 45
Seems to be some problems...
EDIT 4: Fixed the errors, now I got a new one. General Error SQL ERROR [ mysqli ]
Column 'topic_first_poster_colour' cannot be null [1048]
An sql error occurred while fetching this page. Please contact an administrator if this problem persists.
$message = = generate_text_for_storage($meddelande, $new_uid, $new_bitfield, $bbcode_options, false, false, false);
Should be
$message = generate_text_for_storage($meddelande, $new_uid, $new_bitfield, $bbcode_options, false, false, false);
You have an extra = sign in there I also think this:
$mode = post;
Should be
$mode = 'post';
I think $mode expects a string (from memory, been a while since I played with submit_post) edit Yes the 1st parameter is a string. "Can be post, edit, reply, or delete." - taken form the wiki