Skip to content
This repository was archived by the owner on May 11, 2025. It is now read-only.

Commit 3eb5be2

Browse files
committed
fix
1 parent 2a268eb commit 3eb5be2

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

app/error.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
include 'utils.php';
2+
include_once 'utils.php';
33
$dark = isset($_GET['theme']) && $_GET['theme'] === 'dark';
44

55
$header = $dark ? "#fff" : "#434d58";

app/repo.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
$repo = get('repo', 'code-statistic');
77

88
$stats = fetch("repo/$username/$repo");
9-
echo $stats->color;
9+
if (!$stats) {
10+
include 'error.php';
11+
exit;
12+
}
1013
$header = $dark ? "#fff" : "#434d58";
1114
$background = $dark ? "#000" : "#fffefe";
1215

16+
$bar = count($stats->languages);
17+
echo $bar;
1318
ob_start('compress');
1419
?>
1520
<% const left = Math.ceil(langs.length / 2); const height = 215 + (left > 4 ? (left - 4) * 20 : 0) %>

app/utils.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
header('Content-Type: image/svg+xml');
2+
//header('Content-Type: image/svg+xml');
33
header('Cache-Control: no-cache');
44

55
function compress($buffer)
@@ -19,8 +19,9 @@ function fetch($uri)
1919
);
2020

2121
$context = stream_context_create($opts);
22-
$response = file_get_contents("http://localhost:8080/api/" . $uri, false, $context);
23-
return json_decode($response);
22+
$response = @file_get_contents("http://localhost:8080/api/" . $uri, false, $context);
23+
$ok = $response !== false;
24+
return $ok ? json_decode($response, true) : null;
2425
}
2526

2627
function get($param, $default = null)

0 commit comments

Comments
 (0)