-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrap.php
More file actions
44 lines (32 loc) · 964 Bytes
/
crap.php
File metadata and controls
44 lines (32 loc) · 964 Bytes
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
<?php
// textcrap configuration file
# SQL Configuration
function db ( ) {
$dbhost = "localhost";
$dbuser = "root";
$dbpassword = "password";
$db = "textcrap";
$db = new mysqli ( $dbhost, $dbuser, $dbpassword, $db );
if ( $db->connect_error )
die ( 'The MySQL database could not reach the web server.' );
return $db;
}
# Variables
$allow_access = true;
$allow_access_msg = "Sorry, but textcrap has been closed for the time being.";
# Initialize the website
if ( !$allow_access )
die ( $allow_access_msg );
# Functions
function doSafe ( $string ) {
return htmlentities( mysqli_real_escape_string ( db( ), $string ) );
}
function doID ( $length = 6 ) {
$characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$char_length = strlen ( $characters );
$randomString = '';
for ( $i = 0; $i < $length; $i++ ) {
$randomString .= $characters[rand(0, $char_length - 1)];
}
return $randomString;
}