<?
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'common.php');
include($phpbb_root_path . 'includes/functions_posting.php' );
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
function phpbb_submit_post($author, $subj, $text, $date, $data) {
global $user, $auth, $db;
$auth->login($author, 'murajo3000');
if (!$user->data['is_registered']) die("Cannot login 2.");
// variables to hold the parameters for submit_post
$poll = $uid = $bitfield = $options = '';
$subj = utf8_normalize_nfc($subj);
$text = utf8_normalize_nfc($text);
generate_text_for_storage($subj, $uid, $bitfield, $options, false, false, false);
generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);
echo "\n<br>inphpbb: date is '$date'<br>";
$data = array_merge($data,array(
'icon_id' => false, // The Icon ID in which the post will be displayed with on the viewforum, set to false for icon_id. (int)
'enable_bbcode' => true,
'enable_smilies' => true,
'enable_urls' => true,
'enable_sig' => true,
'topic_title' => $subj,
'message' => $text,
'message_md5' => md5($text),
'bbcode_bitfield' => $bitfield,
'bbcode_uid' => $uid,
'post_edit_locked' => 0,
'notify_set' => false,
'notify' => false,
'post_time' => $date, // Timestamp, 0 for NOW
'forum_name' => '', // For identifying the name of the forum in a notification email. (string)
'enable_indexing' => true, // Allow indexing the post? (bool)
'force_approved_state' => true, // Allow the post to be submitted without going into unapproved queue
));
submit_post($data['topic_id'] ? 'reply' : 'post', $subj, '', POST_NORMAL, $poll, $data);
//если текущая статья старше 'user_regdate' - апдейтим юзеру regdate
//если user_lastpost_time < текущей статьи - апдейтим и user_lastpost_time
$user->data['user_regdate'] = min( $user->data['user_regdate'], ($date-1*60) );
$user->data['user_lastpost_time'] = max( $user->data['user_lastpost_time'], $date );
$user->data['user_lastvisit'] = max( $user->data['user_lastvisit'], ($date+rand(1*60,25*60)) );
$user->data['user_lastmark'] = $user->data['user_regdate'];
$sql = "UPDATE " . USERS_TABLE . " SET user_posts=user_posts+1,
user_regdate = '". (int) $user->data['user_regdate'] ."' ,
user_lastpost_time = '". (int) $user->data['user_lastpost_time'] ."' ,
user_lastvisit = '". (int) $user->data['user_lastvisit'] ."' ,
user_lastmark = '". (int) $user->data['user_lastmark'] ."'
WHERE user_id = " . $user->data['user_id'] ." LIMIT 1 ";
echo "<br>$sql<br>";
$db->sql_query($sql);
// При постинге phpbb ставит текущее время. Поменяем его на $date прямо в базе
$sql = "UPDATE " . POSTS_TABLE . " SET post_time = '$date' WHERE post_id = '".$data['post_id']."' LIMIT 1";
echo "<br>$sql<br>";
$db->sql_query($sql);
$sql = "UPDATE " . TOPICS_TABLE . "
SET
topic_time = LEAST(topic_time, $date) ,
topic_last_post_time = '". $date ."',
topic_last_view_time = '". $date ."'
WHERE topic_id = '".$data['topic_id']."' LIMIT 1";
echo "<br>$sql<br>";
$db->sql_query($sql);
$sql = "UPDATE " . FORUMS_TABLE . " SET forum_last_post_time = '$date' WHERE forum_id = '".$data['forum_id']."' LIMIT 1";
echo "<br>$sql<br>";
$db->sql_query($sql);
return array(
'topic_id' => $data['topic_id'],
'post_id' => $data['post_id'],
);
}