Unverified Commit 3f63e29d authored by David Morley's avatar David Morley
Browse files

Merge branch 'noplanman-code_structure'

parents d9b0a90d b2dd66f7
<?php <?php
//Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. //Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file.
if ($_GET['key'] != '4r45tg') {die;} if ($_GET['key'] != '4r45tg') {
die;
}
require_once __DIR__ . '/config.php'; require_once __DIR__ . '/config.php';
...@@ -8,6 +10,7 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); ...@@ -8,6 +10,7 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { if (!$dbh) {
die('Error in connection: ' . pg_last_error()); die('Error in connection: ' . pg_last_error());
} }
if ($_GET['format'] == 'georss') { if ($_GET['format'] == 'georss') {
echo <<<EOF echo <<<EOF
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
...@@ -18,15 +21,15 @@ xmlns:georss="http://www.georss.org/georss"> ...@@ -18,15 +21,15 @@ xmlns:georss="http://www.georss.org/georss">
<link href="http://podupti.me/"/> <link href="http://podupti.me/"/>
EOF; EOF;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'"; $sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { if (!$result) {
die('Error in SQL query: ' . pg_last_error()); die('Error in SQL query: ' . pg_last_error());
} }
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
$pod_name = htmlentities($row['name'], ENT_QUOTES); $pod_name = htmlentities($row['name'], ENT_QUOTES);
$tip = sprintf( $tip = sprintf(
'This pod %1$s has been watched for %2$s months and its average ping time is %3$s with uptime of %4$s%% this month and was last checked on %5$s. On a score of 100 this pod is a %6$s right now', 'This pod %1$s has been watched for %2$s months and its average ping time is %3$s with uptime of %4$s%% this month and was last checked on %5$s. On a score of 100 this pod is a %6$s right now',
$pod_name, $pod_name,
$row['monthsmonitored'], $row['monthsmonitored'],
...@@ -35,8 +38,12 @@ EOF; ...@@ -35,8 +38,12 @@ EOF;
$row['dateupdated'], $row['dateupdated'],
$row['score'] $row['score']
); );
if ($row['secure'] == 'true') {$method = 'https://';} else {$method = 'http://';} if ($row['secure'] == 'true') {
echo <<<EOF $method = 'https://';
} else {
$method = 'http://';
}
echo <<<EOF
<entry> <entry>
<title>{$method}{$row['domain']}</title> <title>{$method}{$row['domain']}</title>
<link href="{$method}{$row['domain']}"/> <link href="{$method}{$row['domain']}"/>
...@@ -51,9 +58,8 @@ EOF; ...@@ -51,9 +58,8 @@ EOF;
EOF; EOF;
} }
echo '</feed>'; echo '</feed>';
} } elseif ($_GET['format'] == 'json') {
elseif ($_GET['format'] == 'json') { $sql = 'SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods';
$sql = 'SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods';
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { if (!$result) {
die('Error in SQL query: ' . pg_last_error()); die('Error in SQL query: ' . pg_last_error());
...@@ -61,34 +67,42 @@ elseif ($_GET['format'] == 'json') { ...@@ -61,34 +67,42 @@ elseif ($_GET['format'] == 'json') {
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
//json output, thx Vipul A M for fixing this //json output, thx Vipul A M for fixing this
header('Content-type: application/json'); header('Content-type: application/json');
$rows=array_values(pg_fetch_all($result)); $rows = array_values(pg_fetch_all($result));
$obj->podcount = $numrows; $obj->podcount = $numrows;
$obj->pods = $rows; $obj->pods = $rows;
if ($_GET['method'] == 'jsonp') { if ($_GET['method'] == 'jsonp') {
print $_GET['callback'] . '(' . json_encode($obj) . ')'; print $_GET['callback'] . '(' . json_encode($obj) . ')';
} else { } else {
print json_encode($obj); print json_encode($obj);
} }
} } else {
else { $i = 0;
$i=0; $sql = "SELECT * FROM pods WHERE hidden <> 'yes' ORDER BY uptimelast7 DESC";
$sql = "SELECT * FROM pods WHERE hidden <> 'yes' ORDER BY uptimelast7 DESC";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { if (!$result) {
die('Error in SQL query: ' . pg_last_error()); die('Error in SQL query: ' . pg_last_error());
} }
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($row['status'] == 'up'){$status = 'Online';} else {$status = 'Offline';} if ($row['status'] == 'up') {
if ($row['secure'] == 'true') {$method = 'https://';$class = 'green';} else {$method = 'http://';$class = 'red';} $status = 'Online';
} else {
$status = 'Offline';
}
if ($row['secure'] == 'true') {
$method = 'https://';
$class = 'green';
} else {
$method = 'http://';
$class = 'red';
}
echo $row['domain'] . ' Up ' . $row['uptimelast7'] . '% This Month - Located in: ' . $row['country']; echo $row['domain'] . ' Up ' . $row['uptimelast7'] . '% This Month - Located in: ' . $row['country'];
if ($i < ($numrows -1)) { if ($i < ($numrows - 1)) {
echo ','; echo ',';
} }
$i++; $i ++;
}
}
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
} }
<?php <?php
$tt=0; $tt = 0;
require_once __DIR__ . '/config.php'; require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { if (!$dbh) {
die('Error in connection: ' . pg_last_error()); die('Error in connection: ' . pg_last_error());
} }
$sql = "SELECT * FROM pods WHERE hidden <> 'no' AND score < 50 ORDER BY weightedscore"; $sql = "SELECT * FROM pods WHERE hidden <> 'no' AND score < 50 ORDER BY weightedscore";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { if (!$result) {
die('Error in SQL query: ' . pg_last_error()); die('Error in SQL query: ' . pg_last_error());
} }
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
?> ?>
<meta property="og:title" content="<?php echo $numrows; ?> #Diaspora Pods listed, Come see the privacy aware social network." /><?php echo $numrows; ?> pods that are open for signup now. <meta property="og:title" content="<?php echo $numrows; ?> #Diaspora Pods listed, Come see the privacy aware social network."/><?php echo $numrows; ?> pods that are open for signup now.
<meta charset="utf-8"> <meta charset="utf-8">
<!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ --> <!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ -->
<table id="myTable" class="table table-striped table-sm tablesorter table-hover tfont"> <table id="myTable" class="table table-striped table-sm tablesorter table-hover tfont">
<thead> <thead>
<tr> <tr>
<th>Pod<a class="tipsy" title="A pod is a site for you to set up your account.">?</a></th> <th>Pod<a class="tipsy" title="A pod is a site for you to set up your account.">?</a></th>
<th>Version<a class="tipsy" title="Version of Diaspora this pod runs">?</a></th> <th>Version<a class="tipsy" title="Version of Diaspora this pod runs">?</a></th>
<th>Uptime<a class="tipsy" title="Percent of the time the pod is online for <?php echo date('F') ?>.">?</a></th> <th>Uptime<a class="tipsy" title="Percent of the time the pod is online for <?php echo date('F') ?>.">?</a></th>
<th>ms</th> <th>ms</th>
<th>Signups</th> <th>Signups</th>
<th>Total<a class="tipsy" title="Number of total users on this pod.">?</a></th> <th>Total<a class="tipsy" title="Number of total users on this pod.">?</a></th>
<th>Active 6<a class="tipsy" title="Number of users active last 6 months on this pod.">?</a></th> <th>Active 6<a class="tipsy" title="Number of users active last 6 months on this pod.">?</a></th>
<th>Active 1<a class="tipsy" title="Number of users active last 1 month on this pod.">?</a></th> <th>Active 1<a class="tipsy" title="Number of users active last 1 month on this pod.">?</a></th>
<th>Posts<a class="tipsy" title="Number of total posts on this pod.">?</a></th> <th>Posts<a class="tipsy" title="Number of total posts on this pod.">?</a></th>
<th>Comm<a class="tipsy" title="Number of total comments on this pod.">?</a></th> <th>Comm<a class="tipsy" title="Number of total comments on this pod.">?</a></th>
<th>Month<a class="tipsy" title="How many months has this pod been online? Click number for more history.">?</a></th> <th>Month<a class="tipsy" title="How many months has this pod been online? Click number for more history.">?</a>
<th>Sc<a class="tipsy" title="System Score on a 100 scale">?</a></th> </th>
<th>conn<a class="tipsy" title="">?</a></th> <th>Sc<a class="tipsy" title="System Score on a 100 scale">?</a></th>
<th>Delete?<a class="tipsy" title="Delete this pod from DB?">?</a></th> <th>conn<a class="tipsy" title="">?</a></th>
</tr> <th>Delete?<a class="tipsy" title="Delete this pod from DB?">?</a></th>
</thead> </tr>
<tbody> </thead>
<?php <tbody>
while ($row = pg_fetch_array($result)) { <?php
$tt=$tt+1; while ($row = pg_fetch_array($result)) {
if ($row['secure'] == 'true') { $tt = $tt + 1;
$method = 'https://'; if ($row['secure'] == 'true') {
$class= 'green'; $method = 'https://';
$tip= 'This pod uses SSL encryption for traffic.';} $class = 'green';
$tip = 'This pod uses SSL encryption for traffic.';
else { } else {
$method = 'http://'; $method = 'http://';
$class= 'red'; $class = 'red';
$tip= 'This pod does not offer SSL'; $tip = 'This pod does not offer SSL';
} }
$verdiff = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']); $verdiff = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']);
$pod_name = htmlentities($row['name'], ENT_QUOTES); $pod_name = htmlentities($row['name'], ENT_QUOTES);
$tip .= sprintf( $tip .= sprintf(
"\n" . 'This pod %1$s has been watched for %2$s months and its average ping time is %3$s with uptime of %4$s%% this month and was last checked on %5$s. On a score of -20 to +20 this pod is a %6$s right now', "\n" . 'This pod %1$s has been watched for %2$s months and its average ping time is %3$s with uptime of %4$s%% this month and was last checked on %5$s. On a score of -20 to +20 this pod is a %6$s right now',
$pod_name, $pod_name,
$row['monthsmonitored'], $row['monthsmonitored'],
$row['responsetimelast7'], $row['responsetimelast7'],
$row['uptimelast7'], $row['uptimelast7'],
$row['dateupdated'], $row['dateupdated'],
$row['score'] $row['score']
); );
echo '<tr><td><a class="' . $class . '" target="_self" href="' . $method . $row['domain'] . '">' . $row['domain'] . '<div title="' . $tip . '" class="tipsy" style="display: inline-block">?</div></a></td>'; echo '<tr><td><a class="' . $class . '" target="_self" href="' . $method . $row['domain'] . '">' . $row['domain'] . '<div title="' . $tip . '" class="tipsy" style="display: inline-block">?</div></a></td>';
if (stristr($row['shortversion'],'head')) if (stristr($row['shortversion'], 'head')) {
{$version = '.dev';$pre = 'This pod runs pre release $version = '.dev';
development code';} elseif (!$row['shortversion']) $pre = 'This pod runs pre release development code';
{$version = '0';$pre = 'This pod runs } elseif (!$row['shortversion']) {
unknown code';} $version = '0';
else $pre = 'This pod runs unknown code';
{$version =$row['shortversion'];$pre = 'This pod runs production code';} } else {
if ($row['shortversion'] == $row['masterversion'] && $row['shortversion'] != '') {$classver = 'green';} elseif ($verdiff > 6) {$classver = 'red';} else {$classver = 'black';} $version = $row['shortversion'];
echo '<td class="' . $classver . '"><div title="' . $pre . ' codename: ' . $row['longversion'] . ' master version is: ' . $row['masterversion'] . '" class="tipsy">' . $version . '</div></td>'; $pre = 'This pod runs production code';
echo '<td>' . $row['uptimelast7'] . '</td>'; }
echo '<td>' . $row['responsetimelast7'] . '</td>'; if ($row['shortversion'] == $row['masterversion'] && $row['shortversion'] != '') {
if ($row['signup'] == 1) {$signup = 'Open';} else {$signup = 'Closed';} $classver = 'green';
echo '<td>' . $signup . '</td>'; } elseif ($verdiff > 6) {
echo '<td>' . $row['total_users'] . '</td>'; $classver = 'red';
echo '<td>' . $row['active_users_halfyear'] . '</td>'; } else {
echo '<td>' . $row['active_users_monthly'] . '</td>'; $classver = 'black';
echo '<td>' . $row['local_posts'] . '</td>'; }
echo '<td>' . $row['comment_counts'] . '</td>'; echo '<td class="' . $classver . '"><div title="' . $pre . ' codename: ' . $row['longversion'] . ' master version is: ' . $row['masterversion'] . '" class="tipsy">' . $version . '</div></td>';
if (strpos($row['pingdomurl'], echo '<td>' . $row['uptimelast7'] . '</td>';
'pingdom.com')) {$moreurl = $row['pingdomurl'];} else {$moreurl = 'http://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $row['pingdomurl'];} echo '<td>' . $row['responsetimelast7'] . '</td>';
echo '<td><div title="Last Check ' . $row['dateupdated'] . '" class="tipsy"><a target="_self" href="' . $moreurl . '">' . $row['monthsmonitored'] . '</a></div></td>'; if ($row['signup'] == 1) {
echo '<td>' . $row['score'] . '</td>'; $signup = 'Open';
echo '<td><div class="tipsy" title="' . $row['sslvalid'] . '">con info </td>'; } else {
?> $signup = 'Closed';
<td> }
<form method="post" action="db/kill.php" target="_blank"> echo '<td>' . $signup . '</td>';
<input name="comments" value="<?php echo $row['sslvalid']; ?>" size=10> echo '<td>' . $row['total_users'] . '</td>';
<input name="domain" value="<?php echo $row['domain']; ?>" type="hidden"> echo '<td>' . $row['active_users_halfyear'] . '</td>';
<input name="adminkey" value="<?php echo $_COOKIE['adminkey']; ?>" type="hidden"> echo '<td>' . $row['active_users_monthly'] . '</td>';
<input name="action" type="radio" value="warn">warn echo '<td>' . $row['local_posts'] . '</td>';
<input name="action" type="radio" value="delete">delete echo '<td>' . $row['comment_counts'] . '</td>';
<input type="submit" value="Process"> if (strpos($row['pingdomurl'],
</form> 'pingdom.com')) {
</td> $moreurl = $row['pingdomurl'];
<?php } else {
echo '</td></tr>'; $moreurl = 'http://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $row['pingdomurl'];
} }
pg_free_result($result); echo '<td><div title="Last Check ' . $row['dateupdated'] . '" class="tipsy"><a target="_self" href="' . $moreurl . '">' . $row['monthsmonitored'] . '</a></div></td>';
pg_close($dbh); echo '<td>' . $row['score'] . '</td>';
?> echo '<td><div class="tipsy" title="' . $row['sslvalid'] . '">con info </td>';
</tbody> ?>
<td>
<form method="post" action="db/kill.php" target="_blank">
<input name="comments" value="<?php echo $row['sslvalid']; ?>" size=10>
<input name="domain" value="<?php echo $row['domain']; ?>" type="hidden">
<input name="adminkey" value="<?php echo $_COOKIE['adminkey']; ?>" type="hidden">
<input name="action" type="radio" value="warn">warn
<input name="action" type="radio" value="delete">delete
<input type="submit" value="Process">
</form>
</td>
<?php
echo '</td></tr>';
}
pg_free_result($result);
pg_close($dbh);
?>
</tbody>
</table> </table>
...@@ -17,4 +17,4 @@ $adminemail = ''; ...@@ -17,4 +17,4 @@ $adminemail = '';
//admin key for deleting pods, set this as a cookie on your own //admin key for deleting pods, set this as a cookie on your own
$adminkey = ''; $adminkey = '';
//apikey for public api calls //apikey for public api calls
$apikey= ''; $apikey = '';
<!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ --> <!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ -->
<?php <?php
$valid=0; $valid = 0;
require_once __DIR__ . '/../logging.php'; require_once __DIR__ . '/../logging.php';
$log = new Logging(); $log = new Logging();
$log->lfile($log_dir . '/add.php.log'); $log->lfile($log_dir . '/add.php.log');
if (!$_POST['url']){ if (!$_POST['url']) {
$log->lwrite('no url given '.$_POST['domain']); $log->lwrite('no url given ' . $_POST['domain']);
die('no url given'); die('no url given');
} }
if (!$_POST['email']){ if (!$_POST['email']) {
$log->lwrite('no email given '.$_POST['domain']); $log->lwrite('no email given ' . $_POST['domain']);
die('no email given'); die('no email given');
} }
if (!$_POST['domain']){ if (!$_POST['domain']) {
$log->lwrite('no domain given '.$_POST['domain']); $log->lwrite('no domain given ' . $_POST['domain']);
die('no pod domain given'); die('no pod domain given');
} }
if (!$_POST['url']){ if (!$_POST['url']) {
$log->lwrite('no api given '.$_POST['domain']); $log->lwrite('no api given ' . $_POST['domain']);
die('no API key for your stats'); die('no API key for your stats');
} }
if (strlen($_POST['url']) < 14){ if (strlen($_POST['url']) < 14) {
$log->lwrite('api key too short '.$_POST['domain']); $log->lwrite('api key too short ' . $_POST['domain']);
die('API key bad needs to be like m58978-80abdb799f6ccf15e3e3787ee'); die('API key bad needs to be like m58978-80abdb799f6ccf15e3e3787ee');
} }
...@@ -32,18 +32,18 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); ...@@ -32,18 +32,18 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { if (!$dbh) {
die('Error in connection: ' . pg_last_error()); die('Error in connection: ' . pg_last_error());
} }
$sql = 'SELECT domain,pingdomurl FROM pods'; $sql = 'SELECT domain,pingdomurl FROM pods';
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { if (!$result) {
die('Error in SQL query: ' . pg_last_error()); die('Error in SQL query: ' . pg_last_error());
} }
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($row['domain'] == $_POST['domain']) { if ($row['domain'] == $_POST['domain']) {
$log->lwrite('domain already exists '.$_POST['domain']); $log->lwrite('domain already exists ' . $_POST['domain']);
die('domain already exists'); die('domain already exists');
} }
if ($row['pingdomurl'] == $_POST['url']) { if ($row['pingdomurl'] == $_POST['url']) {
$log->lwrite('API key already exists '.$_POST['domain']); $log->lwrite('API key already exists ' . $_POST['domain']);
die('API key already exists'); die('API key already exists');
} }
} }
...@@ -70,38 +70,38 @@ $output = curl_exec($ch); ...@@ -70,38 +70,38 @@ $output = curl_exec($ch);
curl_close($ch); curl_close($ch);
if (stristr($outputssl, 'nodeName')) { if (stristr($outputssl, 'nodeName')) {
$log->lwrite('Your pod has ssl and is valid '.$_POST['domain']); $log->lwrite('Your pod has ssl and is valid ' . $_POST['domain']);
echo 'Your pod has ssl and is valid<br>'; echo 'Your pod has ssl and is valid<br>';
$valid=1; $valid = 1;
} }
if (stristr($output, 'nodeName')) { if (stristr($output, 'nodeName')) {
$log->lwrite('Your pod does not have ssl but is a valid pod '.$_POST['domain']); $log->lwrite('Your pod does not have ssl but is a valid pod ' . $_POST['domain']);
echo 'Your pod does not have ssl but is a valid pod<br>'; echo 'Your pod does not have ssl but is a valid pod<br>';
$valid=1; $valid = 1;
} }
if ($valid == '1') { if ($valid == '1') {
$sql = "INSERT INTO pods (domain, pingdomurl, email) VALUES($1, $2, $3)"; $sql = "INSERT INTO pods (domain, pingdomurl, email) VALUES($1, $2, $3)";
$result = pg_query_params($dbh, $sql, array($_POST['domain'], $_POST['url'], $_POST['email'])); $result = pg_query_params($dbh, $sql, [$_POST['domain'], $_POST['url'], $_POST['email']]);
if (!$result) { if (!$result) {
die('Error in SQL query: ' . pg_last_error()); die('Error in SQL query: ' . pg_last_error());
} }
$to = $adminemail; $to = $adminemail;
$cc = $_POST['email']; $cc = $_POST['email'];
$subject = 'New pod added to podupti.me '; $subject = 'New pod added to podupti.me ';
$message.= sprintf( $message .= sprintf(
"%1$s\n\n Stats Url: %2$s\n\n Pod: %3$s\n\n", "%1$s\n\n Stats Url: %2$s\n\n Pod: %3$s\n\n",
'https://podupti.me', 'https://podupti.me',
'https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $_POST['url'], 'https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $_POST['url'],
'https://podupti.me/db/pull.php?debug=1&domain=' . $_POST['domain'] 'https://podupti.me/db/pull.php?debug=1&domain=' . $_POST['domain']
); );
$message.= 'Your pod will not show right away, needs to pass a few checks, Give it a few hours!'; $message .= 'Your pod will not show right away, needs to pass a few checks, Give it a few hours!';
$headers = 'From: ' . $_POST['email'] . "\r\nReply-To: " . $_POST['email'] . "\r\nCc: " . $_POST['email'] . "\r\n"; $headers = 'From: ' . $_POST['email'] . "\r\nReply-To: " . $_POST['email'] . "\r\nCc: " . $_POST['email'] . "\r\n";
@mail( $to, $subject, $message, $headers ); @mail($to, $subject, $message, $headers);
echo 'Data successfully inserted! Your pod will be reviewed and live on the list in a few hours!'; echo 'Data successfully inserted! Your pod will be reviewed and live on the list in a few hours!';
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
} else { } else {
$log->lwrite('Could not validate your pod on http or https, check your setup! ' . $_POST['domain']); $log->lwrite('Could not validate your pod on http or https, check your setup! ' . $_POST['domain']);
......
...@@ -6,26 +6,26 @@ require_once __DIR__ . '/../config.php'; ...@@ -6,26 +6,26 @@ require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { if (!$dbh) {
die('Error in connection: ' . pg_last_error()); die('Error in connection: ' . pg_last_error());
} }
$sql = "SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods WHERE domain = $1"; $sql = "SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, array($_GET['url'])); $result = pg_query_params($dbh, $sql, [$_GET['url']]);
if (!$result) { if (!$result) {
die('Error in SQL query: ' . pg_last_error()); die('Error in SQL query: ' . pg_last_error());
} }
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($_GET['format'] == 'json') { if ($_GET['format'] == 'json') {
echo json_encode($row); echo json_encode($row);
} else { } else {
echo 'Status: ' . $row['status'] . '<br>'; echo 'Status: ' . $row['status'] . '<br>';
echo 'Last Git Pull: ' . $row['hgitdate'] . '<br>'; echo 'Last Git Pull: ' . $row['hgitdate'] . '<br>';
echo 'Uptime This Month ' . $row['uptimelast7'] . '<br>'; echo 'Uptime This Month ' . $row['uptimelast7'] . '<br>';
echo 'Months Monitored: ' . $row['monthsmonitored'] . '<br>'; echo 'Months Monitored: ' . $row['monthsmonitored'] . '<br>';
echo 'Response Time: ' . $row['responsetimelast7'] . '<br>'; echo 'Response Time: ' . $row['responsetimelast7'] . '<br>';
echo 'User Rating: ' . $row['userrating'] . '<br>'; echo 'User Rating: ' . $row['userrating'] . '<br>';
echo 'Server Location: ' . $row['country'] . '<br>'; echo 'Server Location: ' . $row['country'] . '<br>';
echo 'Latitude: ' . $row['lat'] . '<br>'; echo 'Latitude: ' . $row['lat'] . '<br>';
echo 'Longitude: ' . $row['long'] . '<br>'; echo 'Longitude: ' . $row['long'] . '<br>';
} }
} }
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
<?php <?php
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
$keep = (60 * 60 * 6) * 1; $keep = (60 * 60 * 6) * 1;
$dump_date = date('Ymd_Hs');