{"id":797,"date":"2010-08-18T18:31:23","date_gmt":"2010-08-18T16:31:23","guid":{"rendered":"http:\/\/www.andboson.com\/?p=797"},"modified":"2010-08-18T19:22:35","modified_gmt":"2010-08-18T17:22:35","slug":"simple-machines-forum-%d0%ba%d1%80%d0%be%d1%81%d1%81-%d0%bf%d0%be%d1%81%d1%82-%d0%b8-%d0%b0%d0%b2%d1%82%d0%be%d1%80%d0%b8%d0%b7%d0%b0%d1%86%d0%b8%d1%8f","status":"publish","type":"post","link":"https:\/\/www.andboson.com\/?p=797","title":{"rendered":"Simple Machines Forum \u043a\u0440\u043e\u0441\u0441-\u043f\u043e\u0441\u0442 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f."},"content":{"rendered":"<p>\u0417\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043c\u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u0430\u0439\u0442 <a href=\"http:\/\/maps.ck.ua\" target=\"_blank\">http:\/\/maps.ck.ua<\/a> \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432. \u0414\u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e, \u0430 <span style=\"text-decoration: line-through;\">\u0437\u043e\u043b\u043e\u0442\u0443\u044e<\/span> \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u0443\u044e. \u0422.\u0435. \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0441\u0442\u0438\u0442\u044c \u0438 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438 \u0441 \u0441\u0430\u0439\u0442\u0430 \u0438 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u043c \u0438 \u0442\u0435\u043a\u0441\u0442\u0430 &#8212; \u0441 \u0444\u043e\u0440\u0443\u043c\u0430.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u043e\u0440\u0443\u043c\u0430 \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u043b\u044e\u0431\u0438\u043c\u044b\u0439 SMF, 2 \u0432\u0435\u0440\u0441\u0438\u0438. \u041f\u043e\u0447\u0435\u043c\u0443 \u043b\u044e\u0431\u0438\u043c\u044b\u0439 &#8212; \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0438\u043c\u043f\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0434\u0438\u0437\u0430\u0439\u043d, \u043e\u0447\u0435\u043d\u044c, \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0430\u0434\u043c\u0438\u043d\u043a\u0430 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e API \u0434\u043b\u044f SMF 2.\u0445 \u0435\u0449\u0435 \u043d\u0435\u0442\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0443\u0436\u0438\u0435 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 \u044d\u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435, \u043f\u043b\u044e\u0441 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0438 \u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0444\u043e\u0440\u0443\u043c\u0430.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u043d\u0438\u0436\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0445\u0430\u0440\u0434\u043a\u043e\u0434\u0438\u043d\u0433\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u0430\u0441 \u0432\u043e\u0440\u043e\u0442\u0438\u0442 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430, \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nfunction login($_user,$_password ) {\r\nrequire_once (&quot;.....\/forum\/SSI.php&quot;);\r\nrequire_once(&quot;.....\/forum\/Sources\/Subs-Auth.php&quot;);\r\n $db_prefix=&quot;\u0418\u041c\u042f_\u0411\u0414.\u041f\u0420\u0415\u0424\u0418\u041a\u0421_\u0422\u0410\u0411\u041b\u0418\u0426;\r\n\r\n $request = mysql_query(&quot;\r\n SELECT ID_MEMBER\r\n FROM {$db_prefix}members\r\n WHERE member_name = '$_user'\r\n LIMIT 1&quot;);\r\n\r\n if ($request == false &amp;&amp; mysql_num_rows($request) &lt; 1)\r\n {\r\n mysql_free_result($request);\r\n setLoginCookie(-3600, 0);\r\n return &quot;no user name&quot;;\r\n }\r\n\r\n $get_password_hash = mysql_query (&quot;\r\n SELECT passwd, ID_MEMBER, ID_GROUP, lngfile, is_activated, email_address, additional_groups, member_name, password_salt\r\n FROM {$db_prefix}members\r\n WHERE member_name = '$_user'\r\n LIMIT 1&quot;);\r\n\r\n $user_settings = mysql_fetch_assoc($get_password_hash);\r\n $hash_input_password = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars(stripslashes($_password)));\r\n\r\n if ($user_settings['passwd']==$hash_input_password)\r\n {\r\n $cookielength = 3153600;\r\n setLoginCookie( $cookielength, $user_settings['ID_MEMBER'], sha1($user_settings['passwd'] . $user_settings['password_salt']));\r\n\r\n } else{\r\n setLoginCookie(-3600, 0);\r\n return &quot;no user&quot;;\r\n }\r\n\r\n return &quot;ok&quot;;\r\n}\r\n\r\n<\/pre>\n<p>\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f, \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0438\u0437 \u043a\u0443\u043a\u0438.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nfunction smf_authenticateUser($mode=&quot;all&quot;){\r\nrequire_once (&quot;.....\/forum\/SSI.php&quot;);\r\nrequire_once(&quot;.....\/forum\/\/Sources\/Subs-Auth.php&quot;);\r\n global $smf_connection, $smf_settings, $smf_user_info;\r\n $ID_MEMBER = 0;\r\n if (isset($_COOKIE[$cookiename]))\r\n {\r\n $_COOKIE[$cookiename] = stripslashes($_COOKIE[$cookiename]);\r\n \/\/ Fix a security hole in PHP 4.3.9 and below...\r\n if (preg_match('~^a:[34]:\\{i:0;(i:\\d{1,6}|s:[1-8]:&quot;\\d{1,8}&quot;);i:1;s:(0|40):&quot;([a-fA-F0-9]{40})?&quot;;i:2;[id]:\\d{1,14};(i:3;i:\\d;)?\\}$~',$_COOKIE[$cookiename]) == 1)\r\n {\r\n list ($ID_MEMBER, $password) = @unserialize($_COOKIE[$cookiename]);\r\n $ID_MEMBER = !empty($ID_MEMBER) &amp;&amp; strlen($password) &gt; 0 ? (int) $ID_MEMBER : 0;\r\n } else return &quot;no cookie&quot;;\r\n } else return &quot;no cookie2&quot;;\r\n \/\/echo $ID_MEMBER;\r\n \/\/ Don't even bother if they have no authentication data.\r\n if ($ID_MEMBER != 0){\r\n $request = mysql_query(&quot;\r\n SELECT *\r\n FROM {$db_prefix}members\r\n WHERE ID_MEMBER = $ID_MEMBER\r\n LIMIT 1&quot;);\r\n \/\/ Did we find 'im?\u00a0 If not, junk it.\r\n if (mysql_num_rows($request) != 0)\r\n {\r\n \/\/ The base settings array.\r\n $smf_user_info = mysql_fetch_assoc($request);\r\n if (strlen($password) == 40)\r\n $check = sha1($smf_user_info['passwd'] . $smf_user_info['password_salt']) == $password;\r\n else\r\n $check = false;\r\n\r\n \/\/ Wrong password or not activated - either way, you're going nowhere.\r\n $ID_MEMBER = $check &amp;&amp; ($smf_user_info['is_activated'] == 1 || $smf_user_info['is_activated'] == 11) ? $smf_user_info['id_member'] : 0;\r\n } else {\r\n $ID_MEMBER = 0;\r\n mysql_free_result($request);\r\n return &quot;no user in mysql&quot;;\r\n }\r\n } else {\r\n return &quot;no cookie&quot;;\r\n }\r\n if(!empty($ID_MEMBER)){\r\n $cookielength = 3153600;\r\n setLoginCookie( $cookielength, $smf_user_info['id_member'], sha1($smf_user_info['passwd'] . $smf_user_info['password_salt']));\r\n } else return &quot;no member&quot;;\r\n\r\n \/\/ A few things to make life easier...\r\n $smf_user_info['id'] = &amp;$smf_user_info['id_member'];\r\n $smf_user_info['username'] = &amp;$smf_user_info['member_name'];\r\n $smf_user_info['name'] = &amp;$smf_user_info['real_name'];\r\n $smf_user_info['email'] = &amp;$smf_user_info['email_address'];\r\n $smf_user_info['messages'] = &amp;$smf_user_info['instant_messages'];\r\n $smf_user_info['unread_messages'] = &amp;$smf_user_info['unread_messages'];\r\n $smf_user_info['is_guest'] = $ID_MEMBER == 0;\r\n $smf_user_info['is_admin'] = in_array(1, $smf_user_info['id_group']);\r\n $smf_user_info['status']=&quot;ok&quot;;\r\n if (empty($smf_user_info['time_format']))\r\n $smf_user_info['time_format'] = $smf_settings['time_format'];\r\n\r\n if($mode==&quot;all&quot;) return $smf_user_info;\r\n if($mode==&quot;check&quot;) return &quot;ok&quot;;\r\n if($mode==&quot;json&quot;) return json_encode($smf_user_info);\r\n if($mode==&quot;id&quot;)\u00a0 return\u00a0 $smf_user_info['id'];\r\n}\r\n<\/pre>\n<p>\u041f\u043e\u0441\u0442\u0438\u043d\u0433 \u0432 \u0444\u043e\u0440\u0443\u043c. \u0415\u0441\u043b\u0438 topic \u043f\u0443\u0441\u0442\u043e\u0439 \u0438\u043b\u0438 \u0440\u0430\u0432\u0435\u043d 0, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0442\u0435\u043c\u0430.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">function post_to_smf($board,$topic,$subject,$txt,$oid,$otype,$maptype) {\r\n $ID_MEMBER = smf_authenticateUser(&quot;id&quot;);\r\n if($ID_MEMBER==0 or !is_numeric($ID_MEMBER)) return &quot;wrong poster&quot;;\r\n require_once(&quot;........\/forum\/SSI.php&quot;);\r\n require_once(&quot;........\/forum\/Sources\/Subs-Post.php&quot;);\r\n global $smcFunc;\r\n $TOPIC=$topic;\r\n $ID_BOARD=$board;\r\n\r\n $excerpt = stripcslashes(trim(strip_tags($txt)));\r\n $words = preg_split(&quot;\/(?&lt;=(\\.|!|\\?)+)\\s\/&quot;, $excerpt, -1, PREG_SPLIT_NO_EMPTY);\r\n foreach ( $words as $word )\r\n {\r\n $new_text = $text . substr($excerpt, 0, strpos($excerpt, $word) + strlen($word));\r\n $excerpt = substr($excerpt, strpos($excerpt, $word) + strlen($word), strlen($excerpt));\r\n\r\n if ( ( strlen($text) != 0 ) &amp;&amp; ( strlen($new_text) &gt; $max_length ) )\r\n {\r\n break;\r\n }\r\n\r\n $text = $new_text;\r\n }\r\n $post_text = $text;\r\n\r\n $msgOptions = array(\r\n 'id' =&gt;\u00a0 0,\r\n 'subject' =&gt; stripcslashes($subject),\r\n 'body' =&gt; $post_text,\r\n 'smileys_enabled' =&gt; true,\r\n );\r\n\r\n $topicOptions = array(\r\n 'id' =&gt; $TOPIC,\r\n 'board' =&gt; $ID_BOARD,\r\n 'mark_as_read' =&gt; true,\r\n );\r\n\r\n $posterOptions = array(\r\n 'id' =&gt; $ID_MEMBER,\r\n );\r\n\r\n $out=Array();\r\n\r\n $top=createPost2($msgOptions, $topicOptions, $posterOptions);\r\n if($top) {\r\n $out[&quot;status&quot;]=&quot;ok&quot;;\r\n $out[&quot;topicid&quot;]=$top;\r\n\r\n return json_encode($out);\r\n } else {\r\n $out[&quot;status&quot;]=&quot;error create post&quot;;\r\n return json_encode($out);\r\n }\r\n}\r\n\r\nfunction createPost2(&amp;$msgOptions, &amp;$topicOptions, &amp;$posterOptions)\r\n{\r\n global $user_info, $txt, $modSettings, $smcFunc, $context;\r\n\r\n \/\/ Set optional parameters to the default value.\r\n $msgOptions['icon'] = empty($msgOptions['icon']) ? 'xx' : $msgOptions['icon'];\r\n $msgOptions['smileys_enabled'] = !empty($msgOptions['smileys_enabled']);\r\n $msgOptions['attachments'] = empty($msgOptions['attachments']) ? array() : $msgOptions['attachments'];\r\n $msgOptions['approved'] = isset($msgOptions['approved']) ? (int) $msgOptions['approved'] : 1;\r\n $topicOptions['id'] = empty($topicOptions['id']) ? 0 : (int) $topicOptions['id'];\r\n $topicOptions['poll'] = isset($topicOptions['poll']) ? (int) $topicOptions['poll'] : null;\r\n $topicOptions['lock_mode'] = isset($topicOptions['lock_mode']) ? $topicOptions['lock_mode'] : null;\r\n $topicOptions['sticky_mode'] = isset($topicOptions['sticky_mode']) ? $topicOptions['sticky_mode'] : null;\r\n $posterOptions['id'] = empty($posterOptions['id']) ? 0 : (int) $posterOptions['id'];\r\n $posterOptions['ip'] = empty($posterOptions['ip']) ? $user_info['ip'] : $posterOptions['ip'];\r\n\r\n $smcFunc['db_query']('', 'SET NAMES UTF8',null);\r\n \/\/ We need to know if the topic is approved. If we're told that's great - if not find out.\r\n if (!$modSettings['postmod_active'])\r\n $topicOptions['is_approved'] = true;\r\n elseif (!empty($topicOptions['id']) &amp;&amp; !isset($topicOptions['is_approved']))\r\n {\r\n $request = $smcFunc['db_query']('', '\r\n SELECT approved\r\n FROM {db_prefix}topics\r\n WHERE id_topic = {int:id_topic}\r\n LIMIT 1',\r\n array(\r\n 'id_topic' =&gt; $topicOptions['id'],\r\n )\r\n );\r\n list ($topicOptions['is_approved']) = $smcFunc['db_fetch_row']($request);\r\n $smcFunc['db_free_result']($request);\r\n }\r\n\r\n \/\/ If nothing was filled in as name\/e-mail address, try the member table.\r\n if (!isset($posterOptions['name']) || $posterOptions['name'] == '' || (empty($posterOptions['email']) &amp;&amp; !empty($posterOptions['id'])))\r\n {\r\n if (empty($posterOptions['id']))\r\n {\r\n $posterOptions['id'] = 0;\r\n $posterOptions['name'] = $txt['guest_title'];\r\n $posterOptions['email'] = '';\r\n }\r\n elseif ($posterOptions['id'] != $user_info['id'])\r\n {\r\n $request = $smcFunc['db_query']('', '\r\n SELECT member_name, email_address\r\n FROM {db_prefix}members\r\n WHERE id_member = {int:id_member}\r\n LIMIT 1',\r\n array(\r\n 'id_member' =&gt; $posterOptions['id'],\r\n )\r\n );\r\n \/\/ Couldn't find the current poster?\r\n if ($smcFunc['db_num_rows']($request) == 0)\r\n {\r\n trigger_error('createPost(): Invalid member id ' . $posterOptions['id'], E_USER_NOTICE);\r\n $posterOptions['id'] = 0;\r\n $posterOptions['name'] = $txt['guest_title'];\r\n $posterOptions['email'] = '';\r\n }\r\n else\r\n list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);\r\n $smcFunc['db_free_result']($request);\r\n }\r\n else\r\n {\r\n $posterOptions['name'] = $user_info['name'];\r\n $posterOptions['email'] = $user_info['email'];\r\n }\r\n }\r\n\r\n \/\/ It's do or die time: forget any user aborts!\r\n $previous_ignore_user_abort = ignore_user_abort(true);\r\n\r\n $new_topic = empty($topicOptions['id']);\r\n\r\n \/\/ Insert the post.\r\n $smcFunc['db_insert']('',\r\n '{db_prefix}messages',\r\n array(\r\n 'id_board' =&gt; 'int', 'id_topic' =&gt; 'int', 'id_member' =&gt; 'int', 'subject' =&gt; 'string-255', 'body' =&gt; (!empty($modSettings['max_messageLength']) &amp;&amp; $modSettings['max_messageLength'] &gt; 65534 ? 'string-' . $modSettings['max_messageLength'] : 'string-65534'),\r\n 'poster_name' =&gt; 'string-255', 'poster_email' =&gt; 'string-255', 'poster_time' =&gt; 'int', 'poster_ip' =&gt; 'string-255',\r\n 'smileys_enabled' =&gt; 'int', 'modified_name' =&gt; 'string', 'icon' =&gt; 'string-16', 'approved' =&gt; 'int',\r\n ),\r\n array(\r\n $topicOptions['board'], $topicOptions['id'], $posterOptions['id'], $msgOptions['subject'], $msgOptions['body'],\r\n $posterOptions['name'], $posterOptions['email'], time(), $posterOptions['ip'],\r\n $msgOptions['smileys_enabled'] ? 1 : 0, '', $msgOptions['icon'], $msgOptions['approved'],\r\n ),\r\n array('id_msg')\r\n );\r\n $msgOptions['id'] = $smcFunc['db_insert_id']('{db_prefix}messages', 'id_msg');\r\n\r\n \/\/ Something went wrong creating the message...\r\n if (empty($msgOptions['id']))\r\n return false;\r\n\r\n \/\/ Fix the attachments.\r\n if (!empty($msgOptions['attachments']))\r\n $smcFunc['db_query']('', '\r\n UPDATE {db_prefix}attachments\r\n SET id_msg = {int:id_msg}\r\n WHERE id_attach IN ({array_int:attachment_list})',\r\n array(\r\n 'attachment_list' =&gt; $msgOptions['attachments'],\r\n 'id_msg' =&gt; $msgOptions['id'],\r\n )\r\n );\r\n\r\n \/\/ Insert a new topic (if the topicID was left empty.\r\n if ($new_topic)\r\n {\r\n $smcFunc['db_insert']('',\r\n '{db_prefix}topics',\r\n array(\r\n 'id_board' =&gt; 'int', 'id_member_started' =&gt; 'int', 'id_member_updated' =&gt; 'int', 'id_first_msg' =&gt; 'int',\r\n 'id_last_msg' =&gt; 'int', 'locked' =&gt; 'int', 'is_sticky' =&gt; 'int', 'num_views' =&gt; 'int',\r\n 'id_poll' =&gt; 'int', 'unapproved_posts' =&gt; 'int', 'approved' =&gt; 'int',\r\n ),\r\n array(\r\n $topicOptions['board'], $posterOptions['id'], $posterOptions['id'], $msgOptions['id'],\r\n $msgOptions['id'], $topicOptions['lock_mode'] === null ? 0 : $topicOptions['lock_mode'], $topicOptions['sticky_mode'] === null ? 0 : $topicOptions['sticky_mode'], 0,\r\n $topicOptions['poll'] === null ? 0 : $topicOptions['poll'], $msgOptions['approved'] ? 0 : 1, $msgOptions['approved'],\r\n ),\r\n array('id_topic')\r\n );\r\n $topicOptions['id'] = $smcFunc['db_insert_id']('{db_prefix}topics', 'id_topic');\r\n\r\n \/\/ The topic couldn't be created for some reason.\r\n if (empty($topicOptions['id']))\r\n {\r\n \/\/ We should delete the post that did work, though...\r\n $smcFunc['db_query']('', '\r\n DELETE FROM {db_prefix}messages\r\n WHERE id_msg = {int:id_msg}',\r\n array(\r\n 'id_msg' =&gt; $msgOptions['id'],\r\n )\r\n );\r\n\r\n return false;\r\n }\r\n\r\n \/\/ Fix the message with the topic.\r\n $smcFunc['db_query']('', '\r\n UPDATE {db_prefix}messages\r\n SET id_topic = {int:id_topic}\r\n WHERE id_msg = {int:id_msg}',\r\n array(\r\n 'id_topic' =&gt; $topicOptions['id'],\r\n 'id_msg' =&gt; $msgOptions['id'],\r\n )\r\n );\r\n\r\n \/\/ There's been a new topic AND a new post today.\r\n trackStats(array('topics' =&gt; '+', 'posts' =&gt; '+'));\r\n\r\n updateStats('topic', true);\r\n updateStats('subject', $topicOptions['id'], $msgOptions['subject']);\r\n \/\/What if we want to export new topics out to a CMS?\r\n if (isset($modSettings['integrate_create_topic']) &amp;&amp; is_callable($modSettings['integrate_create_topic']))\r\n call_user_func(strpos($modSettings['integrate_create_topic'], '::') === false ? $modSettings['integrate_create_topic'] : explode('::', $modSettings['integrate_create_topic']), $msgOptions, $topicOptions, $posterOptions);\r\n }\r\n \/\/ The topic already exists, it only needs a little updating.\r\n else\r\n {\r\n $countChange = $msgOptions['approved'] ? 'num_replies = num_replies + 1' : 'unapproved_posts = unapproved_posts + 1';\r\n\r\n \/\/ Update the number of replies and the lock\/sticky status.\r\n $smcFunc['db_query']('', '\r\n UPDATE {db_prefix}topics\r\n SET\r\n ' . ($msgOptions['approved'] ? 'id_member_updated = {int:poster_id}, id_last_msg = {int:id_msg},' : '') . '\r\n ' . $countChange . ($topicOptions['lock_mode'] === null ? '' : ',\r\n locked = {int:locked}') . ($topicOptions['sticky_mode'] === null ? '' : ',\r\n is_sticky = {int:is_sticky}') . '\r\n WHERE id_topic = {int:id_topic}',\r\n array(\r\n 'poster_id' =&gt; $posterOptions['id'],\r\n 'id_msg' =&gt; $msgOptions['id'],\r\n 'locked' =&gt; $topicOptions['lock_mode'],\r\n 'is_sticky' =&gt; $topicOptions['sticky_mode'],\r\n 'id_topic' =&gt; $topicOptions['id'],\r\n )\r\n );\r\n\r\n \/\/ One new post has been added today.\r\n trackStats(array('posts' =&gt; '+'));\r\n }\r\n\r\n \/\/ Creating is modifying...in a way.\r\n \/\/!!! Why not set id_msg_modified on the insert?\r\n $smcFunc['db_query']('', '\r\n UPDATE {db_prefix}messages\r\n SET id_msg_modified = {int:id_msg}\r\n WHERE id_msg = {int:id_msg}',\r\n array(\r\n 'id_msg' =&gt; $msgOptions['id'],\r\n )\r\n );\r\n\r\n \/\/ Increase the number of posts and topics on the board.\r\n if ($msgOptions['approved'])\r\n $smcFunc['db_query']('', '\r\n UPDATE {db_prefix}boards\r\n SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . '\r\n WHERE id_board = {int:id_board}',\r\n array(\r\n 'id_board' =&gt; $topicOptions['board'],\r\n )\r\n );\r\n else\r\n {\r\n $smcFunc['db_query']('', '\r\n UPDATE {db_prefix}boards\r\n SET unapproved_posts = unapproved_posts + 1' . ($new_topic ? ', unapproved_topics = unapproved_topics + 1' : '') . '\r\n WHERE id_board = {int:id_board}',\r\n array(\r\n 'id_board' =&gt; $topicOptions['board'],\r\n )\r\n );\r\n\r\n \/\/ Add to the approval queue too.\r\n $smcFunc['db_insert']('',\r\n '{db_prefix}approval_queue',\r\n array(\r\n 'id_msg' =&gt; 'int',\r\n ),\r\n array(\r\n $msgOptions['id'],\r\n ),\r\n array()\r\n );\r\n }\r\n\r\n \/\/ Mark inserted topic as read (only for the user calling this function).\r\n if (!empty($topicOptions['mark_as_read']) &amp;&amp; !$user_info['is_guest'])\r\n {\r\n \/\/ Since it's likely they *read* it before replying, let's try an UPDATE first.\r\n if (!$new_topic)\r\n {\r\n $smcFunc['db_query']('', '\r\n UPDATE {db_prefix}log_topics\r\n SET id_msg = {int:id_msg}\r\n WHERE id_member = {int:current_member}\r\n AND id_topic = {int:id_topic}',\r\n array(\r\n 'current_member' =&gt; $posterOptions['id'],\r\n 'id_msg' =&gt; $msgOptions['id'],\r\n 'id_topic' =&gt; $topicOptions['id'],\r\n )\r\n );\r\n\r\n $flag = $smcFunc['db_affected_rows']() != 0;\r\n }\r\n\r\n if (empty($flag))\r\n {\r\n $smcFunc['db_insert']('ignore',\r\n '{db_prefix}log_topics',\r\n array('id_topic' =&gt; 'int', 'id_member' =&gt; 'int', 'id_msg' =&gt; 'int'),\r\n array($topicOptions['id'], $posterOptions['id'], $msgOptions['id']),\r\n array('id_topic', 'id_member')\r\n );\r\n }\r\n }\r\n\r\n \/\/ If there's a custom search index, it needs updating...\r\n if (!empty($modSettings['search_custom_index_config']))\r\n {\r\n $customIndexSettings = unserialize($modSettings['search_custom_index_config']);\r\n\r\n $inserts = array();\r\n foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word)\r\n $inserts[] = array($word, $msgOptions['id']);\r\n\r\n if (!empty($inserts))\r\n $smcFunc['db_insert']('ignore',\r\n '{db_prefix}log_search_words',\r\n array('id_word' =&gt; 'int', 'id_msg' =&gt; 'int'),\r\n $inserts,\r\n array('id_word', 'id_msg')\r\n );\r\n }\r\n\r\n \/\/ Increase the post counter for the user that created the post.\r\n if (!empty($posterOptions['update_post_count']) &amp;&amp; !empty($posterOptions['id']) &amp;&amp; $msgOptions['approved'])\r\n {\r\n \/\/ Are you the one that happened to create this post?\r\n if ($user_info['id'] == $posterOptions['id'])\r\n $user_info['posts']++;\r\n updateMemberData($posterOptions['id'], array('posts' =&gt; '+'));\r\n }\r\n\r\n \/\/ They've posted, so they can make the view count go up one if they really want. (this is to keep views &gt;= replies...)\r\n $_SESSION['last_read_topic'] = 0;\r\n\r\n \/\/ Better safe than sorry.\r\n if (isset($_SESSION['topicseen_cache'][$topicOptions['board']]))\r\n $_SESSION['topicseen_cache'][$topicOptions['board']]--;\r\n\r\n \/\/ Update all the stats so everyone knows about this new topic and message.\r\n updateStats('message', true, $msgOptions['id']);\r\n\r\n \/\/ Update the last message on the board assuming it's approved AND the topic is.\r\n if ($msgOptions['approved'])\r\n updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);\r\n\r\n \/\/ Alright, done now... we can abort now, I guess... at least this much is done.\r\n ignore_user_abort($previous_ignore_user_abort);\r\n\r\n \/\/ Success.\r\n return $topicOptions['id'];\r\n}\r\n\r\n<\/pre>\n<p>\u0442\u0443\u0442 \u0432 \u0441\u0442\u0440\u043e\u0447\u043a\u0435<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">$ID_MEMBER = smf_authenticateUser(&quot;id&quot;);<\/pre>\n<p>\u0436\u0434\u0435\u0442 \u0441\u044e\u0440\u043f\u0438\u0437. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u0442\u0438\u0442 \u043d\u0435 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443.<br \/>\n\u0414\u043b\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043b\u0435\u0437\u0442\u044c \u0432 \u0444\u0430\u0439\u043b forum\/SSI.php \u0438 \u0432\u044b\u0448\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438<\/p>\n<p>loadPermissions();<\/p>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c<\/p>\n<p>loadBoard();<\/p>\n<p>\u0413\u043d\u0443\u0441\u043d\u044b\u0439 \u0445\u0430\u0440\u0434\u043a\u043e\u0434\u0438\u043d\u0433 :\\<\/p>\n<p>\u0412 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u0434\u0430 \u043c\u043e\u0441\u0442\u0430 Mambo-SMF, \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u0434\u0430 \u0441\u0430\u043c\u043e\u0433\u043e SMF, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043a \u0444\u043e\u0440\u0443\u043c\u0443.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043c\u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u0430\u0439\u0442 http:\/\/maps.ck.ua \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432. \u0414\u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e, \u0430 \u0437\u043e\u043b\u043e\u0442\u0443\u044e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u0443\u044e. \u0422.\u0435. \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0441\u0442\u0438\u0442\u044c \u0438 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438 \u0441 \u0441\u0430\u0439\u0442\u0430 \u0438 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u043c \u0438 \u0442\u0435\u043a\u0441\u0442\u0430 &#8212; \u0441 \u0444\u043e\u0440\u0443\u043c\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u043e\u0440\u0443\u043c\u0430 \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u043b\u044e\u0431\u0438\u043c\u044b\u0439 SMF, 2 \u0432\u0435\u0440\u0441\u0438\u0438. \u041f\u043e\u0447\u0435\u043c\u0443 \u043b\u044e\u0431\u0438\u043c\u044b\u0439 &#8212; \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0438\u043c\u043f\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0434\u0438\u0437\u0430\u0439\u043d, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[355,353,354,356,358,357],"_links":{"self":[{"href":"https:\/\/www.andboson.com\/index.php?rest_route=\/wp\/v2\/posts\/797"}],"collection":[{"href":"https:\/\/www.andboson.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.andboson.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.andboson.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.andboson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=797"}],"version-history":[{"count":4,"href":"https:\/\/www.andboson.com\/index.php?rest_route=\/wp\/v2\/posts\/797\/revisions"}],"predecessor-version":[{"id":800,"href":"https:\/\/www.andboson.com\/index.php?rest_route=\/wp\/v2\/posts\/797\/revisions\/800"}],"wp:attachment":[{"href":"https:\/\/www.andboson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.andboson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.andboson.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}