diff --git a/htdocs/batch_process.php b/htdocs/batch_process.php index 9194f41..e5f2f1d 100644 --- a/htdocs/batch_process.php +++ b/htdocs/batch_process.php @@ -61,5 +61,6 @@ rrmdir(ReportParser::getWorkPath()); if ($nr) { + Memc::flush(); IRCNotify::send("#SingularityViewer", "[CrashProcessor] $nr new reports. http://crash.singularityviewer.org/crashes.php "); -} \ No newline at end of file +} diff --git a/htdocs/css/singularity/singularity.css b/htdocs/css/singularity/singularity.css index 6543b69..b66bf5f 100644 --- a/htdocs/css/singularity/singularity.css +++ b/htdocs/css/singularity/singularity.css @@ -15,6 +15,12 @@ body { color: #a0a0a0; } +@media screen and (max-width: 768px) { + body { + padding: 0px; + } +} + div { display: block; padding: 0; diff --git a/htdocs/lib/CrashReport.php b/htdocs/lib/CrashReport.php index c234e53..e25cffb 100644 --- a/htdocs/lib/CrashReport.php +++ b/htdocs/lib/CrashReport.php @@ -66,12 +66,16 @@ class CrashReport global $DB; $where = $filter->getWhere(); - if (!$res = $DB->query("select count(id) as total from reports $where") OR !$row = $DB->fetchRow($res)) + $q = "select count(id) as total from reports $where"; + if (false !== $cached = Memc::getq($q)) return $cached; + + if (!$res = $DB->query($q) OR !$row = $DB->fetchRow($res)) { return 0; } else { + Memc::setq($q, $row["total"]); return $row["total"]; } } @@ -81,7 +85,10 @@ class CrashReport global $DB; $ret = array(); - if (!$res = $DB->query("select $fields from reports " . $filter->getWhere() . kl_str_sql(" order by id desc limit !i offset !i", $filter->limit, $filter->offset))) + $q = "select $fields from reports " . $filter->getWhere() . kl_str_sql(" order by id desc limit !i offset !i", $filter->limit, $filter->offset); + if (false !== $cached = Memc::getq($q)) return $cached; + + if (!$res = $DB->query($q)) { return $ret; } @@ -93,6 +100,7 @@ class CrashReport $ret[] = $r; } + Memc::setq($q, $ret); return $ret; } diff --git a/htdocs/lib/DBH.php b/htdocs/lib/DBH.php index 138839f..32b3ecf 100644 --- a/htdocs/lib/DBH.php +++ b/htdocs/lib/DBH.php @@ -40,7 +40,7 @@ class DBH $this->db_user = $db_user; $this->db_host = $db_host; - $this->dbh = @mysql_connect($db_host, $db_user, $db_pass); + $this->dbh = @mysql_pconnect($db_host, $db_user, $db_pass); if (!$this->dbh) { DBH::log("[error] connection to database failed"); diff --git a/htdocs/lib/Memc.php b/htdocs/lib/Memc.php new file mode 100644 index 0000000..f5ed774 --- /dev/null +++ b/htdocs/lib/Memc.php @@ -0,0 +1,50 @@ +getServerList(); + if (empty($servers)) + { + //This code block will only execute if we are setting up a new EG(persistent_list) entry + self::$mem->setOption(Memcached::OPT_RECV_TIMEOUT, 1000); + self::$mem->setOption(Memcached::OPT_SEND_TIMEOUT, 3000); + self::$mem->setOption(Memcached::OPT_TCP_NODELAY, true); + self::$mem->setOption(Memcached::OPT_PREFIX_KEY, "cr_"); + self::$mem->addServer("localhost", 11211); + } + + self::$active = true; + } + + function getq($q) + { + if (!self::$active) return false; + + $key = md5($q); + return self::$mem->get($key); + } + + function setq($q, $data) + { + if (!self::$active) return false; + + $key = md5($q); + return self::$mem->set($key, $data, self::$expire); + } + + function flush() + { + if (!self::$active) return false; + self::$mem->flush(); + } + +} +?> \ No newline at end of file diff --git a/htdocs/lib/SearchFilter.php b/htdocs/lib/SearchFilter.php index a3373b9..0a5bd5b 100644 --- a/htdocs/lib/SearchFilter.php +++ b/htdocs/lib/SearchFilter.php @@ -86,6 +86,8 @@ class SearchFilter $ret = array(); $where = $this->chan ? kl_str_sql("where client_channel=!s", $this->chan) : ''; $q = "select distinct client_version from reports $where order by client_version desc"; + if (false !== $cached = Memc::getq($q)) return $cached; + if (!$res = $DB->query($q)) { return $ret; @@ -96,6 +98,7 @@ class SearchFilter $ret[] = $row["client_version"]; } + Memc::setq($q, $ret); return $ret; } @@ -105,6 +108,8 @@ class SearchFilter $ret = array(); $q = "select distinct grid from reports order by grid asc"; + if (false !== $cached = Memc::getq($q)) return $cached; + if (!$res = $DB->query($q)) { return $ret; @@ -115,6 +120,7 @@ class SearchFilter $ret[] = $row["grid"]; } + Memc::setq($q, $ret); return $ret; } @@ -135,7 +141,7 @@ class SearchFilter
-
+
Filter
diff --git a/htdocs/lib/init.php b/htdocs/lib/init.php index e8ebd87..ae2a817 100644 --- a/htdocs/lib/init.php +++ b/htdocs/lib/init.php @@ -15,6 +15,8 @@ function __autoload($class) require_once(SITE_ROOT . '/lib/' . $class . '.php'); } +Memc::init(); + /* Directory relative to server root * No leading or trailing slash. * Example: http://www.example.com/applications/app1/ @@ -67,7 +69,7 @@ if (!$DB->connect($DB_NAME, $DB_HOST, $DB_USER, $DB_PASS)) { die(); } -Option::init(); +//Option::init(); $S = new Session(); if (!defined('NO_SESSION') && PHP_SAPI != "cli") {