mirror of
https://github.com/PurpleI2P/regi2p.git
synced 2025-02-10 19:04:14 +00:00
add autojump, update css, add host disabling
Signed-off-by: r4sas <r4sas@i2pmail.org>
This commit is contained in:
parent
ee04d00c70
commit
e79d2bb28e
@ -65,7 +65,7 @@ foreach ($results as $host => $result)
|
|||||||
{
|
{
|
||||||
if($result)
|
if($result)
|
||||||
{
|
{
|
||||||
$pdo->exec("UPDATE `hosts` SET `last_seen` = current_timestamp() WHERE `host` = '" . $host . "'");
|
$pdo->exec("UPDATE `hosts` SET `last_seen` = current_timestamp(), `disabled` = 0, `hidden` = 0 WHERE `host` = '" . $host . "'");
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,11 @@ $options = [
|
|||||||
'approvedelay' => 24, // check host for availability before publishing for this time (hours)
|
'approvedelay' => 24, // check host for availability before publishing for this time (hours)
|
||||||
'approveseen' => 3, // host must be seen lesser than this amount of hours for approving (hours)
|
'approveseen' => 3, // host must be seen lesser than this amount of hours for approving (hours)
|
||||||
|
|
||||||
'newdays' => 7, // assume host as new for that amout of days
|
'newdays' => 14, // assume host as new for that amout of days
|
||||||
'delnewdays' => 3, // if new host not seen more than X days, disable it and disapprove
|
'delnewdays' => 3, // if new host not seen more than X days, disable it and disapprove
|
||||||
'delolddays' => 30, // same as above, but for old hosts
|
'delolddays' => 45, // same as above, but for old hosts
|
||||||
|
|
||||||
|
'hidedays' => 3, // days before domain will be marked as hidden in period before disabling
|
||||||
|
|
||||||
'fullhour' => 8, // make hosts full-check at that hour (0-23). Usage of out-of-range value or at other hours, checker will validate only enabled domains.
|
'fullhour' => 8, // make hosts full-check at that hour (0-23). Usage of out-of-range value or at other hours, checker will validate only enabled domains.
|
||||||
];
|
];
|
||||||
|
37
export.php
37
export.php
@ -8,16 +8,18 @@ date_default_timezone_set ('UTC');
|
|||||||
$pdo = (new App\DB($options))->pdo;
|
$pdo = (new App\DB($options))->pdo;
|
||||||
$util = new App\Utils;
|
$util = new App\Utils;
|
||||||
|
|
||||||
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `add_date`, `last_seen`, `approved`, `initial`, `disabled` FROM hosts");
|
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `add_date`, `last_seen`, `approved`, `initial`, `disabled`, `hidden` FROM hosts");
|
||||||
$hosts = $STH->fetchAll(PDO::FETCH_ASSOC);
|
$hosts = $STH->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
// for automatic approving
|
// for automatic approving
|
||||||
$approffs = date ("Y-m-d H:i:s", strtotime ("-" . $options["approvedelay"] . " hour")); // approval offset
|
$approffs = date ("Y-m-d H:i:s", strtotime ("-" . $options["approvedelay"] . " hour")); // approval offset
|
||||||
$apprseen = date ("Y-m-d H:i:s", strtotime ("-" . $options["approveseen"] . " hour")); // approval maxseen offset
|
$apprseen = date ("Y-m-d H:i:s", strtotime ("-" . $options["approveseen"] . " hour")); // approval maxseen offset
|
||||||
|
|
||||||
$newregoffs = date ("Y-m-d H:i:s", strtotime ("-" . $options["newdays"] . " day")); // 7
|
$newregoffs = date ("Y-m-d H:i:s", strtotime ("-" . $options["newdays"] . " day"));
|
||||||
$newseenlim = date ("Y-m-d H:i:s", strtotime ("-" . $options["delnewdays"] . " day")); // 3
|
$newseenlim = date ("Y-m-d H:i:s", strtotime ("-" . $options["delnewdays"] . " day"));
|
||||||
$oldseenlim = date ("Y-m-d H:i:s", strtotime ("-" . $options["delolddays"] . " day")); // 30
|
$oldseenlim = date ("Y-m-d H:i:s", strtotime ("-" . $options["delolddays"] . " day"));
|
||||||
|
|
||||||
|
$hideoffs = date ("Y-m-d H:i:s", strtotime ("-" . $options["hidedays"] . " day")); // hide offset
|
||||||
|
|
||||||
$export_full = $export_live = $export_init = [];
|
$export_full = $export_live = $export_init = [];
|
||||||
$export_addr_full = $export_addr_live = $export_addr_init = [];
|
$export_addr_full = $export_addr_live = $export_addr_init = [];
|
||||||
@ -31,27 +33,28 @@ foreach ($hosts as $host)
|
|||||||
array_push($export_addr_full, $domain . "," . $host["base32"]);
|
array_push($export_addr_full, $domain . "," . $host["base32"]);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
($options["approval"] == false || $host["approved"] == 1) &&
|
($options["approval"] == false || $host["approved"] == 1) && $host["hidden"] == 0 &&
|
||||||
($host["disabled"] == 0 ||
|
($host["disabled"] == 0 ||
|
||||||
(
|
(
|
||||||
($host["add_date"] > $newregoffs && $host["last_seen"] > $newseenlim) ||
|
($host["add_date"] > $newregoffs && $host["last_seen"] > $newseenlim) ||
|
||||||
($host["add_date"] < $newregoffs && $host["last_seen"] > $oldseenlim)
|
($host["add_date"] < $newregoffs && $host["last_seen"] > $oldseenlim) // is seen till disabling date
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
array_push($export_live, $domain . "=" . $host["base64"]);
|
if ($host["last_seen"] > $hideoffs) { // if seen not earlier than hide offset
|
||||||
array_push($export_addr_live, $domain . "," . $host["base32"]);
|
array_push($export_live, $domain . "=" . $host["base64"]);
|
||||||
|
array_push($export_addr_live, $domain . "," . $host["base32"]);
|
||||||
|
|
||||||
if ($host["initial"] == 1)
|
if ($host["initial"] == 1)
|
||||||
{
|
{
|
||||||
array_push($export_init, $domain . "=" . $host["base64"]);
|
array_push($export_init, $domain . "=" . $host["base64"]);
|
||||||
array_push($export_addr_init, $domain . "," . $host["base32"]);
|
array_push($export_addr_init, $domain . "," . $host["base32"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else // hide because not available for "hidedays" days
|
||||||
if ($host["disabled"] == 1)
|
|
||||||
{
|
{
|
||||||
$pdo->exec ("UPDATE `hosts` SET `disabled` = 0 WHERE `host` = '" . $host["host"] . "'");
|
$pdo->exec ("UPDATE `hosts` SET `hidden` = 1 WHERE `host` = '" . $host["host"] . "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
@ -68,7 +71,7 @@ foreach ($hosts as $host)
|
|||||||
if (
|
if (
|
||||||
$host["disabled"] == 0 &&
|
$host["disabled"] == 0 &&
|
||||||
($host["add_date"] > $newregoffs && $host["last_seen"] < $newseenlim) ||
|
($host["add_date"] > $newregoffs && $host["last_seen"] < $newseenlim) ||
|
||||||
($host["add_date"] < $newregoffs && $host["last_seen"] < $oldseenlim)
|
($host["add_date"] < $newregoffs && $host["last_seen"] < $oldseenlim) // is seen more that disabling period days
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$pdo->exec ("UPDATE `hosts` SET `disabled` = 1 WHERE `host` = '" . $host["host"] . "'");
|
$pdo->exec ("UPDATE `hosts` SET `disabled` = 1 WHERE `host` = '" . $host["host"] . "'");
|
||||||
|
@ -153,9 +153,9 @@ class Utils {
|
|||||||
{
|
{
|
||||||
$len = strlen($data);
|
$len = strlen($data);
|
||||||
|
|
||||||
if($len < 5 || $len > 67)
|
if($len < 5 || $len > 255) // rfc2181, section 11
|
||||||
{
|
{
|
||||||
$result = "Domain must be longer than 5 and lesser than 67 chars.";
|
$result = "Domain must be longer than 5 and lesser than 255 chars.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ class Utils {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$result = "Domain is not valid or is not in Punycode format.";
|
$result = "Domain is not valid. Check if you domain label is lesser than 63 chars, and uses only ASCII or Punycode format.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,9 +188,9 @@ class Utils {
|
|||||||
{
|
{
|
||||||
$len = strlen($data);
|
$len = strlen($data);
|
||||||
|
|
||||||
if($len < 5 || $len > 67)
|
if($len < 5 || $len > 255) // rfc2181, section 11
|
||||||
{
|
{
|
||||||
$result = "Domain must be longer than 5 and lesser than 67 chars.";
|
$result = "Domain must be longer than 5 and lesser than 255 chars.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,8 +368,12 @@ abbr {
|
|||||||
color: #ddddff;
|
color: #ddddff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table__row td:last-of-type {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
.table__cell {
|
.table__cell {
|
||||||
padding: 10px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table__cell_center-bold {
|
.table__cell_center-bold {
|
||||||
|
@ -27,6 +27,10 @@ $r->addRoute('^/jump/?(.*)/?', function($url, $query = "") {
|
|||||||
require __DIR__ . '/../views/jump.php';
|
require __DIR__ . '/../views/jump.php';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$r->addRoute('^/autojump/?(.*)/?', function($url, $query = "") {
|
||||||
|
require __DIR__ . '/../views/autojump.php';
|
||||||
|
});
|
||||||
|
|
||||||
$r->addRoute('^/latest/?$', function($url) {
|
$r->addRoute('^/latest/?$', function($url) {
|
||||||
require __DIR__ . '/../views/latest.php';
|
require __DIR__ . '/../views/latest.php';
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,11 @@
|
|||||||
<tbody class="table__body">
|
<tbody class="table__body">
|
||||||
{% for host in hosts %}
|
{% for host in hosts %}
|
||||||
<tr class="table__row">
|
<tr class="table__row">
|
||||||
<td class="table__cell"><a href="http://{{ host.host }}/" rel="external nofollow noopener noreferrer" target="_blank">{{ host.host }}</a></td>
|
{% if host.host|length > 24 %}
|
||||||
|
<td class="table__cell table__cell_long-ass"><a href="http://{{ host.host }}/" rel="external nofollow noopener noreferrer" target="_blank">{{ host.host|slice(0, 23) }}…</a></td>
|
||||||
|
{% else %}
|
||||||
|
<td class="table__cell table__cell_long-ass"><a href="http://{{ host.host }}/" rel="external nofollow noopener noreferrer" target="_blank">{{ host.host }}</a></td>
|
||||||
|
{% endif %}
|
||||||
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.host }}/?i2paddresshelper={{ host.base64 }}" rel="external nofollow noopener noreferrer" target="_blank">A</a></td>
|
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.host }}/?i2paddresshelper={{ host.base64 }}" rel="external nofollow noopener noreferrer" target="_blank">A</a></td>
|
||||||
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.base32 }}.b32.i2p/" rel="external nofollow noopener noreferrer" target="_blank">B</a></td>
|
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.base32 }}.b32.i2p/" rel="external nofollow noopener noreferrer" target="_blank">B</a></td>
|
||||||
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}.b32.i2p</td>
|
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}.b32.i2p</td>
|
||||||
|
@ -42,7 +42,10 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>{{ delnewdays }} days if registered less than {{ newdays }} days ago</li>
|
<li>{{ delnewdays }} days if registered less than {{ newdays }} days ago</li>
|
||||||
<li>{{ delolddays }} days if registered more than {{ newdays }} days ago</li>
|
<li>{{ delolddays }} days if registered more than {{ newdays }} days ago</li>
|
||||||
|
<li>1 year if registered more than {{ delolddays }} days ago</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Domains that are inaccessible before the disabling date for {{ hidedays }} days, will be hidden from <a href="/alive">alive</a> list, removed from export lists, but will still be checked every hour.<br>
|
||||||
|
When domain dead for amount days stated above, it will be marked as disabled, opened for registration and will be checked once a day for availability at {{ fullhour }} o'clock UTC.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{% if approval %}
|
{% if approval %}
|
||||||
|
@ -1,6 +1,22 @@
|
|||||||
{% extends "_page.twig" %}
|
{% extends "_page.twig" %}
|
||||||
|
|
||||||
{% block title %}Jump to site{% endblock %}
|
{% block title %}Jump to site{% endblock %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
{{ parent() }}
|
||||||
|
{% if autojump %}
|
||||||
|
{% if not result %}
|
||||||
|
<meta http-equiv="refresh" content="2; URL=/jump/" />
|
||||||
|
{% elseif result.error|length > 0 %}
|
||||||
|
{# Skipping redirect #}
|
||||||
|
{% elseif result.uri|length > 0 %}
|
||||||
|
<meta http-equiv="refresh" content="4; URL=http://{{ result.host }}/{{ result.uri }}{% if '?' in result.uri %}&{% else %}?{% endif %}i2paddresshelper={{ result.base64 }}" />
|
||||||
|
{% else %}
|
||||||
|
<meta http-equiv="refresh" content="4; URL=http://{{ result.host }}/?i2paddresshelper={{ result.base64 }}" />
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="jumper">
|
<div class="jumper">
|
||||||
@ -13,11 +29,21 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<div class="jumper__succ">
|
<div class="jumper__succ">
|
||||||
<h3 class="jumper__title title">Query result for "{{ result.host }}"</h3>
|
<h3 class="jumper__title title">Query result for "{{ result.host }}"</h3>
|
||||||
|
{% if autojump %}
|
||||||
|
<div class="jumper__line line">
|
||||||
|
Site is found. You will be redirected soon...
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
{% endif %}
|
||||||
<div class="jumper__line line">
|
<div class="jumper__line line">
|
||||||
<span>
|
<span>
|
||||||
Addresshelper:
|
Addresshelper:
|
||||||
</span>
|
</span>
|
||||||
<a href="http://{{ result.host }}/?i2paddresshelper={{ result.base64 }}" rel="external nofollow noopener noreferrer" target="_blank">Go to site</a>
|
{% if result.uri|length > 0 %}
|
||||||
|
<a href="http://{{ result.host }}/{{ result.uri }}{% if '?' in result.uri %}&{% else %}?{% endif %}i2paddresshelper={{ result.base64 }}" rel="external nofollow noopener noreferrer" target="_blank">Go to site</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="http://{{ result.host }}/?i2paddresshelper={{ result.base64 }}" rel="external nofollow noopener noreferrer" target="_blank">Go to site</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="jumper__line line">
|
<div class="jumper__line line">
|
||||||
@ -36,9 +62,31 @@
|
|||||||
{{ result.base64 }}
|
{{ result.base64 }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="jumper__line line">
|
||||||
|
<span>
|
||||||
|
Added at:
|
||||||
|
</span>
|
||||||
|
<span class="crazy-base64-span">
|
||||||
|
{{ result.add_date }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="jumper__line line">
|
||||||
|
<span>
|
||||||
|
Last seen:
|
||||||
|
</span>
|
||||||
|
<span class="crazy-base64-span">
|
||||||
|
{{ result.last_seen != '0000-00-00 00:00:00' ? result.last_seen : 'Never' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% elseif (autojump and not result) %}
|
||||||
|
<div class="jumper__err">
|
||||||
|
<h3 class="jumper__title title">Error</h3>
|
||||||
|
<b style="color: red;">Empty request, redirecting to jump page</b>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if not autojump %}
|
||||||
<div class="jumper__itself">
|
<div class="jumper__itself">
|
||||||
<p class="important jumper__title title">
|
<p class="important jumper__title title">
|
||||||
Query domain
|
Query domain
|
||||||
@ -51,6 +99,7 @@
|
|||||||
<input type="submit" value="Submit" class="btn jumper__btn">
|
<input type="submit" value="Submit" class="btn jumper__btn">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -22,7 +22,11 @@
|
|||||||
<tbody class="table__body">
|
<tbody class="table__body">
|
||||||
{% for host in hosts %}
|
{% for host in hosts %}
|
||||||
<tr class="table__row">
|
<tr class="table__row">
|
||||||
<td class="table__cell"><a href="http://{{ host.host }}/" rel="external nofollow noopener noreferrer" target="_blank">{{ host.host }}</a></td>
|
{% if host.host|length > 24 %}
|
||||||
|
<td class="table__cell table__cell_long-ass"><a href="http://{{ host.host }}/" rel="external nofollow noopener noreferrer" target="_blank">{{ host.host|slice(0, 23) }}…</a></td>
|
||||||
|
{% else %}
|
||||||
|
<td class="table__cell table__cell_long-ass"><a href="http://{{ host.host }}/" rel="external nofollow noopener noreferrer" target="_blank">{{ host.host }}</a></td>
|
||||||
|
{% endif %}
|
||||||
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.host }}/?i2paddresshelper={{ host.base64 }}" rel="external nofollow noopener noreferrer" target="_blank">A</a></td>
|
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.host }}/?i2paddresshelper={{ host.base64 }}" rel="external nofollow noopener noreferrer" target="_blank">A</a></td>
|
||||||
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.base32 }}.b32.i2p/" rel="external nofollow noopener noreferrer" target="_blank">B</a></td>
|
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.base32 }}.b32.i2p/" rel="external nofollow noopener noreferrer" target="_blank">B</a></td>
|
||||||
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}.b32.i2p</td>
|
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}.b32.i2p</td>
|
||||||
|
@ -50,8 +50,11 @@
|
|||||||
<label for="q">Query:</label>
|
<label for="q">Query:</label>
|
||||||
<input class="text-input search-page__text-input" type="text" id="q" name="q" maxlength="67" placeholder="domain.i2p" required>
|
<input class="text-input search-page__text-input" type="text" id="q" name="q" maxlength="67" placeholder="domain.i2p" required>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form__field">
|
||||||
|
<label for="q">Alive only:</label>
|
||||||
|
<input type="checkbox" id="a" name="a" value="1">
|
||||||
|
</div>
|
||||||
<input type="submit" value="Submit" class="btn search-page__btn">
|
<input type="submit" value="Submit" class="btn search-page__btn">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
|
|||||||
$result["error"] = "Error while validating: " . $error;
|
$result["error"] = "Error while validating: " . $error;
|
||||||
} else {
|
} else {
|
||||||
if ($util->isPunycodeDomain($parsed['host'])) {
|
if ($util->isPunycodeDomain($parsed['host'])) {
|
||||||
$domain = idn_to_utf8($parsed['host']);
|
$domain = idn_to_utf8($parsed['host'], 0, INTL_IDNA_VARIANT_UTS46);
|
||||||
} else {
|
} else {
|
||||||
$domain = $parsed['host'];
|
$domain = $parsed['host'];
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ $pdo = (new App\DB($options))->pdo;
|
|||||||
|
|
||||||
/* Get records amount */
|
/* Get records amount */
|
||||||
$STH = $pdo->query ("SELECT COUNT(*) as `count` FROM `hosts` " .
|
$STH = $pdo->query ("SELECT COUNT(*) as `count` FROM `hosts` " .
|
||||||
"WHERE `approved` = 1 AND (" .
|
"WHERE `approved` = 1 AND `disabled` = 0 AND `hidden` = 0 AND (" .
|
||||||
" (`add_date` < '" . $newregoffs . "' AND `last_seen` > '" . $oldseenlim . "') OR" .
|
" (`add_date` < '" . $newregoffs . "' AND `last_seen` > '" . $oldseenlim . "') OR" .
|
||||||
" (`add_date` > '" . $newregoffs . "' AND `last_seen` > '" . $newseenlim . "')" .
|
" (`add_date` > '" . $newregoffs . "' AND `last_seen` > '" . $newseenlim . "')" .
|
||||||
")");
|
")");
|
||||||
@ -30,7 +30,7 @@ $pages = intdiv($records, $options["tableitems"]) + 1;
|
|||||||
|
|
||||||
/* Get records with limit */
|
/* Get records with limit */
|
||||||
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` " .
|
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` " .
|
||||||
"WHERE `approved` = 1 AND (" .
|
"WHERE `approved` = 1 AND `disabled` = 0 AND `hidden` = 0 AND (" .
|
||||||
" (`add_date` < '" . $newregoffs . "' AND `last_seen` > '" . $oldseenlim . "') OR" .
|
" (`add_date` < '" . $newregoffs . "' AND `last_seen` > '" . $oldseenlim . "') OR" .
|
||||||
" (`add_date` > '" . $newregoffs . "' AND `last_seen` > '" . $newseenlim . "')" .
|
" (`add_date` > '" . $newregoffs . "' AND `last_seen` > '" . $newseenlim . "')" .
|
||||||
") LIMIT " . $offset . ", " . $options["tableitems"]);
|
") LIMIT " . $offset . ", " . $options["tableitems"]);
|
||||||
|
58
views/autojump.php
Normal file
58
views/autojump.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
|
require_once __DIR__ . '/../config.php';
|
||||||
|
|
||||||
|
/* Initialize Twig engine */
|
||||||
|
$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/../templates');
|
||||||
|
$twig = new \Twig\Environment($loader, [
|
||||||
|
'cache' => __DIR__ . '/../cache',
|
||||||
|
'auto_reload' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$utils = new App\Utils;
|
||||||
|
|
||||||
|
$domain = "";
|
||||||
|
$uri = "";
|
||||||
|
$result = [];
|
||||||
|
$error = "";
|
||||||
|
|
||||||
|
// Get request data and check if request contain uri path
|
||||||
|
if (isset($query) && !empty($query)) {
|
||||||
|
if (strpos($query, "/")) {
|
||||||
|
$a = explode ("/", $query, 2);
|
||||||
|
$domain = htmlspecialchars($a[0]);
|
||||||
|
$uri = $a[1];
|
||||||
|
} else {
|
||||||
|
$domain = htmlspecialchars($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check domain name
|
||||||
|
if(!empty($domain) && !$utils->isValidDomain($domain, $error)) {
|
||||||
|
$domain = "";
|
||||||
|
$result["error"] = 'Not valid query: ' . $error;
|
||||||
|
}
|
||||||
|
else if(!empty($domain) && $utils->isValidDomain($domain, $error)) {
|
||||||
|
if ((new App\Utils)->isPunycodeDomain($domain)) {
|
||||||
|
$domain = idn_to_utf8($domain, 0, INTL_IDNA_VARIANT_UTS46);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo = (new App\DB($options))->pdo;
|
||||||
|
|
||||||
|
$STH = $pdo->query("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1");
|
||||||
|
$STH->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
|
$row = $STH->fetchAll();
|
||||||
|
|
||||||
|
if (empty($row)) {
|
||||||
|
$result["error"] = "No such host is found";
|
||||||
|
} else {
|
||||||
|
$result = array_merge($result, $row[0]);
|
||||||
|
if (!empty($uri)) {
|
||||||
|
$result['uri'] = $uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$template = $twig->load('jump.twig');
|
||||||
|
echo $template->render(['autojump' => true, 'domain' => $domain, 'result' => $result]);
|
@ -27,6 +27,8 @@ $vars = array(
|
|||||||
'newdays' => $options['newdays'],
|
'newdays' => $options['newdays'],
|
||||||
'delnewdays' => $options['delnewdays'],
|
'delnewdays' => $options['delnewdays'],
|
||||||
'delolddays' => $options['delolddays'],
|
'delolddays' => $options['delolddays'],
|
||||||
|
'hidedays' => $options['hidedays'],
|
||||||
|
'fullhour' => $options['fullhour'],
|
||||||
'fetcher' => $options['fetcher'],
|
'fetcher' => $options['fetcher'],
|
||||||
'subscrs' => $subscrs
|
'subscrs' => $subscrs
|
||||||
);
|
);
|
||||||
|
@ -12,31 +12,52 @@ $twig = new \Twig\Environment($loader, [
|
|||||||
|
|
||||||
$utils = new App\Utils;
|
$utils = new App\Utils;
|
||||||
|
|
||||||
|
$data = "";
|
||||||
$domain = "";
|
$domain = "";
|
||||||
|
$uri = "";
|
||||||
$result = [];
|
$result = [];
|
||||||
$error = "";
|
$error = "";
|
||||||
if (isset($query) && strlen($query) > 67 || isset($_POST["q"]) && strlen($_POST["q"]) > 67)
|
|
||||||
$result["error"] = "Request is too long, max length is 67 chars";
|
|
||||||
else if (isset($query) && !empty($query))
|
|
||||||
$domain = htmlspecialchars($query);
|
|
||||||
else if (isset($_POST["q"]))
|
|
||||||
$domain = htmlspecialchars($_POST["q"]);
|
|
||||||
|
|
||||||
|
// Get request data
|
||||||
|
if (isset($query) && !empty($query)) {
|
||||||
|
$data = $query;
|
||||||
|
} else if (isset($_POST["q"])) {
|
||||||
|
$data = $_POST["q"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if request contain uri path
|
||||||
|
if (strpos($data, "/")) {
|
||||||
|
$a = explode ("/", $data, 2);
|
||||||
|
$domain = htmlspecialchars($a[0]);
|
||||||
|
$uri = $a[1];
|
||||||
|
} else {
|
||||||
|
$domain = htmlspecialchars($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check domain name
|
||||||
if(!empty($domain) && !$utils->isValidDomain($domain, $error)) {
|
if(!empty($domain) && !$utils->isValidDomain($domain, $error)) {
|
||||||
$domain = "";
|
$domain = "";
|
||||||
$result["error"] = 'Not valid query: ' . $error;
|
$result["error"] = 'Not valid query: ' . $error;
|
||||||
}
|
}
|
||||||
else if(!empty($domain) && $utils->isValidDomain($domain, $error)) {
|
else if(!empty($domain) && $utils->isValidDomain($domain, $error)) {
|
||||||
|
if ((new App\Utils)->isPunycodeDomain($domain)) {
|
||||||
|
$domain = idn_to_utf8($domain, 0, INTL_IDNA_VARIANT_UTS46);
|
||||||
|
}
|
||||||
|
|
||||||
$pdo = (new App\DB($options))->pdo;
|
$pdo = (new App\DB($options))->pdo;
|
||||||
|
|
||||||
$STH = $pdo->query("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1");
|
$STH = $pdo->query("SELECT `host`, `base64`, `base32`, `add_date`, `last_seen` FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1");
|
||||||
$STH->setFetchMode(PDO::FETCH_ASSOC);
|
$STH->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
$row = $STH->fetchAll();
|
$row = $STH->fetchAll();
|
||||||
|
|
||||||
if (empty($row))
|
if (empty($row)) {
|
||||||
$result["error"] = "No such host is found";
|
$result["error"] = "No such host is found";
|
||||||
else
|
} else {
|
||||||
$result = array_merge($result, $row[0]);
|
$result = array_merge($result, $row[0]);
|
||||||
|
if (!empty($uri)) {
|
||||||
|
$result['uri'] = $uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$template = $twig->load('jump.twig');
|
$template = $twig->load('jump.twig');
|
||||||
|
@ -13,7 +13,7 @@ $twig = new \Twig\Environment($loader, [
|
|||||||
$pdo = (new App\DB($options))->pdo;
|
$pdo = (new App\DB($options))->pdo;
|
||||||
|
|
||||||
/* Get records with limit */
|
/* Get records with limit */
|
||||||
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `add_date` FROM `hosts` ORDER BY `add_date` DESC LIMIT " . $options["tableitems"]);
|
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `add_date` FROM `hosts` WHERE `disabled` = 0 ORDER BY `add_date` DESC LIMIT " . $options["tableitems"]);
|
||||||
$STH->setFetchMode(PDO::FETCH_ASSOC);
|
$STH->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
$rows = $STH->fetchAll();
|
$rows = $STH->fetchAll();
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ $utils = new App\Utils;
|
|||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
$q = "";
|
$q = "";
|
||||||
|
$a = false;
|
||||||
|
|
||||||
if (isset($query) && strlen($query) > 67 || isset($_POST["q"]) && strlen($_POST["q"]) > 67) {
|
if (isset($query) && strlen($query) > 67 || isset($_POST["q"]) && strlen($_POST["q"]) > 67) {
|
||||||
$result["error"] = "Request is too long, max length is 67 chars";
|
$result["error"] = "Request is too long, max length is 67 chars";
|
||||||
@ -23,10 +24,19 @@ if (isset($query) && strlen($query) > 67 || isset($_POST["q"]) && strlen($_POST[
|
|||||||
$q = htmlspecialchars($_POST["q"]);
|
$q = htmlspecialchars($_POST["q"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_POST["a"])) {
|
||||||
|
$a = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!empty($q)) {
|
if(!empty($q)) {
|
||||||
$pdo = (new App\DB($options))->pdo;
|
$pdo = (new App\DB($options))->pdo;
|
||||||
|
|
||||||
$STH = $pdo->query("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` WHERE `host` LIKE '%" . $q . "%' OR `base32` LIKE '%" . $q . "%' LIMIT " . $options["tableitems"]);
|
if ($a)
|
||||||
|
$STH = $pdo->query("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` WHERE (`host` LIKE '%" . $q . "%' OR `base32` LIKE '%" . $q . "%') AND `disabled` = 0 LIMIT " . $options["tableitems"]);
|
||||||
|
else
|
||||||
|
$STH = $pdo->query("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` WHERE `host` LIKE '%" . $q . "%' OR `base32` LIKE '%" . $q . "%' LIMIT " . $options["tableitems"]);
|
||||||
|
|
||||||
$STH->setFetchMode(PDO::FETCH_ASSOC);
|
$STH->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
$row = $STH->fetchAll();
|
$row = $STH->fetchAll();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user