-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_file.php
92 lines (59 loc) · 2.03 KB
/
create_file.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
<?php
$filename = "note.txt";
$filename2 = "";
if(isset($_POST["note"])) {
$note = $_POST["note"];
$file = fopen($filename, "a");
fwrite($file, $note . "\n");
fclose($file);
$filename2 = $note . ".html";
$file2 = fopen($filename2, "w");
fwrite($file2, "
<script>
document.addEventListener('DOMContentLoaded', () => {
fetch('https://nostrsites.com/client/')
.then(response => response.json())
.then(data => {
const currentURL = window.location.href;
const urlTag = currentURL.split('.com/')[1].replace('.html', '');
data.forEach(item => {
const content = item.content;
const noteTag = item.note;
if (noteTag === urlTag) {
console.log('Matching note tag:', noteTag);
console.log('Content:', content);
const scriptTags = content.match(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi);
if (scriptTags) {
const div = document.createElement('div');
div.innerHTML = content;
document.body.appendChild(div);
setTimeout(() => {
scriptTags.forEach(scriptTag => {
const scriptCode = scriptTag.replace(/<\/?script[^>]*>/gi, '').trim();
const newScript = document.createElement('script');
newScript.textContent = scriptCode;
document.body.appendChild(newScript);
});
}, 100);
} else {
const div = document.createElement('div');
div.innerHTML = content;
document.body.appendChild(div);
}
}
});
})
.catch(error => {
console.error('Error:', error);
});
});
</script>");
fclose($file2);
echo "THANK YOU! \n\nTHE PAGE WILL REFRESH WITH YOUR NEW SITE IN ABOUT 10 SECONDS";
}
if ($filename2 != "") {
header("Refresh: 10; URL=$filename2");
exit;
}
$url = htmlspecialchars($_SERVER['HTTP_REFERER']);
?>