summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/file.inc21
-rw-r--r--modules/blogapi.module2
-rw-r--r--modules/blogapi/blogapi.module2
-rw-r--r--modules/system.module4
-rw-r--r--modules/system/system.module4
-rw-r--r--modules/upload.module3
-rw-r--r--modules/upload/upload.module3
-rw-r--r--modules/user.module6
-rw-r--r--modules/user/user.module6
9 files changed, 24 insertions, 27 deletions
diff --git a/includes/file.inc b/includes/file.inc
index 1d4399f5d..4018e5acc 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -14,10 +14,9 @@
define('FILE_DOWNLOADS_PUBLIC', 1);
define('FILE_DOWNLOADS_PRIVATE', 2);
-#define('FILE_SEPARATOR', PHP_OS == 'WINNT' ? '\\' : '/');
-define('FILE_SEPARATOR', '/');
define('FILE_CREATE_DIRECTORY', 1);
define('FILE_MODIFY_PERMISSIONS', 2);
+define('FILE_DIRECTORY_TEMP', PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp');
/**
* Create the download path to a file.
@@ -45,7 +44,7 @@ function file_create_path($dest = 0) {
$regex = (PHP_OS == 'WINNT' ? '.?:\\\\' : '/');
if (!file_check_location($dest, variable_get('file_directory_path', 'files')) && !preg_match("|^$regex|", $dest)) {
- return variable_get('file_directory_path', 'files') . FILE_SEPARATOR . trim($dest, '\\/');
+ return variable_get('file_directory_path', 'files') .'/'. trim($dest, '\\/');
}
else {
return $dest;
@@ -65,7 +64,7 @@ function file_check_directory(&$directory, $mode = 0, $form_item = NULL) {
// Check if directory exists.
if (!is_dir($directory)) {
- if (($mode & FILE_CREATE_DIRECTORY) && mkdir($directory, 0760)) {
+ if (($mode & FILE_CREATE_DIRECTORY) && @mkdir($directory, 0760)) {
drupal_set_message(t('Created directory %directory.', array('%directory' => "<em>$directory</em>")));
}
else {
@@ -78,7 +77,7 @@ function file_check_directory(&$directory, $mode = 0, $form_item = NULL) {
// Check to see if the directory is writable.
if (!is_writable($directory)) {
- if (($mode & FILE_MODIFY_PERMISSIONS) && chmod($directory, 0760)) {
+ if (($mode & FILE_MODIFY_PERMISSIONS) && @chmod($directory, 0760)) {
drupal_set_message(t('Modified permissions on directory %directory.', array('%directory' => "<em>$directory</em>")));
}
else {
@@ -208,7 +207,7 @@ function file_copy(&$source, $dest = 0, $replace = 0) {
// If destination file is not specified then use filename of source file.
$basename = $basename ? $basename : basename($source);
- $dest = $directory . FILE_SEPARATOR . $basename;
+ $dest = $directory .'/'. $basename;
// Make sure source and destination filenames are not the same, makes no sense
// to copy it if they are. In fact copying the file will most likely result in
@@ -227,7 +226,7 @@ function file_copy(&$source, $dest = 0, $replace = 0) {
$counter = 0;
do {
- $dest = $directory . FILE_SEPARATOR . $name .'_'. $counter++ . $ext;
+ $dest = $directory .'/'. $name .'_'. $counter++ . $ext;
} while (file_exists($dest));
}
@@ -265,7 +264,7 @@ function file_move(&$source, $dest = 0, $replace = 0) {
}
function file_create_filename($basename, $directory) {
- $dest = $directory . FILE_SEPARATOR . $basename;
+ $dest = $directory .'/'. $basename;
if (file_exists($dest)) {
// Destination file already exists, generate an alternative.
@@ -279,7 +278,7 @@ function file_create_filename($basename, $directory) {
$counter = 0;
do {
- $dest = $directory . FILE_SEPARATOR . $name .'_'. $counter++ . $ext;
+ $dest = $directory .'/'. $name .'_'. $counter++ . $ext;
} while (file_exists($dest));
}
@@ -309,7 +308,7 @@ function file_save_upload($source, $dest = 0, $replace = 0) {
// Make sure $source exists in $_FILES.
if ($file = file_check_upload($source)) {
if (!$dest) {
- $dest = variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp'));
+ $dest = variable_get('file_directory_temp', FILE_DIRECTORY_TEMP);
$temporary = 1;
if (is_file($file->filepath)) {
// If this file was uploaded by this user before replace the temporary copy.
@@ -367,7 +366,7 @@ function file_save_data($data, $dest, $replace = 0) {
return 0;
}
- $temp = variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp'));
+ $temp = variable_get('file_directory_temp', FILE_DIRECTORY_TEMP);
$file = tempnam($temp, 'file');
if (!$fp = fopen($file, 'wb')) {
drupal_set_message(t('Unable to create file.'), 'error');
diff --git a/modules/blogapi.module b/modules/blogapi.module
index ef902edb8..0e472aa46 100644
--- a/modules/blogapi.module
+++ b/modules/blogapi.module
@@ -539,7 +539,7 @@ function blogapi_blogapi() {
function blogapi_rsd() {
global $base_url;
- $xmlrpc = $base_url . FILE_SEPARATOR . 'xmlrpc.php';
+ $xmlrpc = $base_url .'/'. 'xmlrpc.php';
$base = url('', NULL, NULL, TRUE);
$blogid = 1; # until we figure out how to handle multiple bloggers
diff --git a/modules/blogapi/blogapi.module b/modules/blogapi/blogapi.module
index ef902edb8..0e472aa46 100644
--- a/modules/blogapi/blogapi.module
+++ b/modules/blogapi/blogapi.module
@@ -539,7 +539,7 @@ function blogapi_blogapi() {
function blogapi_rsd() {
global $base_url;
- $xmlrpc = $base_url . FILE_SEPARATOR . 'xmlrpc.php';
+ $xmlrpc = $base_url .'/'. 'xmlrpc.php';
$base = url('', NULL, NULL, TRUE);
$blogid = 1; # until we figure out how to handle multiple bloggers
diff --git a/modules/system.module b/modules/system.module
index a2ec2f332..f985e88af 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -202,11 +202,11 @@ function system_view_general() {
$directory_path = variable_get('file_directory_path', 'files');
file_check_directory($directory_path, FILE_CREATE_DIRECTORY, 'file_directory_path');
- $directory_temp = variable_get('file_directory_temp', 'temp');
+ $directory_temp = variable_get('file_directory_temp', FILE_DIRECTORY_TEMP);
file_check_directory(file_create_path($directory_temp), FILE_CREATE_DIRECTORY, 'file_directory_temp');
$group = form_textfield(t('File system path'), 'file_directory_path', $directory_path, 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.'));
- $group .= form_textfield(t('Temporary directory'), 'file_directory_temp', $directory_temp, 70, 255, t('Location where uploaded files will be placed for preview purposes. This directory should be relative to the file system path.'));
+ $group .= form_textfield(t('Temporary directory'), 'file_directory_temp', $directory_temp, 70, 255, t('Location where uploaded files will be kept during previews. Relative paths will be resolved relative to the file system path.'));
$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 settings'), $group);
diff --git a/modules/system/system.module b/modules/system/system.module
index a2ec2f332..f985e88af 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -202,11 +202,11 @@ function system_view_general() {
$directory_path = variable_get('file_directory_path', 'files');
file_check_directory($directory_path, FILE_CREATE_DIRECTORY, 'file_directory_path');
- $directory_temp = variable_get('file_directory_temp', 'temp');
+ $directory_temp = variable_get('file_directory_temp', FILE_DIRECTORY_TEMP);
file_check_directory(file_create_path($directory_temp), FILE_CREATE_DIRECTORY, 'file_directory_temp');
$group = form_textfield(t('File system path'), 'file_directory_path', $directory_path, 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.'));
- $group .= form_textfield(t('Temporary directory'), 'file_directory_temp', $directory_temp, 70, 255, t('Location where uploaded files will be placed for preview purposes. This directory should be relative to the file system path.'));
+ $group .= form_textfield(t('Temporary directory'), 'file_directory_temp', $directory_temp, 70, 255, t('Location where uploaded files will be kept during previews. Relative paths will be resolved relative to the file system path.'));
$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 settings'), $group);
diff --git a/modules/upload.module b/modules/upload.module
index 58e9f2d56..a1ac58ef9 100644
--- a/modules/upload.module
+++ b/modules/upload.module
@@ -177,7 +177,7 @@ function upload_nodeapi(&$node, $op, $arg) {
break;
case 'load':
if (variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) {
- $output->files = upload_load($node);
+ $output['files'] = upload_load($node);
}
break;
case 'view':
@@ -209,7 +209,6 @@ function upload_nodeapi(&$node, $op, $arg) {
foreach ($previews as $file) {
$old = file_create_filename($file->filename, file_create_path());
$new = url($old);
- //drupal_set_message("debug: $old $new");
$node->body = str_replace($old, $new, $node->body);
$node->teaser = str_replace($old, $new, $node->teaser);
}
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 58e9f2d56..a1ac58ef9 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -177,7 +177,7 @@ function upload_nodeapi(&$node, $op, $arg) {
break;
case 'load':
if (variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) {
- $output->files = upload_load($node);
+ $output['files'] = upload_load($node);
}
break;
case 'view':
@@ -209,7 +209,6 @@ function upload_nodeapi(&$node, $op, $arg) {
foreach ($previews as $file) {
$old = file_create_filename($file->filename, file_create_path());
$new = url($old);
- //drupal_set_message("debug: $old $new");
$node->body = str_replace($old, $new, $node->body);
$node->teaser = str_replace($old, $new, $node->teaser);
}
diff --git a/modules/user.module b/modules/user.module
index bb77c128f..11ac79d00 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -205,7 +205,7 @@ function user_validate_picture($file, &$edit, $user) {
else if ($size[0] > $maxwidth || $size[1] > $maxheight) {
form_set_error('picture', t('The uploaded image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'))));
}
- else if ($file = file_save_upload('picture', variable_get('user_picture_path', 'pictures') . FILE_SEPARATOR .'picture-'. $user->uid . $extension, 1)) {
+ else if ($file = file_save_upload('picture', variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid . $extension, 1)) {
$edit['picture'] = $file->filepath;
}
else {
@@ -361,7 +361,7 @@ function user_perm() {
* Ensure that user pictures (avatars) are always downloadable.
*/
function user_file_download($file) {
- if (strpos($file, variable_get('user_picture_path', 'pictures') . FILE_SEPARATOR . 'picture-') === 0) {
+ if (strpos($file, variable_get('user_picture_path', 'pictures') .'/picture-') === 0) {
list($width, $height, $type, $attr) = @getimagesize(file_create_path($file));
$types = array(
IMAGETYPE_GIF => 'image/gif',
@@ -1245,7 +1245,7 @@ function user_configure_settings() {
file_check_directory(file_create_path(variable_get('user_picture_path', 'pictures')), 1, 'user_picture_path');
$group = form_radios(t('Picture support'), 'user_pictures', variable_get('user_pictures', 0), array(t('Disabled'), t('Enabled')), t('Enable picture support.'));
- $group .= form_textfield(t('Picture image path'), 'user_picture_path', variable_get('user_picture_path', 'pictures'), 45, 255, t('Subdirectory in the directory "%dir" where pictures will be stored.', array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR)));
+ $group .= form_textfield(t('Picture image path'), 'user_picture_path', variable_get('user_picture_path', 'pictures'), 45, 255, t('Subdirectory in the directory "%dir" where pictures will be stored.', array('%dir' => variable_get('file_directory_path', 'files') .'/')));
$group .= form_textfield(t('Default picture'), 'user_picture_default', variable_get('user_picture_default', ''), 45, 255, t('URL of picture to display for users with no custom picture selected. Leave blank for none.'));
$group .= form_textfield(t('Picture maximum dimensions'), 'user_picture_dimensions', variable_get('user_picture_dimensions', '85x85'), 10, 10, t('Maximum dimensions for pictures.'));
$group .= form_textfield(t('Picture maximum file size'), 'user_picture_file_size', variable_get('user_picture_file_size', '30'), 10, 10, t('Maximum file size for pictures, in kB.'));
diff --git a/modules/user/user.module b/modules/user/user.module
index bb77c128f..11ac79d00 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -205,7 +205,7 @@ function user_validate_picture($file, &$edit, $user) {
else if ($size[0] > $maxwidth || $size[1] > $maxheight) {
form_set_error('picture', t('The uploaded image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'))));
}
- else if ($file = file_save_upload('picture', variable_get('user_picture_path', 'pictures') . FILE_SEPARATOR .'picture-'. $user->uid . $extension, 1)) {
+ else if ($file = file_save_upload('picture', variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid . $extension, 1)) {
$edit['picture'] = $file->filepath;
}
else {
@@ -361,7 +361,7 @@ function user_perm() {
* Ensure that user pictures (avatars) are always downloadable.
*/
function user_file_download($file) {
- if (strpos($file, variable_get('user_picture_path', 'pictures') . FILE_SEPARATOR . 'picture-') === 0) {
+ if (strpos($file, variable_get('user_picture_path', 'pictures') .'/picture-') === 0) {
list($width, $height, $type, $attr) = @getimagesize(file_create_path($file));
$types = array(
IMAGETYPE_GIF => 'image/gif',
@@ -1245,7 +1245,7 @@ function user_configure_settings() {
file_check_directory(file_create_path(variable_get('user_picture_path', 'pictures')), 1, 'user_picture_path');
$group = form_radios(t('Picture support'), 'user_pictures', variable_get('user_pictures', 0), array(t('Disabled'), t('Enabled')), t('Enable picture support.'));
- $group .= form_textfield(t('Picture image path'), 'user_picture_path', variable_get('user_picture_path', 'pictures'), 45, 255, t('Subdirectory in the directory "%dir" where pictures will be stored.', array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR)));
+ $group .= form_textfield(t('Picture image path'), 'user_picture_path', variable_get('user_picture_path', 'pictures'), 45, 255, t('Subdirectory in the directory "%dir" where pictures will be stored.', array('%dir' => variable_get('file_directory_path', 'files') .'/')));
$group .= form_textfield(t('Default picture'), 'user_picture_default', variable_get('user_picture_default', ''), 45, 255, t('URL of picture to display for users with no custom picture selected. Leave blank for none.'));
$group .= form_textfield(t('Picture maximum dimensions'), 'user_picture_dimensions', variable_get('user_picture_dimensions', '85x85'), 10, 10, t('Maximum dimensions for pictures.'));
$group .= form_textfield(t('Picture maximum file size'), 'user_picture_file_size', variable_get('user_picture_file_size', '30'), 10, 10, t('Maximum file size for pictures, in kB.'));