count('category'); $stats['count_site'] = $DB->count('site'); $stats['count_apply'] = $DB->count('apply', array('reject' => 0)); $stats['count_apply_reject'] = $DB->count('apply', array('reject' => 1)); $stats['count_article'] = $DB->count('article'); $stats['count_article_category'] = $DB->count('article_category'); $stats['count_notice'] = $DB->count('notice'); $stats['count_link'] = $DB->count('link'); $stats['count_tags'] = 131; $top_hits_day = $DB->find('site', 'id, name', array('date' => date("Y-m-d", time())), '`hits_day` desc'); $top_hits_month = $DB->find('site', 'id, name', array('datem' => date("Y-m", time())), '`hits_month` desc'); $top_hits_total = $DB->find('site', 'id, name', null, '`hits_total` desc'); $top_like = $DB->find('site', 'id, name', null, '`like` desc'); $cumulative_hits_result = $DB->query("SELECT SUM(hits_total) as total FROM pre_site")->fetch(); $cumulative_likes_result = $DB->query("SELECT SUM(`like`) as total FROM pre_site")->fetch(); $stats['cumulative_hits'] = $cumulative_hits_result['total'] ?? 0; $stats['cumulative_likes'] = $cumulative_likes_result['total'] ?? 0; $stats['top_hits_day'] = $top_hits_day ? [ 'id' => $top_hits_day['id'], 'name' => $top_hits_day['name'] ] : null; $stats['top_hits_month'] = $top_hits_month ? [ 'id' => $top_hits_month['id'], 'name' => $top_hits_month['name'] ] : null; $stats['top_hits_total'] = $top_hits_total ? [ 'id' => $top_hits_total['id'], 'name' => $top_hits_total['name'] ] : null; $stats['top_like'] = $top_like ? [ 'id' => $top_like['id'], 'name' => $top_like['name'] ] : null; $stats['build_time'] = $conf['build_time'] ?? ''; echo json_encode([ 'ok' => true, 'data' => $stats, 'timestamp' => time() ], JSON_UNESCAPED_UNICODE); } catch (Exception $e) { echo json_encode([ 'ok' => false, 'error' => $e->getMessage() ], JSON_UNESCAPED_UNICODE); }