public function response(array $template_params = []) { $visit_table = $this->curator->tableName(SchemaCurator::VISIT_TABLE); $address_table = $this->curator->tableName(SchemaCurator::ADDRESS_TABLE); $host_table = $this->curator->tableName(SchemaCurator::HOST_TABLE); $path_table = $this->curator->tableName(SchemaCurator::PATH_TABLE); $referer_table = $this->curator->tableName(SchemaCurator::REFERER_TABLE); $browser_table = $this->curator->tableName(SchemaCurator::BROWSER_TABLE); $browser_version_table = $this->curator->tableName(SchemaCurator::BROWSER_VERSION_TABLE); $platform_table = $this->curator->tableName(SchemaCurator::PLATFORM_TABLE); $session_table = $this->curator->tableName(SchemaCurator::SESSION_TABLE); $period = '4 HOUR'; $sql = "SELECT total_visits.count t, unique_visits.count u, total_visits.time_interval i FROM (\n\t\t\tSELECT COUNT(*) count, DATE_SUB(DATE_SUB(datetime, INTERVAL MOD(MINUTE(datetime), 5) MINUTE), INTERVAL SECOND(datetime) SECOND) time_interval\n\t\t\tFROM {$visit_table}\n\t\t\tWHERE datetime > NOW() - INTERVAL {$period}\n\t\t\tGROUP BY time_interval\n\t\t) total_visits LEFT OUTER JOIN (\n\t\t\tSELECT COUNT(*) count, DATE_SUB(DATE_SUB(datetime, INTERVAL MOD(MINUTE(datetime), 5) MINUTE), INTERVAL SECOND(datetime) SECOND) time_interval\n\t\t\tFROM {$visit_table}\n\t\t\tWHERE datetime > NOW() - INTERVAL {$period}\n\t\t\tAND is_unique\n\t\t\tGROUP BY time_interval\n\t\t) unique_visits\n\t\tON unique_visits.time_interval = total_visits.time_interval"; $data = []; $dt = new \DateTime(); $dt->setTimestamp(ceil(time() / 300) * 300); for ($i = 0; $i <= 60 * 4 / 5; $i++) { $time = $dt->sub(new \DateInterval("PT5M"))->format('H:i'); $data[$time] = [$time, 0, 0]; } $stmt = $this->db->query($sql); while ($row = $stmt->fetch()) { $time = new \DateTime($row['i']); $data[$time->format('H:i')] = [$time->format('H:i'), (int) $row['t'], (int) $row['u']]; } $sql = "SELECT visit.id, address, host, path, referer, browser, browser_version,\n\t\t\tplatform, session_id, verb, port, memory, generate, is_unique, datetime, status\n\t\tFROM {$visit_table} visit\n\t\tINNER JOIN {$address_table} address ON visit.address_id = address.id\n\t\tINNER JOIN {$host_table} host ON visit.host_id = host.id\n\t\tINNER JOIN {$path_table} path ON visit.path_id = path.id\n\t\tINNER JOIN {$referer_table} referer ON visit.referer_id = referer.id\n\t\tINNER JOIN {$browser_table} browser ON visit.browser_id = browser.id\n\t\tINNER JOIN {$browser_version_table} browser_version ON visit.browser_version_id = browser_version.id\n\t\tINNER JOIN {$platform_table} platform ON visit.platform_id = platform.id\n\t\tORDER BY visit.id DESC\n\t\tLIMIT 20"; $visits = $this->db->query($sql)->fetchAll(); return parent::response($template_params += ['archive' => array_values(array_reverse($data)), 'visits' => $visits, 'referers' => $this->db->query("SELECT * FROM {$referer_table} WHERE referer != '' ORDER BY id DESC LIMIT 10")->fetchAll()]); }
public function response() { $tables = []; if ($this->da) { foreach ($this->da->schema->tables as $table) { $tables[] = ['table' => $table, 'rows' => $this->da->count($table)]; } } $folders = []; self::recurseWritableFolders($this->fi, $folders); return parent::response(['tables' => $tables, 'folders' => $folders]); }
public function response(array $template_params = []) { return parent::response(['login_attempted' => $this->login_attempted, 'login_attempted_token' => $this->login_attempted_token, 'needs_token' => $this->needs_token, 'username' => $this->username, 'password' => $this->password]); }
public function response(array $template_params = []) { return parent::response($template_params + ['folder' => $this->folder]); }
public function response($template_params = []) { return parent::response($template_params + ['table' => $this->table]); }