diff --git a/.gitignore b/.gitignore index 2589a98..78aeac6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *_test.env -/.env +.env diff --git a/api/requirements.txt b/api/requirements.txt index b6ea2f5..a18ccfd 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -2,7 +2,7 @@ attrs==21.4.0 click==8.1.2 flasgger==0.9.7.1 Flask==2.2.5 -Flask-Caching==1.10.1 +Flask-Caching==2.3.0 importlib-metadata==4.11.3 importlib-resources==5.7.1 itsdangerous==2.1.2 diff --git a/web/config.php b/web/config.php deleted file mode 100644 index 16ed0b5..0000000 --- a/web/config.php +++ /dev/null @@ -1,8 +0,0 @@ - \ No newline at end of file diff --git a/web/delegationPolicyNew.html b/web/delegationPolicyNew.html deleted file mode 100644 index 42a401f..0000000 --- a/web/delegationPolicyNew.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - Delegation Policy - - - - - - - - - - - -
- -
- - -
- -
-

- o(1) Labs Delegation Policy -

-
- -
- - Block Producer Leaderboard - - - -
- - - -
-
-

We Delegate To You

-
-
-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

- -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

- -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

-
-
- -
-
-

How is Performance Calculated?

-
-
-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

- -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

- -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

-
-
- -
-
-

Apply for Delegation

-
-
-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
-
- - - -
- -
-
-
- - - - - - - \ No newline at end of file diff --git a/web/getPageDataForSnark.php b/web/getPageDataForSnark.php index 38eb5d9..cff4ea0 100644 --- a/web/getPageDataForSnark.php +++ b/web/getPageDataForSnark.php @@ -1,11 +1,8 @@ ['default' => 1, 'min_range' => 1]]) : 1; $perPageCount = 120; @@ -13,43 +10,57 @@ $ignoreApplicationStatus = getenv('IGNORE_APPLICATION_STATUS') == 1; // Modify SQL query based on IGNORE_APPLICATION_STATUS -$sqlCondition = $ignoreApplicationStatus ? "score is not null" : "application_status = true and score is not null"; +$sqlCondition = $ignoreApplicationStatus ? "score IS NOT NULL" : "application_status = TRUE AND score IS NOT NULL"; $sql = "SELECT COUNT(*) FROM nodes WHERE {$sqlCondition}"; - if ($result = pg_query($conn, $sql)) { $row = pg_fetch_row($result); - $rowCount = $row[0]; + $rowCount = (int)$row[0]; pg_free_result($result); } $pagesCount = ceil($rowCount / $perPageCount); - $lowerLimit = ($pageNumber - 1) * $perPageCount; // Use the modified SQL condition for the main query as well $sqlQuery = "SELECT block_producer_key, score, score_percent FROM nodes WHERE {$sqlCondition} ORDER BY score DESC"; +// Execute the main query and sanitize the results $results = pg_query($conn, $sqlQuery); -$row = pg_fetch_all($results); +$row = pg_fetch_all($results); -$maxScoreSnark= " WITH recentone as ( - SELECT batch_end_epoch end_epoch, extract('epoch' FROM (to_timestamp(batch_end_epoch) - interval '90' day )) start_epoch +$maxScoreSnark = " + WITH recentone AS ( + SELECT batch_end_epoch end_epoch, + extract('epoch' FROM (to_timestamp(batch_end_epoch) - interval '90' day)) start_epoch FROM bot_logs b - where file_timestamps <= CURRENT_TIMESTAMP - ORDER BY batch_end_epoch DESC LIMIT 1 - ) - SELECT COUNT(1), to_char(to_timestamp(end_epoch), 'DD-MM-YYYY hh24:mi') as last_modified - FROM bot_logs , recentone - WHERE batch_start_epoch >= start_epoch and batch_end_epoch <= end_epoch - AND files_processed > -1 - group by 2 "; - -$maxScoreSnarkresult = pg_query($conn, $maxScoreSnark); -$maxScoreRow = pg_fetch_row($maxScoreSnarkresult); -$maxScore = $maxScoreRow[0]; -$last_modified=$maxScoreRow[1]; - -echo json_encode(array('row' => $row, 'rowCount' => $rowCount, 'maxScore' => $maxScore, 'last_modified'=>$last_modified)); + WHERE file_timestamps <= CURRENT_TIMESTAMP + ORDER BY batch_end_epoch DESC + LIMIT 1 + ) + SELECT COUNT(1), to_char(to_timestamp(end_epoch), 'DD-MM-YYYY hh24:mi') AS last_modified + FROM bot_logs, recentone + WHERE batch_start_epoch >= start_epoch + AND batch_end_epoch <= end_epoch + AND files_processed > -1 + GROUP BY 2 +"; + +// Execute the query +$maxScoreSnarkResult = pg_query($conn, $maxScoreSnark); +$maxScoreRow = pg_fetch_row($maxScoreSnarkResult); + +// Sanitize database output before using it +$maxScore = (int)$maxScoreRow[0]; +$last_modified = htmlspecialchars($maxScoreRow[1], ENT_QUOTES, 'UTF-8'); + +// Ensure to sanitize the JSON output +foreach ($row as &$r) { + $r['block_producer_key'] = htmlspecialchars($r['block_producer_key'], ENT_QUOTES, 'UTF-8'); + $r['score'] = (float)$r['score']; + $r['score_percent'] = (float)$r['score_percent']; +} + +echo json_encode(array('row' => $row, 'rowCount' => $rowCount, 'maxScore' => $maxScore, 'last_modified' => $last_modified)); ?> diff --git a/web/imageDesign.html b/web/imageDesign.html deleted file mode 100644 index c2618e0..0000000 --- a/web/imageDesign.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - Image Design - - - - - - - - - - -
-
- - - - - - -
-

