'folder',
'color' => '#5F6368', // Google's folder gray
'bgColor' => '#ffffff',
'class' => 'folder-item'
];
}
// IMAGES - Show thumbnail
if (strpos($mimeType, 'image/') === 0) {
return [
'icon' => 'image',
'color' => '#EA4335', // Google red
'bgColor' => '#ffffff',
'class' => 'image-file',
'showThumbnail' => true
];
}
// VIDEOS - Show thumbnail with play icon
if (strpos($mimeType, 'video/') === 0) {
return [
'icon' => 'play_circle_filled',
'color' => '#EA4335', // Google red
'bgColor' => '#ffffff',
'class' => 'video-file',
'showThumbnail' => true
];
}
// AUDIO FILES
if (strpos($mimeType, 'audio/') === 0) {
return [
'icon' => 'audiotrack',
'color' => '#EA4335', // Google red
'bgColor' => '#ffffff',
'class' => 'audio-file'
];
}
// PDF FILES - Google red
if ($mimeType === 'application/pdf' || $extension === 'pdf') {
return [
'icon' => 'picture_as_pdf',
'color' => '#EA4335', // Google red
'bgColor' => '#ffffff',
'class' => 'pdf-file'
];
}
// MICROSOFT WORD / GOOGLE DOCS - Google blue
if (in_array($extension, ['doc', 'docx']) || strpos($mimeType, 'word') !== false) {
return [
'icon' => 'description',
'color' => '#4285F4', // Google Docs blue
'bgColor' => '#ffffff',
'class' => 'word-file'
];
}
// MICROSOFT EXCEL / GOOGLE SHEETS - Google green
if (in_array($extension, ['xls', 'xlsx']) || strpos($mimeType, 'excel') !== false || strpos($mimeType, 'spreadsheet') !== false) {
return [
'icon' => 'grid_on',
'color' => '#0F9D58', // Google Sheets green
'bgColor' => '#ffffff',
'class' => 'excel-file'
];
}
// MICROSOFT POWERPOINT / GOOGLE SLIDES - Google yellow
if (in_array($extension, ['ppt', 'pptx']) || strpos($mimeType, 'powerpoint') !== false || strpos($mimeType, 'presentation') !== false) {
return [
'icon' => 'slideshow',
'color' => '#FBBC04', // Google Slides yellow
'bgColor' => '#ffffff',
'class' => 'powerpoint-file'
];
}
// ARCHIVE FILES (ZIP, RAR, etc.)
if (in_array($extension, ['zip', 'rar', '7z', 'tar', 'gz', 'bz2'])) {
return [
'icon' => 'folder_zip',
'color' => '#F4B400', // Yellow
'bgColor' => '#ffffff',
'class' => 'archive-file'
];
}
// CODE FILES
if (in_array($extension, ['html', 'css', 'js', 'php', 'py', 'java', 'cpp', 'c', 'json', 'xml', 'sql', 'sh', 'bat', 'ts', 'jsx', 'tsx'])) {
return [
'icon' => 'code',
'color' => '#5F6368', // Gray
'bgColor' => '#ffffff',
'class' => 'code-file'
];
}
// TEXT FILES
if (strpos($mimeType, 'text/') === 0 || in_array($extension, ['txt', 'md', 'log'])) {
return [
'icon' => 'description',
'color' => '#5F6368', // Gray
'bgColor' => '#ffffff',
'class' => 'text-file'
];
}
// EXECUTABLE FILES (.exe, .msi, .app) ⭐ FIXES YOUR BROKEN ICON ISSUE
if (in_array($extension, ['exe', 'msi', 'app', 'deb', 'rpm', 'apk'])) {
return [
'icon' => 'insert_drive_file',
'color' => '#80868B', // Light gray (like Google Drive)
'bgColor' => '#ffffff',
'class' => 'executable-file'
];
}
// BINARY FILES (.bin, .dll, .dat) ⭐ FIXES YOUR BROKEN ICON ISSUE
if (in_array($extension, ['bin', 'dat', 'dll', 'sys', 'so', 'o'])) {
return [
'icon' => 'insert_drive_file',
'color' => '#80868B', // Light gray (like Google Drive)
'bgColor' => '#ffffff',
'class' => 'binary-file'
];
}
// DISK IMAGES (ISO, IMG, etc.)
if (in_array($extension, ['iso', 'img', 'dmg', 'vhd'])) {
return [
'icon' => 'album',
'color' => '#9334E6', // Purple
'bgColor' => '#ffffff',
'class' => 'disk-file'
];
}
// DEFAULT - Generic file (like Google Drive)
return [
'icon' => 'insert_drive_file',
'color' => '#80868B', // Light gray
'bgColor' => '#ffffff',
'class' => 'default-file'
];
}
?>
/**
* Get Google Drive-style icon and color for file types
* Returns exact Google colors and appropriate Material Icons
*/
function getGoogleDriveIcon($fileName, $mimeType) {
$extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
// FOLDERS
if ($mimeType === 'folder') {
return [
'icon' => 'folder',
'color' => '#5F6368',
'bgColor' => '#ffffff',
'class' => 'folder-item'
];
}
// IMAGES - Show thumbnail
if (strpos($mimeType, 'image/') === 0) {
return [
'icon' => 'image',
'color' => '#EA4335',
'bgColor' => '#ffffff',
'class' => 'image-file',
'showThumbnail' => true
];
}
// VIDEOS
if (strpos($mimeType, 'video/') === 0) {
return [
'icon' => 'play_circle_filled',
'color' => '#EA4335',
'bgColor' => '#ffffff',
'class' => 'video-file',
'showThumbnail' => true
];
}
// AUDIO FILES
if (strpos($mimeType, 'audio/') === 0) {
return [
'icon' => 'audiotrack',
'color' => '#EA4335',
'bgColor' => '#ffffff',
'class' => 'audio-file'
];
}
// PDF FILES
if ($mimeType === 'application/pdf' || $extension === 'pdf') {
return [
'icon' => 'picture_as_pdf',
'color' => '#EA4335',
'bgColor' => '#ffffff',
'class' => 'pdf-file'
];
}
// WORD DOCS
if (in_array($extension, ['doc', 'docx']) || strpos($mimeType, 'word') !== false) {
return [
'icon' => 'description',
'color' => '#4285F4',
'bgColor' => '#ffffff',
'class' => 'word-file'
];
}
// EXCEL/SHEETS
if (in_array($extension, ['xls', 'xlsx']) || strpos($mimeType, 'excel') !== false || strpos($mimeType, 'spreadsheet') !== false) {
return [
'icon' => 'grid_on',
'color' => '#0F9D58',
'bgColor' => '#ffffff',
'class' => 'excel-file'
];
}
// POWERPOINT/SLIDES
if (in_array($extension, ['ppt', 'pptx']) || strpos($mimeType, 'powerpoint') !== false || strpos($mimeType, 'presentation') !== false) {
return [
'icon' => 'slideshow',
'color' => '#FBBC04',
'bgColor' => '#ffffff',
'class' => 'powerpoint-file'
];
}
// ARCHIVES
if (in_array($extension, ['zip', 'rar', '7z', 'tar', 'gz', 'bz2'])) {
return [
'icon' => 'folder_zip',
'color' => '#F4B400',
'bgColor' => '#ffffff',
'class' => 'archive-file'
];
}
// CODE FILES
if (in_array($extension, ['html', 'css', 'js', 'php', 'py', 'java', 'cpp', 'c', 'json', 'xml', 'sql', 'sh', 'bat'])) {
return [
'icon' => 'code',
'color' => '#5F6368',
'bgColor' => '#ffffff',
'class' => 'code-file'
];
}
// TEXT FILES
if (strpos($mimeType, 'text/') === 0 || in_array($extension, ['txt', 'md', 'log'])) {
return [
'icon' => 'description',
'color' => '#5F6368',
'bgColor' => '#ffffff',
'class' => 'text-file'
];
}
// EXECUTABLE FILES (.exe, .msi, .app) ⭐ FIXES YOUR ISSUE
if (in_array($extension, ['exe', 'msi', 'app', 'deb', 'rpm', 'apk'])) {
return [
'icon' => 'insert_drive_file',
'color' => '#80868B',
'bgColor' => '#ffffff',
'class' => 'executable-file'
];
}
// BINARY FILES (.bin, .dll, .dat) ⭐ FIXES YOUR ISSUE
if (in_array($extension, ['bin', 'dat', 'dll', 'sys', 'so', 'o'])) {
return [
'icon' => 'insert_drive_file',
'color' => '#80868B',
'bgColor' => '#ffffff',
'class' => 'binary-file'
];
}
// DISK IMAGES
if (in_array($extension, ['iso', 'img', 'dmg', 'vhd'])) {
return [
'icon' => 'album',
'color' => '#9334E6',
'bgColor' => '#ffffff',
'class' => 'disk-file'
];
}
// DEFAULT
return [
'icon' => 'insert_drive_file',
'color' => '#80868B',
'bgColor' => '#ffffff',
'class' => 'default-file'
];
}
?>
"
draggable="true">
folder
star
SHARED
'folder',
'color' => '#5F6368', // Google's folder gray
'bgColor' => '#ffffff',
'class' => 'folder-item'
];
}
// IMAGES - Show thumbnail
if (strpos($mimeType, 'image/') === 0) {
return [
'icon' => 'image',
'color' => '#EA4335', // Google red
'bgColor' => '#ffffff',
'class' => 'image-file',
'showThumbnail' => true
];
}
// VIDEOS - Show thumbnail with play icon
if (strpos($mimeType, 'video/') === 0) {
return [
'icon' => 'play_circle_filled',
'color' => '#EA4335', // Google red
'bgColor' => '#ffffff',
'class' => 'video-file',
'showThumbnail' => true
];
}
// AUDIO FILES
if (strpos($mimeType, 'audio/') === 0) {
return [
'icon' => 'audiotrack',
'color' => '#EA4335', // Google red
'bgColor' => '#ffffff',
'class' => 'audio-file'
];
}
// PDF FILES - Google red
if ($mimeType === 'application/pdf' || $extension === 'pdf') {
return [
'icon' => 'picture_as_pdf',
'color' => '#EA4335', // Google red
'bgColor' => '#ffffff',
'class' => 'pdf-file'
];
}
// MICROSOFT WORD / GOOGLE DOCS - Google blue
if (in_array($extension, ['doc', 'docx']) || strpos($mimeType, 'word') !== false) {
return [
'icon' => 'description',
'color' => '#4285F4', // Google Docs blue
'bgColor' => '#ffffff',
'class' => 'word-file'
];
}
// MICROSOFT EXCEL / GOOGLE SHEETS - Google green
if (in_array($extension, ['xls', 'xlsx']) || strpos($mimeType, 'excel') !== false || strpos($mimeType, 'spreadsheet') !== false) {
return [
'icon' => 'grid_on',
'color' => '#0F9D58', // Google Sheets green
'bgColor' => '#ffffff',
'class' => 'excel-file'
];
}
// MICROSOFT POWERPOINT / GOOGLE SLIDES - Google yellow
if (in_array($extension, ['ppt', 'pptx']) || strpos($mimeType, 'powerpoint') !== false || strpos($mimeType, 'presentation') !== false) {
return [
'icon' => 'slideshow',
'color' => '#FBBC04', // Google Slides yellow
'bgColor' => '#ffffff',
'class' => 'powerpoint-file'
];
}
// ARCHIVE FILES (ZIP, RAR, etc.)
if (in_array($extension, ['zip', 'rar', '7z', 'tar', 'gz', 'bz2'])) {
return [
'icon' => 'folder_zip',
'color' => '#F4B400', // Yellow
'bgColor' => '#ffffff',
'class' => 'archive-file'
];
}
// CODE FILES
if (in_array($extension, ['html', 'css', 'js', 'php', 'py', 'java', 'cpp', 'c', 'json', 'xml', 'sql', 'sh', 'bat', 'ts', 'jsx', 'tsx'])) {
return [
'icon' => 'code',
'color' => '#5F6368', // Gray
'bgColor' => '#ffffff',
'class' => 'code-file'
];
}
// TEXT FILES
if (strpos($mimeType, 'text/') === 0 || in_array($extension, ['txt', 'md', 'log'])) {
return [
'icon' => 'description',
'color' => '#5F6368', // Gray
'bgColor' => '#ffffff',
'class' => 'text-file'
];
}
// EXECUTABLE FILES (.exe, .msi, .app) ⭐ FIXES YOUR BROKEN ICON ISSUE
if (in_array($extension, ['exe', 'msi', 'app', 'deb', 'rpm', 'apk'])) {
return [
'icon' => 'insert_drive_file',
'color' => '#80868B', // Light gray (like Google Drive)
'bgColor' => '#ffffff',
'class' => 'executable-file'
];
}
// BINARY FILES (.bin, .dll, .dat) ⭐ FIXES YOUR BROKEN ICON ISSUE
if (in_array($extension, ['bin', 'dat', 'dll', 'sys', 'so', 'o'])) {
return [
'icon' => 'insert_drive_file',
'color' => '#80868B', // Light gray (like Google Drive)
'bgColor' => '#ffffff',
'class' => 'binary-file'
];
}
// DISK IMAGES (ISO, IMG, etc.)
if (in_array($extension, ['iso', 'img', 'dmg', 'vhd'])) {
return [
'icon' => 'album',
'color' => '#9334E6', // Purple
'bgColor' => '#ffffff',
'class' => 'disk-file'
];
}
// DEFAULT - Generic file (like Google Drive)
return [
'icon' => 'insert_drive_file',
'color' => '#80868B', // Light gray
'bgColor' => '#ffffff',
'class' => 'default-file'
];
}
// ===== END OF FUNCTION ===== ↑↑↑
// Check if this is a shared link
if (isset($_GET['share']) && !empty($_GET['share'])) {
// ... rest of your code continues
// Check if this is a shared link
if (isset($_GET['share']) && !empty($_GET['share'])) {
$shareId = $_GET['share'];
$metadataFile = 'data/files.json';
if (file_exists($metadataFile)) {
$metadata = json_decode(file_get_contents($metadataFile), true);
if ($metadata && isset($metadata['files'])) {
foreach ($metadata['files'] as $file) {
if ($file['id'] === $shareId) {
// ALL FILES ARE PUBLIC - No checks!
$fileName = $file['name'];
$filePath = $file['path'];
$mimeType = $file['type'];
$fileSize = $file['size'];
$modifiedTime = $file['modified'];
if (file_exists($filePath)) {
if (file_exists('view_shared.php')) {
include 'view_shared.php';
exit;
}
}
die('File not found');
}
}
}
}
die('File not found in database');
}
// Create necessary directories
$dirs = ['uploads', 'data', 'trash'];
foreach ($dirs as $dir) {
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
}
// Initialize metadata file
$metadataFile = 'data/files.json';
if (!file_exists($metadataFile)) {
file_put_contents($metadataFile, json_encode(['files' => []], JSON_PRETTY_PRINT));
}
// Load metadata
function loadMetadata() {
global $metadataFile;
$data = file_get_contents($metadataFile);
return json_decode($data, true);
}
// Save metadata
function saveMetadata($metadata) {
global $metadataFile;
file_put_contents($metadataFile, json_encode($metadata, JSON_PRETTY_PRINT));
}
// Delete directory recursively
function deleteDirectory($dir) {
if (!is_dir($dir)) return;
$files = array_diff(scandir($dir), ['.', '..']);
foreach ($files as $file) {
$path = $dir . '/' . $file;
is_dir($path) ? deleteDirectory($path) : unlink($path);
}
rmdir($dir);
}
// Calculate storage usage
function calculateStorageUsage($directory = 'uploads') {
$totalSize = 0;
if (is_dir($directory)) {
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($files as $file) {
if ($file->isFile()) {
$totalSize += $file->getSize();
}
}
}
return $totalSize;
}
// Format bytes to human readable
function formatBytes($bytes, $precision = 2) {
if ($bytes >= 1073741824) {
return number_format($bytes / 1073741824, $precision) . ' GB';
} elseif ($bytes >= 1048576) {
return number_format($bytes / 1048576, $precision) . ' MB';
} elseif ($bytes >= 1024) {
return number_format($bytes / 1024, $precision) . ' KB';
} else {
return $bytes . ' bytes';
}
}
// Storage quota (50 GB in bytes) - FIXED TYPO
$storageQuota = 50 * 1024 * 1024 * 1024;
$storageUsed = calculateStorageUsage();
$storagePercentage = ($storageUsed / $storageQuota) * 100;
// Determine storage color
if ($storagePercentage >= 95) {
$storageColor = '#ea4335';
} elseif ($storagePercentage >= 80) {
$storageColor = '#f9ab00';
} else {
$storageColor = '#1a73e8';
}
// Get current view and folder
$view = isset($_GET['view']) ? $_GET['view'] : 'my-drive';
$currentFolder = isset($_GET['folder']) ? $_GET['folder'] : 'root';
// Handle file upload via AJAX
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['files'])) {
$uploadedFiles = $_FILES['files'];
$totalFiles = count($uploadedFiles['name']);
$metadata = loadMetadata();
$results = [];
$targetFolder = isset($_POST['targetFolder']) ? $_POST['targetFolder'] : 'root';
// Determine upload path
$uploadPath = 'uploads/';
if ($targetFolder !== 'root') {
foreach ($metadata['files'] as $file) {
if ($file['id'] === $targetFolder && $file['type'] === 'folder') {
$uploadPath = $file['path'] . '/';
break;
}
}
}
for ($i = 0; $i < $totalFiles; $i++) {
if ($uploadedFiles['error'][$i] === UPLOAD_ERR_OK) {
$fileName = basename($uploadedFiles['name'][$i]);
$tempFile = $uploadedFiles['tmp_name'][$i];
$targetFile = $uploadPath . $fileName;
$counter = 1;
$originalName = pathinfo($fileName, PATHINFO_FILENAME);
$extension = pathinfo($fileName, PATHINFO_EXTENSION);
while (file_exists($targetFile)) {
$fileName = $originalName . '_' . $counter . '.' . $extension;
$targetFile = $uploadPath . $fileName;
$counter++;
}
if (move_uploaded_file($tempFile, $targetFile)) {
$fileId = uniqid();
$newFile = [
'id' => $fileId,
'name' => $fileName,
'path' => $targetFile,
'type' => getFileMimeType($targetFile),
'size' => filesize($targetFile),
'created' => time(),
'modified' => time(),
'accessed' => time(),
'starred' => false,
'trashed' => false,
'trashedDate' => null,
'parentFolder' => $targetFolder
];
$metadata['files'][] = $newFile;
$results[] = ['success' => true, 'file' => $newFile];
} else {
$results[] = ['success' => false, 'error' => 'Failed to upload ' . $fileName];
}
}
}
saveMetadata($metadata);
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
header('Content-Type: application/json');
echo json_encode([
'success' => true,
'files' => $results,
'storageUsed' => calculateStorageUsage(),
'storageQuota' => $storageQuota
]);
exit;
}
header('Location: index.php?view=' . $view . '&folder=' . $currentFolder);
exit;
}
// Auto-delete files older than 30 days in trash
$metadata = loadMetadata();
$thirtyDaysAgo = time() - (30 * 24 * 60 * 60);
foreach ($metadata['files'] as $key => $file) {
if (isset($file['trashed']) && $file['trashed'] &&
isset($file['trashedDate']) && $file['trashedDate'] &&
$file['trashedDate'] < $thirtyDaysAgo) {
if ($file['type'] === 'folder') {
if (is_dir($file['path'])) {
deleteDirectory($file['path']);
}
} else {
if (file_exists($file['path'])) {
unlink($file['path']);
}
}
unset($metadata['files'][$key]);
}
}
$metadata['files'] = array_values($metadata['files']);
saveMetadata($metadata);
// Get files based on view
function getFiles($view, $currentFolder) {
$metadata = loadMetadata();
$files = $metadata['files'];
switch ($view) {
case 'my-drive':
return array_filter($files, function($f) use ($currentFolder) {
return !$f['trashed'] && $f['parentFolder'] === $currentFolder;
});
case 'recent':
$recentFiles = array_filter($files, function($f) { return !$f['trashed']; });
usort($recentFiles, function($a, $b) { return $b['accessed'] - $a['accessed']; });
return array_slice($recentFiles, 0, 20);
case 'starred':
return array_filter($files, function($f) { return $f['starred'] && !$f['trashed']; });
case 'trash':
return array_filter($files, function($f) { return $f['trashed']; });
default:
return array_filter($files, function($f) use ($currentFolder) {
return !$f['trashed'] && $f['parentFolder'] === $currentFolder;
});
}
}
$files = getFiles($view, $currentFolder);
// Get folder breadcrumbs
function getBreadcrumbs($folderId) {
if ($folderId === 'root') return [];
$metadata = loadMetadata();
$breadcrumbs = [];
$currentId = $folderId;
while ($currentId !== 'root') {
foreach ($metadata['files'] as $file) {
if ($file['id'] === $currentId) {
array_unshift($breadcrumbs, $file);
$currentId = isset($file['parentFolder']) ? $file['parentFolder'] : 'root';
break;
}
}
if (!isset($file) || $file['id'] !== $currentId) break;
}
return $breadcrumbs;
}
$breadcrumbs = getBreadcrumbs($currentFolder);
function formatFileSize($bytes) {
if ($bytes >= 1073741824) {
return number_format($bytes / 1073741824, 2) . ' GB';
} elseif ($bytes >= 1048576) {
return number_format($bytes / 1048576, 2) . ' MB';
} elseif ($bytes >= 1024) {
return number_format($bytes / 1024, 2) . ' KB';
} else {
return $bytes . ' bytes';
}
}
function getFileMimeType($filePath) {
// Try to get MIME type using multiple methods
$mimeType = false;
// Method 1: Use mime_content_type (most accurate)
if (function_exists('mime_content_type')) {
$mimeType = mime_content_type($filePath);
}
// Method 2: Use finfo (fallback)
if (!$mimeType && function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimeType = finfo_file($finfo, $filePath);
finfo_close($finfo);
}
// Method 3: Detect by extension (for .exe, .bin, etc.)
if ($mimeType === 'application/octet-stream' || !$mimeType) {
$extension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
$extensionMap = [
// Executables
'exe' => 'application/x-msdownload',
'bin' => 'application/x-binary',
'dll' => 'application/x-msdownload',
'app' => 'application/x-executable',
'apk' => 'application/vnd.android.package-archive',
'dmg' => 'application/x-apple-diskimage',
'msi' => 'application/x-msdownload',
// Archives
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'7z' => 'application/x-7z-compressed',
'tar' => 'application/x-tar',
'gz' => 'application/gzip',
'iso' => 'application/x-iso9660-image',
// Documents
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xls' => 'application/vnd.ms-excel',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'ppt' => 'application/vnd.ms-powerpoint',
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
// Code files
'js' => 'application/javascript',
'json' => 'application/json',
'py' => 'text/x-python',
'java' => 'text/x-java',
'cpp' => 'text/x-c++',
'c' => 'text/x-c',
'php' => 'text/x-php',
'html' => 'text/html',
'css' => 'text/css',
// Images
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'png' => 'image/png',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'svg' => 'image/svg+xml',
'webp' => 'image/webp',
// Videos
'mp4' => 'video/mp4',
'avi' => 'video/x-msvideo',
'mov' => 'video/quicktime',
'wmv' => 'video/x-ms-wmv',
'mkv' => 'video/x-matroska',
// Audio
'mp3' => 'audio/mpeg',
'wav' => 'audio/wav',
'ogg' => 'audio/ogg',
'flac' => 'audio/flac'
];
if (isset($extensionMap[$extension])) {
$mimeType = $extensionMap[$extension];
}
}
// Default fallback
return $mimeType ?: 'application/octet-stream';
}
function getFileIcon($mimeType) {
// Image files
if (strpos($mimeType, 'image/') === 0) {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_image_x16.png';
}
// Video files
if (strpos($mimeType, 'video/') === 0) {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_video_x16.png';
}
// Audio files
if (strpos($mimeType, 'audio/') === 0) {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_audio_x16.png';
}
// PDF files
if ($mimeType === 'application/pdf') {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_pdf_x16.png';
}
// Text files
if (strpos($mimeType, 'text/') === 0) {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_text_x16.png';
}
// Document files (Word, Excel, PowerPoint, etc.)
if (in_array($mimeType, [
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.oasis.opendocument.text'
])) {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_document_x16.png';
}
// Spreadsheet files
if (in_array($mimeType, [
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.oasis.opendocument.spreadsheet'
])) {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_spreadsheet_x16.png';
}
// Presentation files
if (in_array($mimeType, [
'application/vnd.ms-powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.oasis.opendocument.presentation'
])) {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_presentation_x16.png';
}
// Archive files (ZIP, RAR, 7Z, TAR, etc.)
if (in_array($mimeType, [
'application/zip',
'application/x-zip-compressed',
'application/x-rar-compressed',
'application/x-7z-compressed',
'application/x-tar',
'application/gzip',
'application/x-compressed'
])) {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_archive_x16.png';
}
// Code files
if (in_array($mimeType, [
'application/javascript',
'application/json',
'application/xml',
'text/javascript',
'text/x-python',
'text/x-java',
'text/x-c',
'text/x-c++',
'text/x-php',
'text/html',
'text/css'
])) {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_code_x16.png';
}
// Executable files (.exe, .bin, .app, .dmg, .apk, etc.)
if (in_array($mimeType, [
'application/x-msdownload',
'application/x-executable',
'application/x-binary',
'application/octet-stream',
'application/x-msdos-program',
'application/x-dosexec',
'application/vnd.microsoft.portable-executable'
])) {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_executable_x16.png';
}
// APK (Android Package)
if ($mimeType === 'application/vnd.android.package-archive') {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_executable_x16.png';
}
// DMG (Mac Disk Image)
if ($mimeType === 'application/x-apple-diskimage') {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_executable_x16.png';
}
// ISO (Disk Image)
if ($mimeType === 'application/x-iso9660-image') {
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_archive_x16.png';
}
// Default for unknown types
return 'https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_generic_x16.png';
}
function getGoogleDriveIcon($fileName, $mimeType) {
$extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
// FOLDERS
if ($mimeType === 'folder') {
return [
'icon' => 'folder',
'color' => '#5F6368',
'bgColor' => '#ffffff',
'class' => 'folder-item'
];
}
// IMAGES - Show thumbnail
if (strpos($mimeType, 'image/') === 0) {
return [
'icon' => 'image',
'color' => '#EA4335',
'bgColor' => '#ffffff',
'class' => 'image-file',
'showThumbnail' => true
];
}
// VIDEOS
if (strpos($mimeType, 'video/') === 0) {
return [
'icon' => 'play_circle_filled',
'color' => '#EA4335',
'bgColor' => '#ffffff',
'class' => 'video-file',
'showThumbnail' => true
];
}
// AUDIO FILES
if (strpos($mimeType, 'audio/') === 0) {
return [
'icon' => 'audiotrack',
'color' => '#EA4335',
'bgColor' => '#ffffff',
'class' => 'audio-file'
];
}
// PDF FILES
if ($mimeType === 'application/pdf' || $extension === 'pdf') {
return [
'icon' => 'picture_as_pdf',
'color' => '#EA4335',
'bgColor' => '#ffffff',
'class' => 'pdf-file'
];
}
// WORD DOCS
if (in_array($extension, ['doc', 'docx']) || strpos($mimeType, 'word') !== false) {
return [
'icon' => 'description',
'color' => '#4285F4',
'bgColor' => '#ffffff',
'class' => 'word-file'
];
}
// EXCEL/SHEETS
if (in_array($extension, ['xls', 'xlsx']) || strpos($mimeType, 'excel') !== false || strpos($mimeType, 'spreadsheet') !== false) {
return [
'icon' => 'grid_on',
'color' => '#0F9D58',
'bgColor' => '#ffffff',
'class' => 'excel-file'
];
}
// POWERPOINT/SLIDES
if (in_array($extension, ['ppt', 'pptx']) || strpos($mimeType, 'powerpoint') !== false || strpos($mimeType, 'presentation') !== false) {
return [
'icon' => 'slideshow',
'color' => '#FBBC04',
'bgColor' => '#ffffff',
'class' => 'powerpoint-file'
];
}
// ARCHIVES
if (in_array($extension, ['zip', 'rar', '7z', 'tar', 'gz', 'bz2'])) {
return [
'icon' => 'folder_zip',
'color' => '#F4B400',
'bgColor' => '#ffffff',
'class' => 'archive-file'
];
}
// CODE FILES
if (in_array($extension, ['html', 'css', 'js', 'php', 'py', 'java', 'cpp', 'c', 'json', 'xml', 'sql', 'sh', 'bat'])) {
return [
'icon' => 'code',
'color' => '#5F6368',
'bgColor' => '#ffffff',
'class' => 'code-file'
];
}
// TEXT FILES
if (strpos($mimeType, 'text/') === 0 || in_array($extension, ['txt', 'md', 'log'])) {
return [
'icon' => 'description',
'color' => '#5F6368',
'bgColor' => '#ffffff',
'class' => 'text-file'
];
}
// EXECUTABLE FILES (.exe, .msi, .app) ⭐ FIXES YOUR ISSUE
if (in_array($extension, ['exe', 'msi', 'app', 'deb', 'rpm', 'apk'])) {
return [
'icon' => 'insert_drive_file',
'color' => '#80868B',
'bgColor' => '#ffffff',
'class' => 'executable-file'
];
}
// BINARY FILES (.bin, .dll, .dat) ⭐ FIXES YOUR ISSUE
if (in_array($extension, ['bin', 'dat', 'dll', 'sys', 'so', 'o'])) {
return [
'icon' => 'insert_drive_file',
'color' => '#80868B',
'bgColor' => '#ffffff',
'class' => 'binary-file'
];
}
// DISK IMAGES
if (in_array($extension, ['iso', 'img', 'dmg', 'vhd'])) {
return [
'icon' => 'album',
'color' => '#9334E6',
'bgColor' => '#ffffff',
'class' => 'disk-file'
];
}
// DEFAULT
return [
'icon' => 'insert_drive_file',
'color' => '#80868B',
'bgColor' => '#ffffff',
'class' => 'default-file'
];
}
function timeAgo($timestamp) {
$diff = time() - $timestamp;
if ($diff < 60) {
return 'Just now';
} elseif ($diff < 3600) {
$mins = floor($diff / 60);
return $mins . ' minute' . ($mins > 1 ? 's' : '') . ' ago';
} elseif ($diff < 86400) {
$hours = floor($diff / 3600);
return $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ago';
} elseif ($diff < 604800) {
$days = floor($diff / 86400);
return $days . ' day' . ($days > 1 ? 's' : '') . ' ago';
} else {
return date('M j, Y', $timestamp);
}
}
?>
My Drive - Google Drive
folder My Drive
chevron_right
people_outline
Nothing shared yet
Files and folders others share with you will show up here
delete_outline
Trash is empty
Items you trash are deleted forever after 30 days
star_outline
No starred items
Add stars to files and folders to find them easily later
access_time
No recent files
Files you open or edit will show up here
folder_open
Drop files here or use the "New" button
Drag files to upload or create a new folder
"
draggable="true">
star
SHARED
info
Public File
This file is publicly shareable. Anyone with the link can view and download it.
cloud_upload
Drop files to upload