Standarize some variables and address some php warnings.
This commit is contained in:
parent
f8ec3d9ca6
commit
3ff76df4fe
|
@ -1 +1 @@
|
||||||
0.9.131
|
0.9.132
|
||||||
|
|
|
@ -202,13 +202,16 @@ function message_read($id, $bodynum = 0, $group = "")
|
||||||
}
|
}
|
||||||
if ($memcacheD) {
|
if ($memcacheD) {
|
||||||
$memcache_key = $memcache_key_prefix . '_' . 'message_read-' . $id . '-0-' . $group;
|
$memcache_key = $memcache_key_prefix . '_' . 'message_read-' . $id . '-0-' . $group;
|
||||||
if ($message = unserialize(gzuncompress($memcacheD->get($memcache_key)))) {
|
$message_data = $memcacheD->get($memcache_key);
|
||||||
|
if ($message_data) {
|
||||||
|
if ($message = unserialize(gzuncompress($message_data))) {
|
||||||
if ($enable_memcache_logging) {
|
if ($enable_memcache_logging) {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $memcache_key", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $memcache_key", FILE_APPEND);
|
||||||
}
|
}
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$message = new messageType();
|
$message = new messageType();
|
||||||
if ((isset($cache_articles)) && ($cache_articles == true)) {
|
if ((isset($cache_articles)) && ($cache_articles == true)) {
|
||||||
// Try to load a cached article
|
// Try to load a cached article
|
||||||
|
|
|
@ -73,14 +73,17 @@ function thread_cache_load($group)
|
||||||
}
|
}
|
||||||
// Check memcache
|
// Check memcache
|
||||||
if ($memcacheD) {
|
if ($memcacheD) {
|
||||||
$key = $memcache_key_prefix . '_' . 'thread_cache-' . $group;
|
$memcache_key = $memcache_key_prefix . '_' . 'thread_cache-' . $group;
|
||||||
if ($headers = unserialize(gzuncompress($memcacheD->get($key)))) {
|
$message_data = $memcacheD->get($memcache_key);
|
||||||
|
if ($message_data) {
|
||||||
|
if ($headers = unserialize(gzuncompress($message_data))) {
|
||||||
if ($enable_memcache_logging) {
|
if ($enable_memcache_logging) {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $key", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $memcache_key", FILE_APPEND);
|
||||||
}
|
}
|
||||||
return $headers;
|
return $headers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$database = $spooldir . '/' . $group . '-data.db3';
|
$database = $spooldir . '/' . $group . '-data.db3';
|
||||||
$table = "threads";
|
$table = "threads";
|
||||||
|
@ -94,23 +97,21 @@ function thread_cache_load($group)
|
||||||
$dbh = null;
|
$dbh = null;
|
||||||
}
|
}
|
||||||
if ($memcacheD) {
|
if ($memcacheD) {
|
||||||
$key = $memcache_key_prefix . '_' . 'thread_cache-' . $group;
|
|
||||||
|
|
||||||
$add_thread = gzcompress(serialize($headers), 9);
|
$add_thread = gzcompress(serialize($headers), 9);
|
||||||
$thread_bytes = strlen($add_thread);
|
$thread_bytes = strlen($add_thread);
|
||||||
$too_big = false;
|
$too_big = false;
|
||||||
if ($thread_bytes < $memcache_maxitemsize) {
|
if ($thread_bytes < $memcache_maxitemsize) {
|
||||||
$nicole = $memcacheD->add($key, $add_thread, $memcache_ttl);
|
$nicole = $memcacheD->add($memcache_key, $add_thread, $memcache_ttl);
|
||||||
} else {
|
} else {
|
||||||
$nicole = false;
|
$nicole = false;
|
||||||
$too_big = true;
|
$too_big = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($nicole && $enable_memcache_logging) {
|
if ($nicole && $enable_memcache_logging) {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $key (" . strlen($add_thread) . " bytes)", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $memcache_key (" . strlen($add_thread) . " bytes)", FILE_APPEND);
|
||||||
}
|
}
|
||||||
if ($too_big) {
|
if ($too_big) {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " $key too large (" . $thread_bytes . " bytes)", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " $memcache_key too large (" . $thread_bytes . " bytes)", FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ($headers);
|
return ($headers);
|
||||||
|
@ -151,26 +152,26 @@ function thread_cache_save($headers, $group)
|
||||||
$dbh->commit();
|
$dbh->commit();
|
||||||
$dbh = null;
|
$dbh = null;
|
||||||
if ($memcacheD) {
|
if ($memcacheD) {
|
||||||
$key = $memcache_key_prefix . '_' . 'thread_cache-' . $group;
|
$memcache_key = $memcache_key_prefix . '_' . 'thread_cache-' . $group;
|
||||||
$del = $memcacheD->delete($key);
|
$del = $memcacheD->delete($memcache_key);
|
||||||
$add_thread = gzcompress(serialize($headers), 9);
|
$add_thread = gzcompress(serialize($headers), 9);
|
||||||
$thread_bytes = strlen($add_thread);
|
$thread_bytes = strlen($add_thread);
|
||||||
$too_big = false;
|
$too_big = false;
|
||||||
if ($thread_bytes < $memcache_maxitemsize) {
|
if ($thread_bytes < $memcache_maxitemsize) {
|
||||||
$nicole = $memcacheD->add($key, $add_thread, $memcache_ttl);
|
$nicole = $memcacheD->add($memcache_key, $add_thread, $memcache_ttl);
|
||||||
} else {
|
} else {
|
||||||
$too_big = true;
|
$too_big = true;
|
||||||
$nicole = false;
|
$nicole = false;
|
||||||
}
|
}
|
||||||
if ($enable_memcache_logging) {
|
if ($enable_memcache_logging) {
|
||||||
if ($del) {
|
if ($del) {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache delete) $key", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache delete) $memcache_key", FILE_APPEND);
|
||||||
}
|
}
|
||||||
if ($nicole) {
|
if ($nicole) {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $key (" . $thread_bytes . " bytes)", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $memcache_key (" . $thread_bytes . " bytes)", FILE_APPEND);
|
||||||
}
|
}
|
||||||
if ($too_big) {
|
if ($too_big) {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " $key too large (" . $thread_bytes . " bytes)", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " $memcache_key too large (" . $thread_bytes . " bytes)", FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -640,9 +640,11 @@ function groups_show($gruppen)
|
||||||
// Get last article info from article database
|
// Get last article info from article database
|
||||||
// First check memcache
|
// First check memcache
|
||||||
if ($memcacheD) {
|
if ($memcacheD) {
|
||||||
$lar_memcache = $memcache_key_prefix . '_' . 'lastarticleinfo-' . $g->name;
|
$memcache_key = $memcache_key_prefix . '_' . 'lastarticleinfo-' . $g->name;
|
||||||
$groupfile = $spooldir . '/' . $g->name . '-lastarticleinfo.dat';
|
$groupfile = $spooldir . '/' . $g->name . '-lastarticleinfo.dat';
|
||||||
if ($lastarticleinfo = unserialize($memcacheD->get($lar_memcache))) {
|
$lar = $memcacheD->get($memcache_key);
|
||||||
|
if ($lar) {
|
||||||
|
if ($lastarticleinfo = unserialize($lar)) {
|
||||||
if ($lastarticleinfo && file_exists($groupfile) && filemtime($groupfile) <= $lastarticleinfo['date']) {
|
if ($lastarticleinfo && file_exists($groupfile) && filemtime($groupfile) <= $lastarticleinfo['date']) {
|
||||||
if ($enable_memcache_logging) {
|
if ($enable_memcache_logging) {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . ' (cache hit) lastarticleinfo for ' . $g->name, FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . ' (cache hit) lastarticleinfo for ' . $g->name, FILE_APPEND);
|
||||||
|
@ -653,6 +655,7 @@ function groups_show($gruppen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (! isset($lastarticleinfo['date'])) {
|
if (! isset($lastarticleinfo['date'])) {
|
||||||
if ($CONFIG['article_database'] == '1') {
|
if ($CONFIG['article_database'] == '1') {
|
||||||
$database = $spooldir . '/' . $g->name . '-articles.db3';
|
$database = $spooldir . '/' . $g->name . '-articles.db3';
|
||||||
|
@ -687,13 +690,13 @@ function groups_show($gruppen)
|
||||||
$lastarticleinfo = $row;
|
$lastarticleinfo = $row;
|
||||||
if ($memcacheD) {
|
if ($memcacheD) {
|
||||||
touch($groupfile, $lastarticleinfo['date']);
|
touch($groupfile, $lastarticleinfo['date']);
|
||||||
$nicole = $memcacheD->delete($lar_memcache);
|
$nicole = $memcacheD->delete($memcache_key);
|
||||||
$memcacheD->add($lar_memcache, serialize($row), $memcache_ttl);
|
$memcacheD->add($memcache_key, serialize($row), $memcache_ttl);
|
||||||
if ($enable_memcache_logging) {
|
if ($enable_memcache_logging) {
|
||||||
if ($nicole) {
|
if ($nicole) {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache update) $lar_memcache", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache update) $memcache_key", FILE_APPEND);
|
||||||
} else {
|
} else {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $lar_memcache", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $memcache_key", FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1623,14 +1626,16 @@ function get_newsgroups_by_msgid($msgid, $noarray = false)
|
||||||
include $config_dir . '/memcache.inc.php';
|
include $config_dir . '/memcache.inc.php';
|
||||||
}
|
}
|
||||||
if ($memcacheD) {
|
if ($memcacheD) {
|
||||||
$key = $memcache_key_prefix . '_' . 'get_newsgroups_by_msgid-' . $msgid;
|
$memcache_key = $memcache_key_prefix . '_' . 'get_newsgroups_by_msgid-' . $msgid;
|
||||||
if ($groups = $memcacheD->get($key)) {
|
if ($getgroups = $memcacheD->get($memcache_key)) {
|
||||||
|
if ($groups = unserialize($getgroups)) {
|
||||||
if ($enable_memcache_logging) {
|
if ($enable_memcache_logging) {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $key", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $memcache_key", FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! $groups) {
|
}
|
||||||
|
if (!isset($groups)) {
|
||||||
$database = $spooldir . '/articles-overview.db3';
|
$database = $spooldir . '/articles-overview.db3';
|
||||||
$table = 'overview';
|
$table = 'overview';
|
||||||
$overview_dbh = overview_db_open($database, $table);
|
$overview_dbh = overview_db_open($database, $table);
|
||||||
|
@ -1649,9 +1654,9 @@ function get_newsgroups_by_msgid($msgid, $noarray = false)
|
||||||
}
|
}
|
||||||
$overview_dbh = null;
|
$overview_dbh = null;
|
||||||
if ($groups && $memcacheD) {
|
if ($groups && $memcacheD) {
|
||||||
$nicole = $memcacheD->add($key, $groups, $memcache_ttl);
|
$nicole = $memcacheD->add($memcache_key, serialize($groups), $memcache_ttl);
|
||||||
if ($enable_memcache_logging && $nicole) {
|
if ($enable_memcache_logging && $nicole) {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $key", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $memcache_key", FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2094,14 +2099,15 @@ function disable_page_by_user_agent($client_device, $useragent, $script = "Page"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function throttle_hits($client_device)
|
function throttle_hits($client_device = null)
|
||||||
{
|
{
|
||||||
global $CONFIG, $OVERRIDES, $logdir, $config_name;
|
global $CONFIG, $OVERRIDES, $logdir, $config_name;
|
||||||
$logfile = $logdir . '/newsportal.log';
|
$logfile = $logdir . '/newsportal.log';
|
||||||
|
|
||||||
|
if (! $client_device) {
|
||||||
$client_device = get_client_user_agent_info();
|
$client_device = get_client_user_agent_info();
|
||||||
|
}
|
||||||
$client_device = strtolower($client_device);
|
$client_device = strtolower($client_device);
|
||||||
$useragent = strtolower($useragent);
|
|
||||||
|
|
||||||
$_SESSION['rsactive'] = true;
|
$_SESSION['rsactive'] = true;
|
||||||
|
|
||||||
|
@ -2112,7 +2118,7 @@ function throttle_hits($client_device)
|
||||||
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Blocking " . $_SERVER['REMOTE_ADDR'] . " '" . $user_agent . "' listed in block list", FILE_APPEND);
|
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Blocking " . $_SERVER['REMOTE_ADDR'] . " '" . $user_agent . "' listed in block list", FILE_APPEND);
|
||||||
$_SESSION['throttled'] = true;
|
$_SESSION['throttled'] = true;
|
||||||
header("HTTP/1.0 403 Forbidden");
|
header("HTTP/1.0 403 Forbidden");
|
||||||
exit;
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,9 @@ function display_threads($threads, $oldest)
|
||||||
$style = 0;
|
$style = 0;
|
||||||
$results = 0;
|
$results = 0;
|
||||||
foreach ($nicole as $key => $value) {
|
foreach ($nicole as $key => $value) {
|
||||||
|
if (isset($this_overboard['msgids'][$key])) {
|
||||||
$target_head = $this_overboard['msgids'][$key];
|
$target_head = $this_overboard['msgids'][$key];
|
||||||
|
}
|
||||||
if (! isset($target_head['msgid'])) {
|
if (! isset($target_head['msgid'])) {
|
||||||
$target_head = get_data_from_msgid($key);
|
$target_head = get_data_from_msgid($key);
|
||||||
}
|
}
|
||||||
|
@ -333,7 +335,6 @@ function display_threads($threads, $oldest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$results ++;
|
$results ++;
|
||||||
$lone == '';
|
|
||||||
$skip = '';
|
$skip = '';
|
||||||
if ($nohead) {
|
if ($nohead) {
|
||||||
if (($style % 2) == 0) {
|
if (($style % 2) == 0) {
|
||||||
|
|
Loading…
Reference in New Issue