O(1) Labs is using cryptography and cryptocurrency to build computing systems that put people back in control of their digital lives.

-
- - - -
-

Projects

-
- -
- - - - -
-
-
-
-

Mina is the world's lightest blockchain, powered by participants

-
- -
-
-
-
-
-

Snarky is an Ocaml front-end for writing R1CS SNARKs.

-
- -
-
- - -
-
-
San Francisco, USA
-
@2018
-
-
-
- - - - - \ No newline at end of file diff --git a/web/performance tracker New.html b/web/performance tracker New.html deleted file mode 100644 index 9705294..0000000 --- a/web/performance tracker New.html +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - Performance Tracker - - - - - - - - - - -
-
- -
-
-

Block Producer Delegation Performance Tracker

-
- - - -
- - -
- -
-
-
-
- - -
- - - -
-
-
-
-
- -
- -
-
-
- -
-
- -
-
-
-
- -
- - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RANKPUBLIC KEY60 Day Uptime Performance SCORE
01LorumIpsum#123499.999%
02Matt Harrop / Figment Network#123499.999%
03LorumIpsum#123499.999%
04Matt Harrop / Figment Network#123499.999%
05LorumIpsum#123499.999%
06Matt Harrop / Figment Network#123499.999%
07LorumIpsum#123499.999%
08Matt Harrop / Figment Network#123499.999%
09LorumIpsum#123499.999%
10Matt Harrop / Figment Network#123499.999%
11LorumIpsum#123499.999%
12Matt Harrop / Figment Network#123499.999%
13LorumIpsum#123499.999%
14Matt Harrop / Figment Network#123499.999%
15LorumIpsum#123499.999%
16Matt Harrop / Figment Network#123499.999%
17LorumIpsum#123499.999%
18Matt Harrop / Figment Network#123499.999%
19LorumIpsum#123499.999%
-
-
- - - - - - - \ No newline at end of file diff --git a/web/policyInfoNewDesign.html b/web/policyInfoNewDesign.html deleted file mode 100644 index 66954b9..0000000 --- a/web/policyInfoNewDesign.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - Policy Info - - - - - - - - - - -
-
- -
-
-

Block Producer Delegation Performance Tracker

-
- - - -
-
- -
-
-
- -
- - - - - - - - -
-

Mina Foundation & o(1) Labs Delegation Policy

-
-
-
-

We Delegate To You

-
-
-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

- -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

- -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

-
-
- -
-
-

How is Performance Calculated?

-
-
-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

- -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

- -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

-
-
-
-
-

Apply for Delegation

