120 lines
3.8 KiB
PHP
Executable file
120 lines
3.8 KiB
PHP
Executable file
<?php
|
|
session_start();
|
|
include 'config.php';
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
if (!isset($_POST["name"]) || !isset($_POST["url"]) || !isset($_POST["category"]) || !isset($_POST["captcha"])) {
|
|
echo("One of the fields wasn't submitted.");
|
|
session_destroy();
|
|
die();
|
|
}
|
|
if (strtoupper($_SESSION['captcha_code']) != strtoupper($_POST["captcha"])) {
|
|
echo("Wrong captcha");
|
|
session_destroy();
|
|
die();
|
|
}
|
|
$name = $_POST["name"];
|
|
$url = $_POST["url"];
|
|
$category = $_POST["category"];
|
|
$summary = $_POST["summary"];
|
|
$url = filter_var($url, FILTER_SANITIZE_URL);
|
|
if (!filter_var($url, FILTER_VALIDATE_URL)) {
|
|
echo("The url you provided, '$url', is not a valid URL. <br> <small> (Try putting https:// or http:// at the beginning)</small>");
|
|
session_destroy();
|
|
die();
|
|
}
|
|
$tld = end(explode(".", parse_url($url, PHP_URL_HOST)));
|
|
if ($tld == "onion" || $tld == "i2p") {
|
|
echo("Hidden services are not allowed");
|
|
session_destroy();
|
|
die();
|
|
}
|
|
if (in_array(parse_url($url, PHP_URL_HOST), constant("bannedhosts"))) {
|
|
echo("Blacklisted host, sorry");
|
|
session_destroy();
|
|
die();
|
|
}
|
|
if (!array_key_exists($category, constant("categories"))) {
|
|
echo("You submitted an invalid category.");
|
|
session_destroy();
|
|
die();
|
|
}
|
|
$name = htmlspecialchars($name);
|
|
$url = htmlspecialchars($url);
|
|
$summary = htmlspecialchars($summary);
|
|
if (70 < strlen($name)) {
|
|
echo("Name too long");
|
|
session_destroy();
|
|
die();
|
|
}
|
|
if (100 < strlen($url)) {
|
|
echo("URL too long");
|
|
session_destroy();
|
|
die();
|
|
}
|
|
if (70 < strlen($summary)) {
|
|
echo("Summary too long");
|
|
session_destroy();
|
|
die();
|
|
}
|
|
if (100 < strlen($category)) {
|
|
echo("Category too long");
|
|
session_destroy();
|
|
die();
|
|
}
|
|
require 'common.php';
|
|
if (submitSite($name, $url, $summary, $category)) {
|
|
session_destroy();
|
|
echo("<html>");
|
|
head();
|
|
echo("<body><p>Your site was submitted. Click <a href=\"/\">here</a> to go back to the homepage.</p></body></html>");
|
|
die();
|
|
} else {
|
|
echo("Error");
|
|
session_destroy();
|
|
die();
|
|
}
|
|
}
|
|
|
|
?>
|
|
<html>
|
|
<?php
|
|
head("Submit");
|
|
?>
|
|
<body>
|
|
<h1>Submit Site</h1>
|
|
<div class="about" style="background-color: #eef;">
|
|
<p> <b>!</b> Please check out the <a href="rules.php">rules</a> before submitting.</p>
|
|
</div>
|
|
<form action="submit.php" method="POST">
|
|
<table>
|
|
<tr><th>Name</th><td><input type="text" name="name" id="name" maxlength="40"> <small>40c</small></td></tr>
|
|
<tr><th>URL</th><td><input type="text" name="url" id="url" maxlength="100" size="50"> <small>100c</small>
|
|
<tr><th>Summary</th><td><input type="text" name="summary" id="summary" maxlength="70" size="50"> <small>70c</small>
|
|
<tr><th>Category</th><td><select name="category" id="category">
|
|
<?php
|
|
foreach (constant("categories") as $key => $name) {
|
|
echo("<option value='");
|
|
echo($key);
|
|
echo("'>");
|
|
echo($name);
|
|
echo("</option>");
|
|
}
|
|
?>
|
|
</select></td></tr>
|
|
<tr><th>Captcha<br><small>(Case-insensitive)</small></th><td><div class="captchacontainer"><img class="captcha" src="/captcha.php"><br><input type="text" size="5" maxlength="5" name="captcha"></div></td></tr>
|
|
<tr><td><input type="submit"></td><td></td></tr>
|
|
</table>
|
|
</form>
|
|
<div style="text-align:left;">
|
|
<p>
|
|
<li>Wiki - Personal is for wikis with a single editor.</li>
|
|
<li>Forum - International is for forums where multiple languages are spoken.</li>
|
|
<li>Note: If your site is for a server for another protocol like a game server, pubnix, IRC, or Gemini/Gopher, categorize it as "Public server". <b>Note that non-HTTP links are allowed, but please categorize them as <i>Other (Not HTTP)</i> if there's not a category for them already.</b></li><p>
|
|
</div>
|
|
<footer>
|
|
<hr>
|
|
<?php echo constant("footer"); ?>
|
|
</footer>
|
|
</body>
|
|
</html>
|
|
|