-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
148 lines (138 loc) · 6.24 KB
/
index.php
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE HTML>
<html lang="en">
<?php
$config = fopen("config.json", "r") or die("Unable to open file!");
$jsonobj = fread($config,filesize("config.json"));
fclose($config);
$obj = json_decode($jsonobj);
$brandName = $obj->brand;
?>
<head>
<title><?php echo $brandName; ?> Blogging</title>
<link href="https://bouncecss.bookie0.repl.co/bounce.css" rel="stylesheet" type="text/css" />
<style>
.error {color: #FF0000;}
card {
float:right;
margin-right:150px;
margin-top:10px;
padding:3px;
background-image: linear-gradient(black, green, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, green, blue, black);
}
</style>
</head>
<body>
<card onclick="window.location.replace(origin+'/blogs.php');">Visit Other Blogs</card>
<?php
// define variables and set to empty values
$nameErr = $emailErr = $websiteErr = $titleErr = "";
$name = $email = $comment = $website = $title = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z-' ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
if (empty($_POST["website"])) {
$website = "";
} else {
$website = test_input($_POST["website"]);
// check if URL address syntax is valid (this regular expression also allows dashes in the URL)
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) {
$websiteErr = "Invalid URL";
}
}
if (empty($_POST["comment"])) {
$comment = "";
} else {
$comment = test_input($_POST["comment"]);
}
if (empty($_POST["title"])) {
$titleErr = "Title is required";
} else {
$title = test_input($_POST["title"]);
// check if title only contains letters and whitespace
if (!preg_match("/^[a-zA-Z-' ]*$/",$title)) {
$titleErr = "Only letters and white space allowed";
$title = 'Error';
}
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<h2><?php echo $brandName; ?> Blogging</h2>
<p><span title='Required' class="error">* required field</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Name: <input type="text" name="name" value="<?php echo $name;?>">
<span title='Required' class="error">* <?php echo $nameErr;?></span>
<br><br>
Title: <input type="text" name="title" value="<?php echo $title;?>">
<span title='Required' class="error">* <?php echo $titleErr;?></span>
<br><br>
E-mail: <input type="text" name="email" value="<?php echo $email;?>">
<span title='Required' class="error">* <?php echo $emailErr;?></span>
<br><br>
Website: <input type="text" name="website" value="<?php echo $website;?>">
<span class="error"><?php echo $websiteErr;?></span>
<br><br>
Content: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea>
<br><br>
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
$myfile = fopen("js/tempwrite.js", "r") or die("Unable to open file!");
$oldjs = fread($myfile,filesize("js/tempwrite.js"));
fclose($myfile);
if ($name !== "") {
$permitted_chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
function generate_string($input, $strength = 16) {
$input_length = strlen($input);
$random_string = '';
for($i = 0; $i < $strength; $i++) {
$random_character = $input[mt_rand(0, $input_length - 1)];
$random_string .= $random_character;
}
return $random_string;
}
$rand = generate_string($permitted_chars, rand(1, 2));
$filename = $name . '.html';
if (strlen($comment) <= 30) {
$description = substr($comment, 0, strlen($comment)-10) . "...";
}
if (strlen($comment) >= 30) {
$desccount = strlen($comment) - 20;
$description = substr($comment, 0, $desccount) . "...";
}
$dat = date("l jS \of F Y h:i:s A");
$content = "<!DOCTYPE HTML5> <html> <head> <meta charset=\"utf-8\"> <meta max-age='1'/> <meta name=\"viewport\" content=\"width=device-width\"> <title>" . $title . " | $brandName Blogs</title> <link href=\"https://bouncecss.bookie0.repl.co/bounce.css\" rel=\"stylesheet\" type=\"text/css\" /> </head> <body><h2>" . $title . '</h2><img style=\'float: right; margin-right: 150px;\' width="450" height="450" title=\'Altify Developing\' src=\'/favicon-0.png\'><br>' . '<br><p>What is it: ' . $comment . '</p><br><p>Email: <a href=\'mailto:' . $email . "' title='Send Email'>" . $email . "</a>" . '</p><br><p>Website: <a href=\'' . $website . "' title='Visit Website'>" . $website . "</a>" . "</p><br><h3>Blog Contributed By: " . $name . "</h3>" . "<h4>Blog Provided to you by <a href='https://www.altifydeveloping.com/'>Altify Developing</a><h4><br><br><br><br>" . '<a href=\'https://github.com/Altify-Developing\' target="_blank" style=\'float: right; margin-right: 150px;\' width="450" height="120" title=\'Altify Developing\'><img src=\'/github.png\' style=\'float: right;\' width="450" height="120" title=\'Altify Developing\'></a>';
$content3 = "document.body.innerHTML += \"<div style=\\\"background-image: linear-gradient(black, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, black);border-style: solid;padding: '50px'\\\"><h4>Blog Title: '" . $title . "'<br>Created By: " . $name . "</h4><br><h5>A Small Description:</h5><p>" . $description . "<br><script> // Blog Provided By $brandName Don't Steal My Source Code Asshole</script>" . "<a href='/" . 'blogs/' . $rand . $filename . "'>Visit Blog</a><p>Date: $dat</p></div>\\n\";\n";
$fh = fopen('blogs/' . $rand . $filename, 'w');
fwrite($fh, $content);
fclose($fh);
$fh = fopen('js/tempwrite.js', 'w');
fwrite($fh, $content3 . "\n$oldjs");
fclose($fh);
echo "<a href='/" . 'blogs/' . $rand . $filename . "'>Visit Blog</a>";
};
?>
</body>
</html>