diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d0b5277d40ade47e8c8aae40f784f25b9ff317..0877608f40c0916532c41f3d02153ff24713ca7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic ## [Unreleased] ### Added +- Added bootstrapping to simplify initialisation of config and database +- Config syntax has changed to array style (#155) +- Added `pghost` config to set database port +- Added `CONTRIBUTING.md` ### Changed - Introduce proper changelog format (#189) - Moved DB migration scripts into `db` folder diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..c9f1111bca691db6b72146869ca6fab19ebc2177 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# How To Contribute + +## Workflow + +* Fork Git Repo https://git.feneas.org/diasporg/Poduptime +* Pull Git +* Create a topic branch to work from +* Commit and push your branch up +* Create a Merge Request to the develop branch + +## Guidelines + +* Note your changes in [`CHANGELOG.md`] following https://keepachangelog.com +* Create any necessary DB migration script in [`db/migrations`] and note them in the changelog. +* Update [`README.md`] with needed changes +* Update the [Wiki] with API changes +* Write your tests and validate them before you do your MR + +## Coding Style + +* PHP follows [PSR-2] +* CSS follows [CSSLint] +* JS follows [ESLint] + +[`README.md`]: https://git.feneas.org/diasporg/Poduptime/blob/master/README.md +[`CHANGELOG.md`]: https://git.feneas.org/diasporg/Poduptime/blob/master/CHANGELOG.md +[`db/migrations`]: https://git.feneas.org/diasporg/Poduptime/tree/master/db/migrations +[Wiki]: https://git.feneas.org/diasporg/Poduptime/wikis/home +[PSR-2]: https://www.php-fig.org/psr/psr-2/ +[CSSLint]: https://github.com/CSSLint/csslint +[ESLint]: https://eslint.org/docs/rules/ diff --git a/boot.php b/boot.php index 3192cefd25de09fb50fd6588a0f77304b5aa379c..50bf1c48e63cc17b7c8efdde0bb03cc64bdb9183 100644 --- a/boot.php +++ b/boot.php @@ -1,5 +1,11 @@ loadHTMLFile('https://' . $domain); + extract(_curl("https://{$domain}/")); + $outputbody = $curl_body; + ($outputbody ? $d->loadHTML($outputbody) : $d->loadHTML('')); $body = $d->getElementsByTagName('html')->item(0); if ($body) { $ld = new Language; - $detectedlanguage = strtoupper(key($ld->detect($body->nodeValue)->bestResults()->close())); + $detectedlanguage = key($ld->detect($body->nodeValue)->bestResults()->close()); } else { $score -= 1; $detectedlanguage = null; @@ -448,3 +446,24 @@ function _debug($label, $var = null, $dump = false) printf('%s: %s%s', $label, $output, $newline); } + +function _curl($url) +{ + global $cafullpath; + + $chss = curl_init(); + curl_setopt($chss, CURLOPT_URL, $url); + curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($chss, CURLOPT_TIMEOUT, 20); + curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($chss, CURLOPT_CERTINFO, 1); + curl_setopt($chss, CURLOPT_CAINFO, $cafullpath); + return [ + 'curl_body' => curl_exec($chss), + 'curl_error' => curl_error($chss), + 'curl_info' => curl_getinfo($chss, CURLINFO_CERTINFO), + 'curl_conntime' => curl_getinfo($chss, CURLINFO_CONNECT_TIME), + 'curl_nstime' => curl_getinfo($chss, CURLINFO_NAMELOOKUP_TIME) + ]; + curl_close($chss); +} diff --git a/js/podup.js b/js/podup.js index b6939ff24206c7b5888430631c32c77c548c9b91..8bcd37386f4122da05c6c8dafeb17373cbc2bfe9 100644 --- a/js/podup.js +++ b/js/podup.js @@ -38,7 +38,7 @@ $(document).ready(function () { $('table').trigger('filterReset'); }); $('.columnsadvanced').on('click', function () { - $('table').trigger('refreshColumnSelector', ['columns', [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 28]]); + $('table').trigger('refreshColumnSelector', ['columns', [2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 28]]); $('#colSelect1').prop('checked', false); $('.columnSelectorWrapper').show().css('display', 'inline-block'); $('.columnssimple').show().css('display', 'inline-block'); @@ -57,7 +57,7 @@ $(document).ready(function () { if (input) { columns[0] = input; } - columns[7] = 'Y'; + columns[7] = 'Yes'; $('table').trigger('search', [columns]); $('.pagerhidden').delay(900).show(200); $('[data-toggle="tooltip"]').tooltip(); diff --git a/showfull.php b/showfull.php index d1bafe838434491f4a7c9b62f0074bcc7adf8d8e..f668da1ab1a5945e527a4e3cb598f89b849cc428 100644 --- a/showfull.php +++ b/showfull.php @@ -56,11 +56,11 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
Pod
Name
Version
-
Software
+
Software
Uptime
-
IPv6
+ IPv6
Latency
-
Signups
+
Signups
Users
6m
1m
@@ -69,18 +69,18 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
Months
Rating
Score
-
Status
-
DNSSEC
-
Country
+
Status
+
DNSSEC
+
Country
City
State
-
Language
+
Language
Services
-
Facebook
-
Twitter
-
Tumblr
-
Wordpress
-
XMPP
+
Facebook
+
Twitter
+
Tumblr
+
Wordpress
+
XMPP
Info
diff --git a/tabledata.php b/tabledata.php index abe0c679d8c0170260684a5fe81c429a518f48af..6e59eb71a2c2b78f163a2418859a3887456990cc 100644 --- a/tabledata.php +++ b/tabledata.php @@ -57,9 +57,9 @@ foreach ($pods as $pod) { echo '
' . $version . '
'; echo '' . $pod['softwarename'] . ''; echo '' . ($pod['uptime_alltime'] > 0 ? $pod['uptime_alltime'] . '%' : '') . ''; - echo '' . ($pod['ipv6'] ? 'Y' : 'N') . ''; + echo '' . ($pod['ipv6'] ? 'Yes' : 'No') . ''; echo '' . ($pod['latency'] > 0 ? $pod['latency'] : '') . ''; - echo '' . ($pod['signup'] ? 'Y' : 'N') . ''; + echo '' . ($pod['signup'] ? 'Yes' : 'No') . ''; echo '' . ($pod['total_users'] > 0 ? $pod['total_users'] : '') . ''; echo '' . ($pod['active_users_halfyear'] > 0 ? $pod['active_users_halfyear'] : '') . ''; echo '' . ($pod['active_users_monthly'] > 0 ? $pod['active_users_monthly'] : '') . ''; @@ -69,7 +69,7 @@ foreach ($pods as $pod) { echo '' . $pod['userrating'] . ''; echo '
' . $pod['score'] . '
'; echo '
' . PodStatus::getKey((int) $pod['status']) . '
'; - echo '' . ($pod['dnssec'] ? 'Y' : 'N') . ''; + echo '' . ($pod['dnssec'] ? 'Yes' : 'No') . ''; if ($country_code === $pod['country']) { echo '' . $pod['country'] . ''; } else { @@ -77,7 +77,7 @@ foreach ($pods as $pod) { } echo '' . $pod['city'] . ''; echo '' . $pod['state'] . ''; - echo '' . ($pod['detectedlanguage'] ?: '') . ''; + echo '' . ($pod['detectedlanguage'] ? strtoupper($pod['detectedlanguage']) : '') . ''; echo ''; $pod['service_facebook'] && print ''; $pod['service_twitter'] && print ''; @@ -85,11 +85,11 @@ foreach ($pods as $pod) { $pod['service_wordpress'] && print ''; $pod['service_xmpp'] && print ''; echo ''; - echo '' . ($pod['service_facebook'] ? 'Y' : 'N') . ''; - echo '' . ($pod['service_twitter'] ? 'Y' : 'N') . ''; - echo '' . ($pod['service_tumblr'] ? 'Y' : 'N') . ''; - echo '' . ($pod['service_wordpress'] ? 'Y' : 'N') . ''; - echo '' . ($pod['service_xmpp'] ? 'Y' : 'N') . ''; + echo '' . ($pod['service_facebook'] ? 'Yes' : 'No') . ''; + echo '' . ($pod['service_twitter'] ? 'Yes' : 'No') . ''; + echo '' . ($pod['service_tumblr'] ? 'Yes' : 'No') . ''; + echo '' . ($pod['service_wordpress'] ? 'Yes' : 'No') . ''; + echo '' . ($pod['service_xmpp'] ? 'Yes' : 'No') . ''; $podmin_statement = htmlentities($pod['podmin_statement'] ?? '', ENT_QUOTES); echo '' . ($podmin_statement ? '💬' : ' ') . '';