Hej Udviklere, længe siden?
Sidder med en irritation af en (API?) kode til phpBB 3.1.4
Den skulle gerne auto generere poster i ny og næ på mit forum.
Selve indholdet på mit forum er sagen ligegyldig, jeg ville dog gerne have den kode jeg har fået til at virke:
- <?PHP
-
- define('IN_PHPBB', true);
- $phpbb_root_path = './forum/';
- $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);
-
- 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
- */
- $username = "Brugernavnet er rigtigt, men, fjernet i exemplet her";
- $password = "Kodeordet er rigtigt, men, fjernet fra udvikleren";
-
- $title = unhtmlentities( "titlen i posten" );
- $text = unhtmlentities( "Indhold i posten" );
-
- $forumid = 4; //det forumid den skal postes i
- $topicid = $_POST["topicid"];
-
- $user->session_begin();
- $auth->login($username, $password, false);
- $auth->acl($user->data);
- $user->setup();
-
- $title = utf8_normalize_nfc($title);
- $text = utf8_normalize_nfc($text);
-
- $poll = $uid = $bitfield = $options = '';
-
- generate_text_for_storage($title, $uid, $bitfield, $options, false, false, false);
- generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);
-
- $data = array(
- 'forum_id' => $forumid,
- 'topic_id' => $topicid,
- 'icon_id' => false,
- 'post_approved' => true,
-
- 'enable_bbcode' => true,
- 'enable_smilies' => true,
- 'enable_urls' => true,
- 'enable_sig' => true,
-
- 'message' => $text,
- 'message_md5' => md5($text),
-
- 'bbcode_bitfield' => $bitfield,
- 'bbcode_uid' => $uid,
-
- 'post_edit_locked' => 0,
- 'topic_title' => $title,
- 'notify_set' => false,
- 'notify' => false,
- 'post_time' => 0,
- 'forum_name' => '',
- 'enable_indexing' => true,
- );
-
- if ($topicid == NULL)
- echo submit_post('post', $title, '', POST_NORMAL, $poll, $data);
- else
- echo submit_post('reply', $title, '', POST_NORMAL, $poll, $data);
-
- $user->session_kill();
-
- ?>