-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgp.php
196 lines (176 loc) · 6.52 KB
/
gp.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Quản lý bài viết</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 20px;
background-color: #f4f4f4;
}
h1 {
color: #2c3e50;
text-align: center;
}
.form-container {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
max-width: 600px;
margin: 0 auto;
}
.form-container textarea,
.form-container input[type="text"] {
width: 100%;
margin-bottom: 15px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
}
.form-container button {
background-color: #2c3e50;
color: #fff;
padding: 10px 15px;
border: none;
border-radius: 5px;
cursor: pointer;
}
.form-container button:hover {
background-color: #34495e;
}
.message {
margin-top: 15px;
text-align: center;
}
</style>
</head>
<body>
<h1>Quản lý bài viết</h1>
<div class="form-container">
<form method="POST" action="">
<label for="title">Tiêu đề bài viết:</label>
<input type="text" name="title" id="title" placeholder="Nhập tiêu đề bài viết" required>
<label for="headline">Tiêu đề chính:</label>
<input type="text" name="headline" id="headline" placeholder="Nhập tiêu đề chính" required>
<label for="keywords">Từ khóa:</label>
<input type="text" name="keywords" id="keywords" placeholder="Nhập từ khóa, cách nhau bởi dấu phẩy" required>
<label for="description">Mô tả:</label>
<input type="text" name="description" id="description" placeholder="Nhập mô tả bài viết" required>
<label for="author">Tên tác giả:</label>
<input type="text" name="author" id="author" placeholder="Nhập tên tác giả" required>
<label for="publisher">Tên nhà xuất bản:</label>
<input type="text" name="publisher" id="publisher" placeholder="Nhập tên nhà xuất bản" required>
<label for="mainEntity">URL của bài viết:</label>
<input type="text" name="mainEntity" id="mainEntity" placeholder="Nhập URL chính" required>
<label for="content">Nội dung bài viết (HTML):</label>
<textarea name="content" id="content" rows="10" placeholder="Nhập nội dung bài viết dạng HTML" required></textarea>
<button type="submit" name="submit">Lưu bài viết</button>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = htmlspecialchars($_POST['title']);
$headline = htmlspecialchars($_POST['headline']);
$keywords = htmlspecialchars($_POST['keywords']);
$description = htmlspecialchars($_POST['description']);
$author = htmlspecialchars($_POST['author']);
$publisher = htmlspecialchars($_POST['publisher']);
$mainEntity = htmlspecialchars($_POST['mainEntity']);
$content = $_POST['content'];
// Lấy ngày tháng năm hiện tại
$datePublished = date('Y-m-d');
$dateModified = date('Y-m-d');
// Kiểm tra thư mục "story"
$directory = "story";
if (!is_dir($directory)) {
mkdir($directory, 0777, true);
}
// Tạo tên file ngẫu nhiên
$filename = $directory . '/' . uniqid('story_', true) . '.html';
// Nội dung HTML
$htmlContent = <<<HTML
<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>$title</title>
<meta name="description" content="$description">
<meta name="keywords" content="$keywords">
<meta name="robots" content="index, follow">
<link rel="icon" type="image/x-icon" href="https://github.com/kevinsocute2/kevinsocute2/blob/main/xd%20logo%202.png?raw=true">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"headline": "$headline",
"description": "$description",
"author": {
"@type": "Person",
"name": "$author"
},
"publisher": {
"@type": "Organization",
"name": "$publisher",
"logo": {
"@type": "ImageObject",
"url": "https://github.com/kevinsocute2/kevinsocute2/blob/main/xd%20logo%202.png?raw=true"
}
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "$mainEntity"
},
"datePublished": "$datePublished",
"dateModified": "$dateModified"
}
</script>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 20px;
padding: 0;
background-color: #f4f4f4;
}
h1, h2 {
color: #2c3e50;
}
p {
text-align: justify;
}
.content {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.highlight {
color: #e74c3c;
}
</style>
</head>
<body>
<div class="content">
$content
</div>
</body>
</html>
HTML;
// Lưu file
if (file_put_contents($filename, $htmlContent)) {
echo "<div class='message'>Tải thành công! File được lưu tại: <a href='$filename' target='_blank'>$filename</a></div>";
} else {
echo "<div class='message'>Đã xảy ra lỗi khi lưu file.</div>";
}
}
?>
</div>
</body>
</html>