-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
62 lines (49 loc) · 2.09 KB
/
index.php
File metadata and controls
62 lines (49 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php require_once 'crap.php'; ?>
<head>
<title>textcrap</title>
<link rel="stylesheet" href="main.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
</head>
<center>
<br>
<a href="index.php" style="text-decoration: none; color: white;"><h1>textcrap</h1></a>
<p style="color: white;">
The easiest way to post your text-based crap online.
</p>
<?php
if ( isset ( $_POST['submit'] ) ) {
# Generate an ID
$id = doID ( );
$id_query = mysqli_query ( db ( ), "SELECT * FROM crap WHERE url = '" . $id . "'" );
while ( mysqli_num_rows ( $id_query ) !== 0 ) {
$id = doID ( );
}
# Insert into the database
$crap = trim ( doSafe ( $_POST['crap'] ) );
$title = trim ( doSafe ( $_POST['title'] ) );
if ( strlen ( $title ) < 2 || strlen ( $crap ) < 5 || strlen ( $title ) > 65535 || strlen ( $crap ) > 65535 ) {
echo ( '<br><div class=notif>Your required fields had too short content to post.</div>' );
} else {
$query = mysqli_query ( db ( ), "INSERT INTO crap (url, crap, title, ip) VALUES ('" . $id . "', '" . $crap . "', '" . $title . "', '" . $_SERVER['REMOTE_ADDR'] . "')" );
if ( !$query )
echo ( '<br><div class=notif>Crap! An unexpected error occurred.</div>' );
else {
$query2 = mysqli_query ( db( ), "SELECT * FROM crap WHERE url = '" . $id . "'" );
$result = mysqli_fetch_assoc ( $query2 );
echo ( "<br><div class=notif>Your crap was uploaded. Click <a href='/c/" . $result['url'] . "'>here</a> to view it.</div>" );
}
}
}
?>
<br>
<form action="" method="post">
<input type="text" name="title" placeholder="Title of the crap" autocomplete="off">
<textarea name="crap" placeholder="Enter some crap here..."></textarea><br>
<input type="submit" name="submit" value="Create">
</form>
<br><br><br><br><br>
Made with ♥ by <a href="http://cammarata.info">Preston Cammarata</a><br>
<a href="http://github.com/aceriou/textcrap">GitHub Repository</a><br>
Made in Rhode Island.
</center>