このリポジトリは2023-09-09にアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュ、イシューの作成、プルリクエストはできません。
kensaku.online/www/submit.php

102 行
4.0 KiB
PHP
Raw パーマリンク Blame 履歴

このファイルには曖昧(ambiguous)なUnicode文字が含まれています

このファイルには、他の文字と見間違える可能性があるUnicode文字が含まれています。 それが意図的なものと考えられる場合は、この警告を無視して構いません。 それらの文字を表示するにはエスケープボタンを使用します。

<?php
session_start();
require_once('../helper.php');
require_once('../config.php');
$err = [];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!isset($_SESSION['csrf'])) die('不正なリクエスト。');
if (!isset($_POST['csrf']) || $_POST['csrf'] !== $_SESSION['csrf']) die('不正なリクエスト。');
$h = htmlspecialchars($_POST['hostname']);
if (str_ends_with($h, '/')) $h = substr($h, 0, -1); // 「/」で終わったら、消して
//// セキュリティチェック
$err = domainsecuritycheck($h);
// OKですDBに入りましょう
if (empty($err)) {
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = mysqli_connect(DBHOST, DBUSER, DBPASS, DBNAME);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($site = mysqli_prepare($mysqli, "SELECT id FROM website WHERE url = ?")) {
mysqli_stmt_bind_param($site, "s", $h);
mysqli_stmt_execute($site);
mysqli_stmt_bind_result($site, $wid);
mysqli_execute($site);
mysqli_stmt_fetch($site);
$rid = $wid;
$wid = null;
mysqli_stmt_close($site);
if (is_null($rid)) mysqli_query($mysqli, "INSERT INTO `website` (url) VALUES ('".$h."');");
else $err[] = 'このウェブサイトは既に索引中です。<br />This website is already being indexed.';
}
mysqli_close($mysqli);
}
}
else {
$csrf = uuid().'-'.bin2hex(openssl_random_pseudo_bytes(16));
$_SESSION['csrf'] = $csrf;
}
$title = 'ウエブサイトの追加';
$linktype = 'side';
require_once('../include/header.php');
require_once('../include/menu.php');
?>
<hr />
<?php if ($_SERVER['REQUEST_METHOD'] === 'POST') { ?>
<p>
<h1><?= $h; ?>の追加</h1>
<?php if (empty($err)) { ?>
URLを追加しました。<br />
24時間以内から索引作業開始しますので、お待ち下さいませ。<br /><br />
Added URL.<br />
Indexing work will start within 24 hours, so please be patient.
<?php } else { ?>
下記のエラーが出ました (I got the following error)<br />
<ul>
<?php foreach ($err as $e) { ?>
<li><?= $e; ?></li>
<?php } ?>
</ul>
<?php } ?>
</p>
<?php } else {?>
<h1>ルール</h1>
<p>送信したウエブサイトはクロンキューに入りますので、すぐ見つけられる様になりません。</p>
<ul>
<li>ウェブページは自動的にウィルスをダウンロードされるのは禁止です。</li>
<li>ウェブページはTor又はVPNユーザーをブロックされる(特にCloudFlareをご利用場合)のは禁止です。</li>
<li>送信URLは「http(s)://」からTLD(.moe, .jp, .com, .net, .org等)までです。クローラーは自動で全部のページを追加されます。</li>
<li>うまく追加するには、「DOCTYPE html」及び「title」タグは必須となります。</li>
</ul>
<p>The website you sent will be in the cron queue, so you won't be able to find it right away.</p>
<ul>
<li>Web pages are prohibited from automatically downloading viruses.</li>
<li>Web pages are prohibited from blocking Tor or VPN users (especially if you are using CloudFlare).</li>
<li>The sending URL is from "http (s): //" to TLD (.moe, .jp, .com, .net, .org, etc.). The crawler will automatically add all pages.</li>
<li>The "DOCTYPE html" and "title" tags are required for successful addition.</li>
</ul>
<hr />
<form action="/submit.php" method="POST">
<input type="hidden" name="csrf" value="<?= $csrf; ?>" />
URL<input type="text" name="hostname" placeholder="例)https://suwakochan.moe" value="" />
<input type="submit" value="送信" />
</form>
<?php } ?>
<?php
require_once('../include/footer.php');
?>