add posts from php

Started by vegihat, June 22, 2015, 10:55:54 AM

Previous topic - Next topic

vegihat

I want to add posts to board from php. Which tables of database do i need to change?
also this function smf_db_insert do i need?

Kindred

DO NOT... I REPEAT -- DO NOT -- attempt to add posts using direct database inserts.
period.
end of sentence.
There are several things that happen when a post is made, and putting posts directly in the database ignores all of those other actions.

Perhaps, if you explain, what EXACTLY you are trying to accomplish, we could assist...

(also, moving to coding, since this is not actually a support question)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

margarett

As stated, do not add posts to the database.

You should include Subs-Post.php to your php code and use the createPost function
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

vegihat

I just want to add posts automaticaly and not manually (save time).

function  createPost(&$msgOptions, &$topicOptions, &$posterOptions) has 3 parameters. What to assign to them if i have
topic-name: example
topic_body: some test here
author: admin
time: 22/6/15

???

Kindred

why don't you look in the function and see where each of them is put?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

vegihat

just wanted to save time, sry for the continius value taking..

margarett

If you look at Post.php you can easily see the required arguments. Example:
// Collect all parameters for the creation or modification of a post.
$msgOptions = array(
'id' => empty($_REQUEST['msg']) ? 0 : (int) $_REQUEST['msg'],
'subject' => $_POST['subject'],
'body' => $_POST['message'],
'icon' => preg_replace('~[\./\\\\*:"\'<>]~', '', $_POST['icon']),
'smileys_enabled' => !isset($_POST['ns']),
'attachments' => empty($attachIDs) ? array() : $attachIDs,
'approved' => $becomesApproved,
);
$topicOptions = array(
'id' => empty($topic) ? 0 : $topic,
'board' => $board,
'poll' => isset($_REQUEST['poll']) ? $id_poll : null,
'lock_mode' => isset($_POST['lock']) ? (int) $_POST['lock'] : null,
'sticky_mode' => isset($_POST['sticky']) && !empty($modSettings['enableStickyTopics']) ? (int) $_POST['sticky'] : null,
'mark_as_read' => true,
'is_approved' => !$modSettings['postmod_active'] || empty($topic) || !empty($board_info['cur_topic_approved']),
);
$posterOptions = array(
'id' => $user_info['id'],
'name' => $_POST['guestname'],
'email' => $_POST['email'],
'update_post_count' => !$user_info['is_guest'] && !isset($_REQUEST['msg']) && $board_info['posts_count'],
);

You don't need to fill all those details. But some are absolutely necessary.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

vegihat

thanks for your support! you saved my day!

Advertisement: