Всем здравствуйте. Подскажите пожалуйста по такому вопросу: Этот код некорректно работает. Там есть условия, если в условии 0, то выводим информацию 1, если в условии 3 значения, то выводим список условий, иначе выводим одно условие, иначе выводим информацию 2. (поймете). Так вот, когда я ввожу 3 значения (к примеру, 5,7,10), то мне выводит информацию 2, а должно выполняться условие, где будет высвечиваться список. Нужно построить код так, чтобы правильно выводилась информация. P.S. В 3х условиях могут быть только цифры (без символов и букв) Код (Text): $tr = array(); preg_match_all('/\[\-private\-data\-([0-9]+)\-([0-9]+)\-\]/', $post['message'], $matches); foreach ($matches[0] as $i => $entire_match) { $post_id = $matches[1][$i]; $hide_id = $matches[2][$i]; if ($post_id != $post['postid']) { continue; } if (!isset($GLOBALS['hides'][$post_id])) { $row = $this->registry->db->query_first(" SELECT hide FROM " . TABLE_PREFIX . "post WHERE postid = " . intval($post_id) . " "); if ($row) { $GLOBALS['hides'][$post_id] = unserialize($row['hide']); } } if (isset($GLOBALS['hides'][$post_id][$hide_id])) { global $permission, $forumid, $vbulletin; $condition = trim(trim(trim($GLOBALS['hides'][$post_id][$hide_id]['condition']), '\'"')); $passed = false; $requirements = array(); $requirements_f = 'AND'; if ($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) { $passed = true; } else if ($post['userid'] == $this->registry->userinfo['userid']) { $passed = true; } else if (($permissions['adminpermissions']) & ($vbulletin->bf_ugp_adminpermissions['ismoderator'])) { $passed = true; } else if ((can_moderate($forumid)) & ($vbulletin->options['mod_hide'])) { $passed = true; } else if (preg_match('#^[0-9]+$#', $condition) || (preg_match('#^[0-9,]+$#', $condition) && substr_count($condition, ',') == 3)) { if ($condition == '0') { $requirements[] = array('Быть зарегистрированным на форуме', $vbulletin->userinfo['userid'] != 0); } else { if (substr_count($condition, ',') == 3) { list ($required_messages, $required_reputation, $required_registration) = explode(",", $condition); } else { $required_messages = round($condition * $condition * $vbulletin->options['hide_post']); $required_reputation = round($condition * $vbulletin->options['hide_rep']); $required_registration = $condition * $vbulletin->options['hide_reg']; } $requirements[] = array('Иметь <b>' . $required_messages . '</b> сообщений (' . max(0, $required_messages - $vbulletin->userinfo['posts']) . ' осталось)', $vbulletin->userinfo['posts'] >= $required_messages); $requirements[] = array('Иметь <b>' . $required_reputation . '</b> очков репутации (' . max(0, $required_reputation - $vbulletin->userinfo['reputation']) . ' осталось)', $vbulletin->userinfo['reputation'] >= $required_reputation); $requirements[] = array('Давность регистрации на форуме не менее <b>' . $required_registration . '</b> дней назад', (time() - ($vbulletin->userinfo['userid'] ? $vbulletin->userinfo['joindate'] : time())) / 86400 >= $required_registration); } } else { $requirements_f = 'OR'; foreach (explode(',', $condition) as $username) { $requirements[] = array('Быть пользователем с ником <b>' . htmlspecialchars_uni($username) . '</b>', strtolower($vbulletin->userinfo['username']) == strtolower($username)); } } if (!$passed) { if ($requirements_f == 'AND') { $passed = true; } else if ($requirements_f == 'OR') { $passed = false; } else { // ??? } foreach ($requirements as $requirement) { if ($requirements_f == 'AND') { $passed = $passed && $requirement[1]; } else if ($requirements_f == 'OR') { $passed = $passed || $requirement[1]; } else { // ??? } } } if ($passed) { $condition_escaped = htmlspecialchars_uni($condition); $tr[$entire_match] = <<<EOF <div class="bbcode_container"> <div class="bbcode_quote"> <div class="quote_container"> <div class="bbcode_postedby"> <img src="images/hide/key.png" alt="" /> <b>Скрытый текст, необходимо выполнение следующих условий: [hide=$condition_escaped]</b> </div> <div class="message" style="font-style: normal;"> EOF; $tr[$entire_match] .= $this->bbcode_parser->parse( $GLOBALS['hides'][$post_id][$hide_id]['text'], $this->forum['forumid'], $this->post['allowsmilie'], false, '', 3, false, $this->post['htmlstate'] ); $tr[$entire_match] .= <<<EOF </div> </div> </div> </div> EOF; } else { $condition_escaped = htmlspecialchars_uni($condition); $requirements_list = array(); foreach ($requirements as $requirement) { $requirements_list[] = ($requirement[1] ? '<img src="images/hide/success.png" />' : '<img src="images/hide/fail.gif" />') . ' ' . $requirement[0]; } $requirements_list = implode('<br />', $requirements_list); $tr[$entire_match] = <<<EOF <div class="bbcode_container"> <div class="bbcode_quote"> <div class="quote_container"> <div class="bbcode_quote_container"></div> <div class="bbcode_postedby"> <img src="images/hide/key.png" alt="" /> <b>Скрытый текст, необходимо выполнение следующих условий: [hide=$condition_escaped]</b> </div> <div class="message" style="font-style: normal;">$requirements_list</div> </div> </div> </div> EOF; } } } $post['message'] = strtr($post['message'], $tr);