🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:functions.php
<?php // Function to safely redirect function redirect($path) { header("Location: " . BASE_URL . $path); exit; } // Function to handle image upload function uploadImage($file, $targetDir = "uploads/logos/") { $targetDir = __DIR__ . "/../" . $targetDir; if (!is_dir($targetDir)) { mkdir($targetDir, 0777, true); } $fileName = time() . '_' . basename($file["name"]); $targetFilePath = $targetDir . $fileName; $fileType = pathinfo($targetFilePath, PATHINFO_EXTENSION); // Allow certain file formats $allowTypes = array('jpg', 'png', 'jpeg', 'gif'); if (in_array(strtolower($fileType), $allowTypes)) { // Upload file to server if (move_uploaded_file($file["tmp_name"], $targetFilePath)) { return $fileName; } } return false; } // Function to handle document upload (CVs) function uploadFile($file, $targetDir = "uploads/cvs/") { $targetDir = __DIR__ . "/../" . $targetDir; if (!is_dir($targetDir)) { mkdir($targetDir, 0777, true); } $fileName = time() . '_' . basename($file["name"]); $targetFilePath = $targetDir . $fileName; $fileType = pathinfo($targetFilePath, PATHINFO_EXTENSION); // Allow certain file formats $allowTypes = array('pdf', 'doc', 'docx'); if (in_array(strtolower($fileType), $allowTypes)) { // Upload file to server if (move_uploaded_file($file["tmp_name"], $targetFilePath)) { return $fileName; } } return false; } // Function to check if user is logged in function isLoggedIn() { return isset($_SESSION['employer_id']) || isset($_SESSION['admin_id']) || isset($_SESSION['candidate_id']); } // Function to get time ago function timeAgo($timestamp) { $time_ago = strtotime($timestamp); $cur_time = time(); $time_elapsed = $cur_time - $time_ago; $seconds = $time_elapsed; $minutes = round($time_elapsed / 60); $hours = round($time_elapsed / 3600); $days = round($time_elapsed / 86400); $weeks = round($time_elapsed / 604800); $months = round($time_elapsed / 2600640); $years = round($time_elapsed / 31207680); if ($seconds <= 60) return "just now"; else if ($minutes <= 60) return ($minutes == 1) ? "1 minute ago" : "$minutes minutes ago"; else if ($hours <= 24) return ($hours == 1) ? "1 hour ago" : "$hours hours ago"; else if ($days <= 7) return ($days == 1) ? "yesterday" : "$days days ago"; else if ($weeks <= 4.3) return ($weeks == 1) ? "1 week ago" : "$weeks weeks ago"; else if ($months <= 12) return ($months == 1) ? "1 month ago" : "$months months ago"; else return ($years == 1) ? "1 year ago" : "$years years ago"; } ?>
Save Changes
Cancel
Create New File
Create New Folder