init
This commit is contained in:
commit
2df55aad6a
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,210 @@
|
|||
<?php
|
||||
// CubicleSoft PHP IP Address functions.
|
||||
// (C) 2013 CubicleSoft. All Rights Reserved.
|
||||
|
||||
class IPAddr
|
||||
{
|
||||
static function NormalizeIP($ipaddr)
|
||||
{
|
||||
$ipv4addr = "";
|
||||
$ipv6addr = "";
|
||||
|
||||
// Generate IPv6 address.
|
||||
$ipaddr = strtolower(trim($ipaddr));
|
||||
if (strpos($ipaddr, ":") === false) $ipaddr = "::ffff:" . $ipaddr;
|
||||
$ipaddr = explode(":", $ipaddr);
|
||||
if (count($ipaddr) < 3) $ipaddr = array("", "", "0");
|
||||
$ipaddr2 = array();
|
||||
$foundpos = false;
|
||||
foreach ($ipaddr as $num => $segment)
|
||||
{
|
||||
$segment = trim($segment);
|
||||
if ($segment != "") $ipaddr2[] = $segment;
|
||||
else if ($foundpos === false && count($ipaddr) > $num + 1 && $ipaddr[$num + 1] != "")
|
||||
{
|
||||
$foundpos = count($ipaddr2);
|
||||
$ipaddr2[] = "0000";
|
||||
}
|
||||
}
|
||||
// Convert ::ffff:123.123.123.123 format.
|
||||
if (strpos($ipaddr2[count($ipaddr2) - 1], ".") !== false)
|
||||
{
|
||||
$x = count($ipaddr2) - 1;
|
||||
if ($ipaddr2[count($ipaddr2) - 2] != "ffff") $ipaddr2[$x] = "0";
|
||||
else
|
||||
{
|
||||
$ipaddr = explode(".", $ipaddr2[$x]);
|
||||
if (count($ipaddr) != 4) $ipaddr2[$x] = "0";
|
||||
else
|
||||
{
|
||||
$ipaddr2[$x] = str_pad(strtolower(dechex($ipaddr[0])), 2, "0", STR_PAD_LEFT) . str_pad(strtolower(dechex($ipaddr[1])), 2, "0", STR_PAD_LEFT);
|
||||
$ipaddr2[] = str_pad(strtolower(dechex($ipaddr[2])), 2, "0", STR_PAD_LEFT) . str_pad(strtolower(dechex($ipaddr[3])), 2, "0", STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
$ipaddr = array_slice($ipaddr2, 0, 8);
|
||||
if ($foundpos !== false && count($ipaddr) < 8) array_splice($ipaddr, $foundpos, 0, array_fill(0, 8 - count($ipaddr), "0000"));
|
||||
foreach ($ipaddr as $num => $segment)
|
||||
{
|
||||
$ipaddr[$num] = substr(str_pad(strtolower(dechex(hexdec($segment))), 4, "0", STR_PAD_LEFT), -4);
|
||||
}
|
||||
$ipv6addr = implode(":", $ipaddr);
|
||||
|
||||
// Extract IPv4 address.
|
||||
if (substr($ipv6addr, 0, 30) == "0000:0000:0000:0000:0000:ffff:") $ipv4addr = hexdec(substr($ipv6addr, 30, 2)) . "." . hexdec(substr($ipv6addr, 32, 2)) . "." . hexdec(substr($ipv6addr, 35, 2)) . "." . hexdec(substr($ipv6addr, 37, 2));
|
||||
|
||||
// Make a short IPv6 address.
|
||||
$shortipv6 = $ipv6addr;
|
||||
$pattern = "0000:0000:0000:0000:0000:0000:0000";
|
||||
do
|
||||
{
|
||||
$shortipv6 = str_replace($pattern, ":", $shortipv6);
|
||||
$pattern = substr($pattern, 5);
|
||||
} while (strlen($shortipv6) == 39 && $pattern != "");
|
||||
$shortipv6 = explode(":", $shortipv6);
|
||||
foreach ($shortipv6 as $num => $segment)
|
||||
{
|
||||
if ($segment != "") $shortipv6[$num] = strtolower(dechex(hexdec($segment)));
|
||||
}
|
||||
$shortipv6 = implode(":", $shortipv6);
|
||||
|
||||
return array("ipv6" => $ipv6addr, "shortipv6" => $shortipv6, "ipv4" => $ipv4addr);
|
||||
}
|
||||
|
||||
static function GetRemoteIP($proxies = array())
|
||||
{
|
||||
$ipaddr = self::NormalizeIP(isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : "127.0.0.1");
|
||||
|
||||
// Check for trusted proxies. Stop at first untrusted IP in the chain.
|
||||
if (isset($proxies[$ipaddr["ipv6"]]) || ($ipaddr["ipv4"] != "" && isset($proxies[$ipaddr["ipv4"]])))
|
||||
{
|
||||
$xforward = (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? explode(",", $_SERVER["HTTP_X_FORWARDED_FOR"]) : array());
|
||||
$clientip = (isset($_SERVER["HTTP_CLIENT_IP"]) ? explode(",", $_SERVER["HTTP_CLIENT_IP"]) : array());
|
||||
|
||||
do
|
||||
{
|
||||
$found = false;
|
||||
|
||||
if (isset($proxies[$ipaddr["ipv6"]])) $header = $proxies[$ipaddr["ipv6"]];
|
||||
else $header = $proxies[$ipaddr["ipv4"]];
|
||||
|
||||
$header = strtolower($header);
|
||||
if ($header == "xforward" && count($xforward) > 0)
|
||||
{
|
||||
$ipaddr = self::NormalizeIP(array_pop($xforward));
|
||||
$found = true;
|
||||
}
|
||||
else if ($header == "clientip" && count($clientip) > 0)
|
||||
{
|
||||
$ipaddr = self::NormalizeIP(array_pop($clientip));
|
||||
$found = true;
|
||||
}
|
||||
} while ($found && (isset($proxies[$ipaddr["ipv6"]]) || ($ipaddr["ipv4"] != "" && isset($proxies[$ipaddr["ipv4"]]))));
|
||||
}
|
||||
|
||||
return $ipaddr;
|
||||
}
|
||||
|
||||
static function IsMatch($pattern, $ipaddr)
|
||||
{
|
||||
if (is_string($ipaddr)) $ipaddr = self::NormalizeIP($ipaddr);
|
||||
|
||||
if (strpos($pattern, ":") !== false)
|
||||
{
|
||||
// Pattern is IPv6.
|
||||
$pattern = explode(":", strtolower($pattern));
|
||||
$ipaddr = explode(":", $ipaddr["ipv6"]);
|
||||
if (count($pattern) != 8 || count($ipaddr) != 8) return false;
|
||||
foreach ($pattern as $num => $segment)
|
||||
{
|
||||
$found = false;
|
||||
$pieces = explode(",", $segment);
|
||||
foreach ($pieces as $piece)
|
||||
{
|
||||
$piece = trim($piece);
|
||||
$piece = explode(".", $piece);
|
||||
if (count($piece) == 1)
|
||||
{
|
||||
$piece = $piece[0];
|
||||
|
||||
if ($piece == "*") $found = true;
|
||||
else if (strpos($piece, "-") !== false)
|
||||
{
|
||||
$range = explode("-", $piece);
|
||||
$range[0] = hexdec($range[0]);
|
||||
$range[1] = hexdec($range[1]);
|
||||
$val = hexdec($ipaddr[$num]);
|
||||
if ($range[0] > $range[1]) $range[0] = $range[1];
|
||||
if ($val >= $range[0] && $val <= $range[1]) $found = true;
|
||||
}
|
||||
else if ($piece === $ipaddr[$num]) $found = true;
|
||||
}
|
||||
else if (count($piece) == 2)
|
||||
{
|
||||
// Special IPv4-like notation.
|
||||
$found2 = false;
|
||||
$found3 = false;
|
||||
$val = hexdec(substr($ipaddr[$num], 0, 2));
|
||||
$val2 = hexdec(substr($ipaddr[$num], 2, 2));
|
||||
|
||||
if ($piece[0] == "*") $found2 = true;
|
||||
else if (strpos($piece[0], "-") !== false)
|
||||
{
|
||||
$range = explode("-", $piece[0]);
|
||||
if ($range[0] > $range[1]) $range[0] = $range[1];
|
||||
if ($val >= $range[0] && $val <= $range[1]) $found2 = true;
|
||||
}
|
||||
else if ($piece[0] == $val) $found2 = true;
|
||||
|
||||
if ($piece[1] == "*") $found3 = true;
|
||||
else if (strpos($piece[1], "-") !== false)
|
||||
{
|
||||
$range = explode("-", $piece[1]);
|
||||
if ($range[0] > $range[1]) $range[0] = $range[1];
|
||||
if ($val >= $range[0] && $val <= $range[1]) $found3 = true;
|
||||
}
|
||||
else if ($piece[1] == $val2) $found3 = true;
|
||||
|
||||
if ($found2 && $found3) $found = true;
|
||||
}
|
||||
|
||||
if ($found) break;
|
||||
}
|
||||
|
||||
if (!$found) return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pattern is IPv4.
|
||||
$pattern = explode(".", strtolower($pattern));
|
||||
$ipaddr = explode(".", $ipaddr["ipv4"]);
|
||||
if (count($pattern) != 4 || count($ipaddr) != 4) return false;
|
||||
foreach ($pattern as $num => $segment)
|
||||
{
|
||||
$found = false;
|
||||
$pieces = explode(",", $segment);
|
||||
foreach ($pieces as $piece)
|
||||
{
|
||||
$piece = trim($piece);
|
||||
|
||||
if ($piece == "*") $found = true;
|
||||
else if (strpos($piece, "-") !== false)
|
||||
{
|
||||
$range = explode("-", $piece);
|
||||
if ($range[0] > $range[1]) $range[0] = $range[1];
|
||||
if ($ipaddr[$num] >= $range[0] && $ipaddr[$num] <= $range[1]) $found = true;
|
||||
}
|
||||
else if ($piece == $ipaddr[$num]) $found = true;
|
||||
|
||||
if ($found) break;
|
||||
}
|
||||
|
||||
if (!$found) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,208 @@
|
|||
<?php
|
||||
// CubicleSoft PHP UTF8 (Unicode) functions.
|
||||
// (C) 2014 CubicleSoft. All Rights Reserved.
|
||||
|
||||
class UTF8
|
||||
{
|
||||
// Removes invalid characters from the data string.
|
||||
// http://www.w3.org/International/questions/qa-forms-utf-8
|
||||
public static function MakeValid($data)
|
||||
{
|
||||
$result = "";
|
||||
$x = 0;
|
||||
$y = strlen($data);
|
||||
while ($x < $y)
|
||||
{
|
||||
$tempchr = ord($data[$x]);
|
||||
if ($y - $x > 1) $tempchr2 = ord($data[$x + 1]);
|
||||
else $tempchr2 = 0x00;
|
||||
if ($y - $x > 2) $tempchr3 = ord($data[$x + 2]);
|
||||
else $tempchr3 = 0x00;
|
||||
if ($y - $x > 3) $tempchr4 = ord($data[$x + 3]);
|
||||
else $tempchr4 = 0x00;
|
||||
if ($tempchr == 0x09 || $tempchr == 0x0A || $tempchr == 0x0D || ($tempchr >= 0x20 && $tempchr <= 0x7E))
|
||||
{
|
||||
// ASCII minus control and special characters.
|
||||
$result .= chr($tempchr);
|
||||
$x++;
|
||||
}
|
||||
else if (($tempchr >= 0xC2 && $tempchr <= 0xDF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF))
|
||||
{
|
||||
// Non-overlong (2 bytes).
|
||||
$result .= chr($tempchr);
|
||||
$result .= chr($tempchr2);
|
||||
$x += 2;
|
||||
}
|
||||
else if ($tempchr == 0xE0 && ($tempchr2 >= 0xA0 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF))
|
||||
{
|
||||
// Non-overlong (3 bytes).
|
||||
$result .= chr($tempchr);
|
||||
$result .= chr($tempchr2);
|
||||
$result .= chr($tempchr3);
|
||||
$x += 3;
|
||||
}
|
||||
else if ((($tempchr >= 0xE1 && $tempchr <= 0xEC) || $tempchr == 0xEE || $tempchr == 0xEF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF))
|
||||
{
|
||||
// Normal/straight (3 bytes).
|
||||
$result .= chr($tempchr);
|
||||
$result .= chr($tempchr2);
|
||||
$result .= chr($tempchr3);
|
||||
$x += 3;
|
||||
}
|
||||
else if ($tempchr == 0xED && ($tempchr2 >= 0x80 && $tempchr2 <= 0x9F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF))
|
||||
{
|
||||
// Non-surrogates (3 bytes).
|
||||
$result .= chr($tempchr);
|
||||
$result .= chr($tempchr2);
|
||||
$result .= chr($tempchr3);
|
||||
$x += 3;
|
||||
}
|
||||
else if ($tempchr == 0xF0 && ($tempchr2 >= 0x90 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF))
|
||||
{
|
||||
// Planes 1-3 (4 bytes).
|
||||
$result .= chr($tempchr);
|
||||
$result .= chr($tempchr2);
|
||||
$result .= chr($tempchr3);
|
||||
$result .= chr($tempchr4);
|
||||
$x += 4;
|
||||
}
|
||||
else if (($tempchr >= 0xF1 && $tempchr <= 0xF3) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF))
|
||||
{
|
||||
// Planes 4-15 (4 bytes).
|
||||
$result .= chr($tempchr);
|
||||
$result .= chr($tempchr2);
|
||||
$result .= chr($tempchr3);
|
||||
$result .= chr($tempchr4);
|
||||
$x += 4;
|
||||
}
|
||||
else if ($tempchr == 0xF4 && ($tempchr2 >= 0x80 && $tempchr2 <= 0x8F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF))
|
||||
{
|
||||
// Plane 16 (4 bytes).
|
||||
$result .= chr($tempchr);
|
||||
$result .= chr($tempchr2);
|
||||
$result .= chr($tempchr3);
|
||||
$result .= chr($tempchr4);
|
||||
$x += 4;
|
||||
}
|
||||
else $x++;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function IsValid($data)
|
||||
{
|
||||
$x = 0;
|
||||
$y = strlen($data);
|
||||
while ($x < $y)
|
||||
{
|
||||
$tempchr = ord($data[$x]);
|
||||
if ($y - $x > 1) $tempchr2 = ord($data[$x + 1]);
|
||||
else $tempchr2 = 0x00;
|
||||
if ($y - $x > 2) $tempchr3 = ord($data[$x + 2]);
|
||||
else $tempchr3 = 0x00;
|
||||
if ($y - $x > 3) $tempchr4 = ord($data[$x + 3]);
|
||||
else $tempchr4 = 0x00;
|
||||
if ($tempchr == 0x09 || $tempchr == 0x0A || $tempchr == 0x0D || ($tempchr >= 0x20 && $tempchr <= 0x7E)) $x++;
|
||||
else if (($tempchr >= 0xC2 && $tempchr <= 0xDF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF)) $x += 2;
|
||||
else if ($tempchr == 0xE0 && ($tempchr2 >= 0xA0 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $x += 3;
|
||||
else if ((($tempchr >= 0xE1 && $tempchr <= 0xEC) || $tempchr == 0xEE || $tempchr == 0xEF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $x += 3;
|
||||
else if ($tempchr == 0xED && ($tempchr2 >= 0x80 && $tempchr2 <= 0x9F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $x += 3;
|
||||
else if ($tempchr == 0xF0 && ($tempchr2 >= 0x90 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $x += 4;
|
||||
else if (($tempchr >= 0xF1 && $tempchr <= 0xF3) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $x += 4;
|
||||
else if ($tempchr == 0xF4 && ($tempchr2 >= 0x80 && $tempchr2 <= 0x8F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $x += 4;
|
||||
else return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Locates the next UTF8 character in a UTF8 string.
|
||||
// Set Pos and Size to 0 to start at the beginning.
|
||||
// Returns false at the end of the string or bad UTF8 character. Otherwise, returns true.
|
||||
public static function NextChrPos(&$data, $datalen, &$pos, &$size)
|
||||
{
|
||||
$pos += $size;
|
||||
$size = 0;
|
||||
$x = $pos;
|
||||
$y = $datalen;
|
||||
if ($x >= $y) return false;
|
||||
|
||||
$tempchr = ord($data[$x]);
|
||||
if ($y - $x > 1) $tempchr2 = ord($data[$x + 1]);
|
||||
else $tempchr2 = 0x00;
|
||||
if ($y - $x > 2) $tempchr3 = ord($data[$x + 2]);
|
||||
else $tempchr3 = 0x00;
|
||||
if ($y - $x > 3) $tempchr4 = ord($data[$x + 3]);
|
||||
else $tempchr4 = 0x00;
|
||||
if ($tempchr == 0x09 || $tempchr == 0x0A || $tempchr == 0x0D || ($tempchr >= 0x20 && $tempchr <= 0x7E)) $size = 1;
|
||||
else if (($tempchr >= 0xC2 && $tempchr <= 0xDF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF)) $size = 2;
|
||||
else if ($tempchr == 0xE0 && ($tempchr2 >= 0xA0 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $size = 3;
|
||||
else if ((($tempchr >= 0xE1 && $tempchr <= 0xEC) || $tempchr == 0xEE || $tempchr == 0xEF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $size = 3;
|
||||
else if ($tempchr == 0xED && ($tempchr2 >= 0x80 && $tempchr2 <= 0x9F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $size = 3;
|
||||
else if ($tempchr == 0xF0 && ($tempchr2 >= 0x90 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $size = 4;
|
||||
else if (($tempchr >= 0xF1 && $tempchr <= 0xF3) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $size = 4;
|
||||
else if ($tempchr == 0xF4 && ($tempchr2 >= 0x80 && $tempchr2 <= 0x8F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $size = 4;
|
||||
else return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Determines if a UTF8 string can also be viewed as ASCII.
|
||||
public static function IsASCII($data)
|
||||
{
|
||||
$pos = 0;
|
||||
$size = 0;
|
||||
$y = strlen($data);
|
||||
while (self::NextChrPos($data, $y, $pos, $size) && $size == 1) {}
|
||||
if ($pos < $y || $size > 1) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns the number of characters in a UTF8 string.
|
||||
public static function strlen($data)
|
||||
{
|
||||
$num = 0;
|
||||
$pos = 0;
|
||||
$size = 0;
|
||||
$y = strlen($data);
|
||||
while (self::NextChrPos($data, $y, $pos, $size)) $num++;
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
// Converts a UTF8 string to ASCII and drops bad UTF8 and non-ASCII characters in the process.
|
||||
public static function ConvertToASCII($data)
|
||||
{
|
||||
$result = "";
|
||||
|
||||
$pos = 0;
|
||||
$size = 0;
|
||||
$y = strlen($data);
|
||||
while ($pos < $y)
|
||||
{
|
||||
if (self::NextChrPos($data, $y, $pos, $size) && $size == 1) $result .= $data[$pos];
|
||||
else if (!$size) $size = 1;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Converts UTF8 characters in a string to HTML entities.
|
||||
public static function ConvertToHTML($data)
|
||||
{
|
||||
return preg_replace_callback('/([\xC0-\xF7]{1,1}[\x80-\xBF]+)/', 'UTF8::ConvertToHTML__Callback', $data);
|
||||
}
|
||||
|
||||
private static function ConvertToHTML__Callback($data)
|
||||
{
|
||||
$data = $data[1];
|
||||
$num = 0;
|
||||
$data = str_split(strrev(chr((ord(substr($data, 0, 1)) % 252 % 248 % 240 % 224 % 192) + 128) . substr($data, 1)));
|
||||
foreach ($data as $k => $v) $num += (ord($v) % 128) * pow(64, $k);
|
||||
|
||||
return "&#" . $num . ";";
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,2 @@
|
|||
</body>
|
||||
</html>
|
|
@ -0,0 +1,23 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>tilde.pw<?=isset($title) ? " → $title" : "" ?></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<pre> _
|
||||
o | | |
|
||||
_|_ | | __| _ _
|
||||
| | |/ / | |/ |/ \_| | |_
|
||||
|_/|_/|__/\_/|_/|__/o|__/ \/ \/
|
||||
/|
|
||||
\| </pre>
|
||||
<p class="align-right">
|
||||
<a href='/'>home</a> ~
|
||||
<a href='signup.php'>sign up</a> ~
|
||||
<a href='https://tildegit.org/pw'>git</a> ~
|
||||
<a href='users.php'>users</a>
|
||||
</p>
|
||||
<br><hr>
|
||||
</header>
|
|
@ -0,0 +1,13 @@
|
|||
<?php include('header.php'); ?>
|
||||
<main>
|
||||
<p>hi! welcome to tilde.pw.</p>
|
||||
<p>tilde.pw is a unix server with some people on it and that unix server hosts webpages and other things too.</p>
|
||||
<p>it is <a href="https://tildeverse.org">one of many</a> servers attempting to create a more <i>empathetic</i> and <i>open</i> programming community.</p>
|
||||
<p>tilde.pw's sysadmins are <a href="~fen/">~fen</a> and <a href="~anton/">~anton</a>.</p>
|
||||
<br><hr>
|
||||
<p>here are our ssh host keys for your verification and security:</p>
|
||||
<p>ECDSA: SHA256:l9U2XAtdy0JDSgH1ZqhfwQHSZLUM0AQfJDotCy/67zM</p>
|
||||
<p>ED25519: SHA256:wqxWNtX5dXrzEbfVo5u7mMbxUW1IqIn5cTu+ejSOqno</p>
|
||||
<p>RSA: SHA256:Fe5YhqEtGeRYGLAVcmbGG52UzzM8q3DsTIIhO5t5IKU</p>
|
||||
</main>
|
||||
<?php include('footer.php'); ?>
|
|
@ -0,0 +1,3 @@
|
|||
<p>503</p>
|
||||
<p>down for maintenance</p>
|
||||
<a href="javascript:location.reload()">click to reload</a>
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
require_once "email/smtp.php";
|
||||
|
||||
function forbidden_name($name) {
|
||||
return in_array($name, [
|
||||
'0x0',
|
||||
'abuse',
|
||||
'admin',
|
||||
'administrator',
|
||||
'auth',
|
||||
'autoconfig',
|
||||
'bbj',
|
||||
'broadcasthost',
|
||||
'cloud',
|
||||
'forum',
|
||||
'ftp',
|
||||
'git',
|
||||
'gopher',
|
||||
'hostmaster',
|
||||
'imap',
|
||||
'info',
|
||||
'irc',
|
||||
'is',
|
||||
'isatap',
|
||||
'it',
|
||||
'localdomain',
|
||||
'localhost',
|
||||
'lounge',
|
||||
'mail',
|
||||
'mailer-daemon',
|
||||
'marketing',
|
||||
'marketting',
|
||||
'mis',
|
||||
'news',
|
||||
'nobody',
|
||||
'noc',
|
||||
'noreply',
|
||||
'pop',
|
||||
'pop3',
|
||||
'postmaster',
|
||||
'retro',
|
||||
'root',
|
||||
'sales',
|
||||
'security',
|
||||
'smtp',
|
||||
'ssladmin',
|
||||
'ssladministrator',
|
||||
'sslwebmaster',
|
||||
'support',
|
||||
'sysadmin',
|
||||
'team',
|
||||
'usenet',
|
||||
'uucp',
|
||||
'webmaster',
|
||||
'wpad',
|
||||
'www',
|
||||
'znc',
|
||||
]);
|
||||
}
|
||||
|
||||
$message = "";
|
||||
if (isset($_REQUEST["username"]) && isset($_REQUEST["email"])) {
|
||||
// Check the name.
|
||||
$name = trim($_REQUEST["username"]);
|
||||
if ($name == "")
|
||||
$message .= "<li>please fill in your desired username</li>";
|
||||
|
||||
if (strlen($name) > 32)
|
||||
$message .= "<li>username too long (32 character max)</li>";
|
||||
|
||||
if (!preg_match('/^[a-z][a-z0-9]{1,31}$/', $name))
|
||||
$message .= "<li>username contains invalid characters (lowercase ascii only, must start with a letter)</li>";
|
||||
|
||||
if ($_REQUEST["sshkey"] == "" || mb_substr($_REQUEST["sshkey"], 0, 4) !== "ssh-")
|
||||
$message .= '<li>ssh key required: please create one and submit the public key.</li>';
|
||||
|
||||
if ($_REQUEST["interest"] == "")
|
||||
$message .= "<li>please explain why you're interested so we can make sure you're a real human being</li>";
|
||||
|
||||
if (posix_getpwnam($name) || forbidden_name($name))
|
||||
$message .= "<li>sorry, the username $name is unavailable</li>";
|
||||
|
||||
// Check the e-mail address.
|
||||
$email = trim($_REQUEST["email"]);
|
||||
if ($email == "")
|
||||
$message .= "<li>please fill in your email address</li>";
|
||||
else {
|
||||
$result = SMTP::MakeValidEmailAddress($_REQUEST["email"]);
|
||||
if (!$result["success"])
|
||||
$message .= "<li>invalid email address: " . htmlspecialchars($result["error"]) . "</li>";
|
||||
elseif ($result["email"] != $email)
|
||||
$message .= "<li>invalid email address. did you mean: " . htmlspecialchars($result["email"]) . "</li>";
|
||||
}
|
||||
|
||||
|
||||
// no validation errors
|
||||
if ($message == "") {
|
||||
$sshkey = trim($_REQUEST["sshkey"]);
|
||||
$makeuser = "makeuser {$_REQUEST["username"]} {$_REQUEST["email"]} \"{$sshkey}\"";
|
||||
$msgbody = "
|
||||
username: {$_REQUEST["username"]}
|
||||
email: {$_REQUEST["email"]}
|
||||
reason: {$_REQUEST["interest"]}
|
||||
|
||||
$makeuser
|
||||
";
|
||||
|
||||
if (mail('fen', 'new tilde.pw signup', $msgbody)) {
|
||||
echo '
|
||||
email sent! we\'ll get back to you soon (usually within a day) with login instructions! <a href="/">back to tilde.pw</a>
|
||||
';
|
||||
file_put_contents("/var/signups", $makeuser.PHP_EOL, FILE_APPEND);
|
||||
} else {
|
||||
echo '
|
||||
something went wrong... please send an email to <a href="mailto:sudo@tilde.pw">sudo@tilde.pw</a> with details of what happened
|
||||
';
|
||||
}
|
||||
|
||||
} else {
|
||||
?>
|
||||
<strong>please correct the following errors: </strong>
|
||||
<?=$message?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php $title = "sign up"; include('header.php'); ?>
|
||||
<form method="post">
|
||||
<?php include 'signup-handler.php'; ?>
|
||||
<p>your desired username (numbers and lowercase letters only, no spaces)</p>
|
||||
<input name="username" value="<?=$_REQUEST["username"] ?? ""?>" type="text" required>
|
||||
|
||||
<p>email to contact you with account info</p>
|
||||
<input name="email" value="<?=$_REQUEST["email"] ?? ""?>" type="text" required>
|
||||
|
||||
<p>what interests you about tilde.pw? we want to make sure you're a real human being :)</p>
|
||||
<textarea required name="interest" id="" cols="40" rows="7"><?=$_REQUEST["interest"] ?? ""?></textarea>
|
||||
|
||||
<p>SSH public key</p>
|
||||
<textarea required class="form-control" name="sshkey" id="" cols="40" rows="10"><?=$_REQUEST["sshkey"] ?? ""?></textarea>
|
||||
|
||||
<br><br><button type="submit">submit! <3</button>
|
||||
</form>
|
||||
<?php include('footer.php'); ?>
|
|
@ -0,0 +1,58 @@
|
|||
body {
|
||||
max-width: 38rem;
|
||||
padding: 2rem;
|
||||
margin: 0 auto;
|
||||
color: #3f0;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
@media (max-device-width: 736px) {
|
||||
body {padding: 0.5rem;}
|
||||
}
|
||||
|
||||
hr {
|
||||
overflow: visible; /* For IE */
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-top: medium double #3f0;
|
||||
color: #3f0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
hr:after {
|
||||
content: "~";
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: -0.7em;
|
||||
font-size: 1.5em;
|
||||
padding: 0 0.25em;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.align-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #3f0;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #9f7;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
textarea, input {
|
||||
border: 1px solid #3f0;
|
||||
background: black;
|
||||
color: #3f0;
|
||||
}
|
||||
|
||||
button {
|
||||
border: 1px solid #3f0;
|
||||
background: black;
|
||||
color: #3f0;
|
||||
border-radius: 0;
|
||||
padding: 0.5rem;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?php $title = "users"; include('header.php'); ?>
|
||||
<p><b>note:</b> only shows users who have changed their index.html page</p>
|
||||
<ol>
|
||||
<?php foreach (glob("/home/*") as $user) {
|
||||
$index = "$user/public_html/index.html";
|
||||
if (!file_exists($index) ||
|
||||
in_array(sha1_file($index),
|
||||
// these are the hashes of previous and current default pages
|
||||
["386a1e5ec2359ed8996d9b6687c7b306d7e79c0c"])) continue;
|
||||
$user = basename($user); ?>
|
||||
<li><a href="/~<?=$user?>/">~<?=$user?></a></li>
|
||||
<?php } ?>
|
||||
</ol>
|
||||
|
||||
<?php include('footer.php'); ?>
|
Loading…
Reference in New Issue