首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过PHP发送到SMF论坛

通过PHP发送到SMF论坛
EN

Stack Overflow用户
提问于 2016-01-07 03:57:07
回答 1查看 974关注 0票数 0

我正在建立一个CMS,支持一个网站,其中也包含一个SMF论坛(2.0.11)。CMS中的一个模块涉及一个跟踪出席情况的“报告”。该数据被查询到smf之外的表中,但在同一个数据库中。除了它现在所做的,我还想在包含格式化内容的SMF论坛上的一个特定的董事会中发布一个帖子。由于所有的帖子都包含在数据库中,所以这当然是可能的,但它似乎不仅仅是一个表中的一行。

要把它放在最简单的代码中,下面是我在页面上单击Submit时想要发生的事情。

代码语言:javascript
复制
$title = "2015-03-04 - Attendance";
$author = "KGrimes";
$body = "Attendance was good.";

$SQL = "INSERT INTO smf_some_table (title, author, body) VALUES ($title, $author, $body)";
$result = mysqli_query($db_handle, $SQL);

在挖掘了smf表以及post()和post2()函数之后,在创建post时似乎涉及了多个表。以前有人概述过这个吗?

我已经研究过诸如自定义表单模型之类的解决方案,但是这些表单和模板并不是我想要的。我已经有数据输入和张贴到变量,我只需要正确的表(S)插入它,以便它出现在论坛上。

提前感谢您的帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-09 02:47:15

来源:http://www.simplemachines.org/community/index.php?topic=542521.0

要在其中创建post的代码:

代码语言:javascript
复制
                    //Define variables
                    //msgOptions
                    $smf_subject = "Test Title";

                    //Handle & escape
                    $smf_subject = htmlspecialchars($smf_subject);
                    $smf_subject = quote_smart($smf_subject, $db_handle);

                    $smf_body = "This is a test.";

                    //Handle & escape
                    $smf_body = htmlspecialchars($smf_body);
                    $smf_body = quote_smart($smf_body, $db_handle);

                    //topicOptions
                    $smf_board = 54; //Any board id, found in URL

                    //posterOptions
                    $smf_id = 6; //any id, this is found as ID in memberlist

                    //SMF Post function
                    require_once('../../forums/SSI.php');
                    require_once('../../forums/Sources/Subs-Post.php');

                    //createPost($msgOptions, $topicOptions, $posterOptions);
                    // Create a post, either as new topic (id_topic = 0) or in an existing one.
                    // The input parameters of this function assume:
                    // - Strings have been escaped.
                    // - Integers have been cast to integer.
                    // - Mandatory parameters are set.

                    // Collect all parameters for the creation or modification of a post.
                    $msgOptions = array(
                        'subject' => $smf_subject,
                        'body' => $smf_body,
                        //'smileys_enabled' => !isset($_POST['ns']),
                    );
                    $topicOptions = array(
                        //'id' => empty($topic) ? 0 : $topic,
                        'board' => $smf_board,
                        'mark_as_read' => true,
                    );
                    $posterOptions = array(
                        'id' => $smf_id,
                    );

                    //Execute SMF post
                    createPost($msgOptions, $topicOptions, $posterOptions);

这将创建最简单的文章,标题和正文由您定义,以及位置和作者是谁。在createPost的SMF函数数据库中可以找到更多的参数。SSI和Subs-Post.php包含必须是原始的,复制它们并不有效。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34647112

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档