z konieczności napisałem klasę/metodę tworzącą nowy post na forum phpBB. Może komuś się przyda:
<?php class Helper_Phpbb { /** * Creates new topic for phpBB forum * * @access public * @static * * @param string $title Topic title * @param string $content Topic body content * @param int $forumId Destination forum * @param int $posterId Post author id * * @return int Created topic's id. 0 if there were any problems... */ $forumId = (int)$forumId; $poserId = (int)$posterId; // creating new topic $q = 'INSERT INTO '.TOPICS_TABLE.' SET forum_id='.$forumId.', topic_title="'.$title.'", topic_poster='.$posterId.', topic_time='.time().', topic_views=1, topic_replies=0, topic_status=0, topic_vote=0, topic_type=0, to ic_first_post_id=0, topic_last_post_id=0, topic_moved_id=0, topic_last_post_uid='.$posterId; return 0; } // creating new post $q = 'INSERT INTO '.POSTS_TABLE.' SET topic_id='.$topicId.', forum_id='.$forumId.', poster_id='.$posterId.', post_time='.time().', poster_ip="'.encode_ip($_SERVER['REMOTE_ADDR']).'", post_username=NULL, enable_bbcode=1, enable_html=0, enable_smilies=1, ena
ble_s g=0, post_edit_time=NULL, post_edit_count=0, raport=0, notice=0'; return 0; } // creating post content $q = 'INSERT INTO '.POSTS_TEXT_TABLE.' SET post_id='.$postId.', bbcode_uid="'.make_bbcode_uid2().'", post_subject="'.$title.'", post_text="'.$content.'", mods_notice=NULL'; return 0; } // updating posts table $q = 'UPDATE '.TOPICS_TABLE.' SET topic_first_post_id='.$postId.', topic_last_post_id='.$postId.' WHERE topic_id='.$topicId.' LIMIT 1'; return 0; } // updating forum statistics $q = 'UPDATE '.FORUMS_TABLE.' SET forum_posts=forum_posts+1, forum_topics=forum_topics+1, forum_last_post_id='.$postId.' WHERE forum_id='.$forumId.' LIMIT 1'; return 0; } // updating poster statistics $q = 'UPDATE '.USERS_TABLE.' SET user_posts=user_posts+1 WHERE user_id='.$posterId.' LIMIT 1'; return 0; } return $topicId; } } ?>
pion
PS: Jeśli odpowiedniejszym działem będzie "Algorytmy, klasy, funkcje" proszę o przeniesienie tematu.