forked from imabutahersiddik/CodeStore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit.php
More file actions
206 lines (176 loc) · 9.1 KB
/
submit.php
File metadata and controls
206 lines (176 loc) · 9.1 KB
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
197
198
199
200
201
202
203
204
205
206
<?php
require_once 'config.php';
require_once 'functions.php';
$categories = ['Games', 'Productivity', 'Education', 'Entertainment', 'Business', 'Other'];
$platforms = ['iOS', 'Android', 'Web'];
$licenseTypes = ['Free', 'Paid', 'Open Source', 'Trial'];
$message = '';
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
require_once 'process_submission.php';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web App Submission</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.required::after { content: " *"; color: red; }
</style>
</head>
<body>
<div class="container my-5">
<h1 class="mb-4">Submit Your Web App</h1>
<?php if ($message): ?>
<div class="alert alert-success"><?php echo $message; ?></div>
<?php endif; ?>
<?php if ($error): ?>
<div class="alert alert-danger"><?php echo $error; ?></div>
<?php endif; ?>
<form method="POST" enctype="multipart/form-data" id="appSubmissionForm">
<div class="row">
<div class="col-md-6 mb-3">
<label for="appName" class="form-label required">App Name</label>
<input type="text" class="form-control" id="appName" name="appName" required>
</div>
<div class="col-md-6 mb-3">
<label for="developerName" class="form-label required">Developer Name</label>
<input type="text" class="form-control" id="developerName" name="developerName" required>
</div>
</div>
<div class="mb-3">
<label for="description" class="form-label required">App Description</label>
<textarea class="form-control" id="description" name="description" rows="4" required></textarea>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="metaTitle" class="form-label required">Meta Title</label>
<input type="text" class="form-control" id="metaTitle" name="metaTitle" required>
</div>
<div class="col-md-6 mb-3">
<label for="metaDescription" class="form-label required">Meta Description</label>
<textarea class="form-control" id="metaDescription" name="metaDescription" required></textarea>
</div>
</div>
<div class="row">
<div class="col-md-4 mb-3">
<label for="category" class="form-label">Category</label>
<select class="form-select" id="category" name="category">
<option value="">Select Category</option>
<?php foreach ($categories as $category): ?>
<option value="<?php echo htmlspecialchars($category); ?>"><?php echo htmlspecialchars($category); ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-4 mb-3">
<label for="version" class="form-label required">Version (X.X.X)</label>
<input type="text" class="form-control" id="version" name="version" pattern="^\d+\.\d+\.\d+$" required>
</div>
<div class="col-md-4 mb-3">
<label for="releaseDate" class="form-label">Release Date</label>
<input type="date" class="form-control" id="releaseDate" name="releaseDate">
</div>
</div>
<div class="row">
<div class="col-md-4 mb-3">
<label for="appIcon" class="form-label">App Icon</label>
<input type="file" class="form-control" id="appIcon" name="appIcon" accept=".png,.jpg,.jpeg,.svg">
<div id="iconPreview" class="mt-2"></div>
</div>
<div class="col-md-4 mb-3">
<label for="appPackage" class="form-label required">Web App Package (ZIP)</label>
<input type="file" class="form-control" id="appPackage" name="appPackage" accept=".zip" required>
</div>
<div class="col-md-4 mb-3">
<label for="screenshots" class="form-label">Screenshots</label>
<input type="file" class="form-control" id="screenshots" name="screenshots[]" accept=".png,.jpg,.jpeg" multiple>
<div id="screenshotsPreview" class="mt-2"></div>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="appUrl" class="form-label">App URL</label>
<input type="url" class="form-control" id="appUrl" name="appUrl">
</div>
<div class="col-md-6 mb-3">
<label class="form-label">Platform</label>
<div class="d-flex gap-3">
<?php foreach ($platforms as $platform): ?>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="platform[]" value="<?php echo htmlspecialchars($platform); ?>" id="platform<?php echo $platform; ?>">
<label class="form-check-label" for="platform<?php echo $platform; ?>"><?php echo htmlspecialchars($platform); ?></label>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="licenseType" class="form-label">License Type</label>
<select class="form-select" id="licenseType" name="licenseType">
<option value="">Select License Type</option>
<?php foreach ($licenseTypes as $license): ?>
<option value="<?php echo htmlspecialchars($license); ?>"><?php echo htmlspecialchars($license); ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6 mb-3">
<label for="tags" class="form-label">Tags (comma-separated)</label>
<input type="text" class="form-control" id="tags" name="tags">
</div>
</div>
<div class="mb-3">
<label for="additionalMetadata" class="form-label">Additional Metadata (JSON)</label>
<textarea class="form-control" id="additionalMetadata" name="additionalMetadata" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit App</button>
</form>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
// Preview functionality for images
function previewImage(input, previewDiv, multiple = false) {
previewDiv.innerHTML = '';
const files = multiple ? Array.from(input.files) : [input.files[0]];
files.forEach(file => {
if (file && file.type.startsWith('image/')) {
const reader = new FileReader();
reader.onload = function(e) {
const img = document.createElement('img');
img.src = e.target.result;
img.style.maxHeight = '100px';
img.style.marginRight = '10px';
img.className = 'mt-2';
previewDiv.appendChild(img);
}
reader.readAsDataURL(file);
}
});
}
document.getElementById('appIcon').addEventListener('change', function() {
previewImage(this, document.getElementById('iconPreview'));
});
document.getElementById('screenshots').addEventListener('change', function() {
previewImage(this, document.getElementById('screenshotsPreview'), true);
});
// Form validation
document.getElementById('appSubmissionForm').addEventListener('submit', function(e) {
const version = document.getElementById('version').value;
const appPackage = document.getElementById('appPackage').value;
if (!version.match(/^\d+\.\d+\.\d+$/)) {
alert('Version must be in X.X.X format');
e.preventDefault();
return;
}
if (appPackage && !appPackage.endsWith(`v${version}.zip`)) {
alert(`ZIP file must be named v${version}.zip`);
e.preventDefault();
return;
}
});
</script>
</body>
</html>