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
aaa29209
Commit
aaa29209
authored
Mar 07, 2014
by
MatrixCrawler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No commit message
No commit message
parent
2c10a5af
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
126 additions
and
75 deletions
+126
-75
db/config.php.example
db/config.php.example
+10
-0
db/pull.php
db/pull.php
+42
-14
db/sql/mysql.sql
db/sql/mysql.sql
+74
-61
No files found.
db/config.php.example
View file @
aaa29209
...
@@ -18,4 +18,14 @@ $adminkey = '';
...
@@ -18,4 +18,14 @@ $adminkey = '';
$chimpkey
=
''
;
$chimpkey
=
''
;
//apikey for public api calls
//apikey for public api calls
$apikey
=
''
;
$apikey
=
''
;
// Database connection
define
(
"DB_DRIVER"
,
"pgsql"
);
//requires pdo-pgsql
// define("DB_DRIVER","mysql"); // requires pdo-mysql
define
(
"DB_NAME"
,
"dbname"
);
define
(
"DB_HOST"
,
"localhost"
);
define
(
"DB_USER"
,
"dbuser"
);
define
(
"DB_PASSWORD"
,
"dbpassword"
);
?>
?>
db/pull.php
View file @
aaa29209
<?php
<?php
error_reporting
(
E_ALL
);
/**
/**
* Copyright (c) 2011, David Morley.
* Copyright (c) 2011, David Morley.
* This file is licensed under the Affero General Public License version 3 or later.
* This file is licensed under the Affero General Public License version 3 or later.
...
@@ -7,23 +7,24 @@ error_reporting(E_ALL);
...
@@ -7,23 +7,24 @@ error_reporting(E_ALL);
*/
*/
require_once
"Net/GeoIP.php"
;
require_once
"Net/GeoIP.php"
;
require_once
'config.php'
;
// The options for the cUrl Requests
define
(
"CURL_POST"
,
0
);
define
(
"CURL_POST"
,
0
);
define
(
"CURL_HEADER"
,
1
);
define
(
"CURL_HEADER"
,
1
);
define
(
"CURL_CONNECTTIMEOUT"
,
5
);
define
(
"CURL_CONNECTTIMEOUT"
,
5
);
define
(
"CURL_RETURNTRANSFER"
,
1
);
define
(
"CURL_RETURNTRANSFER"
,
1
);
define
(
"CURL_NOBODY"
,
0
);
define
(
"CURL_NOBODY"
,
0
);
define
(
"DB_DRIVER"
,
"pgsql"
);
//requires pdo-pgsql
// define("DB_DRIVER","mysql"); // requires pdo-mysql
define
(
"DB_NAME"
,
"poduptime"
);
define
(
"DB_HOST"
,
"localhost"
);
define
(
"DB_USER"
,
"poduptime"
);
define
(
"DB_PASSWORD"
,
"poduptimetest"
);
define
(
"DEBUG"
,
true
);
define
(
"DEBUG"
,
true
);
define
(
"VERBOSE_CURL"
,
false
);
define
(
"VERBOSE_CURL"
,
false
);
/**
* Class collecting functions for pulling data from Pods
* @author J. Brunswicker
* @version 1.0
*
*/
class
Pull
{
class
Pull
{
/**
/**
...
@@ -82,6 +83,10 @@ class Pull {
...
@@ -82,6 +83,10 @@ class Pull {
*/
*/
public
static
function
getDatabaseConnection
()
{
public
static
function
getDatabaseConnection
()
{
$dsn
=
DB_DRIVER
.
":dbname="
.
DB_NAME
.
";host="
.
DB_HOST
;
$dsn
=
DB_DRIVER
.
":dbname="
.
DB_NAME
.
";host="
.
DB_HOST
;
if
(
DB_DRIVER
==
'mysql'
)
{
$dsn
.=
";charset=UTF8"
;
}
try
{
try
{
$connection
=
new
PDO
(
$dsn
,
DB_USER
,
DB_PASSWORD
);
$connection
=
new
PDO
(
$dsn
,
DB_USER
,
DB_PASSWORD
);
...
@@ -359,6 +364,16 @@ class Pull {
...
@@ -359,6 +364,16 @@ class Pull {
}
}
}
}
/**
* Gets data from pingdom.com
* @param string $pingdomUrl
* @param string $responsetime
* @param string $months
* @param string $uptime
* @param string $live
* @param string $score
* @deprecated
*/
private
static
function
getPingdomData
(
$pingdomUrl
,
&
$responsetime
,
&
$months
,
&
$uptime
,
&
$live
,
&
$score
)
{
private
static
function
getPingdomData
(
$pingdomUrl
,
&
$responsetime
,
&
$months
,
&
$uptime
,
&
$live
,
&
$score
)
{
// Pod is monitored via pingdom
// Pod is monitored via pingdom
$thismonth
=
"/"
.
date
(
"Y"
)
.
"/"
.
date
(
"m"
);
$thismonth
=
"/"
.
date
(
"Y"
)
.
"/"
.
date
(
"m"
);
...
@@ -377,8 +392,6 @@ class Pull {
...
@@ -377,8 +392,6 @@ class Pull {
preg_match_all
(
'/<option(.*?)/s'
,
$implodemonths
,
$matchdates
);
preg_match_all
(
'/<option(.*?)/s'
,
$implodemonths
,
$matchdates
);
$months
=
isset
(
$matchdates
[
0
])
?
count
(
$matchdates
[
0
])
:
0
;
$months
=
isset
(
$matchdates
[
0
])
?
count
(
$matchdates
[
0
])
:
0
;
//echo $matchdates[0];
//uptime %
preg_match_all
(
'/<h3>Uptime this month<\/h3>\s*<p class="large">(.*?)%</'
,
$pingdom
,
$matchper
);
preg_match_all
(
'/<h3>Uptime this month<\/h3>\s*<p class="large">(.*?)%</'
,
$pingdom
,
$matchper
);
$uptime
=
isset
(
$matchper
[
1
][
0
])
?
preg_replace
(
"/,/"
,
"."
,
$matchper
[
1
][
0
])
:
0
;
$uptime
=
isset
(
$matchper
[
1
][
0
])
?
preg_replace
(
"/,/"
,
"."
,
$matchper
[
1
][
0
])
:
0
;
...
@@ -409,6 +422,14 @@ class Pull {
...
@@ -409,6 +422,14 @@ class Pull {
}
}
/**
* Gets data from the uptimerobot
* @param string $pingdomUrl
* @param string $responsetime
* @param string $months
* @param string $uptime
* @param string $live
*/
private
static
function
getUptimerobotData
(
$pingdomUrl
,
&
$responsetime
,
&
$months
,
&
$uptime
,
&
$live
)
{
private
static
function
getUptimerobotData
(
$pingdomUrl
,
&
$responsetime
,
&
$months
,
&
$uptime
,
&
$live
)
{
//do uptimerobot API instead
//do uptimerobot API instead
$uptimerobot
=
Pull
::
getCurlResult
(
$pingdomUrl
);
$uptimerobot
=
Pull
::
getCurlResult
(
$pingdomUrl
);
...
@@ -452,7 +473,7 @@ class Pull {
...
@@ -452,7 +473,7 @@ class Pull {
if
(
strpos
(
$pingdomUrl
,
"pingdom.com"
))
{
if
(
strpos
(
$pingdomUrl
,
"pingdom.com"
))
{
Pull
::
getPingdomData
(
$pingdomUrl
,
$responsetime
,
$months
,
$uptime
,
$live
,
$score
);
Pull
::
getPingdomData
(
$pingdomUrl
,
$responsetime
,
$months
,
$uptime
,
$live
,
$score
);
}
else
{
}
else
{
Pull
::
getUptimerobotData
(
$pingdomUrl
,
$responsetime
,
$months
,
$uptime
,
$live
);
Pull
::
getUptimerobotData
(
"http://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey="
.
$pingdomUrl
,
$responsetime
,
$months
,
$uptime
,
$live
);
}
}
}
else
{
}
else
{
echo
"No PingdomURL provided<br />"
;
echo
"No PingdomURL provided<br />"
;
...
@@ -464,11 +485,18 @@ class Pull {
...
@@ -464,11 +485,18 @@ class Pull {
$sql
=
"UPDATE pods SET Hgitdate="
.
$connection
->
quote
(
$gitdate
)
.
", Hencoding="
.
$connection
->
quote
(
$encoding
)
.
", secure="
.
$connection
->
quote
(
$secure
)
.
", hidden="
.
$connection
->
quote
(
$hidden
)
.
", Hruntime="
.
$connection
->
quote
(
$runtime
)
.
", "
;
$sql
=
"UPDATE pods SET Hgitdate="
.
$connection
->
quote
(
$gitdate
)
.
", Hencoding="
.
$connection
->
quote
(
$encoding
)
.
", secure="
.
$connection
->
quote
(
$secure
)
.
", hidden="
.
$connection
->
quote
(
$hidden
)
.
", Hruntime="
.
$connection
->
quote
(
$runtime
)
.
", "
;
$sql
.=
"Hgitref="
.
$connection
->
quote
(
$gitrev
)
.
", ip="
.
$connection
->
quote
(
$ipnum
)
.
", ipv6="
.
$connection
->
quote
(
$ipv6
)
.
", monthsmonitored="
.
$months
.
", uptimelast7="
.
$connection
->
quote
(
$uptime
)
.
", status="
.
$connection
->
quote
(
$live
)
.
", "
;
$sql
.=
"Hgitref="
.
$connection
->
quote
(
$gitrev
)
.
", ip="
.
$connection
->
quote
(
$ipnum
)
.
", ipv6="
.
$connection
->
quote
(
$ipv6
)
.
", monthsmonitored="
.
$months
.
", uptimelast7="
.
$connection
->
quote
(
$uptime
)
.
", status="
.
$connection
->
quote
(
$live
)
.
", "
;
$sql
.=
"dateLaststats="
.
$connection
->
quote
(
$pingdomdate
)
.
", dateUpdated="
.
$connection
->
quote
(
$timenow
)
.
", responsetimelast7="
.
$connection
->
quote
(
$responsetime
)
.
", score="
.
$connection
->
quote
(
$score
)
.
", "
;
$sql
.=
"dateLaststats="
.
$connection
->
quote
(
$pingdomdate
)
.
", dateUpdated="
.
$connection
->
quote
(
$timenow
)
.
", responsetimelast7="
.
$connection
->
quote
(
$responsetime
)
.
", score="
.
$connection
->
quote
(
$score
)
.
", "
;
$sql
.=
"adminrating="
.
$connection
->
quote
(
$adminRating
)
.
", country="
.
$connection
->
quote
(
$country
)
.
", city="
.
$connection
->
quote
(
$city
)
.
", state="
.
$connection
->
quote
(
$state
)
.
", lat="
.
$connection
->
quote
(
$lat
)
.
",
long="
.
$connection
->
quote
(
$long
)
.
",
"
;
$sql
.=
"adminrating="
.
$connection
->
quote
(
$adminRating
)
.
", country="
.
$connection
->
quote
(
$country
)
.
", city="
.
$connection
->
quote
(
$city
)
.
", state="
.
$connection
->
quote
(
$state
)
.
", lat="
.
$connection
->
quote
(
$lat
)
.
", "
;
$sql
.=
"
postalcode='',
connection="
.
$connection
->
quote
(
$diasporaVersion
)
.
", whois="
.
$connection
->
quote
(
$whois
)
.
", userrating="
.
$connection
->
quote
(
$userRating
)
.
", longversion="
.
$connection
->
quote
(
$xdver
)
.
", "
;
$sql
.=
"connection="
.
$connection
->
quote
(
$diasporaVersion
)
.
", whois="
.
$connection
->
quote
(
$whois
)
.
", userrating="
.
$connection
->
quote
(
$userRating
)
.
", longversion="
.
$connection
->
quote
(
$xdver
)
.
", "
;
$sql
.=
"shortversion="
.
$connection
->
quote
(
$diasporaVersion
)
.
", masterversion="
.
$connection
->
quote
(
$masterVersion
)
.
", signup="
.
$connection
->
quote
(
$registrationsOpen
)
.
", total_users="
.
$connection
->
quote
(
$totalUsers
)
.
", "
;
$sql
.=
"shortversion="
.
$connection
->
quote
(
$diasporaVersion
)
.
", masterversion="
.
$connection
->
quote
(
$masterVersion
)
.
", signup="
.
$connection
->
quote
(
$registrationsOpen
)
.
", total_users="
.
$connection
->
quote
(
$totalUsers
)
.
", "
;
$sql
.=
"active_users_halfyear="
.
$connection
->
quote
(
$activeUsersHalfyear
)
.
", active_users_monthly="
.
$connection
->
quote
(
$activeUsersMonthly
)
.
", local_posts="
.
$connection
->
quote
(
$localPosts
)
.
", "
;
$sql
.=
"active_users_halfyear="
.
$connection
->
quote
(
$activeUsersHalfyear
)
.
", active_users_monthly="
.
$connection
->
quote
(
$activeUsersMonthly
)
.
", local_posts="
.
$connection
->
quote
(
$localPosts
)
.
", "
;
$sql
.=
"name="
.
$connection
->
quote
(
$podName
)
.
" "
;
$sql
.=
"name="
.
$connection
->
quote
(
$podName
)
.
", "
;
if
(
DB_NAME
==
'mysql'
)
{
$sql
.=
"`long`="
.
$connection
->
quote
(
$long
)
.
" "
;
}
else
{
$sql
.=
"long="
.
$connection
->
quote
(
$long
)
.
" "
;
}
$sql
.=
"WHERE "
;
$sql
.=
"WHERE "
;
$sql
.=
"domain="
.
$connection
->
quote
(
$domain
);
$sql
.=
"domain="
.
$connection
->
quote
(
$domain
);
...
...
db/sql/mysql.sql
View file @
aaa29209
CREATE
TABLE
pods
(
CREATE
TABLE
IF
NOT
EXISTS
`pods`
(
id
bigint
UNIQUE
PRIMARY
KEY
,
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
,
domain
varchar
(
50
)
UNIQUE
NOT
NULL
,
`domain`
varchar
(
100
)
NOT
NULL
,
name
varchar
(
50
),
`name`
varchar
(
100
)
DEFAULT
NULL
,
score
int
DEFAULT
10
,
`score`
tinyint
(
3
)
unsigned
DEFAULT
'10'
,
adminrating
decimal
DEFAULT
10
,
`adminrating`
decimal
(
4
,
2
)
DEFAULT
'10.00'
,
userrating
decimal
DEFAULT
10
,
`userrating`
decimal
(
4
,
2
)
DEFAULT
'10.00'
,
whois
varchar
(
50
),
`whois`
varchar
(
50
)
DEFAULT
NULL
,
hidden
varchar
(
10
)
DEFAULT
'yes'
,
`hidden`
varchar
(
3
)
DEFAULT
'yes'
,
ip
varchar
(
50
),
`ip`
varchar
(
50
)
DEFAULT
NULL
,
ptr
varchar
(
50
),
`country`
varchar
(
50
)
DEFAULT
NULL
,
country
varchar
(
50
),
`city`
varchar
(
50
)
DEFAULT
NULL
,
city
varchar
(
50
),
`state`
varchar
(
50
)
DEFAULT
NULL
,
state
varchar
(
50
),
`lat`
varchar
(
50
)
DEFAULT
NULL
,
lat
varchar
(
50
),
`long`
varchar
(
50
)
DEFAULT
NULL
,
`long`
varchar
(
50
),
`connection`
varchar
(
50
)
DEFAULT
NULL
,
connection
varchar
(
50
),
`email`
varchar
(
50
)
DEFAULT
NULL
,
postalcode
varchar
(
50
),
`ipv6`
varchar
(
50
)
DEFAULT
NULL
,
email
varchar
(
50
),
`secure`
varchar
(
50
)
DEFAULT
NULL
,
ipv6
varchar
(
50
),
`sslvalid`
varchar
(
50
)
DEFAULT
NULL
,
secure
varchar
(
50
),
`Hgitdate`
datetime
DEFAULT
NULL
,
sslvalid
varchar
(
50
),
`Hgitref`
varchar
(
50
)
DEFAULT
NULL
,
Hgitdate
varchar
(
50
),
`Hruntime`
varchar
(
50
)
DEFAULT
NULL
,
Hgitref
varchar
(
50
),
`Hencoding`
varchar
(
50
)
DEFAULT
NULL
,
Hruntime
varchar
(
50
),
`pingdomurl`
varchar
(
50
)
DEFAULT
NULL
,
Hencoding
varchar
(
50
),
`pingdomlast`
varchar
(
50
)
DEFAULT
NULL
,
pingdomurl
varchar
(
50
),
`monthsmonitored`
int
(
11
)
DEFAULT
NULL
,
pingdomlast
varchar
(
50
),
`signup`
tinyint
(
4
)
DEFAULT
NULL
,
monthsmonitored
int
,
`total_users`
int
(
11
)
DEFAULT
NULL
,
signup
int
,
`active_users_halfyear`
int
(
11
)
DEFAULT
NULL
,
total_users
int
,
`active_users_monthly`
int
(
11
)
DEFAULT
NULL
,
active_users_halfyear
int
,
`local_posts`
int
(
11
)
DEFAULT
NULL
,
active_users_monthly
int
,
`uptimelast7`
decimal
(
5
,
2
)
DEFAULT
NULL
,
local_posts
int
,
`status`
varchar
(
50
)
DEFAULT
NULL
,
uptimelast7
numeric
(
5
,
2
),
`responsetimelast7`
varchar
(
50
)
DEFAULT
NULL
,
status
varchar
(
50
),
`dateUpdated`
datetime
DEFAULT
NULL
,
responsetimelast7
varchar
(
50
),
`dateLaststats`
datetime
DEFAULT
NULL
,
dateUpdated
datetime
,
`dateCreated`
datetime
DEFAULT
NULL
,
dateLaststats
datetime
,
`longversion`
varchar
(
20
)
DEFAULT
NULL
,
dateCreated
datetime
`shortversion`
varchar
(
20
)
DEFAULT
NULL
,
);
`masterversion`
varchar
(
20
)
DEFAULT
NULL
,
CREATE
TABLE
rating_comments
(
PRIMARY
KEY
(
`id`
),
id
bigint
UNIQUE
PRIMARY
KEY
,
UNIQUE
KEY
`id`
(
`id`
),
domain
varchar
(
50
)
NOT
NULL
,
UNIQUE
KEY
`domain`
(
`domain`
)
comment
varchar
(
50
),
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
AUTO_INCREMENT
=
2
;
admin
varchar
(
50
),
pod_id
int
,
rating
int
,
CREATE
TABLE
IF
NOT
EXISTS
`rating_comments`
(
username
varchar
(
50
),
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
,
userurl
varchar
(
50
),
`domain`
varchar
(
50
)
NOT
NULL
,
date
datetime
`comment`
varchar
(
50
)
DEFAULT
NULL
,
);
`admin`
tinyint
(
1
)
DEFAULT
'0'
,
CREATE
TABLE
users
(
`pod_id`
int
(
11
)
DEFAULT
NULL
,
id
bigint
UNIQUE
PRIMARY
KEY
,
`rating`
tinyint
(
3
)
unsigned
DEFAULT
NULL
,
admin
int
NOT
NULL
,
`username`
varchar
(
50
)
DEFAULT
NULL
,
username
varchar
(
50
)
UNIQUE
NOT
NULL
,
`userurl`
varchar
(
50
)
DEFAULT
NULL
,
password
varchar
(
50
)
NOT
NULL
,
`date`
datetime
DEFAULT
NULL
,
userurl
varchar
(
50
),
PRIMARY
KEY
(
`id`
),
userpod
varchar
(
50
),
UNIQUE
KEY
`id`
(
`id`
)
dateCreated
datetime
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
AUTO_INCREMENT
=
1
;
);
CREATE
TABLE
IF
NOT
EXISTS
`users`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
,
`admin`
int
(
11
)
NOT
NULL
,
`username`
varchar
(
50
)
NOT
NULL
,
`password`
varchar
(
50
)
NOT
NULL
,
`userurl`
varchar
(
50
)
DEFAULT
NULL
,
`userpod`
varchar
(
50
)
DEFAULT
NULL
,
`dateCreated`
datetime
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`id`
(
`id`
),
UNIQUE
KEY
`username`
(
`username`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
AUTO_INCREMENT
=
1
;
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