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
73fa0b75
Unverified
Commit
73fa0b75
authored
Feb 09, 2017
by
dmorley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make this more logical and work for pods
parent
ca94de08
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
45 deletions
+46
-45
db/pull.php
db/pull.php
+46
-45
No files found.
db/pull.php
View file @
73fa0b75
...
...
@@ -11,7 +11,6 @@ require_once __DIR__ . '/../config.php';
$dbh
=
pg_connect
(
"dbname=
$pgdb
user=
$pguser
password=
$pgpass
"
);
$dbh
||
die
(
'Error in connection: '
.
pg_last_error
());
//foreach pod check it and update db
if
(
$_domain
)
{
$sql
=
'SELECT domain,score,date_created,adminrating,weight,hidden,podmin_notify,email FROM pods WHERE domain = $1'
;
$result
=
pg_query_params
(
$dbh
,
$sql
,
[
$_domain
]);
...
...
@@ -74,62 +73,62 @@ while ($row = pg_fetch_assoc($result)) {
$jsonssl
=
json_decode
(
$outputssl
);
if
(
!
$jsonssl
)
{
_debug
(
'Connection'
,
'Can not connect to pod'
);
$sql_errors
=
'INSERT INTO checks (domain, online, error, ttl) VALUES ($1, $2, $3, $4)'
;
$result_errors
=
pg_query_params
(
$dbh
,
$sql_errors
,
[
$domain
,
0
,
$outputsslerror
,
$ttl
]);
$result_errors
||
die
(
'Error in SQL query: '
.
pg_last_error
());
continue
;
}
if
(
$jsonssl
!==
null
)
{
$xdver
=
$jsonssl
->
software
->
version
??
0
;
$dverr
=
explode
(
'-'
,
trim
(
$xdver
));
$shortversion
=
$dverr
[
0
];
$signup
=
(
$jsonssl
->
openRegistrations
??
false
)
===
true
;
$softwarename
=
$jsonssl
->
software
->
name
??
'unknown'
;
$name
=
$jsonssl
->
metadata
->
nodeName
??
'null'
;
$total_users
=
$jsonssl
->
usage
->
users
->
total
??
0
;
$active_users_halfyear
=
$jsonssl
->
usage
->
users
->
activeHalfyear
??
0
;
$active_users_monthly
=
$jsonssl
->
usage
->
users
->
activeMonth
??
0
;
$local_posts
=
$jsonssl
->
usage
->
localPosts
??
0
;
$comment_counts
=
$jsonssl
->
usage
->
localComments
??
0
;
$service_xmpp
=
(
$jsonssl
->
metadata
->
xmppChat
??
false
)
===
true
;
$service_facebook
=
'false'
;
$service_twitter
=
'false'
;
$service_tumblr
=
'false'
;
$service_wordpress
=
'false'
;
if
(
json_last_error
()
===
0
)
{
(
!
$jsonssl
->
software
->
version
)
||
$score
+=
1
;
$xdver
=
$jsonssl
->
software
->
version
??
0
;
$dverr
=
explode
(
'-'
,
trim
(
$xdver
));
$shortversion
=
$dverr
[
0
];
_debug
(
'Version code'
,
$shortversion
);
$signup
=
(
$jsonssl
->
openRegistrations
===
true
);
$softwarename
=
$jsonssl
->
software
->
name
??
'null'
;
$name
=
$jsonssl
->
metadata
->
nodeName
??
'null'
;
$total_users
=
$jsonssl
->
usage
->
users
->
total
??
0
;
$active_users_halfyear
=
$jsonssl
->
usage
->
users
->
activeHalfyear
??
0
;
$active_users_monthly
=
$jsonssl
->
usage
->
users
->
activeMonth
??
0
;
$local_posts
=
$jsonssl
->
usage
->
localPosts
??
0
;
$comment_counts
=
$jsonssl
->
usage
->
localComments
??
0
;
$service_facebook
=
in_array
(
'facebook'
,
$jsonssl
->
services
->
outbound
,
true
);
$service_twitter
=
in_array
(
'twitter'
,
$jsonssl
->
services
->
outbound
,
true
);
$service_tumblr
=
in_array
(
'tumblr'
,
$jsonssl
->
services
->
outbound
,
true
);
$service_wordpress
=
in_array
(
'wordpress'
,
$jsonssl
->
services
->
outbound
,
true
);
$service_xmpp
=
(
$jsonssl
->
metadata
->
xmppChat
??
false
)
===
true
;
$status
=
'Up'
;
}
if
(
$jsonssl
!==
null
)
{
$status
=
'Up'
;
$sql_checks
=
'INSERT INTO checks (domain, online, ttl, total_users, local_posts, comment_counts, shortversion) VALUES ($1, $2, $3, $4, $5, $6, $7)'
;
$result_checks
=
pg_query_params
(
$dbh
,
$sql_checks
,
[
$domain
,
1
,
$ttl
,
$total_users
,
$local_posts
,
$comment_counts
,
$shortversion
]);
$result_checks
||
die
(
'Error in SQL query: '
.
pg_last_error
());
}
else
{
$score
-=
1
;
$dver
=
'.connect error'
;
$shortversion
=
0
;
}
if
(
!
$jsonssl
)
{
_debug
(
'Connection'
,
'Can not connect to pod'
);
$sql_errors
=
'INSERT INTO checks (domain, online, error, ttl) VALUES ($1, $2, $3, $4)'
;
$result_errors
=
pg_query_params
(
$dbh
,
$sql_errors
,
[
$domain
,
0
,
$outputsslerror
,
$ttl
]);
$result_errors
||
die
(
'Error in SQL query: '
.
pg_last_error
());
$score
-=
1
;
$shortversion
=
'0.error'
;
$status
=
'Down'
;
}
_debug
(
'Version code'
,
$shortversion
);
_debug
(
'Signup Open'
,
$signup
);
$iplookupv4
=
[];
$ip
=
''
;
$ip
=
''
;
exec
(
escapeshellcmd
(
'delv @'
.
$dnsserver
.
' '
.
$domain
),
$iplookupv4
);
_debug
(
'Iplookupv4'
,
$iplookupv4
,
true
);
$dnssec
=
in_array
(
'; fully validated'
,
$iplookupv4
,
true
)
??
false
;
$dnssec
=
in_array
(
'; fully validated'
,
$iplookupv4
,
true
)
??
false
;
$getaonly
=
array_values
(
preg_grep
(
'/\s+IN\s+A\s+.*/'
,
$iplookupv4
));
if
(
$
iplookupv4
)
{
if
(
$
getaonly
)
{
preg_match
(
'/A\s(.*)/'
,
$getaonly
[
0
],
$aversion
);
$ip
=
trim
(
$aversion
[
1
])
??
''
;
$ip
=
trim
(
$aversion
[
1
])
??
''
;
}
$iplookupv6
=
[];
$ipv6
=
null
;
exec
(
escapeshellcmd
(
'delv @'
.
$dnsserver
.
' '
.
$domain
.
' AAAA '
),
$iplookupv6
);
_debug
(
'Iplookupv6'
,
$iplookupv6
,
true
);
$getaaaaonly
=
array_values
(
preg_grep
(
'/\s+IN\s+AAAA\s+.*/'
,
$iplookupv6
));
if
(
$getaaaaonly
)
{
preg_match
(
'/AAAA\s(.*)/'
,
$getaaaaonly
[
0
],
$aaaaversion
);
...
...
@@ -138,21 +137,23 @@ while ($row = pg_fetch_assoc($result)) {
$ip
||
$score
-=
2
;
_debug
(
'IPv4'
,
$ip
);
_debug
(
'Iplookupv4'
,
$iplookupv4
,
true
);
_debug
(
'IPv6'
,
$ipv6
);
_debug
(
'Iplookupv6'
,
$iplookupv6
,
true
);
$location
=
geoip_record_by_name
(
$ip
);
_debug
(
'Location'
,
$location
,
true
);
$country
=
!
empty
(
$location
[
'country_code'
])
?
iconv
(
'UTF-8'
,
'UTF-8//IGNORE'
,
$location
[
'country_code'
])
:
null
;
$city
=
!
empty
(
$location
[
'city'
])
?
iconv
(
'UTF-8'
,
'UTF-8//IGNORE'
,
$location
[
'city'
])
:
null
;
$state
=
!
empty
(
$location
[
'region'
])
?
iconv
(
'UTF-8'
,
'UTF-8//IGNORE'
,
$location
[
'region'
])
:
null
;
$lat
=
!
empty
(
$location
[
'latitude'
])
?
$location
[
'latitude'
]
:
0
;
$long
=
!
empty
(
$location
[
'longitude'
])
?
$location
[
'longitude'
]
:
0
;
$country
=
!
empty
(
$location
[
'country_code'
])
?
iconv
(
'UTF-8'
,
'UTF-8//IGNORE'
,
$location
[
'country_code'
])
:
null
;
$city
=
!
empty
(
$location
[
'city'
])
?
iconv
(
'UTF-8'
,
'UTF-8//IGNORE'
,
$location
[
'city'
])
:
null
;
$state
=
!
empty
(
$location
[
'region'
])
?
iconv
(
'UTF-8'
,
'UTF-8//IGNORE'
,
$location
[
'region'
])
:
null
;
$lat
=
!
empty
(
$location
[
'latitude'
])
?
$location
[
'latitude'
]
:
0
;
$long
=
!
empty
(
$location
[
'longitude'
])
?
$location
[
'longitude'
]
:
0
;
echo
$newline
;
$statslastdate
=
date
(
'Y-m-d H:i:s'
);
$diff
=
(
new
DateTime
())
->
diff
(
new
DateTime
(
$dateadded
));
$months
=
$diff
->
m
+
(
$diff
->
y
*
12
);
$diff
=
(
new
DateTime
())
->
diff
(
new
DateTime
(
$dateadded
));
$months
=
$diff
->
m
+
(
$diff
->
y
*
12
);
$responsetime
=
0
;
$sqlttl
=
'SELECT round(avg(ttl) * 1000) AS ttl FROM checks WHERE domain = $1'
;
...
...
@@ -200,7 +201,7 @@ while ($row = pg_fetch_assoc($result)) {
_debug
(
'Score out of 100'
,
$score
);
echo
'Success
'
;
echo
'Success
'
.
$domain
;
echo
$newline
;
echo
$newline
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment