EFGRG
<?php
require_once 'paste.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = $_POST['title'] ?? 'Untitled Paste';
$content = $_POST['content'] ?? '';
$author = $_POST['author'] ?? '';
$is_html = isset($_POST['is_html']) ? 1 : 0;
$font_choice = $_POST['font_choice'] ?? 'monospace';
$password = $_POST['password'] ?? '';
$expiry_days = (int)($_POST['expiry_days'] ?? 0);
$is_seo_enabled = isset($_POST['is_seo_enabled']) ? 1 : 0;
$is_downloadable = isset($_POST['is_downloadable']) ? 1 : 0;
$paste = new Paste();
$result = $paste->createPaste(
$title,
$content,
$author,
$is_html,
$font_choice,
$password,
$expiry_days,
$is_seo_enabled,
$is_downloadable
);
if ($result) {
$response = [
'success' => true,
'view_url' => SITE_URL . '/view.php?id=' . $result['paste_id'],
'edit_url' => SITE_URL . '/edit.php?id=' . $result['edit_id']
];
} else {
$response = [
'success' => false,
'message' => 'Failed to create paste'
];
}
header('Content-Type: application/json');
echo json_encode($response);
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create New Paste - Clean Pastebin</title>
<?php include 'includes/head.php'; ?>
<!-- Lucide Icons -->
<script src="https://unpkg.com/lucide@latest"></script>
<!-- Notiflix -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/notiflix@3.2.6/dist/notiflix-3.2.6.min.css">
<script src="https://cdn.jsdelivr.net/npm/notiflix@3.2.6/dist/notiflix-3.2.6.min.js"></script>
<style>
:root {
--kindle-bg: #faf8f3;
--kindle-paper: #ffffff;
--kindle-text: #2c2c2c;
--kindle-muted: #666666;
--kindle-border: #e8e5dd;
--kindle-accent: #d4a373;
--kindle-accent-dark: #b8895f;
--kindle-shadow: rgba(0, 0, 0, 0.08);
--kindle-shadow-lg: rgba(0, 0, 0, 0.12);
--radius: 16px;
--radius-sm: 12px;
}
body {
background: var(--kindle-bg);
color: var(--kindle-text);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
line-height: 1.6;
padding: 2rem 1rem;
min-height: 100vh;
}
.container {
max-width: 800px;
margin: 0 auto;
}
.kindle-card {
background: var(--kindle-paper);
border-radius: var(--radius);
padding: 3rem;
box-shadow:
0 4px 6px var(--kindle-shadow),
0 10px 20px var(--kindle-shadow-lg);
border: 1px solid var(--kindle-border);
transition: all 0.3s ease;
}
.kindle-card:hover {
transform: translateY(-2px);
box-shadow:
0 6px 8px var(--kindle-shadow),
0 15px 25px var(--kindle-shadow-lg);
}
h1 {
font-size: 2rem;
font-weight: 600;
margin: 0 0 2rem 0;
color: var(--kindle-text);
display: flex;
align-items: center;
gap: 0.75rem;
}
.form-group {
margin-bottom: 1.75rem;
}
label {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.95rem;
font-weight: 500;
color: var(--kindle-text);
margin-bottom: 0.65rem;
}
label svg {
width: 18px;
height: 18px;
color: var(--kindle-accent);
}
.form-control,
.form-select {
width: 100%;
padding: 0.85rem 1.1rem;
border: 2px solid var(--kindle-border);
border-radius: var(--radius-sm);
font-size: 1rem;
color: var(--kindle-text);
background: var(--kindle-paper);
transition: all 0.2s ease;
font-family: inherit;
}
.form-control:focus,
.form-select:focus {
outline: none;
border-color: var(--kindle-accent);
box-shadow: 0 0 0 4px rgba(212, 163, 115, 0.1);
}
.form-control::placeholder {
color: #aaa;
}
textarea.form-control {
resize: vertical;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
line-height: 1.5;
}
.toggle-container {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem 0;
}
.toggle-switch {
position: relative;
width: 52px;
height: 28px;
}
.toggle-switch input {
opacity: 0;
width: 0;
height: 0;
}
.toggle-slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: var(--kindle-border);
border-radius: 28px;
transition: 0.3s;
}
.toggle-slider:before {
position: absolute;
content: "";
height: 22px;
width: 22px;
left: 3px;
bottom: 3px;
background-color: white;
border-radius: 50%;
transition: 0.3s;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
input:checked + .toggle-slider {
background-color: var(--kindle-accent);
}
input:checked + .toggle-slider:before {
transform: translateX(24px);
}
.toggle-label {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.95rem;
color: var(--kindle-text);
cursor: pointer;
user-select: none;
}
.toggle-label svg {
width: 18px;
height: 18px;
color: var(--kindle-muted);
}
.btn-primary {
width: 100%;
padding: 1rem 2rem;
background: linear-gradient(135deg, var(--kindle-accent), var(--kindle-accent-dark));
color: white;
border: none;
border-radius: var(--radius-sm);
font-size: 1.05rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
gap: 0.65rem;
box-shadow: 0 4px 12px rgba(212, 163, 115, 0.3);
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(212, 163, 115, 0.4);
}
.btn-primary:active {
transform: translateY(0);
}
.btn-primary svg {
width: 20px;
height: 20px;
}
#summernote {
border-radius: var(--radius-sm);
overflow: hidden;
}
/* Divider */
.divider {
height: 1px;
background: var(--kindle-border);
margin: 2rem 0;
}
/* Responsive */
@media (max-width: 768px) {
.kindle-card {
padding: 2rem 1.5rem;
}
h1 {
font-size: 1.6rem;
}
}
/* Custom Notiflix theme */
.notiflix-notify {
border-radius: var(--radius-sm) !important;
font-family: inherit !important;
}
</style>
</head>
<body>
<?php include 'includes/header.php'; ?>
<div class="container">
<div class="kindle-card">
<h1>
<i data-lucide="file-text"></i>
Create New Paste
</h1>
<form id="pasteForm">
<div class="form-group">
<label for="title">
<i data-lucide="heading"></i>
Title
</label>
<input type="text" id="title" name="title" class="form-control" required placeholder="Enter paste title">
</div>
<div class="form-group">
<label for="author">
<i data-lucide="user"></i>
Author <span style="color: var(--kindle-muted); font-weight: normal;">(Optional)</span>
</label>
<input type="text" id="author" name="author" class="form-control" placeholder="Enter author name">
</div>
<div class="form-group">
<div class="toggle-container">
<label class="toggle-switch">
<input type="checkbox" id="editorToggle">
<span class="toggle-slider"></span>
</label>
<label for="editorToggle" class="toggle-label">
<i data-lucide="edit-3"></i>
Use Rich Text Editor
</label>
</div>
</div>
<div class="form-group">
<label for="content">
<i data-lucide="code"></i>
Content
</label>
<textarea id="content" name="content" class="form-control code-editor" rows="10" required placeholder="Paste your content here"></textarea>
<div id="summernote" style="display: none;"></div>
</div>
<div class="form-group">
<label for="font_choice">
<i data-lucide="type"></i>
Font
</label>
<select id="font_choice" name="font_choice" class="form-select">
<option value="monospace">Monospace</option>
<option value="dm-sans">DM Sans (Serif)</option>
<option value="random">Random Font</option>
</select>
</div>
<div class="form-group">
<label for="password">
<i data-lucide="lock"></i>
Password Protection <span style="color: var(--kindle-muted); font-weight: normal;">(Optional)</span>
</label>
<input type="password" id="password" name="password" class="form-control" placeholder="Enter password to protect this paste">
</div>
<div class="form-group">
<label for="expiry_days">
<i data-lucide="clock"></i>
Expiry <span style="color: var(--kindle-muted); font-weight: normal;">(Optional)</span>
</label>
<select id="expiry_days" name="expiry_days" class="form-select">
<option value="0">Never</option>
<option value="1">1 Day</option>
<option value="7">1 Week</option>
<option value="30">1 Month</option>
<option value="90">3 Months</option>
<option value="365">1 Year</option>
</select>
</div>
<div class="divider"></div>
<div class="form-group">
<div class="toggle-container">
<label class="toggle-switch">
<input type="checkbox" id="is_seo_enabled" name="is_seo_enabled" checked>
<span class="toggle-slider"></span>
</label>
<label for="is_seo_enabled" class="toggle-label">
<i data-lucide="search"></i>
Enable SEO (Show content in search engines)
</label>
</div>
</div>
<div class="form-group">
<div class="toggle-container">
<label class="toggle-switch">
<input type="checkbox" id="is_downloadable" name="is_downloadable" checked>
<span class="toggle-slider"></span>
</label>
<label for="is_downloadable" class="toggle-label">
<i data-lucide="download"></i>
Allow Download
</label>
</div>
</div>
<input type="hidden" name="is_html" id="is_html" value="0">
<div class="form-group" style="margin-top: 2rem;">
<button type="submit" class="btn-primary">
<i data-lucide="sparkles"></i>
Create Paste
</button>
</div>
</form>
</div>
</div>
<?php include 'includes/footer.php'; ?>
<script>
// Initialize Lucide icons
lucide.createIcons();
$(document).ready(function() {
// Configure Notiflix
Notiflix.Notify.init({
width: '320px',
position: 'right-top',
distance: '20px',
opacity: 1,
borderRadius: '12px',
rtl: false,
timeout: 4000,
messageMaxLength: 300,
backOverlay: false,
plainText: true,
showOnlyTheLastOne: false,
clickToClose: true,
pauseOnHover: true,
ID: 'NotiflixNotify',
className: 'notiflix-notify',
zindex: 4001,
fontFamily: 'inherit',
fontSize: '15px',
cssAnimationStyle: 'from-right',
cssAnimationDuration: 400,
success: {
background: '#d4a373',
textColor: '#fff',
notiflixIconColor: 'rgba(255,255,255,0.9)',
},
failure: {
background: '#e85d75',
textColor: '#fff',
notiflixIconColor: 'rgba(255,255,255,0.9)',
},
});
Notiflix.Loading.init({
className: 'notiflix-loading',
zindex: 4000,
backgroundColor: 'rgba(0,0,0,0.8)',
rtl: false,
fontFamily: 'inherit',
cssAnimation: true,
cssAnimationDuration: 400,
clickToClose: false,
customSvgUrl: null,
customSvgCode: null,
svgSize: '80px',
svgColor: '#d4a373',
messageID: 'NotiflixLoadingMessage',
messageFontSize: '16px',
messageMaxLength: 34,
messageColor: '#dcdcdc',
});
// Initialize Summernote
$('#summernote').summernote({
height: 300,
toolbar: [
['style', ['style', 'bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough', 'superscript', 'subscript']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['insert', ['link', 'picture', 'table', 'hr']],
['view', ['fullscreen', 'codeview']]
]
});
// Editor toggle
$('#editorToggle').change(function() {
const isHtml = $(this).prop('checked');
$('#is_html').val(isHtml ? '1' : '0');
if (isHtml) {
const content = $('#content').val();
$('#content').hide();
$('#summernote').show().summernote('code', content);
Notiflix.Notify.info('Rich text editor enabled');
} else {
const content = $('#summernote').summernote('code');
$('#summernote').hide();
$('#content').show().val(content);
Notiflix.Notify.info('Plain text editor enabled');
}
});
// Form submission
$('#pasteForm').submit(function(e) {
e.preventDefault();
// Get content from the active editor
if ($('#editorToggle').prop('checked')) {
const content = $('#summernote').summernote('code');
$('#content').val(content);
}
// Show loading
Notiflix.Loading.circle('Creating your paste...');
$.ajax({
url: 'create.php',
method: 'POST',
data: $(this).serialize(),
dataType: 'json',
success: function(response) {
Notiflix.Loading.remove();
if (response.success) {
// Show success notification with custom content
Notiflix.Report.success(
'Paste Created!',
`<div style="text-align: left; margin-top: 1rem;">
<p style="margin-bottom: 1rem;"><strong>View URL:</strong></p>
<input type="text" id="viewUrlCopy" value="${response.view_url}"
style="width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 1rem;" readonly>
<button onclick="copyToClipboard('viewUrlCopy', 'View URL copied!')"
style="width: 100%; padding: 0.6rem; background: #d4a373; color: white; border: none; border-radius: 8px; cursor: pointer; margin-bottom: 1.5rem;">
Copy View URL
</button>
<p style="margin-bottom: 1rem;"><strong>Edit URL (Keep private):</strong></p>
<input type="text" id="editUrlCopy" value="${response.edit_url}"
style="width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 1rem;" readonly>
<button onclick="copyToClipboard('editUrlCopy', 'Edit URL copied!')"
style="width: 100%; padding: 0.6rem; background: #d4a373; color: white; border: none; border-radius: 8px; cursor: pointer;">
Copy Edit URL
</button>
</div>`,
'View Paste',
{
width: '450px',
svgSize: '60px',
plainText: false,
messageMaxLength: 5000,
titleMaxLength: 50,
buttonBackground: '#d4a373',
backOverlayColor: 'rgba(0,0,0,0.5)',
},
function() {
window.location.href = response.view_url;
}
);
} else {
Notiflix.Notify.failure('Error: ' + response.message);
}
},
error: function() {
Notiflix.Loading.remove();
Notiflix.Notify.failure('An error occurred while creating your paste');
}
});
});
});
// Copy to clipboard function
function copyToClipboard(elementId, successMessage) {
const copyText = document.getElementById(elementId);
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
Notiflix.Notify.success(successMessage || 'Copied to clipboard!');
}
</script>
</body>
</html>