summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2003-12-26 23:03:21 +0000
committerDries Buytaert <dries@buytaert.net>2003-12-26 23:03:21 +0000
commit15f289a8f0ab4cc2e1253731ca5af5987b3af0d6 (patch)
treee064d4466941c7044df068e1f07cf831ca23909f /modules
parentc18984562a596fc1c9d823e5e83d5bd2d4fb761c (diff)
downloadbrdo-15f289a8f0ab4cc2e1253731ca5af5987b3af0d6.tar.gz
brdo-15f289a8f0ab4cc2e1253731ca5af5987b3af0d6.tar.bz2
- Added file handling. Work by Kjartan.
Diffstat (limited to 'modules')
-rw-r--r--modules/profile.module75
-rw-r--r--modules/profile/profile.module75
-rw-r--r--modules/system.module37
-rw-r--r--modules/system/system.module37
4 files changed, 96 insertions, 128 deletions
diff --git a/modules/profile.module b/modules/profile.module
index 1123ba4c7..38f44212c 100644
--- a/modules/profile.module
+++ b/modules/profile.module
@@ -57,6 +57,10 @@ function profile_settings() {
_profile_init();
}
+ if (!file_check_directory(file_create_path(variable_get('profile_avatar_path', 'avatars')))) {
+ $error['profile_avatar_path'] = theme('error', t('Directory does not exist, or is not writable.'));
+ }
+
$profile_public_fields = variable_get("profile_public_fields", array());
$profile_private_fields = variable_get("profile_private_fields", array());
$profile_required_fields = variable_get("profile_required_fields", array());
@@ -74,7 +78,7 @@ function profile_settings() {
}
$output .= theme("table", $header, $row);
- $output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "misc/avatars/"), 30, 255, t("Path for avatar directory; it must be writable and visible from the web."));
+ $output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "avatars"), 30, 255, t("Subdirectory in the directory '%dir' where avatars will be stored.", array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR)) . $error['profile_avatar_path']);
$output .= form_textfield(t("Avatar maximum dimensions"), "profile_avatar_dimensions", variable_get("profile_avatar_dimensions", "85x85"), 10, 10, t("Maximum dimensions for avatars."));
$output .= form_textfield(t("Avatar maximum file size"), "profile_avatar_file_size", variable_get("profile_avatar_file_size", "30"), 10, 10, t("Maximum file size for avatars, in kB."));
@@ -133,11 +137,8 @@ function _profile_form($edit, $mode) {
}
if (in_array("avatar", $reg_fields)) {
- if ($edit["profile_avatar"] && $edit["uid"]) {
- $file = profile_avatar_path($edit["uid"], $edit["profile_avatar"]);
- if ($file) {
- $output .= "<img src=\"$file\" alt=\"\" title=\"\" /><br />";
- }
+ if ($edit["profile_avatar"] && file_exists($edit["profile_avatar"])) {
+ $output .= form_item(t("Avatar"), '<img src="'. file_create_url($edit["profile_avatar"]) .'" alt="" title="" />');
}
$output .= form_file($profile_fields["avatar"][1], "profile_avatar", 64, $profile_fields["avatar"][2]);
}
@@ -199,9 +200,8 @@ function _profile_user_view(&$user, $mode) {
case "":
// special
if ($t == "profile_avatar") {
- $file = profile_avatar_path($user->uid, $user->profile_avatar);
- if (file_exists($file)) {
- $output .= form_item(t("Avatar"), "<img src=\"$file\" alt=\"\" title=\"\" />");
+ if (file_exists($user->$t)) {
+ $output .= form_item(t("Avatar"), '<img src="'. file_create_url($user->$t) .'" alt="" title="" />');
}
}
@@ -218,51 +218,44 @@ function _profile_user_view(&$user, $mode) {
return $output;
}
+function profile_file_download($file) {
+ if (strpos($file, variable_get("profile_avatar_path", "avatars")) === 0) {
+ return array("Content-type: $mime");
+ }
+}
+
function _profile_validate_avatar(&$edit, $user) {
// check that uploaded file is an image, with a maximum file size and maximum height/width
unset($edit["profile_avatar"]);
- if ($_FILES["edit"]["name"]["profile_avatar"] == "") {
+ if (!$file = file_check_upload('profile_avatar')) {
$edit["profile_avatar"] = $user->profile_avatar;
- return "";
+ return;
}
- $image_file = $_FILES["edit"]["tmp_name"]["profile_avatar"];
- if (is_uploaded_file($image_file)) {
- $extension = strtolower(strrchr($_FILES["edit"]["name"]["profile_avatar"], "."));
- $size = getimagesize($image_file);
- list($maxwidth, $maxheight) = explode("x", variable_get("profile_avatar_dimensions", "85x85"));
- if ((!in_array($size[2], array(1, 2, 3))) || (!in_array($extension, array(".gif", ".jpg", ".png", ".jpeg")))) {
- $error = t("The uploaded file was not an image.");
- }
- else if (filesize($image_file) > (variable_get("profile_avatar_file_size", "30") * 1000)) {
- $error = t("The uploaded image is too large; the maximum file size is %a kB.", array("%a" => variable_get("profile_avatar_file_size", "30")));
- }
- else if ($size[0] > $maxwidth || $size[1] > $maxheight) {
- $error = t("The uploaded image is too large; the maximum dimensions are %a pixels.", array("%a" => variable_get("profile_avatar_dimensions", "85x85")));
- }
- else if (!is_dir(variable_get("profile_avatar_path", "misc/avatars/"))) {
- $error = t("Failed to upload the avatar image; the '%directory' directory doesn't exist.", array("%directory" => variable_get("profile_avatar_path", "misc/avatars/")));
- }
- else if (!is_writeable(variable_get("profile_avatar_path", "misc/avatars/"))) {
- $error = t("Failed to upload the avatar image; the webserver has no write permission to the '%directory' directory.", array("%directory" => variable_get("profile_avatar_path", "misc/avatars/")));
- }
- else if (!copy($image_file, variable_get("profile_avatar_path", "misc/avatars/").md5($user->uid).$extension)) {
- $error = t("Failed to upload the avatar image; could not copy file '%filename' to directory '%directory'.", array("%filename" => $_FILES["edit"]["name"]["profile_avatar"], "%directory" => variable_get("profile_avatar_path", "misc/avatars/")));
- }
- else {
- $edit["profile_avatar"] = $extension;
- }
+ $extension = strtolower(strrchr($file->name, "."));
+ $size = getimagesize($file->path);
+ list($maxwidth, $maxheight) = explode("x", variable_get("profile_avatar_dimensions", "85x85"));
+ if ((!in_array($size[2], array(1, 2, 3))) || (!in_array($extension, array(".gif", ".jpg", ".png", ".jpeg")))) {
+ $error = t("The uploaded file was not an image.");
+ }
+ else if ($file->size > (variable_get("profile_avatar_file_size", "30") * 1000)) {
+ $error = t("The uploaded image is too large; the maximum file size is %a kB.", array("%a" => variable_get("profile_avatar_file_size", "30")));
+ }
+ else if ($size[0] > $maxwidth || $size[1] > $maxheight) {
+ $error = t("The uploaded image is too large; the maximum dimensions are %a pixels.", array("%a" => variable_get("profile_avatar_dimensions", "85x85")));
+ }
+ else if ($file = file_save_upload('profile_avatar', variable_get("profile_avatar_path", "avatars") . FILE_SEPARATOR .'avatar-'. $user->uid . $extension, 1)) {
+ $edit["profile_avatar"] = $file->name;
+ }
+ else {
+ $error = t("Failed to upload the avatar image; the '%directory' directory doesn't exist.", array("%directory" => variable_get("profile_avatar_path", "avatars")));
}
return $error ? "$error<br />" : "";
}
-function profile_avatar_path($uid, $extension) {
- return $extension ? variable_get("profile_avatar_path", "misc/avatars/") . md5($uid) . $extension : "";
-}
-
function _profile_active_fields($mode) {
return variable_get("profile_". $mode ."_fields", array());
}
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index 1123ba4c7..38f44212c 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -57,6 +57,10 @@ function profile_settings() {
_profile_init();
}
+ if (!file_check_directory(file_create_path(variable_get('profile_avatar_path', 'avatars')))) {
+ $error['profile_avatar_path'] = theme('error', t('Directory does not exist, or is not writable.'));
+ }
+
$profile_public_fields = variable_get("profile_public_fields", array());
$profile_private_fields = variable_get("profile_private_fields", array());
$profile_required_fields = variable_get("profile_required_fields", array());
@@ -74,7 +78,7 @@ function profile_settings() {
}
$output .= theme("table", $header, $row);
- $output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "misc/avatars/"), 30, 255, t("Path for avatar directory; it must be writable and visible from the web."));
+ $output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "avatars"), 30, 255, t("Subdirectory in the directory '%dir' where avatars will be stored.", array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR)) . $error['profile_avatar_path']);
$output .= form_textfield(t("Avatar maximum dimensions"), "profile_avatar_dimensions", variable_get("profile_avatar_dimensions", "85x85"), 10, 10, t("Maximum dimensions for avatars."));
$output .= form_textfield(t("Avatar maximum file size"), "profile_avatar_file_size", variable_get("profile_avatar_file_size", "30"), 10, 10, t("Maximum file size for avatars, in kB."));
@@ -133,11 +137,8 @@ function _profile_form($edit, $mode) {
}
if (in_array("avatar", $reg_fields)) {
- if ($edit["profile_avatar"] && $edit["uid"]) {
- $file = profile_avatar_path($edit["uid"], $edit["profile_avatar"]);
- if ($file) {
- $output .= "<img src=\"$file\" alt=\"\" title=\"\" /><br />";
- }
+ if ($edit["profile_avatar"] && file_exists($edit["profile_avatar"])) {
+ $output .= form_item(t("Avatar"), '<img src="'. file_create_url($edit["profile_avatar"]) .'" alt="" title="" />');
}
$output .= form_file($profile_fields["avatar"][1], "profile_avatar", 64, $profile_fields["avatar"][2]);
}
@@ -199,9 +200,8 @@ function _profile_user_view(&$user, $mode) {
case "":
// special
if ($t == "profile_avatar") {
- $file = profile_avatar_path($user->uid, $user->profile_avatar);
- if (file_exists($file)) {
- $output .= form_item(t("Avatar"), "<img src=\"$file\" alt=\"\" title=\"\" />");
+ if (file_exists($user->$t)) {
+ $output .= form_item(t("Avatar"), '<img src="'. file_create_url($user->$t) .'" alt="" title="" />');
}
}
@@ -218,51 +218,44 @@ function _profile_user_view(&$user, $mode) {
return $output;
}
+function profile_file_download($file) {
+ if (strpos($file, variable_get("profile_avatar_path", "avatars")) === 0) {
+ return array("Content-type: $mime");
+ }
+}
+
function _profile_validate_avatar(&$edit, $user) {
// check that uploaded file is an image, with a maximum file size and maximum height/width
unset($edit["profile_avatar"]);
- if ($_FILES["edit"]["name"]["profile_avatar"] == "") {
+ if (!$file = file_check_upload('profile_avatar')) {
$edit["profile_avatar"] = $user->profile_avatar;
- return "";
+ return;
}
- $image_file = $_FILES["edit"]["tmp_name"]["profile_avatar"];
- if (is_uploaded_file($image_file)) {
- $extension = strtolower(strrchr($_FILES["edit"]["name"]["profile_avatar"], "."));
- $size = getimagesize($image_file);
- list($maxwidth, $maxheight) = explode("x", variable_get("profile_avatar_dimensions", "85x85"));
- if ((!in_array($size[2], array(1, 2, 3))) || (!in_array($extension, array(".gif", ".jpg", ".png", ".jpeg")))) {
- $error = t("The uploaded file was not an image.");
- }
- else if (filesize($image_file) > (variable_get("profile_avatar_file_size", "30") * 1000)) {
- $error = t("The uploaded image is too large; the maximum file size is %a kB.", array("%a" => variable_get("profile_avatar_file_size", "30")));
- }
- else if ($size[0] > $maxwidth || $size[1] > $maxheight) {
- $error = t("The uploaded image is too large; the maximum dimensions are %a pixels.", array("%a" => variable_get("profile_avatar_dimensions", "85x85")));
- }
- else if (!is_dir(variable_get("profile_avatar_path", "misc/avatars/"))) {
- $error = t("Failed to upload the avatar image; the '%directory' directory doesn't exist.", array("%directory" => variable_get("profile_avatar_path", "misc/avatars/")));
- }
- else if (!is_writeable(variable_get("profile_avatar_path", "misc/avatars/"))) {
- $error = t("Failed to upload the avatar image; the webserver has no write permission to the '%directory' directory.", array("%directory" => variable_get("profile_avatar_path", "misc/avatars/")));
- }
- else if (!copy($image_file, variable_get("profile_avatar_path", "misc/avatars/").md5($user->uid).$extension)) {
- $error = t("Failed to upload the avatar image; could not copy file '%filename' to directory '%directory'.", array("%filename" => $_FILES["edit"]["name"]["profile_avatar"], "%directory" => variable_get("profile_avatar_path", "misc/avatars/")));
- }
- else {
- $edit["profile_avatar"] = $extension;
- }
+ $extension = strtolower(strrchr($file->name, "."));
+ $size = getimagesize($file->path);
+ list($maxwidth, $maxheight) = explode("x", variable_get("profile_avatar_dimensions", "85x85"));
+ if ((!in_array($size[2], array(1, 2, 3))) || (!in_array($extension, array(".gif", ".jpg", ".png", ".jpeg")))) {
+ $error = t("The uploaded file was not an image.");
+ }
+ else if ($file->size > (variable_get("profile_avatar_file_size", "30") * 1000)) {
+ $error = t("The uploaded image is too large; the maximum file size is %a kB.", array("%a" => variable_get("profile_avatar_file_size", "30")));
+ }
+ else if ($size[0] > $maxwidth || $size[1] > $maxheight) {
+ $error = t("The uploaded image is too large; the maximum dimensions are %a pixels.", array("%a" => variable_get("profile_avatar_dimensions", "85x85")));
+ }
+ else if ($file = file_save_upload('profile_avatar', variable_get("profile_avatar_path", "avatars") . FILE_SEPARATOR .'avatar-'. $user->uid . $extension, 1)) {
+ $edit["profile_avatar"] = $file->name;
+ }
+ else {
+ $error = t("Failed to upload the avatar image; the '%directory' directory doesn't exist.", array("%directory" => variable_get("profile_avatar_path", "avatars")));
}
return $error ? "$error<br />" : "";
}
-function profile_avatar_path($uid, $extension) {
- return $extension ? variable_get("profile_avatar_path", "misc/avatars/") . md5($uid) . $extension : "";
-}
-
function _profile_active_fields($mode) {
return variable_get("profile_". $mode ."_fields", array());
}
diff --git a/modules/system.module b/modules/system.module
index 5ac19cc54..af45d64f6 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -35,8 +35,7 @@ function system_help($section = "admin/help#system") {
// Start of system_help_cache
$output .= "<p>Drupal has a caching mechanism which stores dynamically generated web pages in a database. By caching a web page, Drupal does not have to create the page each time someone wants to view it, instead it takes only one SQL query to display it, reducing response time and the server's load. Only pages requested by \"anonymous\" users are cached.</p>";
// End of system_help_cache
- $output = t($output, array("%base_url" => $base_url, "%cron-link" => "<a href=\"$base_url/cron.php\
-\">$base_url/cron.php</a>", "%lynx" => "<a href=\"http://lynx.browser.org\">lynx</a>", "%wget" => "<a href=\"http://www.gnu.org/software/wget/wget.html\">wget</a>" ));
+ $output = t($output, array("%base_url" => $base_url, "%cron-link" => "<a href=\"$base_url/cron.php\">$base_url/cron.php</a>", "%lynx" => "<a href=\"http://lynx.browser.org\">lynx</a>", "%wget" => "<a href=\"http://www.gnu.org/software/wget/wget.html\">wget</a>" ));
break;
case 'admin/system/modules#description':
$output = t("Configuration system that lets administrators modify the workings of the site.");
@@ -56,6 +55,7 @@ function system_perm() {
function system_link($type) {
if ($type == "system") {
+ menu("system/files", t("file download"), "file_download", 0, MENU_HIDE);
if (user_access("administer site configuration")) {
menu("admin/system", t("configuration"), "system_admin", 3);
@@ -126,6 +126,17 @@ function system_view_general() {
$output .= form_group(t("Cache settings"), $group);
+ // file system:
+ if (!file_check_directory(variable_get('file_directory_path', 'files'))) {
+ $error['file_directory_path'] = theme('error', t('Directory does not exist, or is not writable.'));
+ }
+ if (!file_check_directory(variable_get('file_directory_temp', ini_get('upload_tmp_dir')))) {
+ $error['file_directory_temp'] = theme('error', t('Directory does not exist, or is not writable.'));
+ }
+ $group = form_textfield(t('File system path'), 'file_directory_path', variable_get('file_directory_path', 'files'), 70, 255, t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.') . $error['file_directory_path']);
+ $group .= form_textfield(t('Temporary directory'), 'file_directory_temp', variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')), 70, 255, t('Location where files can be saved temporarily. This directory should not be accessible from the web.') . $error['file_directory_temp']);
+ $group .= form_radios(t('Download method'), 'file_downloads', variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC), array(FILE_DOWNLOADS_PUBLIC => t('Public - files are available using http directly.'), FILE_DOWNLOADS_PRIVATE => t('Private - files are be transferred by Drupal.')), t('This setting can be changed at any time, however, all download URLs will change and there may be unexpected problems so it is not recommended.'));
+ $output .= form_group(t('File system'), $group);
// submission settings:
$rate = array(-10000 => t("Disabled"), 1 => t("Maximum 1 every second"), 5 => t("Maximum 1 every 5 seconds"), 15 => t("Maximum 1 every 15 seconds"), 30 => t("Maximum 1 every 30 seconds"), 60 => t("Maximum 1 every minute"), 300 => t("Maximum 1 every 5 minutes"), 900 => t("Maximum 1 every 15 minutes"), 1800 => t("Maximum 1 every 30 minutes"), 3600 => t("Maximum 1 every hour"), 21600 => t("Maximum 1 every 6 hours"), 43200 => t("Maximum 1 every 12 hours"));
@@ -254,32 +265,12 @@ function system_view($type, $arg = "") {
return form($form);
}
-function system_dirscan($dir, $mask, $nomask = array(".", "..", "CVS")) {
- $files = array();
- if (is_dir($dir) && $handle = opendir($dir)) {
- while ($file = readdir($handle)) {
- if (!in_array($file, $nomask)) {
- if (is_dir("$dir/$file")) {
- $files = array_merge($files, system_dirscan("$dir/$file", $mask, $nomask));
- }
- elseif (ereg($mask, $file)) {
- $name = basename($file);
- $files["$dir/$file"]->filename = "$dir/$file";
- $files["$dir/$file"]->name = substr($name, 0, strrpos($name, '.'));
- }
- }
- }
- closedir($handle);
- }
- return $files;
-}
-
function system_listing($type, $directory, $required = array()) {
// Make sure we set $type correctly
$type = $type != 'theme' ? "module" : "theme";
// Find files in the directory.
- $files = system_dirscan($directory, "\.$type$");
+ $files = file_scan_directory($directory, "\.$type$");
// Extract current files from database.
$result = db_query("SELECT filename, type, status, throttle FROM {system} WHERE type = '%s'", $type);
diff --git a/modules/system/system.module b/modules/system/system.module
index 5ac19cc54..af45d64f6 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -35,8 +35,7 @@ function system_help($section = "admin/help#system") {
// Start of system_help_cache
$output .= "<p>Drupal has a caching mechanism which stores dynamically generated web pages in a database. By caching a web page, Drupal does not have to create the page each time someone wants to view it, instead it takes only one SQL query to display it, reducing response time and the server's load. Only pages requested by \"anonymous\" users are cached.</p>";
// End of system_help_cache
- $output = t($output, array("%base_url" => $base_url, "%cron-link" => "<a href=\"$base_url/cron.php\
-\">$base_url/cron.php</a>", "%lynx" => "<a href=\"http://lynx.browser.org\">lynx</a>", "%wget" => "<a href=\"http://www.gnu.org/software/wget/wget.html\">wget</a>" ));
+ $output = t($output, array("%base_url" => $base_url, "%cron-link" => "<a href=\"$base_url/cron.php\">$base_url/cron.php</a>", "%lynx" => "<a href=\"http://lynx.browser.org\">lynx</a>", "%wget" => "<a href=\"http://www.gnu.org/software/wget/wget.html\">wget</a>" ));
break;
case 'admin/system/modules#description':
$output = t("Configuration system that lets administrators modify the workings of the site.");
@@ -56,6 +55,7 @@ function system_perm() {
function system_link($type) {
if ($type == "system") {
+ menu("system/files", t("file download"), "file_download", 0, MENU_HIDE);
if (user_access("administer site configuration")) {
menu("admin/system", t("configuration"), "system_admin", 3);
@@ -126,6 +126,17 @@ function system_view_general() {
$output .= form_group(t("Cache settings"), $group);
+ // file system:
+ if (!file_check_directory(variable_get('file_directory_path', 'files'))) {
+ $error['file_directory_path'] = theme('error', t('Directory does not exist, or is not writable.'));
+ }
+ if (!file_check_directory(variable_get('file_directory_temp', ini_get('upload_tmp_dir')))) {
+ $error['file_directory_temp'] = theme('error', t('Directory does not exist, or is not writable.'));
+ }
+ $group = form_textfield(t('File system path'), 'file_directory_path', variable_get('file_directory_path', 'files'), 70, 255, t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.') . $error['file_directory_path']);
+ $group .= form_textfield(t('Temporary directory'), 'file_directory_temp', variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')), 70, 255, t('Location where files can be saved temporarily. This directory should not be accessible from the web.') . $error['file_directory_temp']);
+ $group .= form_radios(t('Download method'), 'file_downloads', variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC), array(FILE_DOWNLOADS_PUBLIC => t('Public - files are available using http directly.'), FILE_DOWNLOADS_PRIVATE => t('Private - files are be transferred by Drupal.')), t('This setting can be changed at any time, however, all download URLs will change and there may be unexpected problems so it is not recommended.'));
+ $output .= form_group(t('File system'), $group);
// submission settings:
$rate = array(-10000 => t("Disabled"), 1 => t("Maximum 1 every second"), 5 => t("Maximum 1 every 5 seconds"), 15 => t("Maximum 1 every 15 seconds"), 30 => t("Maximum 1 every 30 seconds"), 60 => t("Maximum 1 every minute"), 300 => t("Maximum 1 every 5 minutes"), 900 => t("Maximum 1 every 15 minutes"), 1800 => t("Maximum 1 every 30 minutes"), 3600 => t("Maximum 1 every hour"), 21600 => t("Maximum 1 every 6 hours"), 43200 => t("Maximum 1 every 12 hours"));
@@ -254,32 +265,12 @@ function system_view($type, $arg = "") {
return form($form);
}
-function system_dirscan($dir, $mask, $nomask = array(".", "..", "CVS")) {
- $files = array();
- if (is_dir($dir) && $handle = opendir($dir)) {
- while ($file = readdir($handle)) {
- if (!in_array($file, $nomask)) {
- if (is_dir("$dir/$file")) {
- $files = array_merge($files, system_dirscan("$dir/$file", $mask, $nomask));
- }
- elseif (ereg($mask, $file)) {
- $name = basename($file);
- $files["$dir/$file"]->filename = "$dir/$file";
- $files["$dir/$file"]->name = substr($name, 0, strrpos($name, '.'));
- }
- }
- }
- closedir($handle);
- }
- return $files;
-}
-
function system_listing($type, $directory, $required = array()) {
// Make sure we set $type correctly
$type = $type != 'theme' ? "module" : "theme";
// Find files in the directory.
- $files = system_dirscan($directory, "\.$type$");
+ $files = file_scan_directory($directory, "\.$type$");
// Extract current files from database.
$result = db_query("SELECT filename, type, status, throttle FROM {system} WHERE type = '%s'", $type);