Ripcurlsurf commited on
Commit
433cb52
·
verified ·
1 Parent(s): aebe3c9

can it be converted locally on a pc and save the file locally

Browse files
Files changed (2) hide show
  1. README.md +8 -4
  2. index.html +298 -18
README.md CHANGED
@@ -1,10 +1,14 @@
1
  ---
2
- title: Asp2php Wizard
3
- emoji: 🐢
4
  colorFrom: green
5
- colorTo: blue
 
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
1
  ---
2
+ title: ASP2PHP Wizard 🧙‍♂️
 
3
  colorFrom: green
4
+ colorTo: pink
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://deepsite.hf.co).
14
+
index.html CHANGED
@@ -1,19 +1,299 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>ASP to PHP Converter</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://unpkg.com/feather-icons"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <style>
11
+ .dropzone {
12
+ border: 2px dashed #cbd5e0;
13
+ transition: all 0.3s;
14
+ }
15
+ .dropzone.active {
16
+ border-color: #4f46e5;
17
+ background-color: #eef2ff;
18
+ }
19
+ </style>
20
+ </head>
21
+ <body class="bg-gray-50 min-h-screen">
22
+ <div class="max-w-4xl mx-auto py-12 px-4 sm:px-6 lg:px-8">
23
+ <div class="text-center mb-12">
24
+ <div class="flex justify-center mb-4">
25
+ <div class="bg-indigo-100 p-4 rounded-full">
26
+ <i data-feather="wifi" class="w-12 h-12 text-indigo-600"></i>
27
+ </div>
28
+ </div>
29
+ <h1 class="text-3xl font-extrabold text-gray-900 sm:text-4xl">
30
+ ASP to PHP Converter
31
+ </h1>
32
+ <p class="mt-3 text-xl text-gray-500">
33
+ Upload your ASP files and convert them to PHP for Windows 11
34
+ </p>
35
+ </div>
36
+
37
+ <div class="bg-white shadow rounded-lg overflow-hidden">
38
+ <div class="p-6">
39
+ <div id="dropzone" class="dropzone rounded-lg p-12 text-center cursor-pointer">
40
+ <div class="flex justify-center mb-4">
41
+ <i data-feather="upload" class="w-10 h-10 text-gray-400"></i>
42
+ </div>
43
+ <h3 class="text-lg font-medium text-gray-900">Drag and drop files here</h3>
44
+ <p class="mt-1 text-sm text-gray-500">or click to browse</p>
45
+ <input type="file" id="fileInput" class="hidden" multiple accept=".asp,.aspx">
46
+ </div>
47
+
48
+ <div class="mt-6">
49
+ <button id="convertBtn" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-3 px-4 rounded-md shadow-sm flex items-center justify-center transition-colors duration-200">
50
+ <i data-feather="refresh-cw" class="w-5 h-5 mr-2"></i>
51
+ Convert Files
52
+ </button>
53
+ </div>
54
+ </div>
55
+
56
+ <div id="fileList" class="border-t border-gray-200 divide-y divide-gray-200">
57
+ <!-- Files will be listed here -->
58
+ </div>
59
+ </div>
60
+
61
+ <div class="mt-8 bg-white shadow rounded-lg overflow-hidden">
62
+ <div class="px-6 py-4 border-b border-gray-200">
63
+ <h3 class="text-lg font-medium text-gray-900">Conversion Guide</h3>
64
+ </div>
65
+ <div class="p-6">
66
+ <div class="space-y-4">
67
+ <div class="flex items-start">
68
+ <div class="flex-shrink-0 mt-1">
69
+ <div class="flex items-center justify-center h-6 w-6 rounded-full bg-green-100 text-green-800">
70
+ <i data-feather="check" class="w-4 h-4"></i>
71
+ </div>
72
+ </div>
73
+ <div class="ml-3">
74
+ <p class="text-sm text-gray-700">
75
+ All ASP files will be converted to PHP format compatible with Windows 11
76
+ </p>
77
+ </div>
78
+ </div>
79
+ <div class="flex items-start">
80
+ <div class="flex-shrink-0 mt-1">
81
+ <div class="flex items-center justify-center h-6 w-6 rounded-full bg-green-100 text-green-800">
82
+ <i data-feather="check" class="w-4 h-4"></i>
83
+ </div>
84
+ </div>
85
+ <div class="ml-3">
86
+ <p class="text-sm text-gray-700">
87
+ Supports multiple file upload and batch conversion
88
+ </p>
89
+ </div>
90
+ </div>
91
+ <div class="flex items-start">
92
+ <div class="flex-shrink-0 mt-1">
93
+ <div class="flex items-center justify-center h-6 w-6 rounded-full bg-green-100 text-green-800">
94
+ <i data-feather="check" class="w-4 h-4"></i>
95
+ </div>
96
+ </div>
97
+ <div class="ml-3">
98
+ <p class="text-sm text-gray-700">
99
+ Automatic download of converted files
100
+ </p>
101
+ </div>
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </div>
106
+ </div>
107
+ <script>
108
+ feather.replace();
109
+
110
+ // Add loader icon to feather
111
+ feather.icons.loader = {
112
+ contents: '<line x1="12" y1="2" x2="12" y2="6"/><line x1="12" y1="18" x2="12" y2="22"/><line x1="4.93" y1="4.93" x2="7.76" y2="7.76"/><line x1="16.24" y1="16.24" x2="19.07" y2="19.07"/><line x1="2" y1="12" x2="6" y2="12"/><line x1="18" y1="12" x2="22" y2="12"/><line x1="4.93" y1="19.07" x2="7.76" y2="16.24"/><line x1="16.24" y1="7.76" x2="19.07" y2="4.93"/>'
113
+ };
114
+ const dropzone = document.getElementById('dropzone');
115
+ const fileInput = document.getElementById('fileInput');
116
+ const fileList = document.getElementById('fileList');
117
+ const convertBtn = document.getElementById('convertBtn');
118
+ let files = [];
119
+
120
+ // Handle drag and drop
121
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
122
+ dropzone.addEventListener(eventName, preventDefaults, false);
123
+ });
124
+
125
+ function preventDefaults(e) {
126
+ e.preventDefault();
127
+ e.stopPropagation();
128
+ }
129
+
130
+ ['dragenter', 'dragover'].forEach(eventName => {
131
+ dropzone.addEventListener(eventName, highlight, false);
132
+ });
133
+
134
+ ['dragleave', 'drop'].forEach(eventName => {
135
+ dropzone.addEventListener(eventName, unhighlight, false);
136
+ });
137
+
138
+ function highlight() {
139
+ dropzone.classList.add('active');
140
+ }
141
+
142
+ function unhighlight() {
143
+ dropzone.classList.remove('active');
144
+ }
145
+
146
+ dropzone.addEventListener('drop', handleDrop, false);
147
+ dropzone.addEventListener('click', () => fileInput.click());
148
+
149
+ fileInput.addEventListener('change', function(e) {
150
+ handleFiles(e.target.files);
151
+ });
152
+
153
+ function handleDrop(e) {
154
+ const dt = e.dataTransfer;
155
+ handleFiles(dt.files);
156
+ }
157
+
158
+ function handleFiles(newFiles) {
159
+ files = [...files, ...Array.from(newFiles)];
160
+ updateFileList();
161
+ }
162
+
163
+ function updateFileList() {
164
+ fileList.innerHTML = '';
165
+
166
+ if (files.length === 0) {
167
+ const emptyState = document.createElement('div');
168
+ emptyState.className = 'p-4 text-center text-gray-500';
169
+ emptyState.textContent = 'No files selected';
170
+ fileList.appendChild(emptyState);
171
+ return;
172
+ }
173
+
174
+ files.forEach((file, index) => {
175
+ const fileItem = document.createElement('div');
176
+ fileItem.className = 'p-4 flex items-center justify-between';
177
+
178
+ const fileInfo = document.createElement('div');
179
+ fileInfo.className = 'flex items-center';
180
+
181
+ const icon = document.createElement('div');
182
+ icon.className = 'flex-shrink-0';
183
+ icon.innerHTML = '<i data-feather="file" class="w-5 h-5 text-gray-500"></i>';
184
+
185
+ const fileName = document.createElement('div');
186
+ fileName.className = 'ml-3';
187
+ fileName.innerHTML = `<p class="text-sm font-medium text-gray-900">${file.name}</p>
188
+ <p class="text-xs text-gray-500">${formatFileSize(file.size)}</p>`;
189
+
190
+ fileInfo.appendChild(icon);
191
+ fileInfo.appendChild(fileName);
192
+
193
+ const removeBtn = document.createElement('button');
194
+ removeBtn.className = 'ml-4 text-red-500 hover:text-red-700';
195
+ removeBtn.innerHTML = '<i data-feather="trash-2" class="w-5 h-5"></i>';
196
+ removeBtn.onclick = () => {
197
+ files.splice(index, 1);
198
+ updateFileList();
199
+ };
200
+
201
+ fileItem.appendChild(fileInfo);
202
+ fileItem.appendChild(removeBtn);
203
+ fileList.appendChild(fileItem);
204
+ });
205
+
206
+ feather.replace();
207
+ }
208
+
209
+ function formatFileSize(bytes) {
210
+ if (bytes === 0) return '0 Bytes';
211
+ const k = 1024;
212
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
213
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
214
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
215
+ }
216
+ convertBtn.addEventListener('click', async function() {
217
+ if (files.length === 0) {
218
+ alert('Please select files to convert');
219
+ return;
220
+ }
221
+
222
+ // Show processing indicator
223
+ convertBtn.disabled = true;
224
+ convertBtn.innerHTML = '<i data-feather="loader" class="w-5 h-5 mr-2 animate-spin"></i>Processing...';
225
+
226
+ for (const file of files) {
227
+ try {
228
+ const content = await readFileAsText(file);
229
+ const phpContent = convertASPtoPHP(content);
230
+ const phpFileName = file.name.replace(/\.asp$/, '.php').replace(/\.aspx$/, '.php');
231
+
232
+ // Save file locally
233
+ const blob = new Blob([phpContent], { type: 'text/plain' });
234
+ const url = URL.createObjectURL(blob);
235
+ const a = document.createElement('a');
236
+ a.href = url;
237
+ a.download = phpFileName;
238
+ document.body.appendChild(a);
239
+ a.click();
240
+ document.body.removeChild(a);
241
+ URL.revokeObjectURL(url);
242
+
243
+ } catch (error) {
244
+ console.error('Error converting file:', file.name, error);
245
+ alert(`Error converting ${file.name}: ${error.message}`);
246
+ }
247
+ }
248
+
249
+ // Reset after conversion
250
+ convertBtn.disabled = false;
251
+ convertBtn.innerHTML = '<i data-feather="refresh-cw" class="w-5 h-5 mr-2"></i>Convert Files';
252
+ files = [];
253
+ updateFileList();
254
+ alert('Conversion complete! Files downloaded.');
255
+ });
256
+
257
+ function readFileAsText(file) {
258
+ return new Promise((resolve, reject) => {
259
+ const reader = new FileReader();
260
+ reader.onload = () => resolve(reader.result);
261
+ reader.onerror = () => reject(new Error('Failed to read file'));
262
+ reader.readAsText(file);
263
+ });
264
+ }
265
+
266
+ function convertASPtoPHP(content) {
267
+ // Basic ASP to PHP conversions
268
+ let phpContent = content
269
+ .replace(/<%=\s*/g, '<?= ')
270
+ .replace(/<%([^=])/g, '<?php $1')
271
+ .replace(/%>/g, '?>')
272
+ .replace(/Response\.Write/g, 'echo')
273
+ .replace(/Server\.CreateObject\(/g, 'new ')
274
+ .replace(/Set\s+(\w+)\s*=\s*/g, '$1 = ')
275
+ .replace(/\bSub\b/g, 'function')
276
+ .replace(/\bEnd Sub\b/g, '}')
277
+ .replace(/\bFunction\b/g, 'function')
278
+ .replace(/\bEnd Function\b/g, '}')
279
+ .replace(/\bDim\b/g, '</script>
280
+ </body>
281
+ </html>
282
+ )
283
+ .replace(/\bThen\b/g, '')
284
+ .replace(/End If/g, '}')
285
+ .replace(/If\s+(.*?)\s+Then/g, 'if ($1) {')
286
+ .replace(/End While/g, '}')
287
+ .replace(/While\s+(.*?)/g, 'while ($1) {')
288
+ .replace(/Loop/g, '}');
289
+
290
+ // Add PHP opening tag if not present
291
+ if (!phpContent.includes('<?php')) {
292
+ phpContent = '<?php\n' + phpContent;
293
+ }
294
+
295
+ return phpContent;
296
+ }
297
+ </script>
298
+ </body>
299
  </html>