本文整理汇总了PHP中bb2_read_settings函数的典型用法代码示例。如果您正苦于以下问题:PHP bb2_read_settings函数的具体用法?PHP bb2_read_settings怎么用?PHP bb2_read_settings使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bb2_read_settings函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bad_behavior
/**
* bad_behavior
*/
public function bad_behavior()
{
// Calls inward to Bad Behavor itself.
require_once BB2_CWD . "/bad-behavior/version.inc.php";
require_once BB2_CWD . "/bad-behavior/core.inc.php";
bb2_start(bb2_read_settings());
}
示例2: bb2_insert_stats
function bb2_insert_stats($force = false)
{
$settings = bb2_read_settings();
if ($force || $settings['display_stats']) {
$blocked = bb2_db_query("SELECT COUNT(*) FROM " . $settings['log_table'] . " WHERE `key` NOT LIKE '00000000'");
if ($blocked !== FALSE) {
echo sprintf('<p><a href="http://www.bad-behavior.ioerror.us/">%1$s</a> %2$s <strong>%3$s</strong> %4$s</p>', __('Bad Behavior'), __('has blocked'), $blocked[0]["COUNT(*)"], __('access attempts in the last 7 days.'));
}
}
}
示例3: bb2_options
function bb2_options()
{
$settings = bb2_read_settings();
if ($_POST) {
if ($_POST['display_stats']) {
$settings['display_stats'] = true;
} else {
$settings['display_stats'] = false;
}
if ($_POST['strict']) {
$settings['strict'] = true;
} else {
$settings['strict'] = false;
}
if ($_POST['verbose']) {
$settings['verbose'] = true;
} else {
$settings['verbose'] = false;
}
if ($_POST['logging']) {
if ($_POST['logging'] == 'verbose') {
$settings['verbose'] = true;
$settings['logging'] = true;
} else {
if ($_POST['logging'] == 'normal') {
$settings['verbose'] = false;
$settings['logging'] = true;
} else {
$settings['verbose'] = false;
$settings['logging'] = false;
}
}
} else {
$settings['verbose'] = false;
$settings['logging'] = false;
}
bb2_write_settings($settings);
?>
<div id="message" class="updated fade"><p><strong><?php
_e('Options saved.');
?>
</strong></p></div>
<?php
}
?>
<div class="wrap">
<h2><?php
_e("Bad Behavior");
?>
</h2>
<form method="post" action="<?php
echo $_SERVER['REQUEST_URI'];
?>
">
<p>For more information please visit the <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> homepage.</p>
<p>If you find Bad Behavior valuable, please consider making a <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=error%40ioerror%2eus&item_name=Bad%20Behavior%20<?php
echo BB2_VERSION;
?>
%20%28From%20Admin%29&no_shipping=1&cn=Comments%20about%20Bad%20Behavior&tax=0¤cy_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8">financial contribution</a> to further development of Bad Behavior.</p>
<fieldset class="options">
<legend><?php
_e('Statistics');
?>
</legend>
<?php
bb2_insert_stats(true);
?>
<p><label><input type="checkbox" name="display_stats" value="true" <?php
if ($settings['display_stats']) {
?>
checked="checked" <?php
}
?>
/> <?php
_e('Display statistics in blog footer');
?>
</label></p>
</fieldset>
<fieldset class="options">
<legend><?php
_e('Logging');
?>
</legend>
<p><label><input type="radio" name="logging" value="verbose" <?php
if ($settings['verbose'] && $settings['logging']) {
?>
checked="checked" <?php
}
?>
/> <?php
_e('Verbose HTTP request logging');
?>
</label></p>
<p><label><input type="radio" name="logging" value="normal" <?php
if ($settings['logging'] && !$settings['verbose']) {
?>
checked="checked" <?php
}
//.........这里部分代码省略.........
示例4: bb2_mediawiki_entry
function bb2_mediawiki_entry()
{
global $bb2_timer_total;
$bb2_mtime = explode(" ", microtime());
$bb2_timer_start = $bb2_mtime[1] + $bb2_mtime[0];
if (php_sapi_name() != 'cli') {
require_once BB2_CWD . "/bad-behavior/core.inc.php";
bb2_install();
// FIXME: see above
$settings = bb2_read_settings();
bb2_start($settings);
}
$bb2_mtime = explode(" ", microtime());
$bb2_timer_stop = $bb2_mtime[1] + $bb2_mtime[0];
$bb2_timer_total = $bb2_timer_stop - $bb2_timer_start;
}
示例5: bb2_insert_stats
/**
* Display Statistics (default off)
* Enabling this option will return a string to add a blurb to your site footer
* advertising Bad Behavior’s presence and the number of recently blocked requests.
*
* This option is not available or has no effect when logging is not in use.
*
* @param bool $force
*/
function bb2_insert_stats($force = false)
{
global $txt;
$settings = bb2_read_settings();
if ($force || $settings['display_stats']) {
// Get the blocked count for the last 7 days ... cache this as well
if (($bb2_blocked = cache_get_data('bb2_blocked', 900)) === null) {
$bb2_blocked = bb2_db_query('SELECT COUNT(*) FROM {db_prefix}log_badbehavior WHERE `valid` NOT LIKE \'00000000\'');
cache_put_data('bb2_blocked', $bb2_blocked, 900);
}
if ($bb2_blocked !== false) {
return sprintf($txt['badbehavior_blocked'], $bb2_blocked[0]['COUNT(*)']);
}
}
}
示例6: bb2_install
function bb2_install()
{
$settings = bb2_read_settings();
if ($settings['is_installed'] == false) {
bb2_db_query(bb2_table_structure($settings['log_table']));
$settings['is_installed'] = true;
bb2_write_settings($settings);
}
}
示例7: bb2_insert_stats
function bb2_insert_stats($force = false)
{
$settings = bb2_read_settings();
global $CONF;
if ($force || $settings['display_stats']) {
//$blocked = bb2_db_query("SELECT COUNT(*) as blocks FROM " . $settings['log_table'] . " WHERE `key` NOT LIKE '00000000'");
$blocked = sql_num_rows(sql_query("SELECT id FROM " . $settings['log_table'] . " WHERE `key` NOT LIKE '00000000'"));
if ($blocked !== FALSE) {
require_once BB2_CORE . "/responses.inc.php";
echo sprintf('<p><a href="http://www.bad-behavior.ioerror.us/">%1$s</a> %2$s <strong>%3$s</strong> %4$s</p>', 'Bad Behavior', 'has blocked', $blocked, 'access attempts in the last 7 days.');
$res = sql_query("SELECT `key`, COUNT(*) FROM " . $settings['log_table'] . " WHERE `key` NOT LIKE '00000000' GROUP BY `key`");
echo "<table>\n";
echo "<tr><th>Count</th><th>Key</th><th>Response</th><th>Explanation</th><th>Log</th><th>Details</th></tr>\n";
while ($row = sql_fetch_assoc($res)) {
$response = bb2_get_response($row['key']);
echo "<tr>\n";
echo "<td>" . $row['COUNT(*)'] . "</td>\n";
echo "<td>" . $row['key'] . "</td>\n";
echo "<td>" . $response['response'] . "</td>\n";
echo "<td>" . $response['explanation'] . "</td>\n";
echo "<td>" . $response['log'] . "</td>\n";
echo "<td>\n";
echo '<form method="post" action="' . $CONF['PluginURL'] . 'badbehavior/index.php">' . "\n";
echo '<input type="hidden" name="tname" value="' . sql_table('bad_behavior') . '" />' . "\n";
echo '<input type="hidden" name="showlist" value="logs" />' . "\n";
echo '<input type="hidden" name="fname" value="key" />' . "\n";
echo '<input type="hidden" name="oname" value="like" />' . "\n";
echo '<input type="hidden" name="iname" value="' . $row['key'] . '" />' . "\n";
echo '<input type="submit" value="View" class="formbutton" /></form>' . "\n";
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}
}
}
示例8: getBadBehaviorRequestsCount
function getBadBehaviorRequestsCount()
{
$settings = bb2_read_settings();
return $this->db->getValueByName("SELECT COUNT(*) AS COUNT FROM #_bad_behavior WHERE `key` NOT LIKE '00000000'", 'count');
}
示例9: bb2_expireBans
function bb2_expireBans()
{
global $_CONF;
if (!isset($_CONF['bb2_ban_timeout'])) {
$_CONF['bb2_ban_timeout'] = 24;
}
if ($_CONF['bb2_ban_timeout'] == 0) {
return;
}
$settings = bb2_read_settings();
$oldBans = time() - $_CONF['bb2_ban_timeout'] * 60 * 60;
DB_query("DELETE FROM {$settings['ban_table']} WHERE type != 0 AND timestamp < " . $oldBans, 1);
return;
}
示例10: bb2_insert_head
// This will put the bb2 screener into the f3 hive key for javascript
function bb2_insert_head()
{
global $bb2_javascript;
$f3->set('bb2_javascript', $bb2_javascript);
return TRUE;
}
// Write stats into the $f3 hive
function bb2_insert_stats($force = false)
{
global $bb_settings, $f3;
if ($force || $bb_settings['display_stats']) {
$blocked = bb2_db_query("SELECT COUNT(*) FROM " . $bb_settings['log_table'] . " WHERE `key` NOT LIKE '00000000'");
if ($blocked !== FALSE) {
$f3->set('bb2_stats', $blocked[0]["COUNT(*)"]);
}
}
}
// Return the top-level relative path of wherever we are (for cookies)
function bb2_relative_path()
{
return \Base::instance()->get('BASE') . '/';
}
// Calls inward to Bad Behavor itself.
require_once BB2_CWD . "/bad-behavior/core.inc.php";
$bb_db = $f3->get('DB');
$bb_settings = bb2_read_settings();
bb2_install();
bb2_start($bb_settings);
// eFiction 5 specific
bb2_insert_stats();
示例11: bb2_insert_stats
function bb2_insert_stats($force = false)
{
global $bb2_result;
$settings = bb2_read_settings();
if ($force || $settings['display_stats']) {
$blocked = bb2_db_query("SELECT COUNT(*) FROM " . $settings['log_table'] . " WHERE `key` NOT LIKE '00000000'");
if ($blocked !== FALSE) {
echo sprintf('<p><a href="http://bad-behavior.ioerror.us/">%1$s</a> %2$s <strong>%3$s</strong> %4$s</p>', __('Bad Behavior'), __('has blocked'), $blocked[0]["COUNT(*)"], __('access attempts in the last 7 days.'));
}
}
if (@(!empty($bb2_result))) {
echo sprintf("\n<!-- Bad Behavior result was %s! This request would have been blocked. -->\n", $bb2_result);
unset($bb2_result);
}
}
示例12: loadBadBehavior
/**
* Decide if we are going to enable bad behavior scanning for this user
*
* What it does:
* - Admins and Moderators get a free pass
* - Optionally existing users with post counts over a limit are bypassed
* - Others get a humane frisking
*/
function loadBadBehavior()
{
global $modSettings, $user_info, $bb2_results;
// Bad Behavior Enabled?
if (!empty($modSettings['badbehavior_enabled'])) {
require_once EXTDIR . '/bad-behavior/badbehavior-plugin.php';
$bb_run = true;
// We may want to give some folks a hallway pass
if (!$user_info['is_guest']) {
if (!empty($user_info['is_mod']) || !empty($user_info['is_admin'])) {
$bb_run = false;
} elseif (!empty($modSettings['badbehavior_postcount_wl']) && $modSettings['badbehavior_postcount_wl'] < 0) {
$bb_run = false;
} elseif (!empty($modSettings['badbehavior_postcount_wl']) && $modSettings['badbehavior_postcount_wl'] > 0 && $user_info['posts'] > $modSettings['badbehavior_postcount_wl']) {
$bb_run = false;
}
}
// Put on the sanitary gloves, its time for a patdown !
if ($bb_run === true) {
$bb2_results = bb2_start(bb2_read_settings());
addInlineJavascript(bb2_insert_head());
}
}
}
示例13: bb2_insert_stats
function bb2_insert_stats($force = FALSE)
{
$settings = bb2_read_settings();
if ($force or $settings['display_stats']) {
$blocked = safe_rows('*', $settings['log_table'], "`key` NOT LIKE '00000000'");
$number = count($blocked);
if ($blocked !== FALSE) {
echo sprintf('<p><a href="http://www.bad-behavior.ioerror.us/">%1$s</a> %2$s <strong>%3$s</strong> %4$s</p>', 'Bad Behavior', 'has blocked', $number, 'access attempts in the last 7 days.');
}
}
}
示例14: bb2_options
function bb2_options()
{
$settings = bb2_read_settings();
$request_uri = $_SERVER["REQUEST_URI"];
if (!$request_uri) {
$request_uri = $_SERVER['SCRIPT_NAME'];
}
# IIS
if ($_POST) {
$_POST = array_map('stripslashes_deep', $_POST);
if ($_POST['display_stats']) {
$settings['display_stats'] = true;
} else {
$settings['display_stats'] = false;
}
if ($_POST['strict']) {
$settings['strict'] = true;
} else {
$settings['strict'] = false;
}
if ($_POST['verbose']) {
$settings['verbose'] = true;
} else {
$settings['verbose'] = false;
}
if ($_POST['logging']) {
if ($_POST['logging'] == 'verbose') {
$settings['verbose'] = true;
$settings['logging'] = true;
} else {
if ($_POST['logging'] == 'normal') {
$settings['verbose'] = false;
$settings['logging'] = true;
} else {
$settings['verbose'] = false;
$settings['logging'] = false;
}
}
} else {
$settings['verbose'] = false;
$settings['logging'] = false;
}
if ($_POST['httpbl_key']) {
if (preg_match("/^[a-z]{12}\$/", $_POST['httpbl_key'])) {
$settings['httpbl_key'] = $_POST['httpbl_key'];
} else {
$settings['httpbl_key'] = '';
}
} else {
$settings['httpbl_key'] = '';
}
if ($_POST['httpbl_threat']) {
$settings['httpbl_threat'] = intval($_POST['httpbl_threat']);
} else {
$settings['httpbl_threat'] = '25';
}
if ($_POST['httpbl_maxage']) {
$settings['httpbl_maxage'] = intval($_POST['httpbl_maxage']);
} else {
$settings['httpbl_maxage'] = '30';
}
if ($_POST['offsite_forms']) {
$settings['offsite_forms'] = true;
} else {
$settings['offsite_forms'] = false;
}
if ($_POST['eu_cookie']) {
$settings['eu_cookie'] = true;
} else {
$settings['eu_cookie'] = false;
}
if ($_POST['reverse_proxy']) {
$settings['reverse_proxy'] = true;
} else {
$settings['reverse_proxy'] = false;
}
if ($_POST['reverse_proxy_header']) {
$settings['reverse_proxy_header'] = sanitize_text_field(uc_all($_POST['reverse_proxy_header']));
} else {
$settings['reverse_proxy_header'] = 'X-Forwarded-For';
}
if ($_POST['reverse_proxy_addresses']) {
$settings['reverse_proxy_addresses'] = preg_split("/[\\s,]+/m", $_POST['reverse_proxy_addresses']);
$settings['reverse_proxy_addresses'] = array_map('sanitize_text_field', $settings['reverse_proxy_addresses']);
} else {
$settings['reverse_proxy_addresses'] = array();
}
bb2_write_settings($settings);
?>
<div id="message" class="updated fade"><p><strong><?php
_e('Options saved.');
?>
</strong></p></div>
<?php
}
?>
<div class="wrap">
<?php
echo bb2_donate_button(admin_url("options-general.php?page=bb2_options"));
?>
//.........这里部分代码省略.........
示例15: bb2_mediawiki_entry
function bb2_mediawiki_entry()
{
global $bb2_timer_total;
$bb2_mtime = explode(" ", microtime());
$bb2_timer_start = $bb2_mtime[1] + $bb2_mtime[0];
if (php_sapi_name() != 'cli') {
bb2_install();
// FIXME: see above
$settings = bb2_read_settings();
// FIXME: Need to make this multi-DB compatible eventually
$dbr = wfGetDB(DB_SLAVE);
if (get_class($dbr) != "DatabaseMysql") {
$settings['logging'] = false;
}
bb2_start($settings);
}
$bb2_mtime = explode(" ", microtime());
$bb2_timer_stop = $bb2_mtime[1] + $bb2_mtime[0];
$bb2_timer_total = $bb2_timer_stop - $bb2_timer_start;
}