OnionSpider/index.php

90 lines
3.5 KiB
PHP

<?php
# Onion Search
# Copyright (C) 2015 y.st. <mailto:copyright@y.st>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
spl_autoload_register();
require 'st/y/function/error_handler.php';
require 'localhost/onion_search/const.php';
set_error_handler('\\st\\y\\error_handler');
// We need to send the correct Content-Type header.
header('Content-Type: application/xhtml+xml');
// These two constants are easier to use in strings if they are variables.
$nocrawl = \localhost\onion_search\ONIONSEARCH_NOCRAWL;
$tocrawl = \localhost\onion_search\ONIONSEARCH_TOCRAWL;
$useragent = htmlspecialchars(\localhost\onion_search\REMOTE_USERAGENT,
ENT_QUOTES|ENT_SUBSTITUTE|ENT_DISALLOWED|ENT_XML1,
'UTF-8', true);
// The database reading/writing object
$MySQLi = new mysqli(
\localhost\onion_search\MYSQLI_HOST,
\localhost\onion_search\MYSQLI_USERNAME,
\localhost\onion_search\MYSQLI_PASSWORD,
\localhost\onion_search\MYSQLI_DATABASE,
\localhost\onion_search\MYSQLI_PORT,
\localhost\onion_search\MYSQLI_SOCKET
); ?>
<?xml version="1.0" encoding="utf-8"?>
<!--
Onion Search
Copyright (C) 2015 y.st. <mailto:copyright@y.st>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>Onions found by <?php
echo $useragent;
?></title>
<meta name="viewport" content="width=device-width" />
</head><body>
<h1>Onions found by <?php
echo $useragent;
?></h1>
<ul><?php
$result = $MySQLi->query("SELECT `uri`, `title` FROM `$tocrawl` ORDER BY `uri`");
foreach($result as $onion):
$title = htmlspecialchars($onion['title'],
ENT_QUOTES|ENT_SUBSTITUTE|ENT_DISALLOWED|ENT_XML1,
'UTF-8', true);
echo "<li><a href=\"$onion[uri]\">$title</a></li>\n";
endforeach;
?></ul><ul><?php
$result = $MySQLi->query("SELECT `uri` FROM `$nocrawl` ORDER BY `uri`");
foreach($result as $onion):
$title = htmlspecialchars($onion['uri'],
ENT_QUOTES|ENT_SUBSTITUTE|ENT_DISALLOWED|ENT_XML1,
'UTF-8', true);
echo "<li><a href=\"$onion[uri]\">$title</a></li>\n";
endforeach;
?></ul><hr/>
<p>Copyright &#169; 2015 <a href="https://y.st/">y.st.</a>; You may modify and/or redistribute this document under the terms of the <abbr title="GNU&apos;s Not Unix">GNU</abbr> <abbr title="Affero General Public License version Three or later">AGPLv3+</abbr>.</p>
</body></html>