function cn_extrn_replace($input) { if (!getoption('use_replacement')) { return $input; } if ($rword = getoption('#rword')) { foreach ($rword as $f => $t) { $input = preg_replace('/' . preg_sanitize($f) . '/i', trim($t), $input); } } return $input; }
} } } if (preg_match($regex_site, $comment)) { echo '<div class="cn_error_comment">' . i18n('Your not allowed to put URL\'s in the comments field.') . '. <a href="' . $refer . '">Go back</a></div>'; return FALSE; } if (getoption('only_registered_comment') && !$logged_as_member) { echo '<div class="cn_error_comment">' . i18n('Only registered users can post comments') . '. <a href="' . $refer . '">Go back</a></div>'; return FALSE; } // Check ip/nick ban filter ---- $block_list = getoption('#ipban'); foreach ($block_list as $ip_test => $_t) { // Create test string $match = '/' . str_replace('\\x2a', '.*?', preg_sanitize($ip_test)) . '/'; if (preg_match($match, CLIENT_IP) || !$logged_as_member && preg_match($match, $name)) { echo '<div class="cn_error_comment">' . i18n('Sorry but you have been blocked from posting comments') . ' (IP=' . cn_htmlspecialchars(CLIENT_IP) . '). <a href="' . $refer . '">Go back</a></div>'; return FALSE; } } // Check for flood (if enabled) if ($flood_time = getoption('flood_time')) { if (!file_exists($fn = cn_path_construct(SERVDIR, 'cdata') . 'flood.txt')) { fclose(fopen($fn, 'w+')); } $flood = file($fn); $found = FALSE; $w = fopen($fn, 'w+'); flock($w, LOCK_EX); foreach ($flood as $item) {
} } } krsort($listing); // Init searching $preg_story = '[^\\|]*'; $preg_author = '[^\\|]*'; $preg_title = '[^\\|]*'; if (!empty($user)) { $preg_author = '.*?(' . preg_replace('/\\s/', '|', preg_sanitize($user)) . ')[^\\|]*'; } if (!empty($title)) { $preg_title = '.*?(' . preg_replace('/\\s/', '|', preg_sanitize($title)) . ')[^\\|]*'; } if (!empty($story)) { $preg_story = '.*?(' . preg_replace('/\\s/', '|', preg_sanitize($story)) . ')[^\\|]*'; } // Search in files $found = array(); foreach ($listing as $id => $newsfile) { // Old archives do not touch if ($id && $id < $date_from) { break; } $news = join('', file(SERVDIR . $newsfile)); $strs = '~^\\d+\\|' . $preg_author . '\\|' . $preg_title . '\\|' . $preg_story . '\\|.*$~im'; if (preg_match_all($strs, $news, $c, PREG_SET_ORDER)) { foreach ($c as $a => $b) { $item = explode("|", $b[0]); if ($item[NEW_ID] < $date_from or $item[NEW_ID] > $date_to) { continue;
function user_remove_ban($ip) { $ip = str_replace(array('|', '"'), '', $ip); if (empty($ip)) { return false; } $users_ban = load_database('users_ban', 'ipban.db'); if (preg_match_all('~^' . preg_sanitize($ip) . '\\|.*$~im', $users_ban, $c, PREG_SET_ORDER)) { foreach ($c as $v) { $users_ban = str_replace($v[0] . "\n", '', $users_ban); } } return rewritefile('/cdata/ipban.db.php', $users_ban); }