Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Poduptime
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
diasporg
Poduptime
Commits
c81adfbb
Commit
c81adfbb
authored
Aug 06, 2018
by
dmorley
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'noplanman/Poduptime-181-improved_config_and_boot' into develop
parents
ac3b6a00
dd65a7f7
Changes
25
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
229 additions
and
253 deletions
+229
-253
Changelog.md
Changelog.md
+67
-0
api.php
api.php
+1
-9
boot.php
boot.php
+49
-0
config.php.example
config.php.example
+29
-24
db/add.php
db/add.php
+11
-23
db/api-more.php
db/api-more.php
+1
-9
db/backup.php
db/backup.php
+8
-8
db/edit.php
db/edit.php
+3
-9
db/gettoken.php
db/gettoken.php
+4
-11
db/monthly_stats.php
db/monthly_stats.php
+2
-10
db/podcrawler.php
db/podcrawler.php
+1
-9
db/pull-masterversions.php
db/pull-masterversions.php
+9
-18
db/pull.php
db/pull.php
+6
-13
db/pull.sh
db/pull.sh
+2
-2
db/saverating.php
db/saverating.php
+1
-9
db/status.php
db/status.php
+1
-1
go.php
go.php
+1
-9
index.php
index.php
+25
-26
podstat-counts.php
podstat-counts.php
+1
-9
podstat-uptime.php
podstat-uptime.php
+1
-9
rate.php
rate.php
+1
-8
showmap.php
showmap.php
+2
-10
statsviewjs.php
statsviewjs.php
+1
-9
tabledata.php
tabledata.php
+1
-9
wizard.php
wizard.php
+1
-9
No files found.
Changelog.md
0 → 100644
View file @
c81adfbb
# 2.4.0
## Backend
*
Added bootstrapping to simplify initialisation of config and database
*
Config syntax has changed to array style
*
Added
`pghost`
config to set database port
# 2.3.1
## End Users
*
Now one table with a basic default view you can customize https://git.feneas.org/diasporg/Poduptime/issues/171
*
Wizard to help you filter the columns to what you need https://git.feneas.org/diasporg/Poduptime/issues/145
## Podmins
*
Can link directly to your pod via https://podupti.me/domain.name for stats and to allow users to rate easier
# 2.3.0
## Podmins
*
Can no longer access db/pull.php to test their pod, they can however get to a debug screen from the edit pod area
*
Language is detected based on your homepage, edit your homepage to non-en if that is what you use
*
Edit will send to email on file and be less delay, runner of site does not really have anyway to verify email address
## DB
*
Add development and release dates to masterversions table https://git.feneas.org/diasporg/Poduptime/issues/143
*
Store full country name, store days monitored each pod https://git.feneas.org/diasporg/Poduptime/issues/150
*
Store detectedlanguage https://git.feneas.org/diasporg/Poduptime/issues/144
*
DB migrations see db/version.md
*
rename table rating_comments to ratingcomments for redbean support https://git.feneas.org/diasporg/Poduptime/issues/146
*
Default new pods to UP to be checked
*
Remove unused hidden and secure columns https://git.feneas.org/diasporg/Poduptime/issues/141 https://git.feneas.org/diasporg/Poduptime/issues/140
## Cleanup
*
Use the git API for release versions, check development releases on pods https://git.feneas.org/diasporg/Poduptime/issues/143
*
Forbid access to files that should be cli only https://git.feneas.org/diasporg/Poduptime/issues/152
*
Move from bower to yarn for packages https://bower.io/blog/2017/how-to-migrate-away-from-bower/
*
Move to PHP 7.2 with declare(strict_types=1);
*
Move to Eslint compliance https://eslint.org/docs/rules/
*
Move to PSR-2 compliance https://www.php-fig.org/psr/psr-2/
*
NOTE config.php.example change to full paths for 2 items!
## End Users
*
Show version and update in full view cleaner https://git.feneas.org/diasporg/Poduptime/issues/143
*
Filter and search on the columns of data https://git.feneas.org/diasporg/Poduptime/issues/147
*
Paginate the results so they fit per page https://git.feneas.org/diasporg/Poduptime/issues/147
*
Show time as human readable everywhere https://git.feneas.org/diasporg/Poduptime/issues/150
# 2.2.0
## Podmins
*
Can now pause/unpause or delete from podmin area
## End Users
*
go.php auto select picks a more stable pod than before
*
Graph on user growth on the network
*
Make map prettier
*
Use lines on tables to make them more readable
## Cleanup
*
Don't delete dead pods, keep them and data for history hide them for users
*
Put daily tasks in the pull.sh and run each day
*
Fix ipv6
## DB
*
Add monthly stats table
*
Update status to 1-5 rather than text
*
Two migrations for this version update see db/version.md
api.php
View file @
c81adfbb
...
...
@@ -15,15 +15,7 @@ $_format = $_GET['format'] ?? '';
$_method
=
$_GET
[
'method'
]
??
''
;
$_callback
=
$_GET
[
'callback'
]
??
''
;
require_once
__DIR__
.
'/vendor/autoload.php'
;
require_once
__DIR__
.
'/config.php'
;
define
(
'PODUPTIME'
,
microtime
(
true
));
// Set up global DB connection.
R
::
setup
(
"pgsql:host=
{
$pghost
}
;dbname=
{
$pgdb
}
"
,
$pguser
,
$pgpass
,
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
require_once
__DIR__
.
'/boot.php'
;
if
(
$_format
===
'georss'
)
{
echo
<<<EOF
...
...
boot.php
0 → 100644
View file @
c81adfbb
<?php
use
RedBeanPHP\R
;
/**
* Helper to get config values.
*
* @param null|string $param
* @param null|mixed $default
*
* @return mixed|null
*/
function
c
(
string
$param
=
null
,
$default
=
null
)
{
static
$config
;
if
(
$config
===
null
)
{
$config
=
require
__DIR__
.
'/config.php'
;
is_array
(
$config
)
||
die
(
'Invalid config format.'
);
}
if
(
$param
===
null
)
{
return
$config
;
}
if
(
array_key_exists
(
$param
,
$config
))
{
return
$config
[
$param
];
}
return
$default
;
}
define
(
'PODUPTIME'
,
microtime
(
true
));
require_once
__DIR__
.
'/vendor/autoload.php'
;
// Set up global DB connection.
R
::
setup
(
sprintf
(
'pgsql:host=%s;port=%d;dbname=%s'
,
c
(
'pghost'
),
c
(
'pgport'
,
5432
),
c
(
'pgdb'
)
),
c
(
'pguser'
),
c
(
'pgpass'
),
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
config.php.example
View file @
c81adfbb
...
...
@@ -4,38 +4,43 @@
* Config for Poduptime.
*/
//backup directory - full dir path
$backup_dir
=
__DIR__
.
'/backup'
;
return
[
//backup directory - full dir path
'backup_dir'
=>
__DIR__
.
'/backup'
,
//log directory - full dir path
$log_dir
=
__DIR__
.
'/log'
;
//log directory - full dir path
'log_dir'
=>
__DIR__
.
'/log'
,
//location of pg dump - full dir path
$pg_dump_dir
=
'/usr/bin'
;
//location of pg dump - full dir path
'pg_dump_dir'
=>
'/usr/bin'
,
//db host
$pghost
=
'localhost'
;
//db host
'pghost'
=>
'localhost'
,
//db username
$pguser
=
''
;
//db port
'pgport'
=>
5432
,
//db password
$pgpass
=
''
;
//db username
'pguser'
=>
''
,
//db name
$pgdb
=
''
;
//db password
'pgpass'
=>
''
,
//admin email for forms
$adminemail
=
''
;
//db name
'pgdb'
=>
''
,
//DNS server for dnssec testing. 1.1.1.1 tests the best
$dnsserver
=
''
;
//admin email for forms
'adminemail'
=>
''
,
//CA for curl to use - full file path (pull.sh will update this monthly)
$cafullpath
=
''
;
//DNS server for dnssec testing. 1.1.1.1 tests the best
'dnsserver'
=>
''
,
//Mapbox.com API key. https://www.mapbox.com/help/how-access-tokens-work/
$mapboxkey
=
''
;
//CA for curl to use - full file path (pull.sh will update this monthly)
'cafullpath'
=>
''
,
//Geolite2-city database file in mmdb format - full file path (pull.sh will update this monthly)
$geoip2db
=
''
;
//Mapbox.com API key. https://www.mapbox.com/help/how-access-tokens-work/
'mapboxkey'
=>
''
,
//Geolite2-city database file in mmdb format - full file path (pull.sh will update this monthly)
'geoip2db'
=>
''
,
];
db/add.php
View file @
c81adfbb
...
...
@@ -8,21 +8,9 @@ declare(strict_types=1);
use
RedBeanPHP\R
;
require_once
__DIR__
.
'/../vendor/autoload.php'
;
require_once
__DIR__
.
'/../config.php'
;
require_once
__DIR__
.
'/../boot.php'
;
define
(
'PODUPTIME'
,
microtime
(
true
));
// Set up global DB connection.
R
::
setup
(
"pgsql:host=
{
$pghost
}
;dbname=
{
$pgdb
}
"
,
$pguser
,
$pgpass
,
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
if
(
!
(
$_domain
=
$_GET
[
'domain'
]
??
null
))
{
die
(
'no pod domain given'
);
}
(
$_domain
=
$_GET
[
'domain'
]
??
null
)
||
die
(
'no pod domain given'
);
// Other parameters.
$_email
=
$_GET
[
'email'
]
??
''
;
...
...
@@ -43,6 +31,7 @@ try {
die
(
'Error in SQL query: '
.
$e
->
getMessage
());
}
$stop
=
false
;
foreach
(
$pods
as
$pod
)
{
if
(
$pod
[
'domain'
]
===
$_domain
)
{
if
(
$pod
[
'email'
])
{
...
...
@@ -85,12 +74,11 @@ foreach ($pods as $pod) {
</form>
EOF;
$stop
=
1
;
$stop
=
true
;
}
}
if
(
!
$stop
)
{
$link
=
'https://'
.
$_domain
.
'/nodeinfo/1.0'
;
if
(
$infos
=
file_get_contents
(
'https://'
.
$_domain
.
'/.well-known/nodeinfo'
))
{
$info
=
json_decode
(
$infos
,
true
);
...
...
@@ -126,7 +114,7 @@ if (!$stop) {
}
if
(
$_email
)
{
$to
=
$adminemail
;
$to
=
c
(
'adminemail'
)
;
$subject
=
'New pod added to '
.
$_SERVER
[
'HTTP_HOST'
];
$headers
=
[
'From: '
.
$_email
,
'Reply-To: '
.
$_email
,
'Cc: '
.
$_email
];
...
...
db/api-more.php
View file @
c81adfbb
...
...
@@ -15,15 +15,7 @@ use RedBeanPHP\R;
// Other parameters.
$_format
=
$_GET
[
'format'
]
??
''
;
require_once
__DIR__
.
'/../vendor/autoload.php'
;
require_once
__DIR__
.
'/../config.php'
;
define
(
'PODUPTIME'
,
microtime
(
true
));
// Set up global DB connection.
R
::
setup
(
"pgsql:host=
{
$pghost
}
;dbname=
{
$pgdb
}
"
,
$pguser
,
$pgpass
,
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
require_once
__DIR__
.
'/../boot.php'
;
try
{
$pod
=
R
::
getRow
(
'
...
...
db/backup.php
View file @
c81adfbb
...
...
@@ -11,19 +11,19 @@ if (PHP_SAPI !== 'cli') {
exit
;
}
require_onc
e
__DIR__
.
'/../config.php'
;
$c
=
requir
e
__DIR__
.
'/../config.php'
;
$keep
=
(
60
*
60
*
6
)
*
1
;
$dump_date
=
date
(
'Ymd_Hs'
);
$file_name
=
$backup_dir
.
'/dump_'
.
$dump_date
.
'.sql'
;
system
(
"export PGPASSWORD=
$pgpass
&&
$pg_dump_dir
/pg_dump --clean --format=tar --username=
$pguser
$pgdb
>>
$file_name
"
);
echo
"pg backup of
$pgdb
made"
;
$dirh
=
dir
(
$
backup_dir
);
$file_name
=
"
{
$c
[
'backup_dir'
]
}
/dump_
{
$dump_date
}
.sql"
;
system
(
"export PGPASSWORD=
{
$c
[
'pgpass'
]
}
&&
{
$c
[
'pg_dump_dir'
]
}
/pg_dump --clean --format=tar --username=
{
$c
[
'pguser'
]
}
{
$c
[
'pgdb'
]
}
>>
{
$file_name
}
"
);
echo
"pg backup of
{
$c
[
'pgdb'
]
}
made"
;
$dirh
=
dir
(
$
c
[
'backup_dir'
]
);
while
(
$entry
=
$dirh
->
read
())
{
$old_file_time
=
(
date
(
'U'
)
-
$keep
)
;
$file_created
=
filectime
(
"
$backup_dir
/
$entry
"
);
$old_file_time
=
date
(
'U'
)
-
$keep
;
$file_created
=
filectime
(
"
{
$c
[
'backup_dir'
]
}
/
{
$entry
}
"
);
if
(
$file_created
<
$old_file_time
&&
!
is_dir
(
$entry
))
{
if
(
unlink
(
"
$backup_dir
/
$entry
"
))
{
if
(
unlink
(
"
{
$c
[
'backup_dir'
]
}
/
{
$entry
}
"
))
{
echo
'Cleaned up old backups'
;
}
}
...
...
db/edit.php
View file @
c81adfbb
...
...
@@ -22,13 +22,7 @@ $_email = $_GET['email'] ?? '';
$_podmin_statement
=
$_GET
[
'podmin_statement'
]
??
''
;
$_podmin_notify
=
$_GET
[
'podmin_notify'
]
??
0
;
require_once
__DIR__
.
'/../vendor/autoload.php'
;
require_once
__DIR__
.
'/../config.php'
;
// Set up global DB connection.
R
::
setup
(
"pgsql:host=
{
$pghost
}
;dbname=
{
$pgdb
}
"
,
$pguser
,
$pgpass
,
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
require_once
__DIR__
.
'/../boot.php'
;
try
{
$pod
=
R
::
findOne
(
'pods'
,
'domain = ?'
,
[
$_domain
]);
...
...
@@ -89,7 +83,7 @@ if ('save' === $_action) {
}
$to
=
$_email
;
$headers
=
[
'From: '
.
$adminemail
,
'Cc: '
.
$pod
[
'email'
],
'Bcc: '
.
$adminemail
];
$headers
=
[
'From: '
.
c
(
'adminemail'
),
'Cc: '
.
$pod
[
'email'
],
'Bcc: '
.
c
(
'adminemail'
)
];
$subject
=
'Edit notice from poduptime'
;
$message
=
'Data for '
.
$_domain
.
' updated. If it was not you reply and let me know!'
;
@
mail
(
$to
,
$subject
,
$message
,
implode
(
"
\r\n
"
,
$headers
));
...
...
db/gettoken.php
View file @
c81adfbb
...
...
@@ -14,14 +14,7 @@ use RedBeanPHP\R;
// Other parameters.
$_email
=
$_GET
[
'email'
]
??
''
;
require_once
__DIR__
.
'/../vendor/autoload.php'
;
require_once
__DIR__
.
'/../config.php'
;
// Set up global DB connection.
R
::
setup
(
"pgsql:host=
{
$pghost
}
;dbname=
{
$pgdb
}
"
,
$pguser
,
$pgpass
,
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
require_once
__DIR__
.
'/../boot.php'
;
try
{
$pod
=
R
::
findOne
(
'pods'
,
'domain = ?'
,
[
$_domain
]);
...
...
@@ -33,7 +26,7 @@ try {
// Set up common variables.
$uuid
=
md5
(
uniqid
(
$_domain
,
true
));
$link
=
sprintf
(
'https://%1$s/?edit&domain=%2$s&token=%3$s'
,
$_SERVER
[
'HTTP_HOST'
],
$_domain
,
$uuid
);
$headers
=
[
'From: '
.
$adminemail
];
$headers
=
[
'From: '
.
c
(
'adminemail'
)
];
$message_lines
=
[];
if
(
$_email
)
{
...
...
@@ -41,7 +34,7 @@ if ($_email) {
$to
=
$_email
;
$subject
=
'Temporary edit key for '
.
$_SERVER
[
'HTTP_HOST'
];
$headers
[]
=
'Bcc: '
.
$adminemail
;
$headers
[]
=
'Bcc: '
.
c
(
'adminemail'
)
;
$expire
=
time
()
+
8700
;
$output
=
'Link sent to your email.'
;
}
elseif
(
!
$pod
[
'email'
])
{
...
...
@@ -49,7 +42,7 @@ if ($_email) {
}
else
{
$to
=
$pod
[
'email'
];
$subject
=
'Temporary edit key for '
.
$_SERVER
[
'HTTP_HOST'
];
$headers
[]
=
'Bcc: '
.
$adminemail
;
$headers
[]
=
'Bcc: '
.
c
(
'adminemail'
)
;
$message_lines
[]
=
'Looks like you did not enter your email address, be sure to update it if you forgot the one we have for you.'
;
$message_lines
[]
=
'Email found: '
.
$pod
[
'email'
];
$expire
=
time
()
+
8700
;
...
...
db/monthly_stats.php
View file @
c81adfbb
...
...
@@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') {
use
RedBeanPHP\R
;
require_once
__DIR__
.
'/../vendor/autoload.php'
;
require_once
__DIR__
.
'/../config.php'
;
define
(
'PODUPTIME'
,
microtime
(
true
));
// Set up global DB connection.
R
::
setup
(
"pgsql:host=
{
$pghost
}
;dbname=
{
$pgdb
}
"
,
$pguser
,
$pgpass
,
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
require_once
__DIR__
.
'/../boot.php'
;
try
{
$monthly_totals
=
R
::
getAll
(
"
...
...
@@ -39,8 +31,8 @@ try {
}
catch
(
\RedBeanPHP\RedException
$e
)
{
die
(
'Error in SQL query: '
.
$e
->
getMessage
());
}
foreach
(
$monthly_totals
as
$monthly
)
{
foreach
(
$monthly_totals
as
$monthly
)
{
// Format date to timestamp.
$timestamp
=
$monthly
[
'yymm'
]
.
'-01 01:01:01-01'
;
...
...
db/podcrawler.php
View file @
c81adfbb
...
...
@@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') {
use
RedBeanPHP\R
;
require_once
__DIR__
.
'/../vendor/autoload.php'
;
require_once
__DIR__
.
'/../config.php'
;
define
(
'PODUPTIME'
,
microtime
(
true
));
// Set up global DB connection.
R
::
setup
(
"pgsql:host=
{
$pghost
}
;dbname=
{
$pgdb
}
"
,
$pguser
,
$pgpass
,
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
require_once
__DIR__
.
'/../boot.php'
;
try
{
$sql
=
'
...
...
db/pull-masterversions.php
View file @
c81adfbb
...
...
@@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') {
use
RedBeanPHP\R
;
require_once
__DIR__
.
'/../vendor/autoload.php'
;
require_once
__DIR__
.
'/../config.php'
;
define
(
'PODUPTIME'
,
microtime
(
true
));
// Set up global DB connection.
R
::
setup
(
"pgsql:host=
{
$pghost
}
;dbname=
{
$pgdb
}
"
,
$pguser
,
$pgpass
,
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
require_once
__DIR__
.
'/../boot.php'
;
$softwares
=
[
'diaspora'
=>
[
'repo'
=>
'diaspora/diaspora'
,
'gitsite'
=>
'api.github.com'
,
'gittype'
=>
'github'
,
'devbranch'
=>
'develop'
],
...
...
@@ -39,11 +31,11 @@ $opts = [
];
foreach
(
$softwares
as
$software
=>
$details
)
{
if
(
$details
[
'gittype'
]
==
'github'
)
{
if
(
$details
[
'gittype'
]
==
=
'github'
)
{
$context
=
stream_context_create
(
$opts
);
$releasejson
=
json_decode
(
file_get_contents
(
'https://'
.
$details
[
"gitsite"
]
.
'/repos/'
.
$details
[
"repo"
]
.
'/releases/latest'
,
false
,
$context
));
if
(
$details
[
"devbranch"
])
{
$commitjson
=
json_decode
(
file_get_contents
(
'https://'
.
$details
[
"gitsite"
]
.
'/repos/'
.
$details
[
"repo"
]
.
'/commits/'
.
$details
[
"devbranch"
],
false
,
$context
));
$releasejson
=
json_decode
(
file_get_contents
(
'https://'
.
$details
[
'gitsite'
]
.
'/repos/'
.
$details
[
'repo'
]
.
'/releases/latest'
,
false
,
$context
));
if
(
$details
[
'devbranch'
])
{
$commitjson
=
json_decode
(
file_get_contents
(
'https://'
.
$details
[
'gitsite'
]
.
'/repos/'
.
$details
[
'repo'
]
.
'/commits/'
.
$details
[
'devbranch'
],
false
,
$context
));
}
else
{
$commitjson
=
''
;
}
...
...
@@ -63,11 +55,11 @@ foreach ($softwares as $software => $details) {
die
(
'Error in SQL query: '
.
$e
->
getMessage
());
}
}
}
elseif
(
$details
[
'gittype'
]
==
'gitlab'
)
{
}
elseif
(
$details
[
'gittype'
]
==
=
'gitlab'
)
{
$context
=
stream_context_create
(
$opts
);
$releasejson
=
json_decode
(
file_get_contents
(
'https://'
.
$details
[
"gitsite"
]
.
'/api/v4/projects/'
.
$details
[
"repo"
]
.
'/repository/tags'
,
false
,
$context
));
if
(
$details
[
"devbranch"
])
{
$commitjson
=
json_decode
(
file_get_contents
(
'https://'
.
$details
[
"gitsite"
]
.
'/api/v4/projects/'
.
$details
[
"repo"
]
.
'/repository/commits/'
.
$details
[
"devbranch"
],
false
,
$context
));
$releasejson
=
json_decode
(
file_get_contents
(
'https://'
.
$details
[
'gitsite'
]
.
'/api/v4/projects/'
.
$details
[
'repo'
]
.
'/repository/tags'
,
false
,
$context
));
if
(
$details
[
'devbranch'
])
{
$commitjson
=
json_decode
(
file_get_contents
(
'https://'
.
$details
[
'gitsite'
]
.
'/api/v4/projects/'
.
$details
[
'repo'
]
.
'/repository/commits/'
.
$details
[
'devbranch'
],
false
,
$context
));
}
else
{
$commitjson
=
''
;
}
...
...
@@ -89,6 +81,5 @@ foreach ($softwares as $software => $details) {
}
}
printf
(
'%s:%s:%s '
,
$software
,
$masterversion
,
$devlastcommit
?:
'n/a'
);
}
db/pull.php
View file @
c81adfbb
...
...
@@ -30,20 +30,13 @@ $_domain = $_GET['domain'] ?? null;
// Must have a domain, except if called from CLI.
$_domain
||
PHP_SAPI
===
'cli'
||
die
(
'No valid input'
);
require_once
__DIR__
.
'/../vendor/autoload.php'
;
require_once
__DIR__
.
'/../config.php'
;
require_once
__DIR__
.
'/../boot.php'
;
define
(
'PODUPTIME'
,
microtime
(
true
));
// Set up global DB connection.
R
::
setup
(
"pgsql:host=
{
$pghost
}
;dbname=
{
$pgdb
}
"
,
$pguser
,
$pgpass
,
true
);
$sqldebug
&&
R
::
debug
(
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
$sqldebug
&&
R
::
fancyDebug
(
true
);
try
{
// Setup GeoIP Database
$reader
=
new
Reader
(
$geoip2db
);
$reader
=
new
Reader
(
c
(
'geoip2db'
)
);
$sql
=
'
SELECT domain, score, date_created, weight, podmin_notify, email, masterversion, shortversion, status
...
...
@@ -114,7 +107,7 @@ foreach ($pods as $pod) {
curl_setopt
(
$chss
,
CURLOPT_TIMEOUT
,
30
);
curl_setopt
(
$chss
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$chss
,
CURLOPT_CERTINFO
,
1
);
curl_setopt
(
$chss
,
CURLOPT_CAINFO
,
$cafullpath
);
curl_setopt
(
$chss
,
CURLOPT_CAINFO
,
c
(
'cafullpath'
)
);
$outputssl
=
curl_exec
(
$chss
);
$outputsslerror
=
curl_error
(
$chss
);
$info
=
curl_getinfo
(
$chss
,
CURLINFO_CERTINFO
);
...
...
@@ -297,7 +290,7 @@ foreach ($pods as $pod) {
_debug
(
'Signup Open'
,
$signup
);
$dnsserver
=
!
empty
(
$dnsserver
)
?
$dnsserver
:
'1.1.1.1'
;
$dnsserver
=
c
(
'dnsserver'
)
?
:
'1.1.1.1'
;
$delv
=
new
NPM\Xec\Command
(
"delv @
{
$dnsserver
}
{
$domain
}
"
);
$delv
->
throwExceptionOnError
(
false
);
...
...
@@ -355,7 +348,7 @@ foreach ($pods as $pod) {
if
(
$score
==
49
&&
$notify
&&
!
$develop
&&
$dbscore
==
50
)
{
$to
=
$email
;
$headers
=
[
'From: '
.
$adminemail
,
'Bcc: '
.
$adminemail
];
$headers
=
[
'From: '
.
c
(
'adminemail'
),
'Bcc: '
.
c
(
'adminemail'
)
];
$subject
=
'Monitoring notice from poduptime'
;
$message
=
'Notice for '
.
$domain
.
'. Your score is '
.
$score
.
' and your pod will fall off the list soon.'
;
@
mail
(
$to
,
$subject
,
$message
,
implode
(
"
\r\n
"
,
$headers
));
...
...
db/pull.sh
View file @
c81adfbb
...
...
@@ -46,14 +46,14 @@ if [ "$HOUR" = 23 ] || [ "$1" = 'init' ]; then
fi
if
[
"
$DAY
"
=
23
]
||
[
"
$1
"
=
'init'
]
;
then
printf
"%s"
"Updating CA..."
CACERT_FILE
=
"
$(
php
-r
"
include __DIR__ . '/../config.php'; echo
\$
cafullpath
;"
)
"
CACERT_FILE
=
"
$(
php
-r
"
echo (require __DIR__ . '/../config.php')['cafullpath']
;"
)
"
if
curl
-Lss
https://curl.haxx.se/ca/cacert.pem
-o
"
$CACERT_FILE
"
;
then
echo
"
$HAPPY
"
else
echo
"
$SAD
"
fi
printf
"%s"
"Updating GeoIP2 DB..."
GEODB_FILE
=
"
$(
php
-r
"
include __DIR__ . '/../config.php'; echo
\$
geoip2db
;"
)
"
GEODB_FILE
=
"
$(
php
-r
"
echo (require __DIR__ . '/../config.php')['geoip2db']
;"
)
"
if
funzip <
(
curl
-Lss
http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
)
>
"
$GEODB_FILE
"
;
then
echo
"
$HAPPY
"
else
...
...
db/saverating.php
View file @
c81adfbb
...
...
@@ -15,15 +15,7 @@ use RedBeanPHP\R;
(
$_comment
=
$_POST
[
'comment'
]
??
null
)
||
die
(
'A comment is required'
);
(
$_rating
=
$_POST
[
'rating'
]
??
null
)
||
die
(
'A rating is required'
);
require_once
__DIR__
.
'/../vendor/autoload.php'
;
require_once
__DIR__
.
'/../config.php'
;
define
(
'PODUPTIME'
,
microtime
(
true
));
// Set up global DB connection.
R
::
setup
(
"pgsql:host=
{
$pghost
}
;dbname=
{
$pgdb
}
"
,
$pguser
,
$pgpass
,
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
require_once
__DIR__
.
'/../boot.php'
;
try
{
$r
=
R
::
dispense
(
'ratingcomments'
);
...
...
db/status.php
View file @
c81adfbb
...
...
@@ -6,7 +6,7 @@
declare
(
strict_types
=
1
);
$dur
=
(
time
()
-
filemtime
(
'last.data'
)
);
$dur
=
time
()
-
filemtime
(
'last.data'
);
echo
$dur
;
if
(
$dur
>
4500
)
{
http_response_code
(
500
);
...
...
go.php
View file @
c81adfbb
...
...
@@ -13,15 +13,7 @@ use RedBeanPHP\R;
// Other parameters.
$_domain
=
$_GET
[
'domain'
]
??
''
;
require_once
__DIR__
.
'/vendor/autoload.php'
;
require_once
__DIR__
.
'/config.php'
;
define
(
'PODUPTIME'
,
microtime
(
true
));
// Set up global DB connection.
R
::
setup
(
"pgsql:host=
{
$pghost
}
;dbname=
{
$pgdb
}
"
,
$pguser
,
$pgpass
,
true
);
R
::
testConnection
()
||
die
(
'Error in DB connection'
);
R
::
usePartialBeans
(
true
);
require_once
__DIR__
.
'/boot.php'
;
try
{
if
(
$_domain
)
{
...
...
index.php
View file @
c81adfbb
...
...
@@ -5,21 +5,22 @@
*/
declare
(
strict_types
=
1
);
use
Carbon\Carbon
;
require_once
__DIR__
.
'/vendor/autoload.php'
;
require_once
__DIR__
.
'/config.php'
;
require_once
__DIR__
.
'/boot.php'
;
$lastfile
=
'db/last.data'
;
$input
=
isset
(
$_GET
[
'input'
])
?
substr
(
$_GET
[
'input'
],
1
)
:
null
;
$mapview
=
isset
(
$_GET
[
'mapview'
])
||
$input
==
'map'
;
$statsview
=
isset
(
$_GET
[
'statsview'
])
||
$input
==
'stats'
;
$podmin
=
isset
(
$_GET
[
'podmin'
])
||
$input
==
'podmin'
;
$podminedit
=
isset
(
$_GET
[
'podminedit'
])
||
$input
==
'podminedit'
;
$edit
=
isset
(
$_GET
[
'edit'
])
||
$input
==
'edit'
;
$add
=
isset
(
$_GET
[
'add'
])
||
$input
==
'add'
;
$gettoken
=
isset
(
$_GET
[
'gettoken'
])
||
$input
==
'gettoken'
;
$mapview
=
isset
(
$_GET
[
'mapview'
])
||
$input
=
==
'map'
;
$statsview
=
isset
(
$_GET
[
'statsview'
])
||
$input
=
==
'stats'
;
$podmin
=
isset
(
$_GET
[
'podmin'
])
||
$input
=
==
'podmin'
;
$podminedit
=
isset
(
$_GET
[
'podminedit'
])
||
$input
=
==
'podminedit'
;
$edit
=
isset
(
$_GET
[
'edit'
])
||
$input
=
==
'edit'
;
$add
=
isset
(
$_GET
[
'add'
])
||
$input
=
==
'add'
;
$gettoken
=
isset
(
$_GET
[
'gettoken'
])
||
$input
=
==
'gettoken'
;
$simpleview
=
!
(
$mapview
||
$podmin
||
$podminedit
||
$statsview
);
$fullview
=
false
;
?>
<!doctype html>
<html
lang=
"en"
>
...
...
@@ -129,7 +130,7 @@ $navs = [
include_once
__DIR__
.
'/db/gettoken.php'
;
}
else
{
include_once
__DIR__
.
'/showfull.php'
;
$fullview
=
1
;
$fullview
=
true
;
}
?>
</div>
...
...
@@ -148,9 +149,7 @@ $navs = [
<script
src=
"node_modules/ion-rangeslider/js/ion.rangeSlider.min.js"
></script>
<?php
$statsview
&&
include_once
__DIR__
.
'/statsviewjs.php'
;
if
(
$fullview
)
{
echo
'<script src="js/podup.js"></script>'
;
}
$fullview
&&
printf
(
'<script src="js/podup.js"></script>'
);