簡體   English   中英

無法通過代碼將主題發布到phpbb-forum

[英]Can't post topic to phpbb-forum by code

我不知道為什么這段代碼不會向論壇提交新主題。

<?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():無法在/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/中打開'../PHPBB3/common.php'以使其包含(include_path ='。:/ usr / local / share / pear')第15行的public_html / phpBB3 / formhandled.php

警告:include(../ PHPBB3 / includes / functions_posting.php):無法打開流:第16行的/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php中沒有此類文件或目錄

警告:include():無法在/ www / webvol11 / jc / 87yqo3f2oz6gicm / baaw中打開'../PHPBB3/includes/functions_posting.php'以將其包含(include_path ='。:/ usr / local / share / pear')。第16行的se / public_html / phpBB3 / formhandled.php

警告:include(../ PHPBB3 / includes / message_parser.php):無法打開流:/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php中沒有此類文件或目錄

警告:include():無法在/ www / webvol11 / jc / 87yqo3f2oz6gicm / baaw中打開'../PHPBB3/includes/message_parser.php'以將其包含(include_path ='。:/ usr / local / share / pear')。第17行的se / public_html / phpBB3 / formhandled.php

警告:include(/baaw.se/public_html/phpBB3/includes/functions_posting.php):無法打開流:/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled中沒有此類文件或目錄。第18行的php

警告:include():無法在/ www / webvol11 / jc /中打開“ /baaw.se/public_html/phpBB3/includes/functions_posting.php”以將其包含在內(include_path ='。:/ usr / local / share / pear')第18行的87yqo3f2oz6gicm / baaw.se / public_html / phpBB3 / formhandled.php

致命錯誤:在第45行上的/www/webvol11/jc/87yqo3f2oz6gicm/baaw.se/public_html/phpBB3/formhandled.php中調用未定義函數utf8_normalize_nfc()

似乎有些問題...

編輯4:修復了錯誤,現在我得到了一個新錯誤。 一般錯誤SQL錯誤[mysqli]

列“ topic_first_poster_colour”不能為空[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需要一個字符串(從內存開始,因為我玩了commit_post已經有一段時間了) edit是,第一個參數是一個字符串。 “可以張貼,編輯,回復或刪除。” -來自Wiki

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM