ProjectsAdminDashboard.class.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. class ProjectsAdminDashboard {
  3. public function display() {
  4. //http://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-s3.html
  5. $database = SqliteDatabase::getSingleton();
  6. $projects = $database->queryArray("SELECT rowid AS project_id, * FROM projects;");
  7. foreach($projects as $index => $project) {
  8. $accounts = $database->queryArray("SELECT accounts.rowid as client_id, subdomain, display_name FROM account_projects JOIN accounts ON accounts.rowid = account_projects.account_id WHERE project_id = " . $project['project_id']. ";");
  9. foreach($accounts as $account) {
  10. $projects[$index]['clients'][] = $account;
  11. }
  12. }
  13. $resumeProjectId = $_GET['resume'] ?? null;
  14. $data = array();
  15. $data['sectionName'] = "Data";
  16. $data['displayName'] = $_SESSION['display_name'];
  17. $data['buckets'] = array(
  18. "ccld-us-east" => "us-east-north-virginia",
  19. "ccld-us-mid" => "us-east-ohio",
  20. "ccld-us-west" => "us-west-north-california",
  21. "ccld-us-pnw" => "us-west-oregon",
  22. "ccld-test" => "ccld-test",
  23. "ccld-public-test" => "ccld-public-test",
  24. );
  25. $data['projects'] = $projects;
  26. $data['resume'] = $resumeProjectId;
  27. $data['superadmin'] = $_SESSION['superadmin'] ?? false;
  28. $abandonedUploads = new GetAbandonedUploads();
  29. $data['abandoned_uploads'] = $abandonedUploads->get();
  30. $sql = "select count(ul.rowid) as count, p.display_name as project_name, ul.uploadtime, u.display_name as user_name, u.username FROM upload_logs ul JOIN users u ON ul.user_id = u.rowid JOIN projects p on ul.project_id = p.rowid GROUP BY (uploadtime);";
  31. $uploads = $database->queryArray($sql);
  32. $data['active_uploads'] = $uploads;
  33. return (new View())->render("admin/data.php", $data);
  34. }
  35. }