-
-
-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
-
- - - - -
- -
-
-
- -
- - - -
- - - - - \ No newline at end of file diff --git a/web/response.php b/web/response.php deleted file mode 100644 index cee38b4..0000000 --- a/web/response.php +++ /dev/null @@ -1,21 +0,0 @@ -getConnstring(); - $this->conn = $connString; - } - - - public function getBlockesData() { - $sql = "SELECT * FROM node_record_table LIMIT 20"; - $queryRecords = pg_query($this->conn, $sql) or die("error to fetch Blocks data"); - $data = pg_fetch_all($queryRecords); - return $data; - } -} -?> \ No newline at end of file diff --git a/web/showDataForTabOne.php b/web/showDataForTabOne.php index d8dcb5f..fb1621c 100644 --- a/web/showDataForTabOne.php +++ b/web/showDataForTabOne.php @@ -1,99 +1,98 @@ $row) { + // Remove any keys that are not in the allowedRowKeys whitelist + $rowData[$key] = array_intersect_key($row, array_flip($allowedRowKeys)); + + // Sanitize each value in the row + $rowData[$key]['block_producer_key'] = isset($rowData[$key]['block_producer_key']) ? htmlspecialchars($rowData[$key]['block_producer_key'], ENT_QUOTES, 'UTF-8') : ''; + $rowData[$key]['score'] = isset($rowData[$key]['score']) ? (float)$rowData[$key]['score'] : 0; + $rowData[$key]['score_percent'] = isset($rowData[$key]['score_percent']) ? (float)$rowData[$key]['score_percent'] : 0; +} + +if ($SearchInputData !== null) { $newArray = array(); - foreach ($rowData as $key => $rowDataKey){ - if(stripos((strtolower($rowDataKey['block_producer_key'])),$SearchInputData) !== false) { - //array_push($newArray, $rowDataKey); + foreach ($rowData as $key => $rowDataKey) { + if (stripos(strtolower($rowDataKey['block_producer_key']), $SearchInputData) !== false) { $rowDataKey['index'] = $key + 1; $newArray[$key] = $rowDataKey; } } - $rowData = $newArray ; + $rowData = $newArray; $rowCount = count($newArray); - //$maxScore =count($newArray); $pagesCount = ceil($rowCount / $perPageCount); } -$row = array_slice($rowData,$pagestart,$perPageCount); + +$row = array_slice($rowData, $pagestart, $perPageCount); $counter = $lowerLimit + 1; -// $console = 'console.log(' . json_encode($SearchInputData) . ');'; -// echo $console; ?>

Results Per Page

- - + - Last updated + Last updated
@@ -106,90 +105,79 @@ RANK PUBLIC KEY - + SCORE(90-Day) - - %(Max Score ) + + %(Max Score ) - +

Under Maintenance

- $data) { - - ?> + $data) { ?> - - - - - - % + + + + + + % - + + -
+

Results Per Page

- - +
  • - Prev
  • + Prev
  • - 1 + 1
  • - 2 + 2
  • . - 2 && ($pageNumber <($pagesCount-1))) { ?> - - + 2 && ($pageNumber <($pagesCount-1))) { ?> + .
  • - +
  • - +
  • - Next + Next
@@ -202,5 +190,3 @@
- - diff --git a/web/uptime Leadeboard New.html b/web/uptime Leadeboard New.html deleted file mode 100644 index c10f6fc..0000000 --- a/web/uptime Leadeboard New.html +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - Uptime Leaderboard - - - - - - - - - - -
- - -
- -
-
-
-

Block Producer Delegation Performance Tracker

-
-
- - - -
-
-
- -
-
-
- -
- -
- - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RANKPUBLIC KEY60 Day Uptime Performance SCORE
010xR4fgsdtw4efggggfgdf3fg899.999%
020xR4fgsdtw4efggggfgdf3fg899.999%
030xR4fgsdtw4efggggfgdf3fg899.999%
040xR4fgsdtw4efggggfgdf3fg899.999%
050xR4fgsdtw4efggggfgdf3fg899.999%
060xR4fgsdtw4efggggfgdf3fg899.999%
070xR4fgsdtw4efggggfgdf3fg899.999%
080xR4fgsdtw4efggggfgdf3fg899.999%
090xR4fgsdtw4efggggfgdf3fg899.999%
100xR4fgsdtw4efggggfgdf3fg899.999%
110xR4fgsdtw4efggggfgdf3fg899.999%
120xR4fgsdtw4efggggfgdf3fg899.999%
130xR4fgsdtw4efggggfgdf3fg899.999%
140xR4fgsdtw4efggggfgdf3fg899.999%
150xR4fgsdtw4efggggfgdf3fg899.999%
160xR4fgsdtw4efggggfgdf3fg899.999%
170xR4fgsdtw4efggggfgdf3fg8Collecting Data
180xR4fgsdtw4efggggfgdf3fg8Collecting Data
190xR4fgsdtw4efggggfgdf3fg8Collecting Data
-
-
- - - - - \ No newline at end of file